@deephaven/jsapi-bootstrap 0.78.1-use-widget.2 → 0.78.1-use-widget.4
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/dist/useWidget.d.ts.map +1 -1
- package/dist/useWidget.js +4 -0
- package/dist/useWidget.js.map +1 -1
- package/package.json +6 -6
package/dist/useWidget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWidget.d.ts","sourceRoot":"","sources":["../src/useWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAQ5C;;GAEG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,IAAI;IACpD,gCAAgC;IAChC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IAEjB,6DAA6D;IAC7D,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,EACvD,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,kBAAkB,GACpC,aAAa,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"useWidget.d.ts","sourceRoot":"","sources":["../src/useWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAQ5C;;GAEG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,IAAI;IACpD,gCAAgC;IAChC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IAEjB,6DAA6D;IAC7D,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,EACvD,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,kBAAkB,GACpC,aAAa,CAAC,CAAC,CAAC,CAgElB;AAED,eAAe,SAAS,CAAC"}
|
package/dist/useWidget.js
CHANGED
|
@@ -43,6 +43,10 @@ export function useWidget(descriptor) {
|
|
|
43
43
|
});
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
// We should be able to load the widget. Load it asynchronously, and set the widget when it's done.
|
|
48
|
+
// If we get cancelled before the fetch is done, we should close the widget and its exported objects.
|
|
49
|
+
// If not though, the consumer of the widget is expected to take ownership and close the widget appropriately.
|
|
46
50
|
var isCancelled = false;
|
|
47
51
|
function loadWidgetInternal() {
|
|
48
52
|
return _loadWidgetInternal.apply(this, arguments);
|
package/dist/useWidget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWidget.js","names":["Log","assertNotNull","useEffect","useState","useObjectFetch","log","module","useWidget","descriptor","wrapper","setWrapper","widget","error","objectFetch","loadWidget","debug","fetch","isCancelled","loadWidgetInternal","_loadWidgetInternal","apply","arguments","_asyncToGenerator","newWidget","debug2","close","exportedObjects","forEach","exportedObject","e"],"sources":["../src/useWidget.ts"],"sourcesContent":["import { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport { assertNotNull } from '@deephaven/utils';\nimport { useEffect, useState } from 'react';\nimport { useObjectFetch } from './useObjectFetch';\n\nconst log = Log.module('useWidget');\n\n/**\n * Wrapper object for a widget and error status. Both widget and error will be `null` if it is still loading.\n */\ntype WidgetWrapper<T extends dh.Widget = dh.Widget> = {\n /** Widget object to retrieve */\n widget: T | null;\n\n /** Error status if there was an issue fetching the widget */\n error: unknown | null;\n};\n\n/**\n * Retrieve a widget for the given variable descriptor. Note that if the widget is successfully fetched, ownership of the widget is passed to the consumer and will need to close the object as well.\n * @param descriptor Descriptor to get the widget for\n * @returns A WidgetWrapper object that contains the widget or an error status if there was an issue fetching the widget. Will contain nulls if still loading.\n */\nexport function useWidget<T extends dh.Widget = dh.Widget>(\n descriptor: dh.ide.VariableDescriptor\n): WidgetWrapper<T> {\n const [wrapper, setWrapper] = useState<WidgetWrapper<T>>(() => ({\n widget: null,\n error: null,\n }));\n\n const objectFetch = useObjectFetch<T>(descriptor);\n\n useEffect(\n function loadWidget() {\n log.debug('loadWidget', descriptor);\n\n const { fetch, error } = objectFetch;\n\n if (error != null) {\n // We can't fetch if there's an error getting the fetcher, just return an error\n setWrapper({ widget: null, error });\n return;\n }\n\n if (fetch == null) {\n // Still loading\n setWrapper({ widget: null, error: null });\n return;\n }\n\n let isCancelled = false;\n async function loadWidgetInternal() {\n try {\n assertNotNull(fetch);\n const newWidget = await fetch();\n if (isCancelled) {\n log.debug2('loadWidgetInternal cancelled', descriptor, newWidget);\n newWidget.close();\n newWidget.exportedObjects.forEach(\n (exportedObject: dh.WidgetExportedObject) => {\n exportedObject.close();\n }\n );\n return;\n }\n log.debug('loadWidgetInternal done', descriptor, newWidget);\n\n setWrapper({ widget: newWidget, error: null });\n } catch (e) {\n if (isCancelled) {\n return;\n }\n log.error('loadWidgetInternal error', descriptor, e);\n setWrapper({ widget: null, error: e });\n }\n }\n loadWidgetInternal();\n return () => {\n isCancelled = true;\n };\n },\n [descriptor, objectFetch]\n );\n\n return wrapper;\n}\n\nexport default useWidget;\n"],"mappings":";;AACA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SACnCC,cAAc;AAEvB,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,WAAW,CAAC;;AAEnC;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CACvBC,UAAqC,EACnB;EAClB,IAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGP,QAAQ,CAAmB,OAAO;IAC9DQ,MAAM,EAAE,IAAI;IACZC,KAAK,EAAE;EACT,CAAC,CAAC,CAAC;EAEH,IAAMC,WAAW,GAAGT,cAAc,CAAII,UAAU,CAAC;EAEjDN,SAAS,CACP,SAASY,UAAUA,CAAA,EAAG;IACpBT,GAAG,CAACU,KAAK,CAAC,YAAY,EAAEP,UAAU,CAAC;IAEnC,IAAM;MAAEQ,KAAK;MAAEJ;IAAM,CAAC,GAAGC,WAAW;IAEpC,IAAID,KAAK,IAAI,IAAI,EAAE;MACjB;MACAF,UAAU,CAAC;QAAEC,MAAM,EAAE,IAAI;QAAEC;MAAM,CAAC,CAAC;MACnC;IACF;IAEA,IAAII,KAAK,IAAI,IAAI,EAAE;MACjB;MACAN,UAAU,CAAC;QAAEC,MAAM,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAK,CAAC,CAAC;MACzC;IACF;
|
|
1
|
+
{"version":3,"file":"useWidget.js","names":["Log","assertNotNull","useEffect","useState","useObjectFetch","log","module","useWidget","descriptor","wrapper","setWrapper","widget","error","objectFetch","loadWidget","debug","fetch","isCancelled","loadWidgetInternal","_loadWidgetInternal","apply","arguments","_asyncToGenerator","newWidget","debug2","close","exportedObjects","forEach","exportedObject","e"],"sources":["../src/useWidget.ts"],"sourcesContent":["import { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport { assertNotNull } from '@deephaven/utils';\nimport { useEffect, useState } from 'react';\nimport { useObjectFetch } from './useObjectFetch';\n\nconst log = Log.module('useWidget');\n\n/**\n * Wrapper object for a widget and error status. Both widget and error will be `null` if it is still loading.\n */\ntype WidgetWrapper<T extends dh.Widget = dh.Widget> = {\n /** Widget object to retrieve */\n widget: T | null;\n\n /** Error status if there was an issue fetching the widget */\n error: unknown | null;\n};\n\n/**\n * Retrieve a widget for the given variable descriptor. Note that if the widget is successfully fetched, ownership of the widget is passed to the consumer and will need to close the object as well.\n * @param descriptor Descriptor to get the widget for\n * @returns A WidgetWrapper object that contains the widget or an error status if there was an issue fetching the widget. Will contain nulls if still loading.\n */\nexport function useWidget<T extends dh.Widget = dh.Widget>(\n descriptor: dh.ide.VariableDescriptor\n): WidgetWrapper<T> {\n const [wrapper, setWrapper] = useState<WidgetWrapper<T>>(() => ({\n widget: null,\n error: null,\n }));\n\n const objectFetch = useObjectFetch<T>(descriptor);\n\n useEffect(\n function loadWidget() {\n log.debug('loadWidget', descriptor);\n\n const { fetch, error } = objectFetch;\n\n if (error != null) {\n // We can't fetch if there's an error getting the fetcher, just return an error\n setWrapper({ widget: null, error });\n return;\n }\n\n if (fetch == null) {\n // Still loading\n setWrapper({ widget: null, error: null });\n return;\n }\n\n // We should be able to load the widget. Load it asynchronously, and set the widget when it's done.\n // If we get cancelled before the fetch is done, we should close the widget and its exported objects.\n // If not though, the consumer of the widget is expected to take ownership and close the widget appropriately.\n let isCancelled = false;\n async function loadWidgetInternal() {\n try {\n assertNotNull(fetch);\n const newWidget = await fetch();\n if (isCancelled) {\n log.debug2('loadWidgetInternal cancelled', descriptor, newWidget);\n newWidget.close();\n newWidget.exportedObjects.forEach(\n (exportedObject: dh.WidgetExportedObject) => {\n exportedObject.close();\n }\n );\n return;\n }\n log.debug('loadWidgetInternal done', descriptor, newWidget);\n\n setWrapper({ widget: newWidget, error: null });\n } catch (e) {\n if (isCancelled) {\n return;\n }\n log.error('loadWidgetInternal error', descriptor, e);\n setWrapper({ widget: null, error: e });\n }\n }\n loadWidgetInternal();\n return () => {\n isCancelled = true;\n };\n },\n [descriptor, objectFetch]\n );\n\n return wrapper;\n}\n\nexport default useWidget;\n"],"mappings":";;AACA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SACnCC,cAAc;AAEvB,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,WAAW,CAAC;;AAEnC;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CACvBC,U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UAE3Db,UAAU,CAAC;YAAEC,MAAM,EAAEY,SAAS;YAAEX,KAAK,EAAE;UAAK,CAAC,CAAC;QAChD,CAAC,CAAC,OAAOiB,CAAC,EAAE;UACV,IAAIZ,WAAW,EAAE;YACf;UACF;UACAZ,GAAG,CAACO,KAAK,CAAC,0BAA0B,EAAEJ,UAAU,EAAEqB,CAAC,CAAC;UACpDnB,UAAU,CAAC;YAAEC,MAAM,EAAE,IAAI;YAAEC,KAAK,EAAEiB;UAAE,CAAC,CAAC;QACxC;MACF,CAAC;MAAA,OAAAV,mBAAA,CAAAC,KAAA,OAAAC,SAAA;IAAA;IACDH,kBAAkB,CAAC,CAAC;IACpB,OAAO,MAAM;MACXD,WAAW,GAAG,IAAI;IACpB,CAAC;EACH,CAAC,EACD,CAACT,UAAU,EAAEK,WAAW,CAC1B,CAAC;EAED,OAAOJ,OAAO;AAChB;AAEA,eAAeF,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/jsapi-bootstrap",
|
|
3
|
-
"version": "0.78.1-use-widget.
|
|
3
|
+
"version": "0.78.1-use-widget.4+61dd02ae",
|
|
4
4
|
"description": "Deephaven JSAPI Bootstrap",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"build:sass": "sass --embed-sources --load-path=../../node_modules ./src:./dist"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@deephaven/components": "^0.78.1-use-widget.
|
|
25
|
+
"@deephaven/components": "^0.78.1-use-widget.4+61dd02ae",
|
|
26
26
|
"@deephaven/jsapi-types": "1.0.0-dev0.34.0",
|
|
27
|
-
"@deephaven/log": "^0.78.1-use-widget.
|
|
28
|
-
"@deephaven/react-hooks": "^0.78.1-use-widget.
|
|
29
|
-
"@deephaven/utils": "^0.78.1-use-widget.
|
|
27
|
+
"@deephaven/log": "^0.78.1-use-widget.4+61dd02ae",
|
|
28
|
+
"@deephaven/react-hooks": "^0.78.1-use-widget.4+61dd02ae",
|
|
29
|
+
"@deephaven/utils": "^0.78.1-use-widget.4+61dd02ae"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"react": "^17.x"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "61dd02aef2e64aba3820e7d0d6fc419c307d5448"
|
|
45
45
|
}
|