@deephaven/jsapi-bootstrap 0.58.1-alpha-theming-preload.6 → 0.58.1-alpha-light-theme-fixes.30
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/useApi.d.ts +4 -0
- package/dist/useApi.d.ts.map +1 -1
- package/dist/useApi.js +4 -0
- package/dist/useApi.js.map +1 -1
- package/dist/useDeferredApi.d.ts +14 -0
- package/dist/useDeferredApi.d.ts.map +1 -0
- package/dist/useDeferredApi.js +62 -0
- package/dist/useDeferredApi.js.map +1 -0
- package/package.json +6 -6
package/dist/useApi.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve the API for the current context.
|
|
4
|
+
* @returns The API instance from the nearest ApiContext.Provider, or throws if none is set
|
|
5
|
+
*/
|
|
2
6
|
export declare function useApi(): DhType;
|
|
3
7
|
export default useApi;
|
|
4
8
|
//# sourceMappingURL=useApi.d.ts.map
|
package/dist/useApi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApi.d.ts","sourceRoot":"","sources":["../src/useApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAI3D,wBAAgB,MAAM,IAAI,MAAM,CAK/B;AAED,eAAe,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"useApi.d.ts","sourceRoot":"","sources":["../src/useApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAI3D;;;GAGG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAK/B;AAED,eAAe,MAAM,CAAC"}
|
package/dist/useApi.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useContextOrThrow } from '@deephaven/react-hooks';
|
|
2
2
|
import { ApiContext } from "./ApiBootstrap.js";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve the API for the current context.
|
|
5
|
+
* @returns The API instance from the nearest ApiContext.Provider, or throws if none is set
|
|
6
|
+
*/
|
|
3
7
|
export function useApi() {
|
|
4
8
|
return useContextOrThrow(ApiContext, 'No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?');
|
|
5
9
|
}
|
package/dist/useApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApi.js","names":["useContextOrThrow","ApiContext","useApi"],"sources":["../src/useApi.ts"],"sourcesContent":["import type { dh as DhType } from '@deephaven/jsapi-types';\nimport { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ApiContext } from './ApiBootstrap';\n\nexport function useApi(): DhType {\n return useContextOrThrow(\n ApiContext,\n 'No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?'\n );\n}\n\nexport default useApi;\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAClDC,UAAU;AAEnB,OAAO,SAASC,MAAMA,CAAA,EAAW;EAC/B,OAAOF,iBAAiB,CACtBC,UAAU,EACV,sFACF,CAAC;AACH;AAEA,eAAeC,MAAM"}
|
|
1
|
+
{"version":3,"file":"useApi.js","names":["useContextOrThrow","ApiContext","useApi"],"sources":["../src/useApi.ts"],"sourcesContent":["import type { dh as DhType } from '@deephaven/jsapi-types';\nimport { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ApiContext } from './ApiBootstrap';\n\n/**\n * Retrieve the API for the current context.\n * @returns The API instance from the nearest ApiContext.Provider, or throws if none is set\n */\nexport function useApi(): DhType {\n return useContextOrThrow(\n ApiContext,\n 'No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?'\n );\n}\n\nexport default useApi;\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAClDC,UAAU;AAEnB;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAAA,EAAW;EAC/B,OAAOF,iBAAiB,CACtBC,UAAU,EACV,sFACF,CAAC;AACH;AAEA,eAAeC,MAAM"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
3
|
+
/** Options for retrieving the deferred */
|
|
4
|
+
export type DeferredApiOptions = Record<string, unknown>;
|
|
5
|
+
export type DeferredApiFetcher = (options?: DeferredApiOptions) => Promise<DhType>;
|
|
6
|
+
export declare const DeferredApiContext: import("react").Context<DhType | DeferredApiFetcher | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Retrieve the API for the current context, given the metadata provided.
|
|
9
|
+
* The API may need to be loaded, and will return `null` until it is ready.
|
|
10
|
+
* @returns A tuple with the API instance, and an error if one occurred.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useDeferredApi(options?: Record<string, unknown>): [DhType | null, unknown | null];
|
|
13
|
+
export default useDeferredApi;
|
|
14
|
+
//# sourceMappingURL=useDeferredApi.d.ts.map
|
|
@@ -0,0 +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,0CAA0C;AAC1C,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,CAAC,EAAE,kBAAkB,KACzB,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,eAAO,MAAM,kBAAkB,6DAExB,CAAC;AAER;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,CAAC,MAAM,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC,CAkDjC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
|
+
import { createContext, useContext, useEffect, useState } from 'react';
|
|
4
|
+
import { ApiContext } from "./ApiBootstrap.js";
|
|
5
|
+
/** Options for retrieving the deferred */
|
|
6
|
+
export var DeferredApiContext = /*#__PURE__*/createContext(null);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve the API for the current context, given the metadata provided.
|
|
10
|
+
* The API may need to be loaded, and will return `null` until it is ready.
|
|
11
|
+
* @returns A tuple with the API instance, and an error if one occurred.
|
|
12
|
+
*/
|
|
13
|
+
export function useDeferredApi(options) {
|
|
14
|
+
var [api, setApi] = useState(null);
|
|
15
|
+
var [error, setError] = useState(null);
|
|
16
|
+
var deferredApi = useContext(DeferredApiContext);
|
|
17
|
+
var contextApi = useContext(ApiContext);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (deferredApi == null) {
|
|
20
|
+
if (contextApi != null) {
|
|
21
|
+
setApi(contextApi);
|
|
22
|
+
setError(null);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
setApi(null);
|
|
26
|
+
setError(new Error('No API available in useDeferredApi. Was code wrapped in ApiBootstrap or DeferredApiContext.Provider?'));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var isCancelled = false;
|
|
30
|
+
function loadApi() {
|
|
31
|
+
return _loadApi.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
function _loadApi() {
|
|
34
|
+
_loadApi = _asyncToGenerator(function* () {
|
|
35
|
+
if (typeof deferredApi === 'function') {
|
|
36
|
+
try {
|
|
37
|
+
var newApi = yield deferredApi(options);
|
|
38
|
+
if (!isCancelled) {
|
|
39
|
+
setApi(newApi);
|
|
40
|
+
setError(null);
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (!isCancelled) {
|
|
44
|
+
setApi(null);
|
|
45
|
+
setError(e);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
setApi(deferredApi);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return _loadApi.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
loadApi();
|
|
55
|
+
return () => {
|
|
56
|
+
isCancelled = true;
|
|
57
|
+
};
|
|
58
|
+
}, [contextApi, deferredApi, options]);
|
|
59
|
+
return [api, error];
|
|
60
|
+
}
|
|
61
|
+
export default useDeferredApi;
|
|
62
|
+
//# sourceMappingURL=useDeferredApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeferredApi.js","names":["createContext","useContext","useEffect","useState","ApiContext","DeferredApiContext","useDeferredApi","options","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/** Options for retrieving the deferred */\nexport type DeferredApiOptions = Record<string, unknown>;\n\nexport type DeferredApiFetcher = (\n options?: DeferredApiOptions\n) => Promise<DhType>;\n\nexport const DeferredApiContext = createContext<\n DhType | DeferredApiFetcher | null\n>(null);\n\n/**\n * Retrieve the API for the current context, given the metadata provided.\n * The API may need to be loaded, and will return `null` until it is ready.\n * @returns A tuple with the API instance, and an error if one occurred.\n */\nexport function useDeferredApi(\n options?: Record<string, unknown>\n): [DhType | null, unknown | null] {\n const [api, setApi] = useState<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(options);\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, options]);\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;AAOA,OAAO,IAAMC,kBAAkB,gBAAGL,aAAa,CAE7C,IAAI,CAAC;;AAEP;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,cAAcA,CAC5BC,OAAiC,EACA;EACjC,IAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAGN,QAAQ,CAAgB,IAAI,CAAC;EACnD,IAAM,CAACO,KAAK,EAAEC,QAAQ,CAAC,GAAGR,QAAQ,CAAiB,IAAI,CAAC;EACxD,IAAMS,WAAW,GAAGX,UAAU,CAACI,kBAAkB,CAAC;EAClD,IAAMQ,UAAU,GAAGZ,UAAU,CAACG,UAAU,CAAC;EAEzCF,SAAS,CAAC,MAAM;IACd,IAAIU,WAAW,IAAI,IAAI,EAAE;MACvB,IAAIC,UAAU,IAAI,IAAI,EAAE;QACtBJ,MAAM,CAACI,UAAU,CAAC;QAClBF,QAAQ,CAAC,IAAI,CAAC;QACd;MACF;MACAF,MAAM,CAAC,IAAI,CAAC;MACZE,QAAQ,CACN,IAAIG,KAAK,CACP,sGACF,CACF,CAAC;MACD;IACF;IACA,IAAIC,WAAW,GAAG,KAAK;IAAC,SAETC,OAAOA,CAAA;MAAA,OAAAC,QAAA,CAAAC,KAAA,OAAAC,SAAA;IAAA;IAAA,SAAAF,SAAA;MAAAA,QAAA,GAAAG,iBAAA,CAAtB,aAAyB;QACvB,IAAI,OAAOR,WAAW,KAAK,UAAU,EAAE;UACrC,IAAI;YACF,IAAMS,MAAM,SAAST,WAAW,CAACL,OAAO,CAAC;YACzC,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,OAAO,CAAC,CAAC;EAEtC,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.58.1-alpha-
|
|
3
|
+
"version": "0.58.1-alpha-light-theme-fixes.30+11945136",
|
|
4
4
|
"description": "Deephaven JSAPI Bootstrap",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"build:sass": "sass --embed-sources --load-path=../../node_modules ./src:./dist"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@deephaven/components": "^0.58.1-alpha-
|
|
26
|
-
"@deephaven/jsapi-types": "^0.58.1-alpha-
|
|
27
|
-
"@deephaven/log": "^0.58.1-alpha-
|
|
28
|
-
"@deephaven/react-hooks": "^0.58.1-alpha-
|
|
25
|
+
"@deephaven/components": "^0.58.1-alpha-light-theme-fixes.30+11945136",
|
|
26
|
+
"@deephaven/jsapi-types": "^0.58.1-alpha-light-theme-fixes.30+11945136",
|
|
27
|
+
"@deephaven/log": "^0.58.1-alpha-light-theme-fixes.30+11945136",
|
|
28
|
+
"@deephaven/react-hooks": "^0.58.1-alpha-light-theme-fixes.30+11945136"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"react": "^17.x"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "11945136a4d11fe4c2245ae4519e117dec87fec1"
|
|
44
44
|
}
|