@deephaven/jsapi-bootstrap 0.78.1-use-widget.3 → 0.78.1-use-widget.2

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.
@@ -19,6 +19,7 @@ export type ObjectFetchUpdate<T = unknown> = {
19
19
  */
20
20
  error: unknown | null;
21
21
  };
22
+ export type ObjectFetchUpdateCallback<T = unknown> = (update: ObjectFetchUpdate<T>) => void;
22
23
  /** ObjectFetchManager for managing a subscription to an object using a VariableDescriptor */
23
24
  export type ObjectFetchManager = {
24
25
  /**
@@ -27,7 +28,7 @@ export type ObjectFetchManager = {
27
28
  * @param onUpdate Callback function to be called when the object is updated.
28
29
  * @returns An unsubscribe function to stop listening for updates and clean up the object.
29
30
  */
30
- subscribe: <T = unknown>(descriptor: dh.ide.VariableDescriptor, onUpdate: (update: ObjectFetchUpdate<T>) => void) => UnsubscribeFunction;
31
+ subscribe: <T = unknown>(descriptor: dh.ide.VariableDescriptor, onUpdate: ObjectFetchUpdateCallback<T>) => UnsubscribeFunction;
31
32
  };
32
33
  /** Context for tracking an implementation of the ObjectFetchManager. */
33
34
  export declare const ObjectFetchManagerContext: import("react").Context<ObjectFetchManager | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"useObjectFetch.d.ts","sourceRoot":"","sources":["../src/useObjectFetch.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAEjD,2DAA2D;AAC3D,MAAM,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,OAAO,IAAI;IAC3C;;OAEG;IACH,KAAK,EAAE,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEjC;;;OAGG;IACH,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,6FAA6F;AAC7F,MAAM,MAA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CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,oDACU,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EACxC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,kBAAkB,GACpC,iBAAiB,CAAC,CAAC,CAAC,CAmCtB"}
@@ -1,16 +1,13 @@
1
1
  import { createContext, useContext, useEffect, useState } from 'react';
2
-
2
+ import { ObjectFetcherContext } from "./useObjectFetcher.js";
3
3
  /** Function for unsubscribing from a given subscription */
4
-
5
4
  /**
6
5
  * Update with the current `fetch` fuonction and status of the object.
7
6
  * - If both `fetch` and `error` are `null`, it is still loading the fetcher
8
7
  * - If `fetch` is not `null`, the object is ready to be fetched
9
8
  * - If `error` is not `null`, there was an error loading the object
10
9
  */
11
-
12
10
  /** ObjectFetchManager for managing a subscription to an object using a VariableDescriptor */
13
-
14
11
  /** Context for tracking an implementation of the ObjectFetchManager. */
15
12
  export var ObjectFetchManagerContext = /*#__PURE__*/createContext(null);
16
13
 
@@ -26,13 +23,21 @@ export function useObjectFetch(descriptor) {
26
23
  fetch: null,
27
24
  error: null
28
25
  }));
26
+ var objectFetcher = useContext(ObjectFetcherContext);
29
27
  var objectFetchManager = useContext(ObjectFetchManagerContext);
30
28
  useEffect(() => {
31
29
  if (objectFetchManager == null) {
32
- setCurrentUpdate({
33
- fetch: null,
34
- error: new Error('No ObjectFetchManager available in context')
35
- });
30
+ if (objectFetcher == null) {
31
+ setCurrentUpdate({
32
+ fetch: null,
33
+ error: new Error('No ObjectFetchManager available in context')
34
+ });
35
+ } else {
36
+ setCurrentUpdate({
37
+ fetch: () => objectFetcher(descriptor),
38
+ error: null
39
+ });
40
+ }
36
41
  return;
37
42
  }
38
43
  // Signal that we're still loading
@@ -41,7 +46,7 @@ export function useObjectFetch(descriptor) {
41
46
  error: null
42
47
  });
43
48
  return objectFetchManager.subscribe(descriptor, setCurrentUpdate);
44
- }, [descriptor, objectFetchManager]);
49
+ }, [descriptor, objectFetcher, objectFetchManager]);
45
50
  return currentUpdate;
46
51
  }
47
52
  //# sourceMappingURL=useObjectFetch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useObjectFetch.js","names":["createContext","useContext","useEffect","useState","ObjectFetchManagerContext","useObjectFetch","descriptor","currentUpdate","setCurrentUpdate","fetch","error","objectFetchManager","Error","subscribe"],"sources":["../src/useObjectFetch.ts"],"sourcesContent":["import { createContext, useContext, useEffect, useState } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\n\n/** Function for unsubscribing from a given subscription */\nexport type UnsubscribeFunction = () => void;\n\n/**\n * Update with the current `fetch` fuonction and status of the object.\n * - If both `fetch` and `error` are `null`, it is still loading the fetcher\n * - If `fetch` is not `null`, the object is ready to be fetched\n * - If `error` is not `null`, there was an error loading the object\n */\nexport type ObjectFetchUpdate<T = unknown> = {\n /**\n * Function to fetch the object. If `null`, the object is still loading or there was an error.\n */\n fetch: (() => Promise<T>) | null;\n\n /**\n * Error that occurred while fetching the object. If `null`, there was no error.\n * Will automatically retry when possible while the subscribed.\n */\n error: unknown | null;\n};\n\n/** ObjectFetchManager for managing a subscription to an object using a VariableDescriptor */\nexport type ObjectFetchManager = {\n /**\n *\n * @param descriptor Descriptor object to fetch the object from. Can be extended by a specific implementation to include more details necessary for the ObjectManager.\n * @param onUpdate Callback function to be called when the object is updated.\n * @returns An unsubscribe function to stop listening for updates and clean up the object.\n */\n subscribe: <T = unknown>(\n descriptor: dh.ide.VariableDescriptor,\n onUpdate: (update: ObjectFetchUpdate<T>) => void\n ) => UnsubscribeFunction;\n};\n\n/** Context for tracking an implementation of the ObjectFetchManager. */\nexport const ObjectFetchManagerContext =\n createContext<ObjectFetchManager | null>(null);\n\n/**\n * Retrieve a `fetch` function for the given variable descriptor.\n *\n * @param descriptor Descriptor to get the `fetch` function for\n * @returns An object with the current `fetch` function, OR an error status set if there was an issue fetching the object.\n * Retrying is left up to the ObjectManager implementation used from this context.\n */\nexport function useObjectFetch<T = unknown>(\n descriptor: dh.ide.VariableDescriptor\n): ObjectFetchUpdate<T> {\n const [currentUpdate, setCurrentUpdate] = useState<ObjectFetchUpdate<T>>(\n () => ({\n fetch: null,\n error: null,\n })\n );\n\n const objectFetchManager = useContext(ObjectFetchManagerContext);\n\n useEffect(() => {\n if (objectFetchManager == null) {\n setCurrentUpdate({\n fetch: null,\n error: new Error('No ObjectFetchManager available in context'),\n });\n return;\n }\n // Signal that we're still loading\n setCurrentUpdate({\n fetch: null,\n error: null,\n });\n return objectFetchManager.subscribe(descriptor, setCurrentUpdate);\n }, [descriptor, objectFetchManager]);\n\n return currentUpdate;\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;;AAGtE;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAcA;;AAcA;AACA,OAAO,IAAMC,yBAAyB,gBACpCJ,aAAa,CAA4B,IAAI,CAAC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,cAAcA,CAC5BC,UAAqC,EACf;EACtB,IAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGL,QAAQ,CAChD,OAAO;IACLM,KAAK,EAAE,IAAI;IACXC,KAAK,EAAE;EACT,CAAC,CACH,CAAC;EAED,IAAMC,kBAAkB,GAAGV,UAAU,CAACG,yBAAyB,CAAC;EAEhEF,SAAS,CAAC,MAAM;IACd,IAAIS,kBAAkB,IAAI,IAAI,EAAE;MAC9BH,gBAAgB,CAAC;QACfC,KAAK,EAAE,IAAI;QACXC,KAAK,EAAE,IAAIE,KAAK,CAAC,4CAA4C;MAC/D,CAAC,CAAC;MACF;IACF;IACA;IACAJ,gBAAgB,CAAC;MACfC,KAAK,EAAE,IAAI;MACXC,KAAK,EAAE;IACT,CAAC,CAAC;IACF,OAAOC,kBAAkB,CAACE,SAAS,CAACP,UAAU,EAAEE,gBAAgB,CAAC;EACnE,CAAC,EAAE,CAACF,UAAU,EAAEK,kBAAkB,CAAC,CAAC;EAEpC,OAAOJ,aAAa;AACtB"}
1
+ {"version":3,"file":"useObjectFetch.js","names":["createContext","useContext","useEffect","useState","ObjectFetcherContext","ObjectFetchManagerContext","useObjectFetch","descriptor","currentUpdate","setCurrentUpdate","fetch","error","objectFetcher","objectFetchManager","Error","subscribe"],"sources":["../src/useObjectFetch.ts"],"sourcesContent":["import { createContext, useContext, useEffect, useState } from 'react';\nimport type { dh } from '@deephaven/jsapi-types';\nimport { ObjectFetcherContext } from './useObjectFetcher';\n\n/** Function for unsubscribing from a given subscription */\nexport type UnsubscribeFunction = () => void;\n\n/**\n * Update with the current `fetch` fuonction and status of the object.\n * - If both `fetch` and `error` are `null`, it is still loading the fetcher\n * - If `fetch` is not `null`, the object is ready to be fetched\n * - If `error` is not `null`, there was an error loading the object\n */\nexport type ObjectFetchUpdate<T = unknown> = {\n /**\n * Function to fetch the object. If `null`, the object is still loading or there was an error.\n */\n fetch: (() => Promise<T>) | null;\n\n /**\n * Error that occurred while fetching the object. If `null`, there was no error.\n * Will automatically retry when possible while the subscribed.\n */\n error: unknown | null;\n};\n\nexport type ObjectFetchUpdateCallback<T = unknown> = (\n update: ObjectFetchUpdate<T>\n) => void;\n\n/** ObjectFetchManager for managing a subscription to an object using a VariableDescriptor */\nexport type ObjectFetchManager = {\n /**\n *\n * @param descriptor Descriptor object to fetch the object from. Can be extended by a specific implementation to include more details necessary for the ObjectManager.\n * @param onUpdate Callback function to be called when the object is updated.\n * @returns An unsubscribe function to stop listening for updates and clean up the object.\n */\n subscribe: <T = unknown>(\n descriptor: dh.ide.VariableDescriptor,\n onUpdate: ObjectFetchUpdateCallback<T>\n ) => UnsubscribeFunction;\n};\n\n/** Context for tracking an implementation of the ObjectFetchManager. */\nexport const ObjectFetchManagerContext =\n createContext<ObjectFetchManager | null>(null);\n\n/**\n * Retrieve a `fetch` function for the given variable descriptor.\n *\n * @param descriptor Descriptor to get the `fetch` function for\n * @returns An object with the current `fetch` function, OR an error status set if there was an issue fetching the object.\n * Retrying is left up to the ObjectManager implementation used from this context.\n */\nexport function useObjectFetch<T = unknown>(\n descriptor: dh.ide.VariableDescriptor\n): ObjectFetchUpdate<T> {\n const [currentUpdate, setCurrentUpdate] = useState<ObjectFetchUpdate<T>>(\n () => ({\n fetch: null,\n error: null,\n })\n );\n\n const objectFetcher = useContext(ObjectFetcherContext);\n const objectFetchManager = useContext(ObjectFetchManagerContext);\n\n useEffect(() => {\n if (objectFetchManager == null) {\n if (objectFetcher == null) {\n setCurrentUpdate({\n fetch: null,\n error: new Error('No ObjectFetchManager available in context'),\n });\n } else {\n setCurrentUpdate({\n fetch: () => objectFetcher(descriptor),\n error: null,\n });\n }\n return;\n }\n // Signal that we're still loading\n setCurrentUpdate({\n fetch: null,\n error: null,\n });\n return objectFetchManager.subscribe(descriptor, setCurrentUpdate);\n }, [descriptor, objectFetcher, objectFetchManager]);\n\n return currentUpdate;\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SAE9DC,oBAAoB;AAE7B;AAGA;AACA;AACA;AACA;AACA;AACA;AAkBA;AAcA;AACA,OAAO,IAAMC,yBAAyB,gBACpCL,aAAa,CAA4B,IAAI,CAAC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,cAAcA,CAC5BC,UAAqC,EACf;EACtB,IAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGN,QAAQ,CAChD,OAAO;IACLO,KAAK,EAAE,IAAI;IACXC,KAAK,EAAE;EACT,CAAC,CACH,CAAC;EAED,IAAMC,aAAa,GAAGX,UAAU,CAACG,oBAAoB,CAAC;EACtD,IAAMS,kBAAkB,GAAGZ,UAAU,CAACI,yBAAyB,CAAC;EAEhEH,SAAS,CAAC,MAAM;IACd,IAAIW,kBAAkB,IAAI,IAAI,EAAE;MAC9B,IAAID,aAAa,IAAI,IAAI,EAAE;QACzBH,gBAAgB,CAAC;UACfC,KAAK,EAAE,IAAI;UACXC,KAAK,EAAE,IAAIG,KAAK,CAAC,4CAA4C;QAC/D,CAAC,CAAC;MACJ,CAAC,MAAM;QACLL,gBAAgB,CAAC;UACfC,KAAK,EAAEA,CAAA,KAAME,aAAa,CAACL,UAAU,CAAC;UACtCI,KAAK,EAAE;QACT,CAAC,CAAC;MACJ;MACA;IACF;IACA;IACAF,gBAAgB,CAAC;MACfC,KAAK,EAAE,IAAI;MACXC,KAAK,EAAE;IACT,CAAC,CAAC;IACF,OAAOE,kBAAkB,CAACE,SAAS,CAACR,UAAU,EAAEE,gBAAgB,CAAC;EACnE,CAAC,EAAE,CAACF,UAAU,EAAEK,aAAa,EAAEC,kBAAkB,CAAC,CAAC;EAEnD,OAAOL,aAAa;AACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/jsapi-bootstrap",
3
- "version": "0.78.1-use-widget.3+4175c2a5",
3
+ "version": "0.78.1-use-widget.2+a7aa1041",
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.3+4175c2a5",
25
+ "@deephaven/components": "^0.78.1-use-widget.2+a7aa1041",
26
26
  "@deephaven/jsapi-types": "1.0.0-dev0.34.0",
27
- "@deephaven/log": "^0.78.1-use-widget.3+4175c2a5",
28
- "@deephaven/react-hooks": "^0.78.1-use-widget.3+4175c2a5",
29
- "@deephaven/utils": "^0.78.1-use-widget.3+4175c2a5"
27
+ "@deephaven/log": "^0.78.1-use-widget.2+a7aa1041",
28
+ "@deephaven/react-hooks": "^0.78.1-use-widget.2+a7aa1041",
29
+ "@deephaven/utils": "^0.78.1-use-widget.2+a7aa1041"
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": "4175c2a5cce59c3c690b4f2e4288794dbdb0b7e7"
44
+ "gitHead": "a7aa10412b4d745a5ae1eae6a206bf4b7bdb32a7"
45
45
  }