@deephaven/jsapi-bootstrap 0.92.1-beta.2 → 0.93.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/dist/useDeferredApi.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export declare const DeferredApiContext: import("react").Context<typeof DhType |
|
|
|
15
15
|
* @param widget The widget descriptor to use to fetch the API
|
|
16
16
|
* @returns A tuple with the API instance, and an error if one occurred.
|
|
17
17
|
*/
|
|
18
|
-
export declare function useDeferredApi(widget: DhType.ide.VariableDescriptor): [typeof DhType | null, unknown | null];
|
|
18
|
+
export declare function useDeferredApi(widget: DhType.ide.VariableDescriptor | null): [dh: typeof DhType | null, error: unknown | null];
|
|
19
19
|
export default useDeferredApi;
|
|
20
20
|
//# sourceMappingURL=useDeferredApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeferredApi.d.ts","sourceRoot":"","sources":["../src/useDeferredApi.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,kBAAkB,KACtC,OAAO,CAAC,OAAO,MAAM,CAAC,CAAC;AAE5B,eAAO,MAAM,kBAAkB,oEAExB,CAAC;AAER;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"useDeferredApi.d.ts","sourceRoot":"","sources":["../src/useDeferredApi.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,kBAAkB,KACtC,OAAO,CAAC,OAAO,MAAM,CAAC,CAAC;AAE5B,eAAO,MAAM,kBAAkB,oEAExB,CAAC;AAER;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,kBAAkB,GAAG,IAAI,GAC3C,CAAC,EAAE,EAAE,OAAO,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC,CAuDnD;AAED,eAAe,cAAc,CAAC"}
|
package/dist/useDeferredApi.js
CHANGED
|
@@ -39,7 +39,12 @@ export function useDeferredApi(widget) {
|
|
|
39
39
|
}
|
|
40
40
|
function _loadApi() {
|
|
41
41
|
_loadApi = _asyncToGenerator(function* () {
|
|
42
|
-
if (
|
|
42
|
+
if (widget == null) {
|
|
43
|
+
if (!isCancelled) {
|
|
44
|
+
setApi(null);
|
|
45
|
+
setError(new Error('No widget provided to useDeferredApi'));
|
|
46
|
+
}
|
|
47
|
+
} else if (typeof deferredApi === 'function') {
|
|
43
48
|
try {
|
|
44
49
|
var newApi = yield deferredApi(widget);
|
|
45
50
|
if (!isCancelled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeferredApi.js","names":["createContext","useContext","useEffect","useState","ApiContext","DeferredApiContext","useDeferredApi","widget","api","setApi","error","setError","deferredApi","contextApi","Error","isCancelled","loadApi","_loadApi","apply","arguments","_asyncToGenerator","newApi","e"],"sources":["../src/useDeferredApi.ts"],"sourcesContent":["import { createContext, useContext, useEffect, useState } from 'react';\nimport type { dh as DhType } from '@deephaven/jsapi-types';\nimport { ApiContext } from './ApiBootstrap';\n\n/**\n * Function to fetch an API based on a provided descriptor object.\n * Depending on the context there may be more properties on the descriptor,\n * providing more information about the object, such as a session ID.\n * @param descriptor Descriptor object to fetch the API from.\n * @returns A promise that resolves to the API instance for the provided variable descriptor.\n */\nexport type DeferredApiFetcher = (\n descriptor: DhType.ide.VariableDescriptor\n) => Promise<typeof DhType>;\n\nexport const DeferredApiContext = createContext<\n typeof DhType | DeferredApiFetcher | null\n>(null);\n\n/**\n * Retrieve the API for the current context, given the widget provided.\n * The API may need to be loaded, and will return `null` until it is ready.\n * @param widget The widget descriptor to use to fetch the API\n * @returns A tuple with the API instance, and an error if one occurred.\n */\nexport function useDeferredApi(\n widget: DhType.ide.VariableDescriptor\n): [typeof DhType | null, unknown | null] {\n const [api, setApi] = useState<typeof DhType | null>(null);\n const [error, setError] = useState<unknown | null>(null);\n const deferredApi = useContext(DeferredApiContext);\n const contextApi = useContext(ApiContext);\n\n useEffect(() => {\n if (deferredApi == null) {\n if (contextApi != null) {\n setApi(contextApi);\n setError(null);\n return;\n }\n setApi(null);\n setError(\n new Error(\n 'No API available in useDeferredApi. Was code wrapped in ApiBootstrap or DeferredApiContext.Provider?'\n )\n );\n return;\n }\n let isCancelled = false;\n\n async function loadApi() {\n if (typeof deferredApi === 'function') {\n try {\n const newApi = await deferredApi(widget);\n if (!isCancelled) {\n setApi(newApi);\n setError(null);\n }\n } catch (e) {\n if (!isCancelled) {\n setApi(null);\n setError(e);\n }\n }\n } else {\n setApi(deferredApi);\n }\n }\n\n loadApi();\n\n return () => {\n isCancelled = true;\n };\n }, [contextApi, deferredApi, widget]);\n\n return [api, error];\n}\n\nexport default useDeferredApi;\n"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SAE9DC,UAAU;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AAKA,OAAO,IAAMC,kBAAkB,gBAAGL,aAAa,CAE7C,IAAI,CAAC;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,cAAcA,CAC5BC,
|
|
1
|
+
{"version":3,"file":"useDeferredApi.js","names":["createContext","useContext","useEffect","useState","ApiContext","DeferredApiContext","useDeferredApi","widget","api","setApi","error","setError","deferredApi","contextApi","Error","isCancelled","loadApi","_loadApi","apply","arguments","_asyncToGenerator","newApi","e"],"sources":["../src/useDeferredApi.ts"],"sourcesContent":["import { createContext, useContext, useEffect, useState } from 'react';\nimport type { dh as DhType } from '@deephaven/jsapi-types';\nimport { ApiContext } from './ApiBootstrap';\n\n/**\n * Function to fetch an API based on a provided descriptor object.\n * Depending on the context there may be more properties on the descriptor,\n * providing more information about the object, such as a session ID.\n * @param descriptor Descriptor object to fetch the API from.\n * @returns A promise that resolves to the API instance for the provided variable descriptor.\n */\nexport type DeferredApiFetcher = (\n descriptor: DhType.ide.VariableDescriptor\n) => Promise<typeof DhType>;\n\nexport const DeferredApiContext = createContext<\n typeof DhType | DeferredApiFetcher | null\n>(null);\n\n/**\n * Retrieve the API for the current context, given the widget provided.\n * The API may need to be loaded, and will return `null` until it is ready.\n * @param widget The widget descriptor to use to fetch the API\n * @returns A tuple with the API instance, and an error if one occurred.\n */\nexport function useDeferredApi(\n widget: DhType.ide.VariableDescriptor | null\n): [dh: typeof DhType | null, error: unknown | null] {\n const [api, setApi] = useState<typeof DhType | null>(null);\n const [error, setError] = useState<unknown | null>(null);\n const deferredApi = useContext(DeferredApiContext);\n const contextApi = useContext(ApiContext);\n\n useEffect(() => {\n if (deferredApi == null) {\n if (contextApi != null) {\n setApi(contextApi);\n setError(null);\n return;\n }\n setApi(null);\n setError(\n new Error(\n 'No API available in useDeferredApi. Was code wrapped in ApiBootstrap or DeferredApiContext.Provider?'\n )\n );\n return;\n }\n let isCancelled = false;\n\n async function loadApi() {\n if (widget == null) {\n if (!isCancelled) {\n setApi(null);\n setError(new Error('No widget provided to useDeferredApi'));\n }\n } else if (typeof deferredApi === 'function') {\n try {\n const newApi = await deferredApi(widget);\n if (!isCancelled) {\n setApi(newApi);\n setError(null);\n }\n } catch (e) {\n if (!isCancelled) {\n setApi(null);\n setError(e);\n }\n }\n } else {\n setApi(deferredApi);\n }\n }\n\n loadApi();\n\n return () => {\n isCancelled = true;\n };\n }, [contextApi, deferredApi, widget]);\n\n return [api, error];\n}\n\nexport default useDeferredApi;\n"],"mappings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AACL,MAAM,CAAC;YACxC,IAAI,CAACQ,WAAW,EAAE;cAChBN,MAAM,CAACY,MAAM,CAAC;cACdV,QAAQ,CAAC,IAAI,CAAC;YAChB;UACF,CAAC,CAAC,OAAOW,CAAC,EAAE;YACV,IAAI,CAACP,WAAW,EAAE;cAChBN,MAAM,CAAC,IAAI,CAAC;cACZE,QAAQ,CAACW,CAAC,CAAC;YACb;UACF;QACF,CAAC,MAAM;UACLb,MAAM,CAACG,WAAW,CAAC;QACrB;MACF,CAAC;MAAA,OAAAK,QAAA,CAAAC,KAAA,OAAAC,SAAA;IAAA;IAEDH,OAAO,CAAC,CAAC;IAET,OAAO,MAAM;MACXD,WAAW,GAAG,IAAI;IACpB,CAAC;EACH,CAAC,EAAE,CAACF,UAAU,EAAED,WAAW,EAAEL,MAAM,CAAC,CAAC;EAErC,OAAO,CAACC,GAAG,EAAEE,KAAK,CAAC;AACrB;AAEA,eAAeJ,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/jsapi-bootstrap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.93.0",
|
|
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.
|
|
25
|
+
"@deephaven/components": "^0.93.0",
|
|
26
26
|
"@deephaven/jsapi-types": "^1.0.0-dev0.34.0",
|
|
27
|
-
"@deephaven/log": "^0.
|
|
28
|
-
"@deephaven/react-hooks": "^0.
|
|
29
|
-
"@deephaven/utils": "^0.
|
|
27
|
+
"@deephaven/log": "^0.93.0",
|
|
28
|
+
"@deephaven/react-hooks": "^0.93.0",
|
|
29
|
+
"@deephaven/utils": "^0.93.0"
|
|
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": "1503a37f687860ed63e5fd009fc2fb9416e40eef"
|
|
45
45
|
}
|