pollination-react-io 1.88.1 → 1.90.0

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.
@@ -12,6 +12,8 @@ export interface FileCardProps {
12
12
  path: string;
13
13
  description: string;
14
14
  file?: Blob | File | string | undefined;
15
+ previewFile?: Blob | File | string | undefined;
16
+ previewName?: string;
15
17
  onClicked?: (card: FileCardProps) => any;
16
18
  isCloud?: boolean;
17
19
  name?: string;
@@ -5,6 +5,7 @@ export * from './useCreateStudy';
5
5
  export * from './useGetGeometry';
6
6
  export * from './useGetHbjson';
7
7
  export * from './useHbjsontoVTK';
8
+ export * from './useVsftoVTK';
8
9
  export * from './useJobs';
9
10
  export * from './useManageSettings';
10
11
  export * from './useRunCommand';
@@ -0,0 +1,5 @@
1
+ export declare const useVsftoVTK: () => {
2
+ loading: boolean;
3
+ vtk: Blob;
4
+ fetchVTK: (vsf: Blob) => Promise<void>;
5
+ };
@@ -40900,7 +40900,7 @@ var useGetHbjson = function () {
40900
40900
  };
40901
40901
  };
40902
40902
 
40903
- var UTILSENDPOINT$1 = process.env.REACT_APP_UTILS_ENDPOINT || 'https://utilities.staging.pollination.cloud';
40903
+ var UTILSENDPOINT$2 = process.env.REACT_APP_UTILS_ENDPOINT || 'https://utilities.staging.pollination.cloud';
40904
40904
  var useHbjsontoVTK = function () {
40905
40905
  var _a = useState(false), loading = _a[0], setLoading = _a[1];
40906
40906
  var _b = useState(), vtk = _b[0], setVTK = _b[1];
@@ -40909,7 +40909,7 @@ var useHbjsontoVTK = function () {
40909
40909
  return undefined;
40910
40910
  setLoading(true);
40911
40911
  return hbjson.text().then(function (fileString) {
40912
- fetch("".concat(UTILSENDPOINT$1, "/hbjson-to-vtk"), {
40912
+ fetch("".concat(UTILSENDPOINT$2, "/hbjson-to-vtk"), {
40913
40913
  method: 'POST',
40914
40914
  headers: {
40915
40915
  'Content-Type': 'application/json',
@@ -40949,6 +40949,53 @@ var useHbjsontoVTK = function () {
40949
40949
  };
40950
40950
  };
40951
40951
 
40952
+ var UTILSENDPOINT$1 = process.env.REACT_APP_UTILS_ENDPOINT || 'https://utilities.staging.pollination.cloud';
40953
+ var useVsftoVTK = function () {
40954
+ var _a = useState(false), loading = _a[0], setLoading = _a[1];
40955
+ var _b = useState(), vtk = _b[0], setVTK = _b[1];
40956
+ var fetchVTK = function (vsf) {
40957
+ if (!vsf || vsf.size < 1)
40958
+ return undefined;
40959
+ setLoading(true);
40960
+ return vsf.text().then(function (fileString) {
40961
+ fetch("".concat(UTILSENDPOINT$1, "/vsf-to-vtk"), {
40962
+ method: 'POST',
40963
+ headers: {
40964
+ 'Content-Type': 'application/json',
40965
+ Accept: '*/*',
40966
+ },
40967
+ body: "{\n \"output_format\": \"vtkjs\",\n \"vsf\": ".concat(fileString, "\n }"),
40968
+ })
40969
+ .catch(function (e) {
40970
+ throw new Error(e);
40971
+ })
40972
+ .then(function (res) { return __awaiter$1(void 0, void 0, void 0, function () {
40973
+ var translatedFile;
40974
+ return __generator$1(this, function (_a) {
40975
+ switch (_a.label) {
40976
+ case 0:
40977
+ if (!res.ok) return [3 /*break*/, 2];
40978
+ return [4 /*yield*/, res.blob()];
40979
+ case 1:
40980
+ translatedFile = _a.sent();
40981
+ setVTK(translatedFile);
40982
+ return [2 /*return*/, translatedFile];
40983
+ case 2: throw new Error('Failed to retrieve .vtkjs from .vsf file.Error translating vsf to vtkjs');
40984
+ }
40985
+ });
40986
+ }); })
40987
+ .finally(function () {
40988
+ setLoading(false);
40989
+ });
40990
+ });
40991
+ };
40992
+ return {
40993
+ loading: loading,
40994
+ vtk: vtk,
40995
+ fetchVTK: fetchVTK,
40996
+ };
40997
+ };
40998
+
40952
40999
  var duration = createCommonjsModule(function (module, exports) {
40953
41000
  !function(t,s){module.exports=s();}(commonjsGlobal,(function(){var t,s,n=1e3,i=6e4,e=36e5,r=864e5,o=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,u=31536e6,h=2592e6,a=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,d={years:u,months:h,days:r,hours:e,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},c=function(t){return t instanceof p},f=function(t,s,n){return new p(t,n,s.$l)},m=function(t){return s.p(t)+"s"},l=function(t){return t<0},$=function(t){return l(t)?Math.ceil(t):Math.floor(t)},y=function(t){return Math.abs(t)},g=function(t,s){return t?l(t)?{negative:!0,format:""+y(t)+s}:{negative:!1,format:""+t+s}:{negative:!1,format:""}},p=function(){function l(t,s,n){var i=this;if(this.$d={},this.$l=n,void 0===t&&(this.$ms=0,this.parseFromMilliseconds()),s)return f(t*d[m(s)],this);if("number"==typeof t)return this.$ms=t,this.parseFromMilliseconds(),this;if("object"==typeof t)return Object.keys(t).forEach((function(s){i.$d[m(s)]=t[s];})),this.calMilliseconds(),this;if("string"==typeof t){var e=t.match(a);if(e){var r=e.slice(2).map((function(t){return null!=t?Number(t):0}));return this.$d.years=r[0],this.$d.months=r[1],this.$d.weeks=r[2],this.$d.days=r[3],this.$d.hours=r[4],this.$d.minutes=r[5],this.$d.seconds=r[6],this.calMilliseconds(),this}}return this}var y=l.prototype;return y.calMilliseconds=function(){var t=this;this.$ms=Object.keys(this.$d).reduce((function(s,n){return s+(t.$d[n]||0)*d[n]}),0);},y.parseFromMilliseconds=function(){var t=this.$ms;this.$d.years=$(t/u),t%=u,this.$d.months=$(t/h),t%=h,this.$d.days=$(t/r),t%=r,this.$d.hours=$(t/e),t%=e,this.$d.minutes=$(t/i),t%=i,this.$d.seconds=$(t/n),t%=n,this.$d.milliseconds=t;},y.toISOString=function(){var t=g(this.$d.years,"Y"),s=g(this.$d.months,"M"),n=+this.$d.days||0;this.$d.weeks&&(n+=7*this.$d.weeks);var i=g(n,"D"),e=g(this.$d.hours,"H"),r=g(this.$d.minutes,"M"),o=this.$d.seconds||0;this.$d.milliseconds&&(o+=this.$d.milliseconds/1e3);var u=g(o,"S"),h=t.negative||s.negative||i.negative||e.negative||r.negative||u.negative,a=e.format||r.format||u.format?"T":"",d=(h?"-":"")+"P"+t.format+s.format+i.format+a+e.format+r.format+u.format;return "P"===d||"-P"===d?"P0D":d},y.toJSON=function(){return this.toISOString()},y.format=function(t){var n=t||"YYYY-MM-DDTHH:mm:ss",i={Y:this.$d.years,YY:s.s(this.$d.years,2,"0"),YYYY:s.s(this.$d.years,4,"0"),M:this.$d.months,MM:s.s(this.$d.months,2,"0"),D:this.$d.days,DD:s.s(this.$d.days,2,"0"),H:this.$d.hours,HH:s.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:s.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:s.s(this.$d.seconds,2,"0"),SSS:s.s(this.$d.milliseconds,3,"0")};return n.replace(o,(function(t,s){return s||String(i[t])}))},y.as=function(t){return this.$ms/d[m(t)]},y.get=function(t){var s=this.$ms,n=m(t);return "milliseconds"===n?s%=1e3:s="weeks"===n?$(s/d[n]):this.$d[n],0===s?0:s},y.add=function(t,s,n){var i;return i=s?t*d[m(s)]:c(t)?t.$ms:f(t,this).$ms,f(this.$ms+i*(n?-1:1),this)},y.subtract=function(t,s){return this.add(t,s,!0)},y.locale=function(t){var s=this.clone();return s.$l=t,s},y.clone=function(){return f(this.$ms,this)},y.humanize=function(s){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!s)},y.milliseconds=function(){return this.get("milliseconds")},y.asMilliseconds=function(){return this.as("milliseconds")},y.seconds=function(){return this.get("seconds")},y.asSeconds=function(){return this.as("seconds")},y.minutes=function(){return this.get("minutes")},y.asMinutes=function(){return this.as("minutes")},y.hours=function(){return this.get("hours")},y.asHours=function(){return this.as("hours")},y.days=function(){return this.get("days")},y.asDays=function(){return this.as("days")},y.weeks=function(){return this.get("weeks")},y.asWeeks=function(){return this.as("weeks")},y.months=function(){return this.get("months")},y.asMonths=function(){return this.as("months")},y.years=function(){return this.get("years")},y.asYears=function(){return this.as("years")},l}();return function(n,i,e){t=e,s=e().$utils(),e.duration=function(t,s){var n=e.locale();return f(t,{$l:n},s)},e.isDuration=c;var r=i.prototype.add,o=i.prototype.subtract;i.prototype.add=function(t,s){return c(t)&&(t=t.asMilliseconds()),r.bind(this)(t,s)},i.prototype.subtract=function(t,s){return c(t)&&(t=t.asMilliseconds()),o.bind(this)(t,s)};}}));
40954
41001
  });
@@ -47003,6 +47050,19 @@ var InputType;
47003
47050
  InputType["DAGArrayInput"] = "DAGArrayInput";
47004
47051
  InputType["DAGJSONObjectInput"] = "DAGJSONObjectInput";
47005
47052
  })(InputType || (InputType = {}));
47053
+ var InputTypeAlias;
47054
+ (function (InputTypeAlias) {
47055
+ InputTypeAlias["DAGGenericInputAlias"] = "DAGGenericInputAlias";
47056
+ InputTypeAlias["DAGStringInputAlias"] = "DAGStringInputAlias";
47057
+ InputTypeAlias["DAGIntegerInputAlias"] = "DAGIntegerInputAlias";
47058
+ InputTypeAlias["DAGNumberInputAlias"] = "DAGNumberInputAlias";
47059
+ InputTypeAlias["DAGBooleanInputAlias"] = "DAGBooleanInputAlias";
47060
+ InputTypeAlias["DAGFolderInputAlias"] = "DAGFolderInputAlias";
47061
+ InputTypeAlias["DAGFileInputAlias"] = "DAGFileInputAlias";
47062
+ InputTypeAlias["DAGPathInputAlias"] = "DAGPathInputAlias";
47063
+ InputTypeAlias["DAGArrayInputAlias"] = "DAGArrayInputAlias";
47064
+ InputTypeAlias["DAGJSONObjectInputAlias"] = "DAGJSONObjectInputAlias";
47065
+ })(InputTypeAlias || (InputTypeAlias = {}));
47006
47066
  var RecipeForm = function (_a) {
47007
47067
  var _b, _c;
47008
47068
  var recipe = _a.recipe, projectName = _a.projectName, projectOwner = _a.projectOwner, client = _a.client, onSubmit = _a.onSubmit, _d = _a.style, style = _d === void 0 ? {} : _d, _e = _a.initAsLocal, initAsLocal = _e === void 0 ? false : _e;
@@ -47013,6 +47073,11 @@ var RecipeForm = function (_a) {
47013
47073
  */
47014
47074
  var _h = useState(false), displaySettings = _h[0], setDisplaySettings = _h[1];
47015
47075
  var _j = useState(false), overSettings = _j[0], setOverSettings = _j[1];
47076
+ /**
47077
+ * Local study
47078
+ */
47079
+ var _k = useState(true), handlers = _k[0], setHandlers = _k[1];
47080
+ var _l = useState(__assign(__assign({}, _defaultConfig), { isLocalJob: initAsLocal, cloudProjectName: projectName, cloudProjectOwner: projectOwner, localRunFolder: simulationPath, useHandlers: handlers })), localConfig = _l[0], setLocalConfig = _l[1];
47016
47081
  /**
47017
47082
  * Input mapping
47018
47083
  */
@@ -47020,9 +47085,10 @@ var RecipeForm = function (_a) {
47020
47085
  if (!recipe)
47021
47086
  return;
47022
47087
  var data = recipe.inputs.map(function (i) {
47023
- var _a;
47088
+ var _a, _b;
47024
47089
  var customTab = (_a = i === null || i === void 0 ? void 0 : i.annotations['group_identifier']) !== null && _a !== void 0 ? _a : undefined;
47025
- return {
47090
+ var alias = handlers && ((_b = i === null || i === void 0 ? void 0 : i.alias) === null || _b === void 0 ? void 0 : _b.find(function (a) { return a.platform.includes(host); }));
47091
+ var inputInfo = {
47026
47092
  type: InputType[i.type],
47027
47093
  required: i.required,
47028
47094
  name: i.name,
@@ -47033,9 +47099,21 @@ var RecipeForm = function (_a) {
47033
47099
  i['extensions'] : [],
47034
47100
  customTab: customTab
47035
47101
  };
47102
+ alias && Object.keys(alias).forEach(function (key) {
47103
+ if (key in inputInfo) {
47104
+ // if the alias is DAGGenericInputAlias use the native input type
47105
+ if (key == 'type') {
47106
+ if (alias[key] == 'DAGGenericInputAlias') {
47107
+ return;
47108
+ }
47109
+ }
47110
+ inputInfo[key] = alias[key];
47111
+ }
47112
+ });
47113
+ return inputInfo;
47036
47114
  });
47037
47115
  return data;
47038
- }, [recipe]);
47116
+ }, [recipe, handlers]);
47039
47117
  var schema = generateSchema(inputs);
47040
47118
  var customTabs = useMemo(function () {
47041
47119
  if (!inputs)
@@ -47053,10 +47131,10 @@ var RecipeForm = function (_a) {
47053
47131
  /**
47054
47132
  * Hooks
47055
47133
  */
47056
- var _k = useForm({
47134
+ var _m = useForm({
47057
47135
  resolver: Oe(schema),
47058
47136
  mode: 'onChange'
47059
- }), control = _k.control, register = _k.register, handleSubmit = _k.handleSubmit, resetField = _k.resetField, watch = _k.watch, _l = _k.formState, errors = _l.errors, isValid = _l.isValid;
47137
+ }), control = _m.control, register = _m.register, handleSubmit = _m.handleSubmit, resetField = _m.resetField, watch = _m.watch, _o = _m.formState, errors = _o.errors, isValid = _o.isValid;
47060
47138
  var watchStudyName = watch('study-name');
47061
47139
  /**
47062
47140
  * Form actions
@@ -47102,12 +47180,15 @@ var RecipeForm = function (_a) {
47102
47180
  var _a, _b, _c, _d, _e;
47103
47181
  switch (i.type) {
47104
47182
  case InputType.DAGNumberInput:
47183
+ case InputTypeAlias.DAGNumberInputAlias:
47105
47184
  return React__default.createElement(NumberInput, { inputProps: __assign(__assign({}, register(i.name, { valueAsNumber: true })), { required: i.required, defaultValue: i.default, min: (_a = i.spec) === null || _a === void 0 ? void 0 : _a.minimum, max: (_b = i.spec) === null || _b === void 0 ? void 0 : _b.maximum, step: 0.1 }), key: i.name, reset: function () { return handleReset(i); } });
47106
47185
  case InputType.DAGIntegerInput:
47186
+ case InputTypeAlias.DAGIntegerInputAlias:
47107
47187
  return React__default.createElement(NumberInput, { key: i.name, icon: i.name.startsWith('cpu')
47108
47188
  ? React__default.createElement(Cpu$1, null)
47109
47189
  : undefined, inputProps: __assign(__assign({}, register(i.name, { valueAsNumber: true })), { required: i.required, defaultValue: i.default, min: (_c = i.spec) === null || _c === void 0 ? void 0 : _c.minimum, max: (_d = i.spec) === null || _d === void 0 ? void 0 : _d.maximum, step: 1 }), reset: function () { return handleReset(i); } });
47110
47190
  case InputType.DAGStringInput:
47191
+ case InputTypeAlias.DAGStringInputAlias:
47111
47192
  return ((_e = i.spec) === null || _e === void 0 ? void 0 : _e.enum)
47112
47193
  ? React__default.createElement(Controller, { name: i.name, control: control, defaultValue: i.default, render: function (_a) {
47113
47194
  var _b = _a.field, onChange = _b.onChange, value = _b.value; __rest(_b, ["onChange", "value"]);
@@ -47115,6 +47196,7 @@ var RecipeForm = function (_a) {
47115
47196
  } })
47116
47197
  : React__default.createElement(TextInput, { key: i.name, inputProps: __assign(__assign({}, register(i.name)), { defaultValue: i.default }), reset: function () { return handleReset(i); } });
47117
47198
  case InputType.DAGFileInput:
47199
+ case InputTypeAlias.DAGFileInputAlias:
47118
47200
  return React__default.createElement(Controller, { name: i.name, control: control, defaultValue: i.default, render: function (_a) {
47119
47201
  var _b, _c;
47120
47202
  var _d = _a.field, value = _d.value, onChange = _d.onChange, field = __rest(_d, ["value", "onChange"]);
@@ -47131,11 +47213,6 @@ var RecipeForm = function (_a) {
47131
47213
  return React__default.createElement(TextInput, { key: i.name, inputProps: __assign(__assign({}, register(i.name)), { defaultValue: i.default }), reset: function () { return handleReset(i); } });
47132
47214
  }
47133
47215
  };
47134
- /**
47135
- * Local study
47136
- */
47137
- var _m = useState(true), handlers = _m[0], setHandlers = _m[1];
47138
- var _o = useState(__assign(__assign({}, _defaultConfig), { isLocalJob: initAsLocal, cloudProjectName: projectName, cloudProjectOwner: projectOwner, localRunFolder: simulationPath, useHandlers: handlers })), localConfig = _o[0], setLocalConfig = _o[1];
47139
47216
  /**
47140
47217
  * Warning for local study folder
47141
47218
  */
@@ -47179,7 +47256,7 @@ var RecipeForm = function (_a) {
47179
47256
  " ",
47180
47257
  recipe.metadata.name,
47181
47258
  " study"),
47182
- React__default.createElement("span", { style: { display: 'inline', float: 'right' }, title: 'Show settings' },
47259
+ host != 'web' && React__default.createElement("span", { style: { display: 'inline', float: 'right' }, title: 'Show settings' },
47183
47260
  React__default.createElement(SettingOutlined$1, { onMouseOver: function () { return setOverSettings(true); }, onMouseLeave: function () { return setOverSettings(false); }, onClick: function () { return setDisplaySettings(function (prev) { return !prev; }); }, style: {
47184
47261
  fontSize: '18px',
47185
47262
  cursor: 'pointer',
@@ -55376,7 +55453,10 @@ var SendGeometry = function (_a) {
55376
55453
  options: geometryOptions
55377
55454
  });
55378
55455
  } },
55379
- !disabled && (currOption === null || currOption === void 0 ? void 0 : currOption.icon),
55456
+ !disabled && React__default.createElement("span", { style: {
55457
+ flexShrink: 0,
55458
+ display: 'flex'
55459
+ } }, currOption === null || currOption === void 0 ? void 0 : currOption.icon),
55380
55460
  !disabled && ((_b = currOption === null || currOption === void 0 ? void 0 : currOption.label) !== null && _b !== void 0 ? _b : 'Pollination'),
55381
55461
  disabled && React__default.createElement("span", { style: { color: 'red' } }, "Enabled in Pollination CAD plugins")));
55382
55462
  };
@@ -55510,7 +55590,10 @@ var SendModel = function (_a) {
55510
55590
  options: {},
55511
55591
  });
55512
55592
  } },
55513
- !disabled && (currOption === null || currOption === void 0 ? void 0 : currOption.icon),
55593
+ !disabled && React__default.createElement("span", { style: {
55594
+ flexShrink: 0,
55595
+ display: 'flex'
55596
+ } }, currOption === null || currOption === void 0 ? void 0 : currOption.icon),
55514
55597
  !disabled && ((_b = currOption === null || currOption === void 0 ? void 0 : currOption.label) !== null && _b !== void 0 ? _b : 'Pollination'),
55515
55598
  disabled && React__default.createElement("span", { style: { color: 'red' } }, "Enabled in Pollination CAD plugins")));
55516
55599
  };
@@ -55697,10 +55780,14 @@ var SendResults = function (_a) {
55697
55780
  border: 'solid 1px #fff',
55698
55781
  flexShrink: '0',
55699
55782
  }, placement: 'bottomRight', activeId: defaultAction, action: 'click', disabled: disabled, onSelect: onSelect, options: values },
55700
- React__default.createElement(Button, { title: helpTextButton[currOption === null || currOption === void 0 ? void 0 : currOption.id], disabled: disabled, style: {
55783
+ React__default.createElement(Button, { title: (((currOption === null || currOption === void 0 ? void 0 : currOption.id) === Action.preview
55784
+ || (currOption === null || currOption === void 0 ? void 0 : currOption.id) === Action.subscribePreview)
55785
+ && (dataSets.length >= 1)
55786
+ ? dataSets === null || dataSets === void 0 ? void 0 : dataSets.map(function (d, index) { return "".concat(d.labels[initialIds[index]]); }).join(' & ')
55787
+ : helpTextButton[currOption === null || currOption === void 0 ? void 0 : currOption.id]), disabled: disabled, style: {
55701
55788
  width: '100%',
55702
55789
  fontSize: '14px',
55703
- border: 'solid 1px #fff'
55790
+ border: 'solid 1px #fff',
55704
55791
  }, onClick: function (e) {
55705
55792
  e.stopPropagation();
55706
55793
  if (disabled)
@@ -55713,15 +55800,22 @@ var SendResults = function (_a) {
55713
55800
  options: geometryOptions,
55714
55801
  });
55715
55802
  } },
55716
- !disabled && (currOption === null || currOption === void 0 ? void 0 : currOption.icon),
55803
+ !disabled && React__default.createElement("span", { style: {
55804
+ flexShrink: 0,
55805
+ display: 'flex'
55806
+ } }, currOption === null || currOption === void 0 ? void 0 : currOption.icon),
55717
55807
  !disabled &&
55718
55808
  ((currOption === null || currOption === void 0 ? void 0 : currOption.id) !== Action.preview && (currOption === null || currOption === void 0 ? void 0 : currOption.id) !== Action.subscribePreview)
55719
55809
  && ((_b = currOption === null || currOption === void 0 ? void 0 : currOption.label) !== null && _b !== void 0 ? _b : 'Pollination'),
55720
55810
  !disabled &&
55721
55811
  ((currOption === null || currOption === void 0 ? void 0 : currOption.id) === Action.preview || (currOption === null || currOption === void 0 ? void 0 : currOption.id) === Action.subscribePreview)
55722
- && (dataSets.length >= 1
55812
+ && React__default.createElement("span", { style: {
55813
+ textOverflow: 'ellipsis',
55814
+ whiteSpace: 'nowrap',
55815
+ overflow: 'hidden',
55816
+ } }, (dataSets.length >= 1
55723
55817
  ? dataSets === null || dataSets === void 0 ? void 0 : dataSets.map(function (d, index) { return "".concat(d.labels[initialIds[index]]); }).join(' & ')
55724
- : ((_c = currOption === null || currOption === void 0 ? void 0 : currOption.label) !== null && _c !== void 0 ? _c : 'Pollination')),
55818
+ : ((_c = currOption === null || currOption === void 0 ? void 0 : currOption.label) !== null && _c !== void 0 ? _c : 'Pollination'))),
55725
55819
  disabled && React__default.createElement("span", { style: { color: 'red' } }, "Enabled in Pollination CAD plugins")),
55726
55820
  (currOption === null || currOption === void 0 ? void 0 : currOption.id)
55727
55821
  && ((currOption === null || currOption === void 0 ? void 0 : currOption.id) === Action.preview || (currOption === null || currOption === void 0 ? void 0 : currOption.id) === Action.subscribePreview)
@@ -56764,22 +56858,26 @@ var FileCard = function (_a) {
56764
56858
  var host = getHost();
56765
56859
  var fromFileToBase64 = usePollinationPanel().fromFileToBase64;
56766
56860
  var _d = useVSFToHTML(), loading = _d.loading, html = _d.html, fetchHTML = _d.fetchHTML;
56861
+ // VTKJS Handlers
56862
+ var _e = useHbjsontoVTK(), loadingHBJSON = _e.loading, vtkHBJSON = _e.vtk, fetchVTKfromHBJSON = _e.fetchVTK;
56863
+ var _f = useVsftoVTK(), loadingVSF = _f.loading, vtkHBVSF = _f.vtk, fetchVTKfromVSF = _f.fetchVTK;
56767
56864
  var downloadArtifact = useArtifacts(projectOwner, projectName, client).downloadArtifact;
56768
- var _e = useState(false), open = _e[0], setOpen = _e[1];
56865
+ var _g = useState(false), open = _g[0], setOpen = _g[1];
56769
56866
  // Hover effects
56770
- var _f = useState(false), infoOver = _f[0], setInfoOver = _f[1];
56771
- var _g = useState(false), downloadOver = _g[0], setDownloadOver = _g[1];
56772
- var _h = useState(false), htmlOver = _h[0], setHtmlOver = _h[1];
56773
- var _j = useState(true), isLoading = _j[0], setIsLoading = _j[1];
56774
- var _k = useState(false), isInactive = _k[0], setIsInactive = _k[1];
56867
+ var _h = useState(false), infoOver = _h[0], setInfoOver = _h[1];
56868
+ var _j = useState(false), downloadOver = _j[0], setDownloadOver = _j[1];
56869
+ var _k = useState(false), htmlOver = _k[0], setHtmlOver = _k[1];
56870
+ var _l = useState(true), isLoading = _l[0], setIsLoading = _l[1];
56871
+ var _m = useState(false), isInactive = _m[0], setIsInactive = _m[1];
56775
56872
  // Data to use for CAD injections
56776
- var _l = useState(), CADdata = _l[0], setCADdata = _l[1];
56873
+ var _o = useState(), CADdata = _o[0], setCADdata = _o[1];
56777
56874
  // File to send to parent
56778
- var _m = useState(), currFile = _m[0], setCurrFile = _m[1];
56875
+ var _p = useState(), currFile = _p[0], setCurrFile = _p[1];
56876
+ var _q = useState(), currPreview = _q[0], setCurrPreview = _q[1];
56779
56877
  // HTML integration
56780
- var _o = useState(false), hasHtml = _o[0], setHasHtml = _o[1];
56878
+ var _r = useState(false), hasHtml = _r[0], setHasHtml = _r[1];
56781
56879
  // ZIP integration
56782
- var _p = useState(), innerName = _p[0], setInnerName = _p[1];
56880
+ var _s = useState(), innerName = _s[0], setInnerName = _s[1];
56783
56881
  /**
56784
56882
  * Get file name to use
56785
56883
  */
@@ -56788,6 +56886,38 @@ var FileCard = function (_a) {
56788
56886
  return;
56789
56887
  return innerName !== null && innerName !== void 0 ? innerName : path.split('/').reverse()[0];
56790
56888
  }, [path, innerName]);
56889
+ useEffect(function () {
56890
+ if (!vtkHBJSON)
56891
+ return;
56892
+ if (filename.endsWith('hbjson')) {
56893
+ setCurrPreview(vtkHBJSON);
56894
+ }
56895
+ }, [vtkHBJSON]);
56896
+ useEffect(function () {
56897
+ if (!vtkHBVSF)
56898
+ return;
56899
+ if (filename.endsWith('vsf')) {
56900
+ setCurrPreview(vtkHBVSF);
56901
+ }
56902
+ }, [vtkHBVSF]);
56903
+ /**
56904
+ * Preview name
56905
+ */
56906
+ var previewName = useMemo(function () {
56907
+ if (!currPreview || !filename)
56908
+ return;
56909
+ var prevName;
56910
+ if (filename.endsWith('zip')) {
56911
+ prevName = filename.replace('.zip', 'vtkjs');
56912
+ }
56913
+ else if (filename.endsWith('hbjson')) {
56914
+ prevName = filename.replace('hbjson', 'vtkjs');
56915
+ }
56916
+ else if (filename.endsWith('vsf')) {
56917
+ prevName = filename.replace('vsf', 'vtkjs');
56918
+ }
56919
+ return prevName;
56920
+ }, [currPreview, filename]);
56791
56921
  /**
56792
56922
  * Get file from a ZIP file.
56793
56923
  * 1 zip = 1 file for now
@@ -56815,10 +56945,12 @@ var FileCard = function (_a) {
56815
56945
  setInnerName(name);
56816
56946
  var blob = f.slice(0, f.size, 'text/plain');
56817
56947
  setCurrFile(blob);
56948
+ // Note: inputs are always available
56818
56949
  if (name.endsWith('vsf')) {
56819
56950
  setHasHtml(true);
56820
56951
  fetchHTML(blob);
56821
56952
  setCADintegration(blob, name);
56953
+ fetchVTKfromVSF(blob);
56822
56954
  }
56823
56955
  });
56824
56956
  });
@@ -56872,6 +57004,7 @@ var FileCard = function (_a) {
56872
57004
  // Deleted from cloud
56873
57005
  setIsInactive(true);
56874
57006
  setCurrFile(undefined);
57007
+ setCurrPreview(undefined);
56875
57008
  setCADintegration(undefined);
56876
57009
  setIsLoading(false);
56877
57010
  setHasHtml(false);
@@ -56891,10 +57024,12 @@ var FileCard = function (_a) {
56891
57024
  setHasHtml(true);
56892
57025
  fetchHTML(blob); // HTML button
56893
57026
  setCADintegration(blob);
57027
+ fetchVTKfromVSF(blob);
56894
57028
  }
56895
57029
  else if (path === null || path === void 0 ? void 0 : path.endsWith('hbjson')) {
56896
57030
  setHasHtml(false);
56897
57031
  setCADintegration(blob);
57032
+ fetchVTKfromHBJSON(blob);
56898
57033
  }
56899
57034
  else {
56900
57035
  setHasHtml(false);
@@ -56948,7 +57083,13 @@ var FileCard = function (_a) {
56948
57083
  // Generate Blob on click
56949
57084
  run && downloadArtifact(path, run.status.job_id)
56950
57085
  .then(function (url) { return fetchAndSet(url); })
56951
- .catch(function () { return onClicked({ label: label, path: path, file: undefined, description: description, name: filename }); });
57086
+ .catch(function () { return onClicked({
57087
+ label: label,
57088
+ path: path,
57089
+ file: undefined,
57090
+ description: description,
57091
+ name: filename
57092
+ }); });
56952
57093
  }
56953
57094
  else {
56954
57095
  // Some inputs has path == null
@@ -56965,14 +57106,19 @@ var FileCard = function (_a) {
56965
57106
  }, [run, label, path]);
56966
57107
  return React__default.createElement("div", { className: isInactive
56967
57108
  ? 'card-param card-folder-inactive'
56968
- : 'card-param card-folder', tabIndex: 0, role: 'button', key: label, onClick: function (event) {
57109
+ : (loadingHBJSON || loadingVSF)
57110
+ ? 'card-param'
57111
+ : 'card-param card-folder', tabIndex: 0, role: (loadingHBJSON || loadingVSF) ? 'none' : 'button', key: label, onClick: function (event) {
56969
57112
  event.stopPropagation();
56970
- if (isInactive)
57113
+ if (isInactive || (loadingHBJSON || loadingVSF))
56971
57114
  return;
56972
- onClicked({ label: label, path: path, file: currFile, description: description, name: filename });
57115
+ onClicked({ label: label, path: path, file: currFile, description: description, name: filename,
57116
+ previewFile: currPreview !== null && currPreview !== void 0 ? currPreview : currFile,
57117
+ previewName: previewName !== null && previewName !== void 0 ? previewName : filename
57118
+ });
56973
57119
  } },
56974
57120
  React__default.createElement("div", { className: 'title-param' },
56975
- React__default.createElement("div", { style: { float: 'left', margin: '0 8px 0 0' } }, !isLoading ? React__default.createElement("div", { title: !isInactive
57121
+ React__default.createElement("div", { style: { float: 'left', margin: '0 8px 0 0' } }, (!isLoading) ? React__default.createElement("div", { title: !isInactive
56976
57122
  ? 'Open the viewer'
56977
57123
  : 'File is missing. Check run workspace' },
56978
57124
  React__default.createElement("span", { style: { margin: '0 8px 0 0' } }, path && filename && getFileIcon(18, ((_b = filename === null || filename === void 0 ? void 0 : filename.split('.')) === null || _b === void 0 ? void 0 : _b.pop()) || '')),
@@ -58034,5 +58180,5 @@ var RunTable = function (_a) {
58034
58180
  React__default.createElement(ChevronRight$1, null)))))));
58035
58181
  };
58036
58182
 
58037
- export { APIClient, AuthUser, Avatar, Button, ComboBox, ComboFileSelector, ConditionalWrapper, ConfigureLocalRun, CreateStudy, Dropdown$2 as Dropdown, FileInput, FilePreview, FormInput, GetGeometry, GetModel, InputDescription, Label, Logo, NumberInput, RadioList, RecipeForm, RunCard, RunDetails, RunRow, RunTable, SelectAccount, SelectCloudArtifacts, SelectLocalArtifacts, SelectProject, SelectRecipe, SelectRun, SelectStudy, SendGeometry, SendModel, SendResults, SettingsButton, StudyCard, TargetPlaform, TextInput, Tooltip, _defaultConfig, checkDotNet, checkPollinationPanel, checkRuby, formatBytes, getHost, recipeLinkFromSource, sendMessageDotNet, sendMessageRuby, useAPIClient, useArtifacts, useCreateStudy, useGetGeometry, useGetHbjson, useHbjsontoVTK, useJobs, useManageSettings, usePollinationPanel, useRunCommand, useRuns, useSendHbjson, useSendMessage, useVSFToHTML, useWindowDimensions };
58183
+ export { APIClient, AuthUser, Avatar, Button, ComboBox, ComboFileSelector, ConditionalWrapper, ConfigureLocalRun, CreateStudy, Dropdown$2 as Dropdown, FileInput, FilePreview, FormInput, GetGeometry, GetModel, InputDescription, Label, Logo, NumberInput, RadioList, RecipeForm, RunCard, RunDetails, RunRow, RunTable, SelectAccount, SelectCloudArtifacts, SelectLocalArtifacts, SelectProject, SelectRecipe, SelectRun, SelectStudy, SendGeometry, SendModel, SendResults, SettingsButton, StudyCard, TargetPlaform, TextInput, Tooltip, _defaultConfig, checkDotNet, checkPollinationPanel, checkRuby, formatBytes, getHost, recipeLinkFromSource, sendMessageDotNet, sendMessageRuby, useAPIClient, useArtifacts, useCreateStudy, useGetGeometry, useGetHbjson, useHbjsontoVTK, useJobs, useManageSettings, usePollinationPanel, useRunCommand, useRuns, useSendHbjson, useSendMessage, useVSFToHTML, useVsftoVTK, useWindowDimensions };
58038
58184
  //# sourceMappingURL=index.esm.js.map