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.
- package/build/RunDetails/Cards/FileCard.d.ts +2 -0
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/useVsftoVTK.d.ts +5 -0
- package/build/index.esm.js +117 -18
- package/build/index.esm.js.map +1 -1
- package/build/index.js +117 -17
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
@@ -40927,7 +40927,7 @@ var useGetHbjson = function () {
|
|
40927
40927
|
};
|
40928
40928
|
};
|
40929
40929
|
|
40930
|
-
var UTILSENDPOINT$
|
40930
|
+
var UTILSENDPOINT$2 = process.env.REACT_APP_UTILS_ENDPOINT || 'https://utilities.staging.pollination.cloud';
|
40931
40931
|
var useHbjsontoVTK = function () {
|
40932
40932
|
var _a = React.useState(false), loading = _a[0], setLoading = _a[1];
|
40933
40933
|
var _b = React.useState(), vtk = _b[0], setVTK = _b[1];
|
@@ -40936,7 +40936,7 @@ var useHbjsontoVTK = function () {
|
|
40936
40936
|
return undefined;
|
40937
40937
|
setLoading(true);
|
40938
40938
|
return hbjson.text().then(function (fileString) {
|
40939
|
-
fetch("".concat(UTILSENDPOINT$
|
40939
|
+
fetch("".concat(UTILSENDPOINT$2, "/hbjson-to-vtk"), {
|
40940
40940
|
method: 'POST',
|
40941
40941
|
headers: {
|
40942
40942
|
'Content-Type': 'application/json',
|
@@ -40976,6 +40976,53 @@ var useHbjsontoVTK = function () {
|
|
40976
40976
|
};
|
40977
40977
|
};
|
40978
40978
|
|
40979
|
+
var UTILSENDPOINT$1 = process.env.REACT_APP_UTILS_ENDPOINT || 'https://utilities.staging.pollination.cloud';
|
40980
|
+
var useVsftoVTK = function () {
|
40981
|
+
var _a = React.useState(false), loading = _a[0], setLoading = _a[1];
|
40982
|
+
var _b = React.useState(), vtk = _b[0], setVTK = _b[1];
|
40983
|
+
var fetchVTK = function (vsf) {
|
40984
|
+
if (!vsf || vsf.size < 1)
|
40985
|
+
return undefined;
|
40986
|
+
setLoading(true);
|
40987
|
+
return vsf.text().then(function (fileString) {
|
40988
|
+
fetch("".concat(UTILSENDPOINT$1, "/vsf-to-vtk"), {
|
40989
|
+
method: 'POST',
|
40990
|
+
headers: {
|
40991
|
+
'Content-Type': 'application/json',
|
40992
|
+
Accept: '*/*',
|
40993
|
+
},
|
40994
|
+
body: "{\n \"output_format\": \"vtkjs\",\n \"vsf\": ".concat(fileString, "\n }"),
|
40995
|
+
})
|
40996
|
+
.catch(function (e) {
|
40997
|
+
throw new Error(e);
|
40998
|
+
})
|
40999
|
+
.then(function (res) { return __awaiter$1(void 0, void 0, void 0, function () {
|
41000
|
+
var translatedFile;
|
41001
|
+
return __generator$1(this, function (_a) {
|
41002
|
+
switch (_a.label) {
|
41003
|
+
case 0:
|
41004
|
+
if (!res.ok) return [3 /*break*/, 2];
|
41005
|
+
return [4 /*yield*/, res.blob()];
|
41006
|
+
case 1:
|
41007
|
+
translatedFile = _a.sent();
|
41008
|
+
setVTK(translatedFile);
|
41009
|
+
return [2 /*return*/, translatedFile];
|
41010
|
+
case 2: throw new Error('Failed to retrieve .vtkjs from .vsf file.Error translating vsf to vtkjs');
|
41011
|
+
}
|
41012
|
+
});
|
41013
|
+
}); })
|
41014
|
+
.finally(function () {
|
41015
|
+
setLoading(false);
|
41016
|
+
});
|
41017
|
+
});
|
41018
|
+
};
|
41019
|
+
return {
|
41020
|
+
loading: loading,
|
41021
|
+
vtk: vtk,
|
41022
|
+
fetchVTK: fetchVTK,
|
41023
|
+
};
|
41024
|
+
};
|
41025
|
+
|
40979
41026
|
var duration = createCommonjsModule(function (module, exports) {
|
40980
41027
|
!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)};}}));
|
40981
41028
|
});
|
@@ -56838,22 +56885,26 @@ var FileCard = function (_a) {
|
|
56838
56885
|
var host = getHost();
|
56839
56886
|
var fromFileToBase64 = usePollinationPanel().fromFileToBase64;
|
56840
56887
|
var _d = useVSFToHTML(), loading = _d.loading, html = _d.html, fetchHTML = _d.fetchHTML;
|
56888
|
+
// VTKJS Handlers
|
56889
|
+
var _e = useHbjsontoVTK(), loadingHBJSON = _e.loading, vtkHBJSON = _e.vtk, fetchVTKfromHBJSON = _e.fetchVTK;
|
56890
|
+
var _f = useVsftoVTK(), loadingVSF = _f.loading, vtkHBVSF = _f.vtk, fetchVTKfromVSF = _f.fetchVTK;
|
56841
56891
|
var downloadArtifact = useArtifacts(projectOwner, projectName, client).downloadArtifact;
|
56842
|
-
var
|
56892
|
+
var _g = React.useState(false), open = _g[0], setOpen = _g[1];
|
56843
56893
|
// Hover effects
|
56844
|
-
var
|
56845
|
-
var
|
56846
|
-
var
|
56847
|
-
var
|
56848
|
-
var
|
56894
|
+
var _h = React.useState(false), infoOver = _h[0], setInfoOver = _h[1];
|
56895
|
+
var _j = React.useState(false), downloadOver = _j[0], setDownloadOver = _j[1];
|
56896
|
+
var _k = React.useState(false), htmlOver = _k[0], setHtmlOver = _k[1];
|
56897
|
+
var _l = React.useState(true), isLoading = _l[0], setIsLoading = _l[1];
|
56898
|
+
var _m = React.useState(false), isInactive = _m[0], setIsInactive = _m[1];
|
56849
56899
|
// Data to use for CAD injections
|
56850
|
-
var
|
56900
|
+
var _o = React.useState(), CADdata = _o[0], setCADdata = _o[1];
|
56851
56901
|
// File to send to parent
|
56852
|
-
var
|
56902
|
+
var _p = React.useState(), currFile = _p[0], setCurrFile = _p[1];
|
56903
|
+
var _q = React.useState(), currPreview = _q[0], setCurrPreview = _q[1];
|
56853
56904
|
// HTML integration
|
56854
|
-
var
|
56905
|
+
var _r = React.useState(false), hasHtml = _r[0], setHasHtml = _r[1];
|
56855
56906
|
// ZIP integration
|
56856
|
-
var
|
56907
|
+
var _s = React.useState(), innerName = _s[0], setInnerName = _s[1];
|
56857
56908
|
/**
|
56858
56909
|
* Get file name to use
|
56859
56910
|
*/
|
@@ -56862,6 +56913,38 @@ var FileCard = function (_a) {
|
|
56862
56913
|
return;
|
56863
56914
|
return innerName !== null && innerName !== void 0 ? innerName : path.split('/').reverse()[0];
|
56864
56915
|
}, [path, innerName]);
|
56916
|
+
React.useEffect(function () {
|
56917
|
+
if (!vtkHBJSON)
|
56918
|
+
return;
|
56919
|
+
if (filename.endsWith('hbjson')) {
|
56920
|
+
setCurrPreview(vtkHBJSON);
|
56921
|
+
}
|
56922
|
+
}, [vtkHBJSON]);
|
56923
|
+
React.useEffect(function () {
|
56924
|
+
if (!vtkHBVSF)
|
56925
|
+
return;
|
56926
|
+
if (filename.endsWith('vsf')) {
|
56927
|
+
setCurrPreview(vtkHBVSF);
|
56928
|
+
}
|
56929
|
+
}, [vtkHBVSF]);
|
56930
|
+
/**
|
56931
|
+
* Preview name
|
56932
|
+
*/
|
56933
|
+
var previewName = React.useMemo(function () {
|
56934
|
+
if (!currPreview || !filename)
|
56935
|
+
return;
|
56936
|
+
var prevName;
|
56937
|
+
if (filename.endsWith('zip')) {
|
56938
|
+
prevName = filename.replace('.zip', 'vtkjs');
|
56939
|
+
}
|
56940
|
+
else if (filename.endsWith('hbjson')) {
|
56941
|
+
prevName = filename.replace('hbjson', 'vtkjs');
|
56942
|
+
}
|
56943
|
+
else if (filename.endsWith('vsf')) {
|
56944
|
+
prevName = filename.replace('vsf', 'vtkjs');
|
56945
|
+
}
|
56946
|
+
return prevName;
|
56947
|
+
}, [currPreview, filename]);
|
56865
56948
|
/**
|
56866
56949
|
* Get file from a ZIP file.
|
56867
56950
|
* 1 zip = 1 file for now
|
@@ -56889,10 +56972,12 @@ var FileCard = function (_a) {
|
|
56889
56972
|
setInnerName(name);
|
56890
56973
|
var blob = f.slice(0, f.size, 'text/plain');
|
56891
56974
|
setCurrFile(blob);
|
56975
|
+
// Note: inputs are always available
|
56892
56976
|
if (name.endsWith('vsf')) {
|
56893
56977
|
setHasHtml(true);
|
56894
56978
|
fetchHTML(blob);
|
56895
56979
|
setCADintegration(blob, name);
|
56980
|
+
fetchVTKfromVSF(blob);
|
56896
56981
|
}
|
56897
56982
|
});
|
56898
56983
|
});
|
@@ -56946,6 +57031,7 @@ var FileCard = function (_a) {
|
|
56946
57031
|
// Deleted from cloud
|
56947
57032
|
setIsInactive(true);
|
56948
57033
|
setCurrFile(undefined);
|
57034
|
+
setCurrPreview(undefined);
|
56949
57035
|
setCADintegration(undefined);
|
56950
57036
|
setIsLoading(false);
|
56951
57037
|
setHasHtml(false);
|
@@ -56965,10 +57051,12 @@ var FileCard = function (_a) {
|
|
56965
57051
|
setHasHtml(true);
|
56966
57052
|
fetchHTML(blob); // HTML button
|
56967
57053
|
setCADintegration(blob);
|
57054
|
+
fetchVTKfromVSF(blob);
|
56968
57055
|
}
|
56969
57056
|
else if (path === null || path === void 0 ? void 0 : path.endsWith('hbjson')) {
|
56970
57057
|
setHasHtml(false);
|
56971
57058
|
setCADintegration(blob);
|
57059
|
+
fetchVTKfromHBJSON(blob);
|
56972
57060
|
}
|
56973
57061
|
else {
|
56974
57062
|
setHasHtml(false);
|
@@ -57022,7 +57110,13 @@ var FileCard = function (_a) {
|
|
57022
57110
|
// Generate Blob on click
|
57023
57111
|
run && downloadArtifact(path, run.status.job_id)
|
57024
57112
|
.then(function (url) { return fetchAndSet(url); })
|
57025
|
-
.catch(function () { return onClicked({
|
57113
|
+
.catch(function () { return onClicked({
|
57114
|
+
label: label,
|
57115
|
+
path: path,
|
57116
|
+
file: undefined,
|
57117
|
+
description: description,
|
57118
|
+
name: filename
|
57119
|
+
}); });
|
57026
57120
|
}
|
57027
57121
|
else {
|
57028
57122
|
// Some inputs has path == null
|
@@ -57039,14 +57133,19 @@ var FileCard = function (_a) {
|
|
57039
57133
|
}, [run, label, path]);
|
57040
57134
|
return React__default["default"].createElement("div", { className: isInactive
|
57041
57135
|
? 'card-param card-folder-inactive'
|
57042
|
-
:
|
57136
|
+
: (loadingHBJSON || loadingVSF)
|
57137
|
+
? 'card-param'
|
57138
|
+
: 'card-param card-folder', tabIndex: 0, role: (loadingHBJSON || loadingVSF) ? 'none' : 'button', key: label, onClick: function (event) {
|
57043
57139
|
event.stopPropagation();
|
57044
|
-
if (isInactive)
|
57140
|
+
if (isInactive || (loadingHBJSON || loadingVSF))
|
57045
57141
|
return;
|
57046
|
-
onClicked({ label: label, path: path, file: currFile, description: description, name: filename
|
57142
|
+
onClicked({ label: label, path: path, file: currFile, description: description, name: filename,
|
57143
|
+
previewFile: currPreview !== null && currPreview !== void 0 ? currPreview : currFile,
|
57144
|
+
previewName: previewName !== null && previewName !== void 0 ? previewName : filename
|
57145
|
+
});
|
57047
57146
|
} },
|
57048
57147
|
React__default["default"].createElement("div", { className: 'title-param' },
|
57049
|
-
React__default["default"].createElement("div", { style: { float: 'left', margin: '0 8px 0 0' } }, !isLoading ? React__default["default"].createElement("div", { title: !isInactive
|
57148
|
+
React__default["default"].createElement("div", { style: { float: 'left', margin: '0 8px 0 0' } }, (!isLoading) ? React__default["default"].createElement("div", { title: !isInactive
|
57050
57149
|
? 'Open the viewer'
|
57051
57150
|
: 'File is missing. Check run workspace' },
|
57052
57151
|
React__default["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()) || '')),
|
@@ -58170,5 +58269,6 @@ exports.useRuns = useRuns;
|
|
58170
58269
|
exports.useSendHbjson = useSendHbjson;
|
58171
58270
|
exports.useSendMessage = useSendMessage;
|
58172
58271
|
exports.useVSFToHTML = useVSFToHTML;
|
58272
|
+
exports.useVsftoVTK = useVsftoVTK;
|
58173
58273
|
exports.useWindowDimensions = useWindowDimensions;
|
58174
58274
|
//# sourceMappingURL=index.js.map
|