pollination-react-io 1.89.0 → 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
  });
@@ -56811,22 +56858,26 @@ var FileCard = function (_a) {
56811
56858
  var host = getHost();
56812
56859
  var fromFileToBase64 = usePollinationPanel().fromFileToBase64;
56813
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;
56814
56864
  var downloadArtifact = useArtifacts(projectOwner, projectName, client).downloadArtifact;
56815
- var _e = useState(false), open = _e[0], setOpen = _e[1];
56865
+ var _g = useState(false), open = _g[0], setOpen = _g[1];
56816
56866
  // Hover effects
56817
- var _f = useState(false), infoOver = _f[0], setInfoOver = _f[1];
56818
- var _g = useState(false), downloadOver = _g[0], setDownloadOver = _g[1];
56819
- var _h = useState(false), htmlOver = _h[0], setHtmlOver = _h[1];
56820
- var _j = useState(true), isLoading = _j[0], setIsLoading = _j[1];
56821
- 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];
56822
56872
  // Data to use for CAD injections
56823
- var _l = useState(), CADdata = _l[0], setCADdata = _l[1];
56873
+ var _o = useState(), CADdata = _o[0], setCADdata = _o[1];
56824
56874
  // File to send to parent
56825
- 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];
56826
56877
  // HTML integration
56827
- var _o = useState(false), hasHtml = _o[0], setHasHtml = _o[1];
56878
+ var _r = useState(false), hasHtml = _r[0], setHasHtml = _r[1];
56828
56879
  // ZIP integration
56829
- var _p = useState(), innerName = _p[0], setInnerName = _p[1];
56880
+ var _s = useState(), innerName = _s[0], setInnerName = _s[1];
56830
56881
  /**
56831
56882
  * Get file name to use
56832
56883
  */
@@ -56835,6 +56886,38 @@ var FileCard = function (_a) {
56835
56886
  return;
56836
56887
  return innerName !== null && innerName !== void 0 ? innerName : path.split('/').reverse()[0];
56837
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]);
56838
56921
  /**
56839
56922
  * Get file from a ZIP file.
56840
56923
  * 1 zip = 1 file for now
@@ -56862,10 +56945,12 @@ var FileCard = function (_a) {
56862
56945
  setInnerName(name);
56863
56946
  var blob = f.slice(0, f.size, 'text/plain');
56864
56947
  setCurrFile(blob);
56948
+ // Note: inputs are always available
56865
56949
  if (name.endsWith('vsf')) {
56866
56950
  setHasHtml(true);
56867
56951
  fetchHTML(blob);
56868
56952
  setCADintegration(blob, name);
56953
+ fetchVTKfromVSF(blob);
56869
56954
  }
56870
56955
  });
56871
56956
  });
@@ -56919,6 +57004,7 @@ var FileCard = function (_a) {
56919
57004
  // Deleted from cloud
56920
57005
  setIsInactive(true);
56921
57006
  setCurrFile(undefined);
57007
+ setCurrPreview(undefined);
56922
57008
  setCADintegration(undefined);
56923
57009
  setIsLoading(false);
56924
57010
  setHasHtml(false);
@@ -56938,10 +57024,12 @@ var FileCard = function (_a) {
56938
57024
  setHasHtml(true);
56939
57025
  fetchHTML(blob); // HTML button
56940
57026
  setCADintegration(blob);
57027
+ fetchVTKfromVSF(blob);
56941
57028
  }
56942
57029
  else if (path === null || path === void 0 ? void 0 : path.endsWith('hbjson')) {
56943
57030
  setHasHtml(false);
56944
57031
  setCADintegration(blob);
57032
+ fetchVTKfromHBJSON(blob);
56945
57033
  }
56946
57034
  else {
56947
57035
  setHasHtml(false);
@@ -56995,7 +57083,13 @@ var FileCard = function (_a) {
56995
57083
  // Generate Blob on click
56996
57084
  run && downloadArtifact(path, run.status.job_id)
56997
57085
  .then(function (url) { return fetchAndSet(url); })
56998
- .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
+ }); });
56999
57093
  }
57000
57094
  else {
57001
57095
  // Some inputs has path == null
@@ -57012,14 +57106,19 @@ var FileCard = function (_a) {
57012
57106
  }, [run, label, path]);
57013
57107
  return React__default.createElement("div", { className: isInactive
57014
57108
  ? 'card-param card-folder-inactive'
57015
- : '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) {
57016
57112
  event.stopPropagation();
57017
- if (isInactive)
57113
+ if (isInactive || (loadingHBJSON || loadingVSF))
57018
57114
  return;
57019
- 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
+ });
57020
57119
  } },
57021
57120
  React__default.createElement("div", { className: 'title-param' },
57022
- 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
57023
57122
  ? 'Open the viewer'
57024
57123
  : 'File is missing. Check run workspace' },
57025
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()) || '')),
@@ -58081,5 +58180,5 @@ var RunTable = function (_a) {
58081
58180
  React__default.createElement(ChevronRight$1, null)))))));
58082
58181
  };
58083
58182
 
58084
- 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 };
58085
58184
  //# sourceMappingURL=index.esm.js.map