next-box 1.3.58 → 1.3.60
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/index.js +1 -1
- package/interfaces.d.ts +3 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PolymaticaApi=t():e.PolymaticaApi=t()}(globalThis,(()=>(()=>{"use strict";var e={752:function(e,t,n){var o,r=this&&this.__extends||(o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.NextBox=void 0;var a=n(139),s=n(437),p=n(382),l=n(679),c=Object.values(l.ExtensionEvents),h=function(e){function t(){var t=e.call(this)||this;return t.debug=!1,t}return r(t,e),t.prototype.on=function(t,n){var o;return(null===(o=this.state)||void 0===o?void 0:o.debug)&&console.log("on",t,n),e.prototype.on.call(this,t,n)},t.prototype.off=function(t,n){var o;return(null===(o=this.state)||void 0===o?void 0:o.debug)&&console.log("off",t,n),e.prototype.off.call(this,t,n)},t.prototype.emit=function(t){for(var n,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return(null===(n=this.state)||void 0===n?void 0:n.debug)&&console.log("emit",t,o),e.prototype.emit.apply(this,i([t],o,!1))},t.prototype.init=function(){this.subscribeEvent(),(0,p.sendEvent)(l.AppEvents.Init)},t.prototype.changeContent=function(e){(0,p.sendEvent)(l.AppEvents.ChangeContent,e)},t.prototype.navigate=function(e,t){(0,p.sendEvent)(l.AppEvents.NavigateTo,{path:e,queryParams:t})},t.prototype.close=function(){(0,p.sendEvent)(l.AppEvents.Close)},t.prototype.openModalFilesSelect=function(e){(0,p.sendEvent)(l.AppEvents.OpenModalFilesSelect,e)},t.prototype.subscribeEvent=function(){var t=this;window.addEventListener("message",(function(n){var o=n.data.event,r=n.data.payload;if(c.includes(o)){switch(t.debug&&console.log("frame.message",o,n.data),o){case l.ExtensionEvents.Ready:t.debug=r.debug,t.state=r,t.fileApi=new s.FileApi(r);break;case l.ExtensionEvents.ChangeState:t.state&&(t.state=r)}e.prototype.emit.call(t,o,r)}}))},t}(a.EventEmitter);t.NextBox=h},139:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventEmitter=void 0;var n=function(){function e(){this._handlers=new Map}return e.prototype.on=function(e,t){var n;this._handlers.has(e)||this._handlers.set(e,new Set),null===(n=this._handlers.get(e))||void 0===n||n.add(t)},e.prototype.off=function(e,t){var n;null===(n=this._handlers.get(e))||void 0===n||n.delete(t)},e.prototype.emit=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];null===(t=this._handlers.get(e))||void 0===t||t.forEach((function(e){e&&e.apply(void 0,n)}))},e}();t.EventEmitter=n},437:function(e,t,n){var o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)},r=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.FileApi=void 0;var i=n(382),a=function(){function e(e){this.state=e}return Object.defineProperty(e.prototype,"dowloadPath",{get:function(){return this.makeDownloadPath(this.currentFilePath)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentFilePath",{get:function(){return(0,i.pathJoin)(this.state.file_info.dir,this.state.file_info.base)},enumerable:!1,configurable:!0}),e.prototype.makeDownloadPath=function(e){return this.makeApiPath("/files")+this.makeSearchParams({path:e})},e.prototype.relativePath=function(e,t){var n;return e?(0,i.pathJoin)((null===(n=this.state.file)||void 0===n?void 0:n.info.base)||"",e):t||""},e.prototype.info=function(e){return(0,i.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"}).then((function(e){return e.json()}))},e.prototype.create=function(e,t,n){return(0,i.sendRequest)(this.makeApiPath("/element"),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:JSON.stringify({name:e,path:this.relativePath(t),type:n})}).then((function(e){return e.json()}))},e.prototype.delete=function(e,t){return(0,i.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e,hard:t}),{method:"DELETE",headers:this.makeHeaders()})},e.prototype.download=function(e){return(0,i.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(e,this.currentFilePath),t:Date.now()}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"})},e.prototype.replace=function(e,t){return(0,i.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(t,this.currentFilePath)}),{cache:"no-cache",method:"PUT",body:e,headers:this.makeHeaders()}).then((function(e){return e.json()}))},e.prototype.upload=function(e,t){var n=new FormData;return n.set("path",this.relativePath(e)),n.set("file",t),(0,i.sendRequest)(this.makeApiPath("/files"),{method:"POST",body:n,headers:this.makeHeaders()}).then((function(e){return e.json()}))},e.prototype.createMeta=function(e,t){return this.create(e||this.metaFileName,t||this.state.file_info.dir,"file")},e.prototype.readMeta=function(e){return this.download(e||this.metaPath)},e.prototype.saveMeta=function(e,t){return this.replace(e,t||this.metaPath)},e.prototype.makeApiPath=function(){for(var e,t,n,o,a,s=[],p=0;p<arguments.length;p++)s[p]=arguments[p];var l="storage";return(null===(e=this.state.file)||void 0===e?void 0:e.rootId)&&(l="disk/".concat(null===(t=this.state.file)||void 0===t?void 0:t.rootId)),(null===(n=this.state)||void 0===n?void 0:n.api_prefinx)?decodeURI(i.pathJoin.apply(void 0,r([null===(o=this.state)||void 0===o?void 0:o.api_prefinx,l],s,!1))):decodeURI(i.pathJoin.apply(void 0,r([null===(a=this.state)||void 0===a?void 0:a.api_path],s,!1)))},Object.defineProperty(e.prototype,"metaPath",{get:function(){return(0,i.pathJoin)(this.state.file_info.dir,this.metaFileName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metaFileName",{get:function(){return"."+(0,i.translite)((0,i.getLang)(this.state.extenstion.name))},enumerable:!1,configurable:!0}),e.prototype.makeSearchParams=function(e){if(this.state.file){e=o(o({},this.state.file.query),e);var t=this.state.file.share,n=t.share_token,r=t.password;n&&(e.share_token=n),r&&(e.SharePass=r)}return"?"+new URLSearchParams(e)},e.prototype.makeHeaders=function(e){var t=o({},e);if(this.state.file){var n=this.state.file.share,r=n.share_token,i=n.password;r&&(t.Authorization="Sharing ".concat(r)),i&&(t.SharePass=i)}return t},e}();t.FileApi=a},382:function(e,t,n){var o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.parentURL=t.dirname=t.fileInfo=t.pathJoin=t.translite=t.devState=t.sendEvent=t.getLang=t.sendRequest=void 0;var r=n(679),i=n(251);function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=[],o=0,r=e.length;o<r;o++)n=n.concat(e[o].split("/"));var i=[];for(o=0,r=n.length;o<r;o++){var a=n[o];a&&"."!==a&&(".."===a?i.pop():i.push(a))}return""===n[0]&&i.unshift(""),i.join("/")||(i.length?"/":".")}function s(){return new URL(window.location!=window.parent.location?document.referrer:document.location.href)}t.sendRequest=function(e,t){var n=s().origin,o=new URL(e,n);return fetch(o,t).then((function(e){return[401,403].includes(e.status)&&parent!==window&&(parent.location.href="/auth"),e}))},t.getLang=function(e,t){if(void 0===t&&(t="ru"),e[t])return e[t];var n=Object.keys(e).pop();return n&&e[n]?e[n]:""},t.sendEvent=function(e,t){if(parent!==window){var n=new URL(window.location!=window.parent.location?document.referrer:document.location.href);parent.postMessage({event:e,payload:t},n.origin)}},t.devState=function(e){return o(o({debug:!0,view:r.ViewState.edit,api_prefinx:"",api_path:""},e),{extenstion:o({id:0,name:{ru:""},type:r.ExtensionType.File},e.extenstion),file_info:o({base:"",dir:"",ext:"",name:"",root:""},e.file_info)})},t.translite=function(e){return(e=(e=(e=(e=(e=e.toLocaleLowerCase()).trim()).replace(/ -/gi,"-")).replace(/- /gi,"-")).replace(/\s{2,}/gi," ")).split("").map((function(e){return/[a-z0-9]/i.test(e)?e:i[e]||""})).join("")},t.pathJoin=a,t.fileInfo=function(e){var t={root:"",dir:"",base:"",ext:"",name:""};if(0===(e=a("/",e)).length)return t;var n,o=e.charCodeAt(0),r=47===o;r?(t.root="/",n=1):n=0;for(var i=-1,s=0,p=-1,l=!0,c=e.length-1,h=0;c>=n;--c)if(47!==(o=e.charCodeAt(c)))-1===p&&(l=!1,p=c+1),46===o?-1===i?i=c:1!==h&&(h=1):-1!==i&&(h=-1);else if(!l){s=c+1;break}return-1===i||-1===p||0===h||1===h&&i===p-1&&i===s+1?-1!==p&&(t.base=t.name=0===s&&r?e.slice(1,p):e.slice(s,p)):(0===s&&r?(t.name=e.slice(1,i),t.base=e.slice(1,p)):(t.name=e.slice(s,i),t.base=e.slice(s,p)),t.ext=e.slice(i,p)),s>0?t.dir=e.slice(0,s-1):r&&(t.dir="/"),t},t.dirname=function(e){if(0===(e=a("/",e)).length)return".";for(var t=e.charCodeAt(0),n=47===t,o=-1,r=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!r){o=i;break}}else r=!1;return-1===o?n?"/":".":n&&1===o?"//":e.slice(0,o)},t.parentURL=s},607:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(679),t),r(n(178),t),r(n(139),t),r(n(382),t),r(n(752),t)},178:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.init=void 0;var o=n(752),r=n(679);t.init=function(e){var t=new o.NextBox;return t.on(r.ExtensionEvents.Ready,e),t.init(),setTimeout((function(){window.parent===self&&e()})),t}},679:(e,t)=>{var n,o,r,i,a,s,p;Object.defineProperty(t,"__esModule",{value:!0}),t.ShareType=t.SharePermissionType=t.StorageElementContentType=t.ExtensionType=t.StorageElementType=t.ViewState=t.ExtensionEvents=t.AppEvents=void 0,(p=t.AppEvents||(t.AppEvents={})).Init="init",p.ChangeContent="change-content",p.Close="close",p.OpenModalFilesSelect="open-modal-files-select",p.ShowConfirm="show-confirm",p.NavigateTo="navigate-to",(s=t.ExtensionEvents||(t.ExtensionEvents={})).Ready="ready",s.ChangeState="change-state",s.SaveAndClose="save-and-close",s.FilesSelected="files-selected",s.ConfirmAccept="confirm-accept",s.ConfirmReject="confirm-reject",(a=t.ViewState||(t.ViewState={})).view="view",a.edit="edit",(i=t.StorageElementType||(t.StorageElementType={})).Dir="dir",i.File="file",i.WorkDir="work_dir",(r=t.ExtensionType||(t.ExtensionType={})).App="app",r.File="file",r.WorkDir="work_dir",(o=t.StorageElementContentType||(t.StorageElementContentType={})).Any="any",o.Dir="dir",o.Code="code",o.Image="image",o.Audio="audio",o.Video="video",o.Text="text",o.Doc="doc",o.Xls="xls",o.Ppt="ppt",(n=t.SharePermissionType||(t.SharePermissionType={})).Read="r",n.ReadAndWrite="rw",(t.ShareType||(t.ShareType={})).FileStorage="file_storage"},251:e=>{e.exports=JSON.parse('{"а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"e","ж":"zh","з":"z","и":"i","й":"i","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"cz","ш":"sh","щ":"scz","ы":"y","ь":"","э":"e","ю":"u","я":"ja"," ":"-"}')}},t={};return function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}(607)})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PolymaticaApi=t():e.PolymaticaApi=t()}(globalThis,(()=>(()=>{"use strict";var e={752:function(e,t,n){var o,r=this&&this.__extends||(o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.NextBox=void 0;var a=n(139),s=n(437),p=n(382),l=n(679),c=Object.values(l.ExtensionEvents),u=function(e){function t(){var t=e.call(this)||this;return t.debug=!1,t}return r(t,e),t.prototype.on=function(t,n){var o;return(null===(o=this.state)||void 0===o?void 0:o.debug)&&console.log("on",t,n),e.prototype.on.call(this,t,n)},t.prototype.off=function(t,n){var o;return(null===(o=this.state)||void 0===o?void 0:o.debug)&&console.log("off",t,n),e.prototype.off.call(this,t,n)},t.prototype.emit=function(t){for(var n,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return(null===(n=this.state)||void 0===n?void 0:n.debug)&&console.log("emit",t,o),e.prototype.emit.apply(this,i([t],o,!1))},t.prototype.init=function(){this.subscribeEvent(),(0,p.sendEvent)(l.AppEvents.Init)},t.prototype.changeContent=function(e){(0,p.sendEvent)(l.AppEvents.ChangeContent,e)},t.prototype.navigate=function(e,t){(0,p.sendEvent)(l.AppEvents.NavigateTo,{path:e,queryParams:t})},t.prototype.close=function(){(0,p.sendEvent)(l.AppEvents.Close)},t.prototype.openModalFilesSelect=function(e){(0,p.sendEvent)(l.AppEvents.OpenModalFilesSelect,e)},t.prototype.subscribeEvent=function(){var t=this;window.addEventListener("message",(function(n){var o=n.data.event,r=n.data.payload;if(c.includes(o)){switch(t.debug&&console.log("frame.message",o,n.data),o){case l.ExtensionEvents.Ready:t.debug=r.debug,t.state=r,t.fileApi=new s.FileApi(r);break;case l.ExtensionEvents.ChangeState:t.state&&(t.state=r)}e.prototype.emit.call(t,o,r)}}))},t}(a.EventEmitter);t.NextBox=u},139:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventEmitter=void 0;var n=function(){function e(){this._handlers=new Map}return e.prototype.on=function(e,t){var n;this._handlers.has(e)||this._handlers.set(e,new Set),null===(n=this._handlers.get(e))||void 0===n||n.add(t)},e.prototype.off=function(e,t){var n;null===(n=this._handlers.get(e))||void 0===n||n.delete(t)},e.prototype.emit=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];null===(t=this._handlers.get(e))||void 0===t||t.forEach((function(e){e&&e.apply(void 0,n)}))},e}();t.EventEmitter=n},437:function(e,t,n){var o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)},r=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.FileApi=void 0;var i=n(382),a=function(){function e(e){this.state=e}return Object.defineProperty(e.prototype,"dowloadPath",{get:function(){return this.makeDownloadPath(this.currentFilePath)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentFilePath",{get:function(){return(0,i.pathJoin)(this.state.file_info.dir,this.state.file_info.base)},enumerable:!1,configurable:!0}),e.prototype.makeDownloadPath=function(e){return this.makeApiPath("/files")+this.makeSearchParams({path:e})},e.prototype.relativePath=function(e,t){var n;return e?(0,i.pathJoin)((null===(n=this.state.file)||void 0===n?void 0:n.info.base)||"",e):t||""},e.prototype.info=function(e){return(0,i.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"}).then((function(e){return e.json()}))},e.prototype.create=function(e,t,n){return(0,i.sendRequest)(this.makeApiPath("/element"),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:JSON.stringify({name:e,path:this.relativePath(t),type:n})}).then((function(e){return e.json()}))},e.prototype.delete=function(e,t){return(0,i.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e,hard:t}),{method:"DELETE",headers:this.makeHeaders()})},e.prototype.download=function(e){return(0,i.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(e,this.currentFilePath),t:Date.now()}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"})},e.prototype.replace=function(e,t){return(0,i.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(t,this.currentFilePath)}),{cache:"no-cache",method:"PUT",body:e,headers:this.makeHeaders()}).then((function(e){return e.json()}))},e.prototype.upload=function(e,t){var n=new FormData;return n.set("path",this.relativePath(e)),n.set("file",t),(0,i.sendRequest)(this.makeApiPath("/files"),{method:"POST",body:n,headers:this.makeHeaders()}).then((function(e){return e.json()}))},e.prototype.createMeta=function(e,t){return this.create(e||this.metaFileName,t||this.state.file_info.dir,"file")},e.prototype.readMeta=function(e){return this.download(e||this.metaPath)},e.prototype.saveMeta=function(e,t){return this.replace(e,t||this.metaPath)},e.prototype.makeApiPath=function(){for(var e,t,n,o,a,s=[],p=0;p<arguments.length;p++)s[p]=arguments[p];var l="storage";return(null===(e=this.state.file)||void 0===e?void 0:e.rootId)&&(l="disk/".concat(null===(t=this.state.file)||void 0===t?void 0:t.rootId)),(null===(n=this.state)||void 0===n?void 0:n.api_prefinx)?decodeURI(i.pathJoin.apply(void 0,r([null===(o=this.state)||void 0===o?void 0:o.api_prefinx,l],s,!1))):decodeURI(i.pathJoin.apply(void 0,r([null===(a=this.state)||void 0===a?void 0:a.api_path],s,!1)))},Object.defineProperty(e.prototype,"metaPath",{get:function(){return(0,i.pathJoin)(this.state.file_info.dir,this.metaFileName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metaFileName",{get:function(){return"."+(0,i.translite)((0,i.getLang)(this.state.extenstion.name))},enumerable:!1,configurable:!0}),e.prototype.makeSearchParams=function(e){if(this.state.file){e=o(o({},this.state.file.query),e);var t=this.state.file.share,n=t.share_token,r=t.password;n&&(e.share_token=n),r&&(e.SharePass=r)}return"?"+new URLSearchParams(e)},e.prototype.makeHeaders=function(e){var t=o({},e);if(this.state.file){var n=this.state.file.share,r=n.share_token,i=n.password;r&&(t.Authorization="Sharing ".concat(r)),i&&(t.SharePass=i)}return t},e}();t.FileApi=a},382:function(e,t,n){var o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.parentURL=t.dirname=t.fileInfo=t.pathJoin=t.translite=t.devState=t.sendEvent=t.getLang=t.sendRequest=void 0;var r=n(679),i=n(251);function a(e,t){if(parent!==window){var n=new URL(window.location!=window.parent.location?document.referrer:document.location.href);parent.postMessage({event:e,payload:t},n.origin)}}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=[],o=0,r=e.length;o<r;o++)n=n.concat(e[o].split("/"));var i=[];for(o=0,r=n.length;o<r;o++){var a=n[o];a&&"."!==a&&(".."===a?i.pop():i.push(a))}return""===n[0]&&i.unshift(""),i.join("/")||(i.length?"/":".")}function p(){return new URL(window.location!=window.parent.location?document.referrer:document.location.href)}t.sendRequest=function(e,t){var n=p().origin,o=new URL(e,n);return fetch(o,t).then((function(e){return parent!==window&&([401].includes(e.status)&&(parent.location.href="/auth"),(400===e.status||e.status>401)&&a(r.AppEvents.RequestError,e)),e}))},t.getLang=function(e,t){if(void 0===t&&(t="ru"),e[t])return e[t];var n=Object.keys(e).pop();return n&&e[n]?e[n]:""},t.sendEvent=a,t.devState=function(e){return o(o({debug:!0,view:r.ViewState.edit,api_prefinx:"",api_path:""},e),{extenstion:o({id:0,name:{ru:""},type:r.ExtensionType.File},e.extenstion),host:"",file_info:o({base:"",dir:"",ext:"",name:"",root:""},e.file_info)})},t.translite=function(e){return(e=(e=(e=(e=(e=e.toLocaleLowerCase()).trim()).replace(/ -/gi,"-")).replace(/- /gi,"-")).replace(/\s{2,}/gi," ")).split("").map((function(e){return/[a-z0-9]/i.test(e)?e:i[e]||""})).join("")},t.pathJoin=s,t.fileInfo=function(e){var t={root:"",dir:"",base:"",ext:"",name:""};if(0===(e=s("/",e)).length)return t;var n,o=e.charCodeAt(0),r=47===o;r?(t.root="/",n=1):n=0;for(var i=-1,a=0,p=-1,l=!0,c=e.length-1,u=0;c>=n;--c)if(47!==(o=e.charCodeAt(c)))-1===p&&(l=!1,p=c+1),46===o?-1===i?i=c:1!==u&&(u=1):-1!==i&&(u=-1);else if(!l){a=c+1;break}return-1===i||-1===p||0===u||1===u&&i===p-1&&i===a+1?-1!==p&&(t.base=t.name=0===a&&r?e.slice(1,p):e.slice(a,p)):(0===a&&r?(t.name=e.slice(1,i),t.base=e.slice(1,p)):(t.name=e.slice(a,i),t.base=e.slice(a,p)),t.ext=e.slice(i,p)),a>0?t.dir=e.slice(0,a-1):r&&(t.dir="/"),t},t.dirname=function(e){if(0===(e=s("/",e)).length)return".";for(var t=e.charCodeAt(0),n=47===t,o=-1,r=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!r){o=i;break}}else r=!1;return-1===o?n?"/":".":n&&1===o?"//":e.slice(0,o)},t.parentURL=p},607:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(679),t),r(n(178),t),r(n(139),t),r(n(382),t),r(n(752),t)},178:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.init=void 0;var o=n(752),r=n(679);t.init=function(e){var t=new o.NextBox;return t.on(r.ExtensionEvents.Ready,e),t.init(),setTimeout((function(){window.parent===self&&e()})),t}},679:(e,t)=>{var n,o,r,i,a,s,p;Object.defineProperty(t,"__esModule",{value:!0}),t.ShareType=t.SharePermissionType=t.StorageElementContentType=t.ExtensionType=t.StorageElementType=t.ViewState=t.ExtensionEvents=t.AppEvents=void 0,(p=t.AppEvents||(t.AppEvents={})).Init="init",p.ChangeContent="change-content",p.Close="close",p.OpenModalFilesSelect="open-modal-files-select",p.ShowConfirm="show-confirm",p.NavigateTo="navigate-to",p.RequestError="request-error",(s=t.ExtensionEvents||(t.ExtensionEvents={})).Ready="ready",s.ChangeState="change-state",s.SaveAndClose="save-and-close",s.FilesSelected="files-selected",s.ConfirmAccept="confirm-accept",s.ConfirmReject="confirm-reject",(a=t.ViewState||(t.ViewState={})).view="view",a.edit="edit",(i=t.StorageElementType||(t.StorageElementType={})).Dir="dir",i.File="file",i.WorkDir="work_dir",(r=t.ExtensionType||(t.ExtensionType={})).App="app",r.File="file",r.WorkDir="work_dir",(o=t.StorageElementContentType||(t.StorageElementContentType={})).Any="any",o.Dir="dir",o.Code="code",o.Image="image",o.Audio="audio",o.Video="video",o.Text="text",o.Doc="doc",o.Xls="xls",o.Ppt="ppt",(n=t.SharePermissionType||(t.SharePermissionType={})).Read="r",n.ReadAndWrite="rw",(t.ShareType||(t.ShareType={})).FileStorage="file_storage"},251:e=>{e.exports=JSON.parse('{"а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"e","ж":"zh","з":"z","и":"i","й":"i","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"cz","ш":"sh","щ":"scz","ы":"y","ь":"","э":"e","ю":"u","я":"ja"," ":"-"}')}},t={};return function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}(607)})()));
|
package/interfaces.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare enum AppEvents {
|
|
|
10
10
|
Close = "close",
|
|
11
11
|
OpenModalFilesSelect = "open-modal-files-select",
|
|
12
12
|
ShowConfirm = "show-confirm",
|
|
13
|
-
NavigateTo = "navigate-to"
|
|
13
|
+
NavigateTo = "navigate-to",
|
|
14
|
+
RequestError = "request-error"
|
|
14
15
|
}
|
|
15
16
|
export declare enum ExtensionEvents {
|
|
16
17
|
Ready = "ready",
|
|
@@ -102,6 +103,7 @@ export interface AppState {
|
|
|
102
103
|
* @deprecated since version 1.4.0
|
|
103
104
|
*/
|
|
104
105
|
file_info: FileInfo;
|
|
106
|
+
host: string;
|
|
105
107
|
file?: {
|
|
106
108
|
info: FileInfo;
|
|
107
109
|
share: ShareSetting;
|