@deephaven/embed-widget 0.61.0 → 0.61.1-beta.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-24336658.js → App-d6de2921.js} +2 -2
- package/build/assets/{App-24336658.js.map → App-d6de2921.js.map} +1 -1
- package/build/assets/{WidgetView-d13909dd.js → WidgetView-0e2c0561.js} +2 -2
- package/build/assets/{WidgetView-d13909dd.js.map → WidgetView-0e2c0561.js.map} +1 -1
- package/build/assets/{index-98ed4df0.js → index-1a83aec3.js} +3 -3
- package/build/assets/{index-98ed4df0.js.map → index-1a83aec3.js.map} +1 -1
- package/build/assets/{index-230fe895.js → index-de06cd4a.js} +2 -2
- package/build/assets/{index-230fe895.js.map → index-de06cd4a.js.map} +1 -1
- package/build/assets/{index-849b9f7f.js → index-f447a3f6.js} +2 -2
- package/build/assets/{index-849b9f7f.js.map → index-f447a3f6.js.map} +1 -1
- package/build/assets/{usePlugins-63482eb2.js → usePlugins-29d49f6f.js} +2 -2
- package/build/assets/{usePlugins-63482eb2.js.map → usePlugins-29d49f6f.js.map} +1 -1
- package/build/index.html +1 -1
- package/package.json +15 -15
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,C as o}from"./vendor-fc3cb542.js";import{L as m,a as g}from"./index-
|
|
2
|
-
//# sourceMappingURL=App-
|
|
1
|
+
import{r as t,C as o}from"./vendor-fc3cb542.js";import{L as m,a as g}from"./index-f447a3f6.js";import{u as w,C as h}from"./usePlugins-29d49f6f.js";import{E as x,W as E,f as y}from"./WidgetView-0e2c0561.js";import"./helpers-de833af9.js";const c=m.module("EmbedWidget.App");function D(){const[s,l]=t.useState(),[e,u]=t.useState(),n=t.useMemo(()=>new URLSearchParams(window.location.search),[]).get("name"),i=w();t.useEffect(function(){async function p(){try{if(n==null)throw new Error('Missing URL parameter "name"');c.debug(`Loading widget definition for ${n}...`);const r=await y(i,n);u(r),c.debug(`Widget definition successfully loaded for ${n}`)}catch(r){c.error(`Unable to load widget definition for ${n}`,r),l(`${r}`)}}p()},[i,n]);const a=e!=null&&s==null,d=e==null&&s==null,f=t.useMemo(()=>e==null?async()=>{throw new Error("Definition is null")}:()=>i.getObject(e),[i,e]);return o.jsxs("div",{className:"App",children:[a&&o.jsx(x,{children:o.jsx(E,{type:e.type,fetch:f})}),!a&&o.jsx(g,{isLoaded:a,isLoading:d,errorMessage:s??null}),o.jsx(h,{})]})}export{D as default};
|
|
2
|
+
//# sourceMappingURL=App-d6de2921.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App-
|
|
1
|
+
{"version":3,"file":"App-d6de2921.js","sources":["../../src/App.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport {\n ContextMenuRoot,\n ErrorBoundary,\n LoadingOverlay,\n} from '@deephaven/components'; // Use the loading spinner from the Deephaven components package\nimport { useConnection } from '@deephaven/jsapi-components';\nimport type { VariableDefinition } from '@deephaven/jsapi-types';\nimport { fetchVariableDefinition } from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { WidgetView } from '@deephaven/plugin';\nimport './App.scss'; // Styles for in this app\n\nconst log = Log.module('EmbedWidget.App');\n\n/**\n * A functional React component that displays a Deephaven Widget using the @deephaven/plugin package.\n * It will attempt to open and display the widget specified with the `name` parameter, expecting it to be present on the server.\n * E.g. http://localhost:4030/?name=myWidget will attempt to open a widget `myWidget`\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 Vite docs for how to update these env vars: https://vitejs.dev/guide/env-and-mode.html\n */\nfunction App(): JSX.Element {\n const [error, setError] = useState<string>();\n const [definition, setDefinition] = useState<VariableDefinition>();\n const searchParams = useMemo(\n () => new URLSearchParams(window.location.search),\n []\n );\n // Get the widget name from the query param `name`.\n const name = searchParams.get('name');\n const connection = useConnection();\n\n useEffect(\n function initializeApp() {\n async function initApp(): Promise<void> {\n try {\n if (name == null) {\n throw new Error('Missing URL parameter \"name\"');\n }\n\n log.debug(`Loading widget definition for ${name}...`);\n\n const newDefinition = await fetchVariableDefinition(connection, name);\n\n setDefinition(newDefinition);\n\n log.debug(`Widget definition successfully loaded for ${name}`);\n } catch (e: unknown) {\n log.error(`Unable to load widget definition for ${name}`, e);\n setError(`${e}`);\n }\n }\n initApp();\n },\n [connection, name]\n );\n\n const isLoaded = definition != null && error == null;\n const isLoading = definition == null && error == null;\n\n const fetch = useMemo(() => {\n if (definition == null) {\n return async () => {\n throw new Error('Definition is null');\n };\n }\n return () => connection.getObject(definition);\n }, [connection, definition]);\n\n return (\n <div className=\"App\">\n {isLoaded && (\n <ErrorBoundary>\n <WidgetView type={definition.type} fetch={fetch} />\n </ErrorBoundary>\n )}\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","App","error","setError","useState","definition","setDefinition","name","useMemo","connection","useConnection","useEffect","initApp","newDefinition","fetchVariableDefinition","e","isLoaded","isLoading","fetch","jsxs","jsx","ErrorBoundary","WidgetView","LoadingOverlay","ContextMenuRoot"],"mappings":"4OAaA,MAAMA,EAAMC,EAAI,OAAO,iBAAiB,EAUxC,SAASC,GAAmB,CAC1B,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAAiB,SAAA,EACrC,CAACC,EAAYC,CAAa,EAAIF,EAA6B,SAAA,EAM3DG,EALeC,EAAA,QACnB,IAAM,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAChD,CAAC,CAAA,EAGuB,IAAI,MAAM,EAC9BC,EAAaC,IAEnBC,EAAA,UACE,UAAyB,CACvB,eAAeC,GAAyB,CAClC,GAAA,CACF,GAAIL,GAAQ,KACJ,MAAA,IAAI,MAAM,8BAA8B,EAG5CR,EAAA,MAAM,iCAAiCQ,CAAI,KAAK,EAEpD,MAAMM,EAAgB,MAAMC,EAAwBL,EAAYF,CAAI,EAEpED,EAAcO,CAAa,EAEvBd,EAAA,MAAM,6CAA6CQ,CAAI,EAAE,QACtDQ,EAAY,CACnBhB,EAAI,MAAM,wCAAwCQ,CAAI,GAAIQ,CAAC,EAClDZ,EAAA,GAAGY,CAAC,EAAE,CACjB,CACF,CACQH,GACV,EACA,CAACH,EAAYF,CAAI,CAAA,EAGb,MAAAS,EAAWX,GAAc,MAAQH,GAAS,KAC1Ce,EAAYZ,GAAc,MAAQH,GAAS,KAE3CgB,EAAQV,EAAAA,QAAQ,IAChBH,GAAc,KACT,SAAY,CACX,MAAA,IAAI,MAAM,oBAAoB,CAAA,EAGjC,IAAMI,EAAW,UAAUJ,CAAU,EAC3C,CAACI,EAAYJ,CAAU,CAAC,EAGzB,OAAAc,EAAA,KAAC,MAAI,CAAA,UAAU,MACZ,SAAA,CACCH,GAAAI,EAAAA,IAACC,GACC,SAACD,EAAAA,IAAAE,EAAA,CAAW,KAAMjB,EAAW,KAAM,MAAAa,EAAc,CACnD,CAAA,EAED,CAACF,GACAI,EAAA,IAACG,EAAA,CACC,SAAAP,EACA,UAAAC,EACA,aAAcf,GAAS,IAAA,CACzB,QAEDsB,EAAgB,EAAA,CACnB,CAAA,CAAA,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{L as m,a as p}from"./index-
|
|
2
|
-
//# sourceMappingURL=WidgetView-
|
|
1
|
+
import{L as m,a as p}from"./index-f447a3f6.js";import{r as c,C as l}from"./vendor-fc3cb542.js";import{T as g,s as h,q as E}from"./usePlugins-29d49f6f.js";var T=m.module("ErrorBoundary");class b extends c.Component{static getDerivedStateFromError(r){return{error:r}}constructor(r){super(r),this.state={error:void 0}}componentDidCatch(r,t){var{onError:e}=this.props;T.error("Error caught by ErrorBoundary",r,t),e==null||e(r,t)}render(){var{children:r,className:t,fallback:e}=this.props,{error:o}=this.state;return o!=null?e??l.jsx("div",{className:t,children:l.jsx(p,{errorMessage:"".concat(o),isLoading:!1,isLoaded:!1})}):r}}var w=1e4;function F(a,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:w;return new Promise((e,o)=>{var n,s=setTimeout(()=>{var i;(i=n)===null||i===void 0||i(),o(new g("Timeout looking for variable ".concat(r)))},t);function v(i){var u,d=i.created.find(f=>f.title===r);clearTimeout(s),(u=n)===null||u===void 0||u(),d!=null?e(d):o(new Error("Variable ".concat(r," not found")))}n=a.subscribeToFieldUpdates(v)})}function C(a){var{fetch:r,type:t}=a,e=h(),o=c.useMemo(()=>[...e.values()].filter(E).find(s=>[s.supportedTypes].flat().includes(t)),[e,t]);if(o!=null){var n=o.component;return l.jsx(n,{fetch:r})}throw new Error("Unknown widget type '".concat(t,"'"))}export{b as E,w as F,C as W,F as f};
|
|
2
|
+
//# sourceMappingURL=WidgetView-0e2c0561.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetView-
|
|
1
|
+
{"version":3,"file":"WidgetView-0e2c0561.js","sources":["../../../components/dist/ErrorBoundary.js","../../../jsapi-utils/dist/ConnectionUtils.js","../../../plugin/dist/WidgetView.js"],"sourcesContent":["import Log from '@deephaven/log';\nimport React, { Component } from 'react';\nimport LoadingOverlay from \"./LoadingOverlay.js\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nvar log = Log.module('ErrorBoundary');\n/**\n * Error boundary for catching render errors in React. Displays an error message if an error is caught by default, or you can specify a fallback component to render.\n * https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n */\nexport class ErrorBoundary extends Component {\n static getDerivedStateFromError(error) {\n return {\n error\n };\n }\n constructor(props) {\n super(props);\n this.state = {\n error: undefined\n };\n }\n componentDidCatch(error, errorInfo) {\n var {\n onError\n } = this.props;\n log.error('Error caught by ErrorBoundary', error, errorInfo);\n onError === null || onError === void 0 ? void 0 : onError(error, errorInfo);\n }\n render() {\n var {\n children,\n className,\n fallback\n } = this.props;\n var {\n error\n } = this.state;\n if (error != null) {\n if (fallback != null) {\n return fallback;\n }\n return /*#__PURE__*/_jsx(\"div\", {\n className: className,\n children: /*#__PURE__*/_jsx(LoadingOverlay, {\n errorMessage: \"\".concat(error),\n isLoading: false,\n isLoaded: false\n })\n });\n }\n return children;\n }\n}\nexport default ErrorBoundary;\n//# sourceMappingURL=ErrorBoundary.js.map","import { TimeoutError } from '@deephaven/utils';\n\n/** Default timeout for fetching a variable definition */\nexport var FETCH_TIMEOUT = 10000;\n\n/**\n * Fetch the definition for a variable given a connection. Subscribes to field updates and triggers when the variable is found.\n * @param connection Connection to get the variable from\n * @param name Name of the definition to fetch\n * @param timeout Timeout for the fetch\n * @returns Promise the resolves to the variable definition if found, or rejects if there's an error or the timeout has exceeded\n */\nexport function fetchVariableDefinition(connection, name) {\n var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : FETCH_TIMEOUT;\n return new Promise((resolve, reject) => {\n var removeListener;\n var timeoutId = setTimeout(() => {\n var _removeListener;\n (_removeListener = removeListener) === null || _removeListener === void 0 ? void 0 : _removeListener();\n reject(new TimeoutError(\"Timeout looking for variable \".concat(name)));\n }, timeout);\n\n /**\n * Checks if the variable we're looking for is in the changes, and resolves the promise if it does\n * @param changes Variables changes that have occurred\n */\n function handleFieldUpdates(changes) {\n var _removeListener2;\n var definition = changes.created.find(def => def.title === name);\n clearTimeout(timeoutId);\n (_removeListener2 = removeListener) === null || _removeListener2 === void 0 ? void 0 : _removeListener2();\n if (definition != null) {\n resolve(definition);\n } else {\n reject(new Error(\"Variable \".concat(name, \" not found\")));\n }\n }\n removeListener = connection.subscribeToFieldUpdates(handleFieldUpdates);\n });\n}\n//# sourceMappingURL=ConnectionUtils.js.map","import React, { useMemo } from 'react';\nimport usePlugins from \"./usePlugins.js\";\nimport { isWidgetPlugin } from \"./PluginTypes.js\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport function WidgetView(_ref) {\n var {\n fetch,\n type\n } = _ref;\n var plugins = usePlugins();\n var plugin = useMemo(() => [...plugins.values()].filter(isWidgetPlugin).find(p => [p.supportedTypes].flat().includes(type)), [plugins, type]);\n if (plugin != null) {\n var Component = plugin.component;\n return /*#__PURE__*/_jsx(Component, {\n fetch: fetch\n });\n }\n throw new Error(\"Unknown widget type '\".concat(type, \"'\"));\n}\nexport default WidgetView;\n//# sourceMappingURL=WidgetView.js.map"],"names":["log","Log","ErrorBoundary","Component","error","props","errorInfo","onError","children","className","fallback","_jsx","LoadingOverlay","FETCH_TIMEOUT","fetchVariableDefinition","connection","name","timeout","resolve","reject","removeListener","timeoutId","_removeListener","TimeoutError","handleFieldUpdates","changes","_removeListener2","definition","def","WidgetView","_ref","fetch","type","plugins","usePlugins","plugin","useMemo","isWidgetPlugin","p"],"mappings":"0JAIA,IAAIA,EAAMC,EAAI,OAAO,eAAe,EAK7B,MAAMC,UAAsBC,EAAAA,SAAU,CAC3C,OAAO,yBAAyBC,EAAO,CACrC,MAAO,CACL,MAAAA,CACN,CACG,CACD,YAAYC,EAAO,CACjB,MAAMA,CAAK,EACX,KAAK,MAAQ,CACX,MAAO,MACb,CACG,CACD,kBAAkBD,EAAOE,EAAW,CAClC,GAAI,CACF,QAAAC,CACN,EAAQ,KAAK,MACTP,EAAI,MAAM,gCAAiCI,EAAOE,CAAS,EAC3DC,GAAY,MAAsCA,EAAQH,EAAOE,CAAS,CAC3E,CACD,QAAS,CACP,GAAI,CACF,SAAAE,EACA,UAAAC,EACA,SAAAC,CACN,EAAQ,KAAK,MACL,CACF,MAAAN,CACN,EAAQ,KAAK,MACT,OAAIA,GAAS,KACPM,GAGgBC,EAAAA,IAAK,MAAO,CAC9B,UAAWF,EACX,SAAuBE,EAAI,IAACC,EAAgB,CAC1C,aAAc,GAAG,OAAOR,CAAK,EAC7B,UAAW,GACX,SAAU,EACpB,CAAS,CACT,CAAO,EAEII,CACR,CACH,CCjDU,IAACK,EAAgB,IASpB,SAASC,EAAwBC,EAAYC,EAAM,CACxD,IAAIC,EAAU,UAAU,OAAS,GAAK,U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