pollination-react-io 1.25.0 → 1.25.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.
@@ -37771,58 +37771,23 @@ var useArtifacts = function (owner, name, client) {
37771
37771
  * Deprecated
37772
37772
  */
37773
37773
  function checkDotNet() {
37774
- checkPollinationPanel();
37775
- return true;
37774
+ return checkPollinationPanel();
37776
37775
  }
37777
37776
  /*
37778
37777
  * Deprecated
37779
37778
  */
37780
37779
  function checkRuby() {
37781
- checkPollinationPanel();
37782
- return true;
37783
- }
37784
- function conditional_throw(message, silent) {
37785
- if (silent === void 0) { silent = true; }
37786
- if (silent) {
37787
- return false;
37788
- }
37789
- else {
37790
- throw new Error(message);
37791
- }
37780
+ return checkPollinationPanel();
37792
37781
  }
37793
37782
  function checkPollinationPanel(silent) {
37794
- if (silent === void 0) { silent = true; }
37795
- try {
37796
- if (typeof window.parent.chrome === 'undefined') {
37797
- return conditional_throw('[POLLINATION-DEBUG]: chrome not found.', silent);
37798
- }
37799
- }
37800
- catch (_a) {
37801
- return conditional_throw('[POLLINATION-DEBUG]: chrome not found.', silent);
37802
- }
37803
- try {
37804
- if (typeof window.parent.chrome.webview === 'undefined') {
37805
- return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37806
- }
37807
- }
37808
- catch (_b) {
37809
- return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37810
- }
37811
- try {
37812
- if (typeof window.parent.chrome.webview.hostObjects === 'undefined') {
37813
- return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37814
- }
37815
- }
37816
- catch (_c) {
37817
- return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37783
+ if (window.parent.chrome == null) {
37784
+ return false;
37818
37785
  }
37819
- try {
37820
- if (typeof window.parent.chrome.webview.hostObjects.sync === 'undefined') {
37821
- return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37822
- }
37786
+ if (window.parent.chrome.webview == null) {
37787
+ return false;
37823
37788
  }
37824
- catch (_d) {
37825
- return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37789
+ if (window.parent.chrome.webview == null) {
37790
+ return false;
37826
37791
  }
37827
37792
  return true;
37828
37793
  }
@@ -37894,13 +37859,7 @@ function blobToBase64(blob) {
37894
37859
  }
37895
37860
  var usePollinationPanel = function () {
37896
37861
  var panel = useMemo(function () {
37897
- try {
37898
- checkPollinationPanel();
37899
- }
37900
- catch (_a) {
37901
- return false;
37902
- }
37903
- return window.parent.chrome.webview.hostObjects.sync.study;
37862
+ return checkPollinationPanel() && window.parent.chrome.webview.hostObjects.sync.study;
37904
37863
  }, []);
37905
37864
  var saveFileBase64 = useCallback(function (key, file, subFolder, fileName) { return __awaiter$1(void 0, void 0, void 0, function () {
37906
37865
  var base64;
@@ -40041,7 +40000,7 @@ var useGetGeometry = function () {
40041
40000
  if (selection === void 0) { selection = false; }
40042
40001
  if (force === void 0) { force = false; }
40043
40002
  if (!checkDotNet())
40044
- ;
40003
+ return;
40045
40004
  var res = {
40046
40005
  data: null,
40047
40006
  identifier: null,
@@ -40105,7 +40064,7 @@ var useGetHbjson = function () {
40105
40064
  if (selection === void 0) { selection = false; }
40106
40065
  if (force === void 0) { force = false; }
40107
40066
  if (!checkDotNet())
40108
- ;
40067
+ return;
40109
40068
  var res = window.parent.chrome.webview
40110
40069
  .hostObjects.sync.hbjson.Get(key, selection);
40111
40070
  if (res) {
@@ -40114,7 +40073,7 @@ var useGetHbjson = function () {
40114
40073
  }, [setReturnValue]);
40115
40074
  var revitGetHbjson = useCallback(function () {
40116
40075
  if (!checkDotNet())
40117
- ;
40076
+ return;
40118
40077
  window.parent.chrome.webview.hostObjects.sync.hbjson.GetAsync();
40119
40078
  }, []);
40120
40079
  var getHbjson = useMemo(function () {
@@ -40276,7 +40235,7 @@ var useManageSettings = function () {
40276
40235
  var getSettings = useCallback(function (key) {
40277
40236
  if (key === void 0) { key = performance.now().toString(); }
40278
40237
  if (!checkDotNet())
40279
- ;
40238
+ return;
40280
40239
  var settings;
40281
40240
  try {
40282
40241
  settings = window.parent.chrome.webview.hostObjects.sync.settings.GetModelSettings();
@@ -40460,7 +40419,7 @@ var useSendHbjson = function () {
40460
40419
  var _a = useState({}), state = _a[0], setState = _a[1];
40461
40420
  var sendHbjson = useCallback(function (action, message) {
40462
40421
  if (!checkDotNet())
40463
- ;
40422
+ return;
40464
40423
  var response = sendMessageDotNet(__assign({ action: action }, message));
40465
40424
  setState(function (state) { return (__assign(__assign({}, state), { response: response })); });
40466
40425
  return response;
@@ -40790,7 +40749,7 @@ var SelectLocalArtifactNative = function (_a) {
40790
40749
  var _g = useState(), selPath = _g[0], setSelPath = _g[1];
40791
40750
  var handleSelectNative = useCallback(function () {
40792
40751
  if (!checkDotNet())
40793
- ;
40752
+ throw new Error('Use handleSelectNative from a Pollination CAD Plugin.');
40794
40753
  var res;
40795
40754
  try {
40796
40755
  if (mode === 'file') {
@@ -44224,23 +44183,33 @@ var CreateStudy = function (_a) {
44224
44183
  if (!basePath) {
44225
44184
  throw new Error('CreateStudy: client.configuration.basepath not defined.');
44226
44185
  }
44227
- // for streamlit apps have to use window.open instead of window.location.href
44228
- window.open("".concat(basePath, "/").concat(accountName, "/projects/").concat(projectName, "/studies/").concat(studyId));
44229
- }, [basePath]);
44230
- var handleCreateStudy = useCallback(function (name, data, description, localConfig) {
44186
+ window.location.href = "".concat(basePath, "/").concat(accountName, "/projects/").concat(projectName, "/studies/").concat(studyId);
44187
+ }, []);
44188
+ var handleCreateStudySuccessLocal = useCallback(function (accountName, projectName, studyId) {
44189
+ console.log("Study is running! Do not close the console.\nYou will find output here ".concat(studyId, "."));
44190
+ }, []);
44191
+ var handleCreateStudy = useCallback(function (name, jobArgs, description, localConfig) {
44231
44192
  if (!selRecipe) {
44232
- return new Promise(function (resolve, reject) { return resolve(); });
44193
+ return Promise.reject();
44233
44194
  }
44234
- var handleSuccess = createStudySuccess !== null && createStudySuccess !== void 0 ? createStudySuccess : handleCreateStudySuccess;
44235
- // don't attempt navigation if the study is a local study
44236
- var handleWebSuccess = localConfig && localConfig.isLocalJob ? handleSuccess : undefined;
44237
- if (host !== 'web') {
44238
- return createLocalStudy({ name: name, recipe: selRecipe, description: description }, data, localConfig, handleWebSuccess);
44195
+ // Custom cloud action
44196
+ var handleCloudSuccess = createStudySuccess !== null && createStudySuccess !== void 0 ? createStudySuccess : handleCreateStudySuccess;
44197
+ var handleSuccess = localConfig && localConfig.isLocalJob ? handleCreateStudySuccessLocal : handleCloudSuccess;
44198
+ if (host !== 'web' && localConfig) {
44199
+ return createLocalStudy({
44200
+ name: name,
44201
+ recipe: selRecipe,
44202
+ description: description !== null && description !== void 0 ? description : 'Study created from pollination',
44203
+ }, jobArgs, localConfig, handleSuccess);
44239
44204
  }
44240
44205
  else {
44241
- return createStudy({ name: name, recipe: selRecipe, description: description }, data, handleWebSuccess);
44206
+ return createStudy({
44207
+ name: name,
44208
+ recipe: selRecipe,
44209
+ description: description !== null && description !== void 0 ? description : 'Study created from pollination',
44210
+ }, jobArgs, handleCloudSuccess);
44242
44211
  }
44243
- }, [createLocalStudy, createStudy, createStudySuccess, handleCreateStudySuccess, host, selRecipe]);
44212
+ }, [selRecipe, host, createLocalStudy, handleCreateStudySuccess, createStudySuccess, createStudy]);
44244
44213
  return (React__default.createElement("div", { "data-testid": "CreateProject", style: __assign(__assign({}, defaultStyle), style) },
44245
44214
  React__default.createElement(Tabs, { selectedIndex: activeTabIndex, onSelect: function (index) { return setActiveTabIndex(index); }, forceRenderTabPanel: true },
44246
44215
  React__default.createElement("div", { style: {