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.
@@ -4,7 +4,8 @@ export interface Options {
4
4
  }
5
5
  export declare type GeometryAction = 'BakeGeometry' | 'ClearGeometry' | 'DrawGeometry' | 'DisableDraw' | 'CombinedRendering';
6
6
  export declare type ModelAction = 'BakePollinationModel' | 'DisableDrawPollinationModel' | 'DrawPollinationModel' | 'CombinedRenderingPollinationModel';
7
- export declare type Action = GeometryAction | ModelAction | 'RunCommand' | 'SetModelSettings';
7
+ export declare type ResultsAction = 'AddResults' | 'ClearResults';
8
+ export declare type Action = GeometryAction | ModelAction | ResultsAction | 'RunCommand' | 'SetModelSettings';
8
9
  export interface Message {
9
10
  action?: Action;
10
11
  data?: any;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useState, useRef, useCallback, useMemo, forwardRef, useEffect } from 'react';
2
+ import React__default, { useState, useRef, useCallback, useEffect, useMemo, forwardRef } from 'react';
3
3
  import e$4 from 'react-dom';
4
4
 
5
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -1961,6 +1961,20 @@ var useGetHbjson = function () {
1961
1961
  }
1962
1962
  hbjsonRef.current = bytes;
1963
1963
  }, []);
1964
+ useEffect(function () {
1965
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1966
+ // @ts-ignore
1967
+ window.parent.readHBJSON = function (hbjson) {
1968
+ var model = JSON.parse(hbjson);
1969
+ if (typeof model !== 'object')
1970
+ throw new Error('Not getting a valid json object from Revit.');
1971
+ var res = {
1972
+ Geometry: model,
1973
+ Identifier: null,
1974
+ };
1975
+ setReturnValue(res, false);
1976
+ };
1977
+ }, [host, setReturnValue]);
1964
1978
  var rubyGetHbjson = useCallback(function (key, selection, force) {
1965
1979
  if (selection === void 0) { selection = false; }
1966
1980
  if (force === void 0) { force = false; }
@@ -1988,18 +2002,23 @@ var useGetHbjson = function () {
1988
2002
  .hostObjects.sync.hbjson.PassPollinationModel(key, selection);
1989
2003
  setReturnValue(res, force);
1990
2004
  }, [setReturnValue]);
2005
+ var revitGetHbjson = useCallback(function () {
2006
+ if (!checkDotNet())
2007
+ return;
2008
+ window.parent.chrome.webview.hostObjects.sync.hbjson.PassHBJSON();
2009
+ }, []);
1991
2010
  var getHbjson = useMemo(function () {
1992
2011
  switch (host) {
1993
2012
  case 'rhino':
1994
2013
  return dotNetGetHbjson;
1995
2014
  case 'revit':
1996
- return dotNetGetHbjson;
2015
+ return revitGetHbjson;
1997
2016
  case 'sketchup':
1998
2017
  return rubyGetHbjson;
1999
2018
  default:
2000
2019
  return undefined;
2001
2020
  }
2002
- }, [dotNetGetHbjson, host, rubyGetHbjson]);
2021
+ }, [dotNetGetHbjson, host, revitGetHbjson, rubyGetHbjson]);
2003
2022
  return {
2004
2023
  host: host,
2005
2024
  hbjson: hbjson,
@@ -4759,12 +4778,6 @@ var GetGeometry = function (_a) {
4759
4778
  var _d = useState(false), subscribe = _d[0], setSubscribe = _d[1];
4760
4779
  // pollination-react-io hooks
4761
4780
  var _e = useGetGeometry(); _e.host; var geometry = _e.geometry, getGeometry = _e.getGeometry;
4762
- // initial retrieval of geometry
4763
- useEffect(function () {
4764
- if (!getGeometry)
4765
- return;
4766
- getGeometry(key);
4767
- }, [key, getGeometry]);
4768
4781
  useEffect(function () {
4769
4782
  if (!geometry || !setParentState)
4770
4783
  return;
@@ -4845,12 +4858,6 @@ var GetModel = function (_a) {
4845
4858
  var _d = useState(false), subscribe = _d[0], setSubscribe = _d[1];
4846
4859
  // pollination-react-io hooks
4847
4860
  var _e = useGetHbjson(), host = _e.host, hbjson = _e.hbjson, getHbjson = _e.getHbjson;
4848
- // initial retrieval of geometry
4849
- useEffect(function () {
4850
- if (!getHbjson)
4851
- return;
4852
- getHbjson(key);
4853
- }, [key, getHbjson]);
4854
4861
  useEffect(function () {
4855
4862
  if (!hbjson || !setParentState)
4856
4863
  return;