pollination-react-io 0.0.20 → 0.0.21

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/index.js CHANGED
@@ -1988,6 +1988,20 @@ var useGetHbjson = function () {
1988
1988
  }
1989
1989
  hbjsonRef.current = bytes;
1990
1990
  }, []);
1991
+ React.useEffect(function () {
1992
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1993
+ // @ts-ignore
1994
+ window.parent.readHBJSON = function (hbjson) {
1995
+ var model = JSON.parse(hbjson);
1996
+ if (typeof model !== 'object')
1997
+ throw new Error('Not getting a valid json object from Revit.');
1998
+ var res = {
1999
+ Geometry: model,
2000
+ Identifier: null,
2001
+ };
2002
+ setReturnValue(res, false);
2003
+ };
2004
+ }, [host, setReturnValue]);
1991
2005
  var rubyGetHbjson = React.useCallback(function (key, selection, force) {
1992
2006
  if (selection === void 0) { selection = false; }
1993
2007
  if (force === void 0) { force = false; }
@@ -2015,18 +2029,23 @@ var useGetHbjson = function () {
2015
2029
  .hostObjects.sync.hbjson.PassPollinationModel(key, selection);
2016
2030
  setReturnValue(res, force);
2017
2031
  }, [setReturnValue]);
2032
+ var revitGetHbjson = React.useCallback(function () {
2033
+ if (!checkDotNet())
2034
+ return;
2035
+ window.parent.chrome.webview.hostObjects.sync.hbjson.PassHBJSON();
2036
+ }, []);
2018
2037
  var getHbjson = React.useMemo(function () {
2019
2038
  switch (host) {
2020
2039
  case 'rhino':
2021
2040
  return dotNetGetHbjson;
2022
2041
  case 'revit':
2023
- return dotNetGetHbjson;
2042
+ return revitGetHbjson;
2024
2043
  case 'sketchup':
2025
2044
  return rubyGetHbjson;
2026
2045
  default:
2027
2046
  return undefined;
2028
2047
  }
2029
- }, [dotNetGetHbjson, host, rubyGetHbjson]);
2048
+ }, [dotNetGetHbjson, host, revitGetHbjson, rubyGetHbjson]);
2030
2049
  return {
2031
2050
  host: host,
2032
2051
  hbjson: hbjson,
@@ -4786,12 +4805,6 @@ var GetGeometry = function (_a) {
4786
4805
  var _d = React.useState(false), subscribe = _d[0], setSubscribe = _d[1];
4787
4806
  // pollination-react-io hooks
4788
4807
  var _e = useGetGeometry(); _e.host; var geometry = _e.geometry, getGeometry = _e.getGeometry;
4789
- // initial retrieval of geometry
4790
- React.useEffect(function () {
4791
- if (!getGeometry)
4792
- return;
4793
- getGeometry(key);
4794
- }, [key, getGeometry]);
4795
4808
  React.useEffect(function () {
4796
4809
  if (!geometry || !setParentState)
4797
4810
  return;
@@ -4872,12 +4885,6 @@ var GetModel = function (_a) {
4872
4885
  var _d = React.useState(false), subscribe = _d[0], setSubscribe = _d[1];
4873
4886
  // pollination-react-io hooks
4874
4887
  var _e = useGetHbjson(), host = _e.host, hbjson = _e.hbjson, getHbjson = _e.getHbjson;
4875
- // initial retrieval of geometry
4876
- React.useEffect(function () {
4877
- if (!getHbjson)
4878
- return;
4879
- getHbjson(key);
4880
- }, [key, getHbjson]);
4881
4888
  React.useEffect(function () {
4882
4889
  if (!hbjson || !setParentState)
4883
4890
  return;