pollination-react-io 1.24.3 → 1.24.4

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
@@ -37807,44 +37807,54 @@ function checkRuby() {
37807
37807
  checkPollinationPanel();
37808
37808
  return true;
37809
37809
  }
37810
- function checkPollinationPanel() {
37810
+ function conditional_throw(message, silent) {
37811
+ if (silent === void 0) { silent = true; }
37812
+ if (silent) {
37813
+ return false;
37814
+ }
37815
+ else {
37816
+ throw new Error(message);
37817
+ }
37818
+ }
37819
+ function checkPollinationPanel(silent) {
37820
+ if (silent === void 0) { silent = true; }
37811
37821
  try {
37812
37822
  if (typeof window.parent.chrome === 'undefined') {
37813
- throw new Error('[POLLINATION-DEBUG]: chrome not found.');
37823
+ return conditional_throw('[POLLINATION-DEBUG]: chrome not found.', silent);
37814
37824
  }
37815
37825
  }
37816
37826
  catch (_a) {
37817
- throw new Error('[POLLINATION-DEBUG]: chrome not found.');
37827
+ return conditional_throw('[POLLINATION-DEBUG]: chrome not found.', silent);
37818
37828
  }
37819
37829
  try {
37820
37830
  if (typeof window.parent.chrome.webview === 'undefined') {
37821
- throw new Error('[POLLINATION-DEBUG]: webview not found.');
37831
+ return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37822
37832
  }
37823
37833
  }
37824
37834
  catch (_b) {
37825
- throw new Error('[POLLINATION-DEBUG]: webview not found.');
37835
+ return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37826
37836
  }
37827
37837
  try {
37828
37838
  if (typeof window.parent.chrome.webview.hostObjects === 'undefined') {
37829
- throw new Error('[POLLINATION-DEBUG]: webview.hostObjects not found.');
37839
+ return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37830
37840
  }
37831
37841
  }
37832
37842
  catch (_c) {
37833
- throw new Error('[POLLINATION-DEBUG]: webview.hostObjects not found.');
37843
+ return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37834
37844
  }
37835
37845
  try {
37836
37846
  if (typeof window.parent.chrome.webview.hostObjects.sync === 'undefined') {
37837
- throw new Error('[POLLINATION-DEBUG]: webview.hostObjects.sync not found.');
37847
+ return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37838
37848
  }
37839
37849
  }
37840
37850
  catch (_d) {
37841
- throw new Error('[POLLINATION-DEBUG]: webview.hostObjects.sync not found.');
37851
+ return conditional_throw('[POLLINATION-DEBUG]: webview not found.', silent);
37842
37852
  }
37843
37853
  return true;
37844
37854
  }
37845
37855
  function sendMessageDotNet(message) {
37846
37856
  if (!checkPollinationPanel())
37847
- ;
37857
+ return undefined;
37848
37858
  // const json = JSON.stringify(message)
37849
37859
  var json = message;
37850
37860
  if (typeof message.data !== 'string') {
@@ -37860,7 +37870,7 @@ function sendMessageDotNet(message) {
37860
37870
  }
37861
37871
  function sendMessageRuby(message) {
37862
37872
  if (!checkPollinationPanel())
37863
- ;
37873
+ return undefined;
37864
37874
  throw new Error('[POLLINATION-DEBUG]: sendMesssageRuby not yet implemented');
37865
37875
  }
37866
37876
  // not sure if this will work from Streamlit?
@@ -46265,7 +46275,7 @@ var SendGeometry = function (_a) {
46265
46275
  var _d = React.useState(defaultKey !== null && defaultKey !== void 0 ? defaultKey : performance.now().toString()), key = _d[0], setKey = _d[1];
46266
46276
  var sendMessage = useSendMessage().sendMessage;
46267
46277
  var disabled = React.useMemo(function () {
46268
- return checkPollinationPanel();
46278
+ return !checkPollinationPanel();
46269
46279
  }, []);
46270
46280
  React.useEffect(function () {
46271
46281
  setSelOpt(defaultAction);
@@ -46391,6 +46401,9 @@ var SendModel = function (_a) {
46391
46401
  var _c = React.useState(defaultAction !== null && defaultAction !== void 0 ? defaultAction : Action$1.preview), selOpt = _c[0], setSelOpt = _c[1];
46392
46402
  var _d = React.useState(defaultKey !== null && defaultKey !== void 0 ? defaultKey : performance.now().toString()), key = _d[0], setKey = _d[1];
46393
46403
  var sendHbjson = useSendHbjson().sendHbjson;
46404
+ var disabled = React.useMemo(function () {
46405
+ return !checkPollinationPanel();
46406
+ }, []);
46394
46407
  React.useEffect(function () {
46395
46408
  setSelOpt(defaultAction);
46396
46409
  }, [defaultAction]);
@@ -46398,7 +46411,7 @@ var SendModel = function (_a) {
46398
46411
  setKey(defaultKey);
46399
46412
  }, [defaultKey]);
46400
46413
  React.useEffect(function () {
46401
- if (!sendHbjson || selOpt !== Action$1.subscribePreview)
46414
+ if (disabled || selOpt !== Action$1.subscribePreview)
46402
46415
  return;
46403
46416
  sendHbjson('SubscribePreviewHBJSON', {
46404
46417
  data: hbjson,
@@ -46418,9 +46431,9 @@ var SendModel = function (_a) {
46418
46431
  },
46419
46432
  });
46420
46433
  };
46421
- }, [selOpt, hbjson, sendHbjson, key]);
46422
- return (React__default["default"].createElement(SettingsButton, { disabled: !sendHbjson, onClick: function () {
46423
- if (!sendHbjson)
46434
+ }, [disabled, hbjson, key, selOpt, sendHbjson]);
46435
+ return (React__default["default"].createElement(SettingsButton, { disabled: disabled, onClick: function () {
46436
+ if (disabled)
46424
46437
  return;
46425
46438
  sendHbjson(getAction$1(selOpt), {
46426
46439
  data: hbjson,
@@ -46441,7 +46454,7 @@ var SendModel = function (_a) {
46441
46454
  label: 'Preview',
46442
46455
  checked: selOpt === Action$1.preview,
46443
46456
  icon: React__default["default"].createElement(Eyeglasses$1, { size: 16 }),
46444
- disabled: !sendHbjson,
46457
+ disabled: disabled,
46445
46458
  onSelect: function () {
46446
46459
  setSelOpt(function (state) { return (state === Action$1.preview ? undefined : Action$1.preview); });
46447
46460
  },
@@ -46452,7 +46465,7 @@ var SendModel = function (_a) {
46452
46465
  label: 'Add',
46453
46466
  checked: selOpt === Action$1.add,
46454
46467
  icon: React__default["default"].createElement(Building$1, { size: 16 }),
46455
- disabled: !sendHbjson,
46468
+ disabled: disabled,
46456
46469
  onSelect: function () {
46457
46470
  setSelOpt(function (state) { return (state === Action$1.add ? undefined : Action$1.add); });
46458
46471
  },
@@ -46463,7 +46476,7 @@ var SendModel = function (_a) {
46463
46476
  label: 'Clear',
46464
46477
  checked: selOpt === Action$1.clear,
46465
46478
  icon: React__default["default"].createElement(Recycle$1, { size: 16 }),
46466
- disabled: !sendHbjson,
46479
+ disabled: disabled,
46467
46480
  onSelect: function () {
46468
46481
  setSelOpt(function (state) { return (state === Action$1.clear ? undefined : Action$1.clear); });
46469
46482
  },
@@ -46474,7 +46487,7 @@ var SendModel = function (_a) {
46474
46487
  label: 'Subscribe Preview',
46475
46488
  checked: selOpt === Action$1.subscribePreview,
46476
46489
  icon: React__default["default"].createElement(ArrowRepeat$1, { size: 16 }),
46477
- disabled: !sendHbjson,
46490
+ disabled: disabled,
46478
46491
  onSelect: function () {
46479
46492
  setSelOpt(function (state) { return (state === Action$1.subscribePreview ? undefined : Action$1.subscribePreview); });
46480
46493
  },
@@ -46516,8 +46529,11 @@ var SendResults = function (_a) {
46516
46529
  var _d = React.useState(defaultKey !== null && defaultKey !== void 0 ? defaultKey : performance.now().toString()), key = _d[0], setKey = _d[1];
46517
46530
  var sendMessage = useSendMessage().sendMessage;
46518
46531
  var disabled = React.useMemo(function () {
46519
- return checkPollinationPanel();
46532
+ return !checkPollinationPanel();
46520
46533
  }, []);
46534
+ React.useEffect(function () {
46535
+ console.log(disabled);
46536
+ }, [disabled]);
46521
46537
  React.useEffect(function () {
46522
46538
  setSelOpt(defaultAction);
46523
46539
  }, [defaultAction]);