pollination-react-io 1.89.0 → 1.90.1

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
  });
@@ -47054,9 +47101,11 @@ var RecipeForm = function (_a) {
47054
47101
  };
47055
47102
  alias && Object.keys(alias).forEach(function (key) {
47056
47103
  if (key in inputInfo) {
47057
- // if the alias is DAGGenericInputAlias use the native input type
47104
+ // if the alias is DAGGenericInputAlias
47105
+ // or DAGLinkedInputAlias use the native input type
47058
47106
  if (key == 'type') {
47059
- if (alias[key] == 'DAGGenericInputAlias') {
47107
+ if (alias[key] === 'DAGGenericInputAlias'
47108
+ || alias[key] === 'DAGLinkedInputAlias') {
47060
47109
  return;
47061
47110
  }
47062
47111
  }
@@ -56811,22 +56860,26 @@ var FileCard = function (_a) {
56811
56860
  var host = getHost();
56812
56861
  var fromFileToBase64 = usePollinationPanel().fromFileToBase64;
56813
56862
  var _d = useVSFToHTML(), loading = _d.loading, html = _d.html, fetchHTML = _d.fetchHTML;
56863
+ // VTKJS Handlers
56864
+ var _e = useHbjsontoVTK(), loadingHBJSON = _e.loading, vtkHBJSON = _e.vtk, fetchVTKfromHBJSON = _e.fetchVTK;
56865
+ var _f = useVsftoVTK(), loadingVSF = _f.loading, vtkHBVSF = _f.vtk, fetchVTKfromVSF = _f.fetchVTK;
56814
56866
  var downloadArtifact = useArtifacts(projectOwner, projectName, client).downloadArtifact;
56815
- var _e = useState(false), open = _e[0], setOpen = _e[1];
56867
+ var _g = useState(false), open = _g[0], setOpen = _g[1];
56816
56868
  // 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];
56869
+ var _h = useState(false), infoOver = _h[0], setInfoOver = _h[1];
56870
+ var _j = useState(false), downloadOver = _j[0], setDownloadOver = _j[1];
56871
+ var _k = useState(false), htmlOver = _k[0], setHtmlOver = _k[1];
56872
+ var _l = useState(true), isLoading = _l[0], setIsLoading = _l[1];
56873
+ var _m = useState(false), isInactive = _m[0], setIsInactive = _m[1];
56822
56874
  // Data to use for CAD injections
56823
- var _l = useState(), CADdata = _l[0], setCADdata = _l[1];
56875
+ var _o = useState(), CADdata = _o[0], setCADdata = _o[1];
56824
56876
  // File to send to parent
56825
- var _m = useState(), currFile = _m[0], setCurrFile = _m[1];
56877
+ var _p = useState(), currFile = _p[0], setCurrFile = _p[1];
56878
+ var _q = useState(), currPreview = _q[0], setCurrPreview = _q[1];
56826
56879
  // HTML integration
56827
- var _o = useState(false), hasHtml = _o[0], setHasHtml = _o[1];
56880
+ var _r = useState(false), hasHtml = _r[0], setHasHtml = _r[1];
56828
56881
  // ZIP integration
56829
- var _p = useState(), innerName = _p[0], setInnerName = _p[1];
56882
+ var _s = useState(), innerName = _s[0], setInnerName = _s[1];
56830
56883
  /**
56831
56884
  * Get file name to use
56832
56885
  */
@@ -56835,6 +56888,38 @@ var FileCard = function (_a) {
56835
56888
  return;
56836
56889
  return innerName !== null && innerName !== void 0 ? innerName : path.split('/').reverse()[0];
56837
56890
  }, [path, innerName]);
56891
+ useEffect(function () {
56892
+ if (!vtkHBJSON)
56893
+ return;
56894
+ if (filename.endsWith('hbjson')) {
56895
+ setCurrPreview(vtkHBJSON);
56896
+ }
56897
+ }, [vtkHBJSON]);
56898
+ useEffect(function () {
56899
+ if (!vtkHBVSF)
56900
+ return;
56901
+ if (filename.endsWith('vsf')) {
56902
+ setCurrPreview(vtkHBVSF);
56903
+ }
56904
+ }, [vtkHBVSF]);
56905
+ /**
56906
+ * Preview name
56907
+ */
56908
+ var previewName = useMemo(function () {
56909
+ if (!currPreview || !filename)
56910
+ return;
56911
+ var prevName;
56912
+ if (filename.endsWith('zip')) {
56913
+ prevName = filename.replace('.zip', 'vtkjs');
56914
+ }
56915
+ else if (filename.endsWith('hbjson')) {
56916
+ prevName = filename.replace('hbjson', 'vtkjs');
56917
+ }
56918
+ else if (filename.endsWith('vsf')) {
56919
+ prevName = filename.replace('vsf', 'vtkjs');
56920
+ }
56921
+ return prevName;
56922
+ }, [currPreview, filename]);
56838
56923
  /**
56839
56924
  * Get file from a ZIP file.
56840
56925
  * 1 zip = 1 file for now
@@ -56862,10 +56947,12 @@ var FileCard = function (_a) {
56862
56947
  setInnerName(name);
56863
56948
  var blob = f.slice(0, f.size, 'text/plain');
56864
56949
  setCurrFile(blob);
56950
+ // Note: inputs are always available
56865
56951
  if (name.endsWith('vsf')) {
56866
56952
  setHasHtml(true);
56867
56953
  fetchHTML(blob);
56868
56954
  setCADintegration(blob, name);
56955
+ fetchVTKfromVSF(blob);
56869
56956
  }
56870
56957
  });
56871
56958
  });
@@ -56919,6 +57006,7 @@ var FileCard = function (_a) {
56919
57006
  // Deleted from cloud
56920
57007
  setIsInactive(true);
56921
57008
  setCurrFile(undefined);
57009
+ setCurrPreview(undefined);
56922
57010
  setCADintegration(undefined);
56923
57011
  setIsLoading(false);
56924
57012
  setHasHtml(false);
@@ -56938,10 +57026,12 @@ var FileCard = function (_a) {
56938
57026
  setHasHtml(true);
56939
57027
  fetchHTML(blob); // HTML button
56940
57028
  setCADintegration(blob);
57029
+ fetchVTKfromVSF(blob);
56941
57030
  }
56942
57031
  else if (path === null || path === void 0 ? void 0 : path.endsWith('hbjson')) {
56943
57032
  setHasHtml(false);
56944
57033
  setCADintegration(blob);
57034
+ fetchVTKfromHBJSON(blob);
56945
57035
  }
56946
57036
  else {
56947
57037
  setHasHtml(false);
@@ -56995,7 +57085,13 @@ var FileCard = function (_a) {
56995
57085
  // Generate Blob on click
56996
57086
  run && downloadArtifact(path, run.status.job_id)
56997
57087
  .then(function (url) { return fetchAndSet(url); })
56998
- .catch(function () { return onClicked({ label: label, path: path, file: undefined, description: description, name: filename }); });
57088
+ .catch(function () { return onClicked({
57089
+ label: label,
57090
+ path: path,
57091
+ file: undefined,
57092
+ description: description,
57093
+ name: filename
57094
+ }); });
56999
57095
  }
57000
57096
  else {
57001
57097
  // Some inputs has path == null
@@ -57012,14 +57108,19 @@ var FileCard = function (_a) {
57012
57108
  }, [run, label, path]);
57013
57109
  return React__default.createElement("div", { className: isInactive
57014
57110
  ? 'card-param card-folder-inactive'
57015
- : 'card-param card-folder', tabIndex: 0, role: 'button', key: label, onClick: function (event) {
57111
+ : (loadingHBJSON || loadingVSF)
57112
+ ? 'card-param'
57113
+ : 'card-param card-folder', tabIndex: 0, role: (loadingHBJSON || loadingVSF) ? 'none' : 'button', key: label, onClick: function (event) {
57016
57114
  event.stopPropagation();
57017
- if (isInactive)
57115
+ if (isInactive || (loadingHBJSON || loadingVSF))
57018
57116
  return;
57019
- onClicked({ label: label, path: path, file: currFile, description: description, name: filename });
57117
+ onClicked({ label: label, path: path, file: currFile, description: description, name: filename,
57118
+ previewFile: currPreview !== null && currPreview !== void 0 ? currPreview : currFile,
57119
+ previewName: previewName !== null && previewName !== void 0 ? previewName : filename
57120
+ });
57020
57121
  } },
57021
57122
  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
57123
+ React__default.createElement("div", { style: { float: 'left', margin: '0 8px 0 0' } }, (!isLoading) ? React__default.createElement("div", { title: !isInactive
57023
57124
  ? 'Open the viewer'
57024
57125
  : 'File is missing. Check run workspace' },
57025
57126
  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 +58182,5 @@ var RunTable = function (_a) {
58081
58182
  React__default.createElement(ChevronRight$1, null)))))));
58082
58183
  };
58083
58184
 
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 };
58185
+ 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
58186
  //# sourceMappingURL=index.esm.js.map