plugin-file-preview-auth 1.0.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.
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.js +10 -0
- package/dist/externalVersion.js +17 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +11 -0
- package/dist/locale/vi-VN.json +11 -0
- package/dist/locale/zh-CN.json +11 -0
- package/dist/server/index.js +42 -0
- package/dist/server/plugin.js +54 -0
- package/package.json +23 -0
- package/plugin-file-preview-auth-1.0.1.tgz +0 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/plugin-file-manager/client"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("plugin-file-preview-auth",["react","@nocobase/plugin-file-manager/client","@nocobase/client","@ant-design/icons","antd"],t):"object"==typeof exports?exports["plugin-file-preview-auth"]=t(require("react"),require("@nocobase/plugin-file-manager/client"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):e["plugin-file-preview-auth"]=t(e.react,e["@nocobase/plugin-file-manager/client"],e["@nocobase/client"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o){return function(){"use strict";var i={482:function(e){e.exports=r},772:function(e){e.exports=n},183:function(e){e.exports=t},721:function(e){e.exports=o},156:function(t){t.exports=e}},l={};function u(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return i[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return!function(){u.r(a),u.d(a,{default:function(){return K},PluginFilePreviewAuthClient:function(){return $}});var e=u(156),t=u.n(e),n=u(482),r=u(721),o=u(772),i=u(183),l=JSON.parse('{"u2":"plugin-file-preview-auth"}');function c(){var e=(0,o.useApp)();return function(t){return e.i18n.t(t,{ns:[l.u2,"client"]})}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n,r,o,i,l){try{var u=e[i](l),a=u.value}catch(e){n(e);return}u.done?t(a):Promise.resolve(a).then(r,o)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){f(i,r,o,l,u,"next",e)}function u(e){f(i,r,o,l,u,"throw",e)}l(void 0)})}}function d(e,t,n){return(d=w()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&y(o,n.prototype),o}).apply(null,arguments)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function m(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,u=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){u=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){var t="function"==typeof Map?new Map:void 0;return(g=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return d(e,arguments,h(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),y(n,e)})(e)}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function x(e,t){var n,r,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var a=[i,u];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var O=["application/pdf"],j=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/bmp"],E=["text/plain","text/csv","text/html","text/css","text/javascript","application/json","application/xml","text/xml"],P=["pdf"],k=["png","jpg","jpeg","gif","webp","svg","bmp"],S=["txt","csv","html","css","js","json","xml","log","md"],C=function(e){var t=("string"==typeof e?e:(null==e?void 0:e.extname)||(null==e?void 0:e.name)||(null==e?void 0:e.filename)||(null==e?void 0:e.url)||"").split("?")[0].split("#")[0],n=t.lastIndexOf(".");return -1!==n?t.slice(n+1).toLowerCase().replace(/^\./,""):""},T=function(e){var t="string"==typeof e?e:null==e?void 0:e.url;return t?t.startsWith("https://")||t.startsWith("http://")?t:"".concat(location.origin,"/").concat(t.replace(/^\//,"")):""},A=function(e){if((null==e?void 0:e.mimetype)&&O.includes(e.mimetype))return!0;var t=C(e);return!!t&&P.includes(t)},R=function(e){if((null==e?void 0:e.mimetype)&&j.includes(e.mimetype)||(null==e?void 0:e.mimetype)&&(0,o.matchMimetype)(e,"image/*"))return!0;var t=C(e);return!!t&&k.includes(t)},L=function(e){if((null==e?void 0:e.mimetype)&&E.includes(e.mimetype))return!0;var t=C(e);return!!t&&S.includes(t)},F=function(e){return e?e.title&&e.extname?"".concat(e.title).concat(e.extname):e.filename||e.name||e.title||"download":"download"};function I(e,t){return U.apply(this,arguments)}function U(){return(U=p(function(e,t){var n,r;return x(this,function(o){switch(o.label){case 0:return n={},t&&(n.Authorization="Bearer ".concat(t)),[4,fetch(e,{method:"GET",headers:n,credentials:"include"})];case 1:if(!(r=o.sent()).ok)throw Error("Failed to fetch file: ".concat(r.status," ").concat(r.statusText));return[2,r.blob()]}})})).apply(this,arguments)}function D(){return(D=p(function(e,t){var n,r;return x(this,function(o){switch(o.label){case 0:return n={},t&&(n.Authorization="Bearer ".concat(t)),[4,fetch(e,{method:"GET",headers:n,credentials:"include"})];case 1:if(!(r=o.sent()).ok)throw Error("Failed to fetch file: ".concat(r.status," ").concat(r.statusText));return[2,r.text()]}})})).apply(this,arguments)}function _(e,t){return q.apply(this,arguments)}function q(){return(q=p(function(e,t){var n,r,o,i,l;return x(this,function(u){switch(u.label){case 0:if(!(n=T(e)))return[2];return[4,I(n,t)];case 1:return r=u.sent(),o=F(e),(i=document.createElement("a")).href=l=URL.createObjectURL(r),i.download=o,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(function(){return URL.revokeObjectURL(l)},1e3),[2]}})})).apply(this,arguments)}function M(t,n){var r=b((0,e.useState)(null),2),o=r[0],i=r[1],l=b((0,e.useState)(!0),2),u=l[0],a=l[1],c=b((0,e.useState)(null),2),s=c[0],f=c[1],p=(0,e.useRef)(null);return(0,e.useEffect)(function(){var e=!1,r=T(t);if(!r){a(!1),f("No file URL");return}return a(!0),f(null),I(r,n).then(function(t){if(!e){var n=URL.createObjectURL(t);p.current=n,i(n),a(!1)}}).catch(function(t){e||(f(t.message||"Failed to load"),a(!1))}),function(){e=!0,p.current&&(URL.revokeObjectURL(p.current),p.current=null)}},["string"==typeof t?t:null==t?void 0:t.url,n]),{blobUrl:o,loading:u,error:s}}function B(e){var n=e.message;return t().createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",width:"100%"}},t().createElement(r.Spin,{tip:n}))}function W(e){var n=e.message;return t().createElement("div",{style:{padding:20,textAlign:"center",color:"#ff4d4f"}},n)}function z(e){var n,r=e.file,i=(0,o.useAPIClient)(),l=c(),u=M(r,(null==(n=i.auth)?void 0:n.token)||""),a=u.blobUrl,s=u.loading,f=u.error;return s?t().createElement(B,{message:l("Loading preview...")}):f||!a?t().createElement(W,{message:l("Failed to load file preview")}):t().createElement("iframe",{src:a,width:"100%",height:"100%",style:{border:"none"}})}function H(e){var n,r=e.file,i=(0,o.useAPIClient)(),l=c(),u=M(r,(null==(n=i.auth)?void 0:n.token)||""),a=u.blobUrl,s=u.loading,f=u.error;return s?t().createElement(B,{message:l("Loading preview...")}):f||!a?t().createElement(W,{message:l("Failed to load file preview")}):t().createElement("img",{src:a,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"},alt:(null==r?void 0:r.title)||(null==r?void 0:r.filename)||""})}function G(n){var r,i,l,u,a,s,f,p,d,h,v=n.file,m=(0,o.useAPIClient)(),y=c(),g=(null==(h=m.auth)?void 0:h.token)||"",w=(i=(r=b((0,e.useState)(null),2))[0],l=r[1],a=(u=b((0,e.useState)(!0),2))[0],s=u[1],p=(f=b((0,e.useState)(null),2))[0],d=f[1],(0,e.useEffect)(function(){var e=!1,t=T(v);if(!t){s(!1),d("No file URL");return}return s(!0),d(null),(function(e,t){return D.apply(this,arguments)})(t,g).then(function(t){e||(l(t),s(!1))}).catch(function(t){e||(d(t.message||"Failed to load"),s(!1))}),function(){e=!0}},["string"==typeof v?v:null==v?void 0:v.url,g]),{text:i,loading:a,error:p}),x=w.text,O=w.loading,j=w.error;return O?t().createElement(B,{message:y("Loading preview...")}):j||null===x?t().createElement(W,{message:y("Failed to load file preview")}):t().createElement("pre",{style:{width:"100%",height:"100%",overflow:"auto",padding:16,margin:0,fontSize:13,lineHeight:1.6,whiteSpace:"pre-wrap",wordWrap:"break-word",background:"#f5f5f5",border:"none"}},x)}var N=function(i){return function(l){var u,a=l.open,s=l.onOpenChange,f=l.onClose,d=l.file,h=l.index,y=l.list,b=l.onSwitchIndex;l.onDownload;var g=(0,o.useAPIClient)(),w=c(),O=(0,e.useCallback)((u=p(function(e){var t,n,o;return x(this,function(i){switch(i.label){case 0:if(!(n=e||d))return[2];o=(null==(t=g.auth)?void 0:t.token)||"",i.label=1;case 1:return i.trys.push([1,3,,4]),[4,_(n,o)];case 2:return i.sent(),[3,4];case 3:return i.sent(),r.message.error(w("Failed to download file")),[3,4];case 4:return[2]}})}),function(e){return u.apply(this,arguments)}),[d,g,w]);if("boolean"!=typeof a)return t().createElement(i,m(v({},l),{onDownload:O}));var j=F(d),E="number"==typeof h&&!!b&&h>0,P="number"==typeof h&&!!b&&h<y.length-1;return t().createElement(r.Modal,{open:a,title:j,onCancel:function(){null==s||s(!1),null==f||f()},footer:t().createElement(r.Space,{size:14,style:{fontSize:"20px"}},t().createElement(n.LeftOutlined,{style:{cursor:E?"pointer":"not-allowed"},onClick:function(){return E&&(null==b?void 0:b(h-1))}}),t().createElement(n.RightOutlined,{style:{cursor:P?"pointer":"not-allowed"},onClick:function(){return P&&(null==b?void 0:b(h+1))}}),t().createElement(n.DownloadOutlined,{onClick:function(){return O(d)}})),width:"90vw",centered:!0},t().createElement("div",{style:{maxWidth:"100%",maxHeight:"calc(100vh - 256px)",height:"80vh",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"}},t().createElement(i,m(v({},l),{onDownload:O}))))}};function Y(n){var i,l,u=n.index,a=n.list,s=n.onSwitchIndex,f=c(),d=(0,o.useAPIClient)(),h=a[u],v=b((0,e.useState)(!1),2),m=v[0],y=v[1],g=(0,e.useCallback)((i=p(function(e){var t,n,o,i;return x(this,function(l){switch(l.label){case 0:null==e||null==(t=e.preventDefault)||t.call(e),null==e||null==(n=e.stopPropagation)||n.call(e),i=(null==(o=d.auth)?void 0:o.token)||"",y(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,_(h,i)];case 2:return l.sent(),[3,5];case 3:return l.sent(),r.message.error(f("Failed to download file")),[3,5];case 4:return y(!1),[7];case 5:return[2]}})}),function(e){return i.apply(this,arguments)}),[h,d,f]),w=(0,e.useCallback)((l=p(function(e){var t,n,o,i,l,u,a;return x(this,function(c){switch(c.label){case 0:if(null==e||null==(t=e.preventDefault)||t.call(e),null==e||null==(n=e.stopPropagation)||n.call(e),i=(null==(o=d.auth)?void 0:o.token)||"",!(l=T(h)))return[2];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,I(l,i)];case 2:return u=c.sent(),a=URL.createObjectURL(u),window.open(a),[3,4];case 3:return c.sent(),r.message.error(f("Failed to load file preview")),[3,4];case 4:return[2]}})}),function(e){return l.apply(this,arguments)}),[h,d,f]),O=(0,e.useCallback)(function(){s(null)},[s]),j=(0,e.useMemo)(function(){return A(h)?z:R(h)?H:L(h)?G:null},[h]),E=null!=j;return t().createElement(r.Modal,{open:null!=u,title:(null==h?void 0:h.title)||(null==h?void 0:h.filename)||(null==h?void 0:h.name)||"File",onCancel:O,footer:[E&&t().createElement(r.Button,{key:"open",onClick:w},f("Open in new window")),t().createElement(r.Button,{key:"download",onClick:g,loading:m},f("Download")),t().createElement(r.Button,{key:"close",onClick:O},f("Close"))].filter(Boolean),width:E?"85vw":520,centered:!0},t().createElement("div",{style:{maxWidth:"100%",maxHeight:E?"calc(100vh - 256px)":"auto",height:E?"70vh":"auto",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"}},E?t().createElement(j,{file:h}):t().createElement(r.Alert,{type:"info",style:{width:"100%"},description:f("This file type cannot be previewed. Click Download to save the file."),showIcon:!0})))}function J(n){var i=n.file,l=(0,o.useAPIClient)(),u=c(),a=(0,e.useCallback)(p(function(){var e,t;return x(this,function(n){switch(n.label){case 0:t=(null==(e=l.auth)?void 0:e.token)||"",n.label=1;case 1:return n.trys.push([1,3,,4]),[4,_(i,t)];case 2:return n.sent(),[3,4];case 3:return n.sent(),r.message.error(u("Failed to download file")),[3,4];case 4:return[2]}})}),[i,l,u]);return t().createElement(r.Alert,{type:"info",style:{width:"100%"},description:t().createElement("span",null,u("This file type cannot be previewed. ")," ",t().createElement("a",{onClick:a,style:{textDecoration:"underline",cursor:"pointer"}},u("Download"))),showIcon:!0})}var $=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=h(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,w()?Reflect.construct(e,t||[],h(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&y(n,e),t=[{key:"load",value:function(){return p(function(){return x(this,function(e){return o.attachmentFileTypes.add({match:function(){return!0},Previewer:Y}),i.filePreviewTypes.add({match:function(){return!0},Previewer:N(J)}),i.filePreviewTypes.add({match:A,Previewer:N(z)}),i.filePreviewTypes.add({match:R,getThumbnailURL:function(e){return(null==e?void 0:e.url)||(null==e?void 0:e.preview)||null},Previewer:N(H)}),i.filePreviewTypes.add({match:L,Previewer:N(G)}),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(g(o.Plugin)),K=$}(),a}()});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
"react": "18.2.0",
|
|
12
|
+
"@ant-design/icons": "5.6.1",
|
|
13
|
+
"antd": "5.24.2",
|
|
14
|
+
"@nocobase/client": "2.0.5",
|
|
15
|
+
"@nocobase/plugin-file-manager": "2.0.5",
|
|
16
|
+
"@nocobase/server": "2.0.5"
|
|
17
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var src_exports = {};
|
|
39
|
+
__export(src_exports, {
|
|
40
|
+
default: () => import_server.default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(src_exports);
|
|
43
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
44
|
+
var import_server = __toESM(require("./server"));
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
...require("./server")
|
|
48
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Preview": "Preview",
|
|
3
|
+
"Open in new window": "Open in new window",
|
|
4
|
+
"Download": "Download",
|
|
5
|
+
"Close": "Close",
|
|
6
|
+
"Loading preview...": "Loading preview...",
|
|
7
|
+
"Failed to load file preview": "Failed to load file preview",
|
|
8
|
+
"Failed to download file": "Failed to download file",
|
|
9
|
+
"This file type cannot be previewed. Click Download to save the file.": "This file type cannot be previewed. Click Download to save the file.",
|
|
10
|
+
"This file type cannot be previewed. ": "This file type cannot be previewed. "
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Preview": "Xem trước",
|
|
3
|
+
"Open in new window": "Mở trong cửa sổ mới",
|
|
4
|
+
"Download": "Tải xuống",
|
|
5
|
+
"Close": "Đóng",
|
|
6
|
+
"Loading preview...": "Đang tải xem trước...",
|
|
7
|
+
"Failed to load file preview": "Không thể tải xem trước file",
|
|
8
|
+
"Failed to download file": "Không thể tải file",
|
|
9
|
+
"This file type cannot be previewed. Click Download to save the file.": "Loại file này không thể xem trước. Nhấn Tải xuống để lưu file.",
|
|
10
|
+
"This file type cannot be previewed. ": "Loại file này không thể xem trước. "
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Preview": "预览",
|
|
3
|
+
"Open in new window": "在新窗口中打开",
|
|
4
|
+
"Download": "下载",
|
|
5
|
+
"Close": "关闭",
|
|
6
|
+
"Loading preview...": "正在加载预览...",
|
|
7
|
+
"Failed to load file preview": "无法加载文件预览",
|
|
8
|
+
"Failed to download file": "无法下载文件",
|
|
9
|
+
"This file type cannot be previewed. Click Download to save the file.": "此文件类型不支持预览。请点击下载以保存文件。",
|
|
10
|
+
"This file type cannot be previewed. ": "此文件类型不支持预览。"
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var server_exports = {};
|
|
38
|
+
__export(server_exports, {
|
|
39
|
+
default: () => import_plugin.default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(server_exports);
|
|
42
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var plugin_exports = {};
|
|
28
|
+
__export(plugin_exports, {
|
|
29
|
+
PluginFilePreviewAuthServer: () => PluginFilePreviewAuthServer,
|
|
30
|
+
default: () => plugin_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
33
|
+
var import_server = require("@nocobase/server");
|
|
34
|
+
class PluginFilePreviewAuthServer extends import_server.Plugin {
|
|
35
|
+
async afterAdd() {
|
|
36
|
+
}
|
|
37
|
+
async beforeLoad() {
|
|
38
|
+
}
|
|
39
|
+
async load() {
|
|
40
|
+
}
|
|
41
|
+
async install() {
|
|
42
|
+
}
|
|
43
|
+
async afterEnable() {
|
|
44
|
+
}
|
|
45
|
+
async afterDisable() {
|
|
46
|
+
}
|
|
47
|
+
async remove() {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var plugin_default = PluginFilePreviewAuthServer;
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
PluginFilePreviewAuthServer
|
|
54
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "plugin-file-preview-auth",
|
|
3
|
+
"displayName": "Authenticated File Previewer",
|
|
4
|
+
"displayName.vi-VN": "Xem trước file có xác thực",
|
|
5
|
+
"displayName.zh-CN": "认证文件预览",
|
|
6
|
+
"description": "Preview PDF, image, and text files with Bearer token authentication via blob URLs.",
|
|
7
|
+
"description.vi-VN": "Xem trước file PDF, hình ảnh và văn bản với xác thực Bearer token qua blob URL.",
|
|
8
|
+
"description.zh-CN": "通过 Bearer 令牌认证和 Blob URL 预览 PDF、图片和文本文件。",
|
|
9
|
+
"version": "1.0.1",
|
|
10
|
+
"main": "dist/server/index.js",
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@nocobase/client": "2.x",
|
|
13
|
+
"@nocobase/plugin-file-manager": "2.x",
|
|
14
|
+
"@nocobase/server": "2.x",
|
|
15
|
+
"@nocobase/test": "2.x"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"File manager",
|
|
19
|
+
"File preview",
|
|
20
|
+
"Authentication"
|
|
21
|
+
],
|
|
22
|
+
"license": "Apache-2.0"
|
|
23
|
+
}
|
|
Binary file
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server');
|