next-box 2.0.17 → 2.0.20
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/README.md +4 -1
- package/app/classes/api.d.ts +2 -1
- package/app/helpers/default-state.d.ts +1 -1
- package/app/index.d.ts +1 -16
- package/app/transport/transport.d.ts +15 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,11 +15,14 @@ https://cdn.jsdelivr.net/npm/next-box@latest/index.min.js
|
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```javascript
|
|
18
|
-
import { NextBox, StorageApi } from 'next-box';
|
|
18
|
+
import { NextBox, StorageApi, Transport } from 'next-box';
|
|
19
19
|
|
|
20
20
|
const nb = new NextBox();
|
|
21
|
+
|
|
21
22
|
nb.init((state) => {
|
|
22
23
|
const api = new StorageApi(state);
|
|
23
24
|
...
|
|
25
|
+
|
|
26
|
+
Transport.navigate();
|
|
24
27
|
});
|
|
25
28
|
```
|
package/app/classes/api.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AppState } from '../types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const defaultState: () => AppState;
|
package/app/index.d.ts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
import { EventEmitter
|
|
1
|
+
import { EventEmitter } from './classes/event-emitter';
|
|
2
2
|
import { AppState } from './types/state';
|
|
3
|
-
import { TransportEvent, TransportPayloadModalFilesSelect, TransportPayloadNavigate } from './types/transport';
|
|
4
3
|
export declare class NextBox extends EventEmitter {
|
|
5
4
|
state?: AppState;
|
|
6
5
|
init(handler?: (state: AppState) => void): void;
|
|
7
|
-
/**
|
|
8
|
-
* Submit a content change message
|
|
9
|
-
* In the case when content is written before exiting the application or when writing large files
|
|
10
|
-
*/
|
|
11
|
-
changeContent(state: boolean): void;
|
|
12
|
-
navigate(path: TransportPayloadNavigate['path'], queryParams?: TransportPayloadNavigate['queryParams']): void;
|
|
13
|
-
/**
|
|
14
|
-
* Send an event to close the editor
|
|
15
|
-
*/
|
|
16
|
-
close(): void;
|
|
17
|
-
openModalFilesSelect(state: TransportPayloadModalFilesSelect): void;
|
|
18
|
-
on(event: TransportEvent, handler: EventHandler): void;
|
|
19
|
-
off(event: TransportEvent, handler: EventHandler): void;
|
|
20
|
-
emit(event: string, ...args: any): void;
|
|
21
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransportEvent, TransportPayload } from '../types/transport';
|
|
1
|
+
import { TransportEvent, TransportPayload, TransportPayloadModalFilesSelect, TransportPayloadNavigate } from '../types/transport';
|
|
2
2
|
import { EventEmitter } from '../classes/event-emitter';
|
|
3
3
|
export declare enum EngineType {
|
|
4
4
|
WebSocket = "websocket",
|
|
@@ -12,5 +12,19 @@ export declare class NBTransport extends EventEmitter {
|
|
|
12
12
|
constructor(engine?: EngineType);
|
|
13
13
|
send(event: TransportEvent, payload?: TransportPayload): void;
|
|
14
14
|
subscribe(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Submit a content change message
|
|
17
|
+
* In the case when content is written before exiting the application or when writing large files
|
|
18
|
+
*/
|
|
19
|
+
changeContent(state: boolean): void;
|
|
20
|
+
/**
|
|
21
|
+
* Navigate parent window (only app extension)
|
|
22
|
+
*/
|
|
23
|
+
navigate(path: TransportPayloadNavigate['path'], queryParams?: TransportPayloadNavigate['queryParams']): void;
|
|
24
|
+
/**
|
|
25
|
+
* Send an event to close the editor
|
|
26
|
+
*/
|
|
27
|
+
close(): void;
|
|
28
|
+
openModalFilesSelect(state: TransportPayloadModalFilesSelect): void;
|
|
15
29
|
}
|
|
16
30
|
export declare const Transport: NBTransport;
|
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={181: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(481),t),r(n(861),t)},481: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)});Object.defineProperty(t,"__esModule",{value:!0}),t.StaticApi=void 0;var i=n(892),a=n(307),s=n(392),p="static/files",c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.upload=function(e,t,n){void 0===n&&(n="");var o=new FormData;return o.set("file",e),(0,s.sendRequest)((0,a.pathJoin)(this.state.api.prefix,p,n,t),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:o}).then((function(e){return e.json()}))},t.prototype.get=function(e){return(0,s.sendRequest)((0,a.pathJoin)(this.state.api.prefix,p,e),{method:"GET"})},t.prototype.delete=function(e){return(0,s.sendRequest)((0,a.pathJoin)(this.state.api.prefix,p,e),{method:"DELETE"}).catch((function(e){return e}))},t}(i.Api);t.StaticApi=c},861: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.StorageApi=void 0;var a=n(307),s=n(892),p=n(566),c=n(392),u=n(299),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.info=function(e){return(0,c.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"}).then(this.responseJSON)},t.prototype.create=function(e,t,n){return(0,c.sendRequest)(this.makeApiPath("/element"),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:JSON.stringify({name:e,path:this.relativePath(t),type:n,divide_id:this.state.api.query.divide_id||null})}).then(this.responseJSON)},t.prototype.delete=function(e,t){return(0,c.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e,hard:t}),{method:"DELETE",headers:this.makeHeaders()})},t.prototype.download=function(e){return(0,c.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(e,this.state.storage.path),t:Date.now()}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"})},t.prototype.replace=function(e,t){return(0,c.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(t,this.state.storage.path)}),{cache:"no-cache",method:"PUT",body:e,headers:this.makeHeaders()}).then(this.responseJSON)},t.prototype.upload=function(e,t){var n=new FormData;return n.set("path",this.relativePath(e)),n.set("file",t),(0,c.sendRequest)(this.makeApiPath("/files"),{method:"POST",body:n,headers:this.makeHeaders()}).then(this.responseJSON)},t.prototype.uploadNet=function(e,t,n){return void 0===n&&(n=!1),(0,c.sendRequest)(this.makeApiPath("/files/net"),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:JSON.stringify({url:t,overwrite:n,path:this.relativePath(e)})}).then(this.responseJSON)},t.prototype.createMeta=function(e,t){return this.create(e||this.metaName,t||"","file")},t.prototype.readMeta=function(e){return this.download(e||this.metaName)},t.prototype.saveMeta=function(e,t){return this.replace(e,t||this.metaName)},t.prototype.relativePath=function(e,t){return!e&&t?t||"":(0,a.pathJoin)(this.state.storage.info.dir||"",e||"")},t.prototype.makeApiPath=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n="storage";return"fca"===this.state.storage.root&&(n="disk/".concat(this.state.storage.rootID)),new URL(decodeURI(a.pathJoin.apply(void 0,i([this.state.api.prefix,n],e,!1))),this.state.api.host)},Object.defineProperty(t.prototype,"metaName",{get:function(){return"."+(0,u.translite)((0,p.getLang)(this.state.extenstion.name))},enumerable:!1,configurable:!0}),t}(s.Api);t.StorageApi=l},892:function(e,t){var n=this&&this.__assign||function(){return n=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},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.Api=void 0;var o=function(){function e(e){this.state=e}return e.prototype.makeSearchParams=function(e){return e=n(n({},this.state.api.query),e),"?"+new URLSearchParams(e)},e.prototype.makeHeaders=function(e){return n(n({},e),this.state.api.headers)},e.prototype.responseJSON=function(e){return e.status>=200&&e.status<400?e.json():Promise.resolve({error:"Parse error"})},e}();t.Api=o},970:function(e,t){var n=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.EventEmitter=void 0;var o=function(){function e(){this._handlers=new Map,this._globalHandlers=new Set}return e.prototype.listen=function(e){this._globalHandlers.add(e)},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,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];null===(t=this._handlers.get(e))||void 0===t||t.forEach((function(e){e&&e.apply(void 0,o)})),this._globalHandlers.forEach((function(t){t.apply(void 0,n([e],o,!1))}))},e}();t.EventEmitter=o},534: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(892),t),r(n(970),t)},755:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultState=void 0;var o=n(796);t.DefaultState=function(){return{extenstion:{id:0,name:{},type:o.ExtensionType.File},api:{host:"",prefix:"",headers:{},query:{}},debug:!0,view:o.ViewState.view,brouserURL:"",storage:{root:"me",rootID:0,path:"",info:{base:"",dir:"",ext:"",name:"",root:""}}}}},223:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dirname=void 0;var o=n(307);t.dirname=function(e){if(0===(e=(0,o.pathJoin)("/",e)).length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,i=!0,a=e.length-1;a>=1;--a)if(47===(t=e.charCodeAt(a))){if(!i){r=a;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"//":e.slice(0,r)}},572:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileInfo=void 0;var o=n(307);t.fileInfo=function(e){var t={root:"",dir:"",base:"",ext:"",name:""};if(0===(e=(0,o.pathJoin)("/",e)).length)return t;var n,r=e.charCodeAt(0),i=47===r;i?(t.root="/",n=1):n=0;for(var a=-1,s=0,p=-1,c=!0,u=e.length-1,l=0;u>=n;--u)if(47!==(r=e.charCodeAt(u)))-1===p&&(c=!1,p=u+1),46===r?-1===a?a=u:1!==l&&(l=1):-1!==a&&(l=-1);else if(!c){s=u+1;break}return-1===a||-1===p||0===l||1===l&&a===p-1&&a===s+1?-1!==p&&(t.base=t.name=0===s&&i?e.slice(1,p):e.slice(s,p)):(0===s&&i?(t.name=e.slice(1,a),t.base=e.slice(1,p)):(t.name=e.slice(s,a),t.base=e.slice(s,p)),t.ext=e.slice(a,p)),s>0?t.dir=e.slice(0,s-1):i&&(t.dir="/"),t}},424:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getGlobal=void 0;var o=n(837);t.getGlobal=function(){return(0,o.isBrowser)()?window:n.g}},566:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getLang=void 0,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]:""}},462: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(223),t),r(n(572),t),r(n(566),t),r(n(719),t),r(n(307),t),r(n(392),t),r(n(299),t),r(n(424),t),r(n(837),t)},837:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=void 0,t.isBrowser=function(){return"undefined"!=typeof window}},719:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parentURL=void 0,t.parentURL=function(){return new URL(window.location!=window.parent.location?document.referrer:document.location.href)}},307:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pathJoin=void 0,t.pathJoin=function(){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?"/":".")}},392:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=void 0;var o=n(831),r=n(512);t.sendRequest=function(e,t){return fetch(e,t).then((function(e){return parent!==window&&([401].includes(e.status)&&(parent.location.href="/auth"),(400===e.status||e.status>401)&&o.Transport.send(r.TransportEvent.ExtRequestError,e)),e}))}},299:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.translite=void 0;var n={а:"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.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:n[e]||""})).join("")}},495: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(970),s=n(755),p=n(831),c=n(512),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.init=function(e){var t=this,n=function(e){return t.state=e};if(!p.Transport.engineType){var o=(0,s.DefaultState)();n(o),e&&e(o)}p.Transport.on(c.TransportEvent.AppReady,(function(t){n(t),e&&e(t)})),p.Transport.on(c.TransportEvent.AppReload,(function(){window.location.reload()})),p.Transport.on(c.TransportEvent.AppChangeState,n),p.Transport.send(c.TransportEvent.ExtInit)},t.prototype.changeContent=function(e){p.Transport.send(c.TransportEvent.ExtChangeContent,e)},t.prototype.navigate=function(e,t){p.Transport.send(c.TransportEvent.ExtNavigateTo,{path:e,queryParams:t})},t.prototype.close=function(){p.Transport.send(c.TransportEvent.ExtClose)},t.prototype.openModalFilesSelect=function(e){p.Transport.send(c.TransportEvent.ExtOpenModalFilesSelect,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}(a.EventEmitter);t.NextBox=u},185:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TransportEmpty=void 0;var n=function(){function e(){}return e.prototype.send=function(e,t){},e.prototype.subscribe=function(e){},e}();t.TransportEmpty=n},176: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(595),t),r(n(831),t)},595:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},521:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TransportPostMessage=void 0;var n=function(){function e(){}return e.prototype.send=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)}},e.prototype.subscribe=function(e){window.addEventListener("message",(function(t){var n=t.data.event,o=t.data.payload;e(n,o)}))},e}();t.TransportPostMessage=n},831: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)});Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.NBTransport=t.EngineType=void 0;var i,a=n(970),s=n(521),p=n(424),c=n(742),u=n(185);!function(e){e.WebSocket="websocket",e.PostMessage="postmessage",e.Empty=""}(i=t.EngineType||(t.EngineType={}));var l=function(e){function t(t){var n,o=this;(o=e.call(this)||this).engineType=i.Empty,o.debug=!1;var r=new URLSearchParams((null===(n=(0,p.getGlobal)().location)||void 0===n?void 0:n.search)||"");return o.engineType=t||r.get("engine")||i.Empty,o.engine=new u.TransportEmpty,o.engineType===i.PostMessage&&(o.engine=new s.TransportPostMessage),o.engineType===i.WebSocket&&(o.engine=new c.TransportWebsocket),o}return r(t,e),t.prototype.send=function(e,t){this.engine.send(e,t)},t.prototype.subscribe=function(){var e=this;this.engine.subscribe((function(t,n){t&&(e.debug&&console.log("frame.message",t,n),e.emit(t,n))}))},t}(a.EventEmitter);t.NBTransport=l;var d=(0,p.getGlobal)();d._nb_transport instanceof l||(d._nb_transport=new l,d._nb_transport.subscribe()),t.Transport=d._nb_transport},742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TransportWebsocket=void 0;var n=Symbol("transport-socket"),o=function(){function e(){window[n]||this.init()}return e.prototype.init=function(){var e=new URLSearchParams(window.location.search),t=e.get("host")||"localhost",o=e.get("port")||8999;window[n]=new WebSocket("ws://".concat(t,":").concat(o)),window[n].onopen=function(){},window[n].onclose=function(e){e.wasClean?console.log("Соединение закрыто"):console.log("Обрыв соединения"),console.log("Код: "+e.code+" причина: "+e.reason)},window[n].onerror=function(e){console.log("Ошибка подключения ws: "+e.message)}},e.prototype.send=function(e,t){var o=this;window[n].readyState?window[n].send(JSON.stringify({event:e,payload:t})):setTimeout((function(){o.send(e,t)}),100)},e.prototype.subscribe=function(e){window[n].onmessage=function(t){try{var n=JSON.parse(t.data),o=n.event,r=n.payload;e(o,r)}catch(e){}}},e}();t.TransportWebsocket=o},85:(e,t)=>{var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensionFileMode=t.ExtensionType=void 0,(o=t.ExtensionType||(t.ExtensionType={})).App="app",o.File="file",o.WorkDir="work_dir",(n=t.ExtensionFileMode||(t.ExtensionFileMode={})).Read="read",n.Write="write",n.ReadAndWrite="read_and_write"},745:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},796: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(85),t),r(n(492),t),r(n(517),t),r(n(512),t),r(n(745),t)},492:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ViewState=void 0,(n=t.ViewState||(t.ViewState={})).view="view",n.edit="edit"},517:(e,t)=>{var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.StorageElementContentType=t.StorageElementType=void 0,(o=t.StorageElementType||(t.StorageElementType={})).Dir="dir",o.File="file",o.WorkDir="work_dir",(n=t.StorageElementContentType||(t.StorageElementContentType={})).Any="any",n.Dir="dir",n.Code="code",n.Image="image",n.Audio="audio",n.Video="video",n.Text="text",n.Doc="doc",n.Xls="xls",n.Ppt="ppt"},512:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.TransportEvent=void 0,(n=t.TransportEvent||(t.TransportEvent={})).ExtInit="ext-init",n.ExtChangeContent="ext-change-content",n.ExtOpenModalFilesSelect="ext-open-modal-files-select",n.ExtShowConfirm="ext-show-confirm",n.ExtNavigateTo="ext-navigate-to",n.ExtRequestError="ext-request-error",n.ExtClose="ext-close",n.AppReload="ext-reload",n.AppReady="app-ready",n.AppChangeState="app-change-state",n.AppSaveAndClose="app-save-and-close",n.AppFilesSelected="app-files-selected",n.AppConfirmAccept="app-confirm-accept",n.AppConfirmReject="app-confirm-reject"},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(495),t),r(n(796),t),r(n(176),t),r(n(462),t),r(n(534),t),r(n(181),t)}},t={};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}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(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={181: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(481),t),r(n(861),t)},481: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)});Object.defineProperty(t,"__esModule",{value:!0}),t.StaticApi=void 0;var i=n(892),a=n(307),s=n(392),p="static/files",c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.upload=function(e,t,n){void 0===n&&(n="");var o=new FormData;return o.set("file",e),(0,s.sendRequest)((0,a.pathJoin)(this.state.api.prefix,p,n,t),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:o}).then((function(e){return e.json()}))},t.prototype.get=function(e){return(0,s.sendRequest)((0,a.pathJoin)(this.state.api.prefix,p,e),{method:"GET"})},t.prototype.delete=function(e){return(0,s.sendRequest)((0,a.pathJoin)(this.state.api.prefix,p,e),{method:"DELETE"}).catch((function(e){return e}))},t}(i.Api);t.StaticApi=c},861: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.StorageApi=void 0;var a=n(307),s=n(892),p=n(566),c=n(392),u=n(299),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.info=function(e){return(0,c.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"}).then(this.responseJSON)},t.prototype.create=function(e,t,n){return(0,c.sendRequest)(this.makeApiPath("/element"),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:JSON.stringify({name:e,path:this.relativePath(t),type:n,divide_id:this.state.api.query.divide_id||null})}).then(this.responseJSON)},t.prototype.delete=function(e,t){return(0,c.sendRequest)(this.makeApiPath("/element")+this.makeSearchParams({path:e,hard:t}),{method:"DELETE",headers:this.makeHeaders()})},t.prototype.download=function(e){return(0,c.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(e,this.state.storage.path),t:Date.now()}),{headers:this.makeHeaders(),method:"GET",cache:"no-cache"})},t.prototype.replace=function(e,t){return(0,c.sendRequest)(this.makeApiPath("/files")+this.makeSearchParams({path:this.relativePath(t,this.state.storage.path)}),{cache:"no-cache",method:"PUT",body:e,headers:this.makeHeaders()}).then(this.responseJSON)},t.prototype.upload=function(e,t){var n=new FormData;return n.set("path",this.relativePath(e)),n.set("file",t),(0,c.sendRequest)(this.makeApiPath("/files"),{method:"POST",body:n,headers:this.makeHeaders()}).then(this.responseJSON)},t.prototype.uploadNet=function(e,t,n){return void 0===n&&(n=!1),(0,c.sendRequest)(this.makeApiPath("/files/net"),{method:"POST",headers:this.makeHeaders({"Content-Type":"application/json"}),body:JSON.stringify({url:t,overwrite:n,path:this.relativePath(e)})}).then(this.responseJSON)},t.prototype.createMeta=function(e,t){return this.create(e||this.metaName,t||"","file")},t.prototype.readMeta=function(e){return this.download(e||this.metaName)},t.prototype.saveMeta=function(e,t){return this.replace(e,t||this.metaName)},t.prototype.relativePath=function(e,t){return!e&&t?t||"":(0,a.pathJoin)(this.state.storage.info.dir||"",e||"")},t.prototype.makeApiPath=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n="storage";return"fca"===this.state.storage.root&&(n="disk/".concat(this.state.storage.rootID)),new URL(decodeURI(a.pathJoin.apply(void 0,i([this.state.api.prefix,n],e,!1))),this.state.api.host)},Object.defineProperty(t.prototype,"metaName",{get:function(){return"."+(0,u.translite)((0,p.getLang)(this.state.extenstion.name))},enumerable:!1,configurable:!0}),t}(s.Api);t.StorageApi=l},892: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.Api=void 0;var r=n(755),i=function(){function e(e){void 0===e&&(e=(0,r.defaultState)()),this.changeState(e)}return e.prototype.changeState=function(e){this.state=e},e.prototype.makeSearchParams=function(e){return e=o(o({},this.state.api.query),e),"?"+new URLSearchParams(e)},e.prototype.makeHeaders=function(e){return o(o({},e),this.state.api.headers)},e.prototype.responseJSON=function(e){return e.status>=200&&e.status<400?e.json():Promise.resolve({error:"Parse error"})},e}();t.Api=i},970:function(e,t){var n=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.EventEmitter=void 0;var o=function(){function e(){this._handlers=new Map,this._globalHandlers=new Set}return e.prototype.listen=function(e){this._globalHandlers.add(e)},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,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];null===(t=this._handlers.get(e))||void 0===t||t.forEach((function(e){e&&e.apply(void 0,o)})),this._globalHandlers.forEach((function(t){t.apply(void 0,n([e],o,!1))}))},e}();t.EventEmitter=o},534: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(892),t),r(n(970),t)},755:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultState=void 0;var o=n(796);t.defaultState=function(){return{extenstion:{id:0,name:{},type:o.ExtensionType.File},api:{host:window.location.origin,prefix:"/api/v1",headers:{},query:{}},debug:!0,view:o.ViewState.view,brouserURL:"",storage:{root:"me",rootID:0,path:"",info:{base:"",dir:"",ext:"",name:"",root:""}}}}},223:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dirname=void 0;var o=n(307);t.dirname=function(e){if(0===(e=(0,o.pathJoin)("/",e)).length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,i=!0,a=e.length-1;a>=1;--a)if(47===(t=e.charCodeAt(a))){if(!i){r=a;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"//":e.slice(0,r)}},572:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileInfo=void 0;var o=n(307);t.fileInfo=function(e){var t={root:"",dir:"",base:"",ext:"",name:""};if(0===(e=(0,o.pathJoin)("/",e)).length)return t;var n,r=e.charCodeAt(0),i=47===r;i?(t.root="/",n=1):n=0;for(var a=-1,s=0,p=-1,c=!0,u=e.length-1,l=0;u>=n;--u)if(47!==(r=e.charCodeAt(u)))-1===p&&(c=!1,p=u+1),46===r?-1===a?a=u:1!==l&&(l=1):-1!==a&&(l=-1);else if(!c){s=u+1;break}return-1===a||-1===p||0===l||1===l&&a===p-1&&a===s+1?-1!==p&&(t.base=t.name=0===s&&i?e.slice(1,p):e.slice(s,p)):(0===s&&i?(t.name=e.slice(1,a),t.base=e.slice(1,p)):(t.name=e.slice(s,a),t.base=e.slice(s,p)),t.ext=e.slice(a,p)),s>0?t.dir=e.slice(0,s-1):i&&(t.dir="/"),t}},424:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getGlobal=void 0;var o=n(837);t.getGlobal=function(){return(0,o.isBrowser)()?window:n.g}},566:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getLang=void 0,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]:""}},462: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(223),t),r(n(572),t),r(n(566),t),r(n(719),t),r(n(307),t),r(n(392),t),r(n(299),t),r(n(424),t),r(n(837),t)},837:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=void 0,t.isBrowser=function(){return"undefined"!=typeof window}},719:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parentURL=void 0,t.parentURL=function(){return new URL(window.location!=window.parent.location?document.referrer:document.location.href)}},307:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pathJoin=void 0,t.pathJoin=function(){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?"/":".")}},392:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=void 0;var o=n(831),r=n(512);t.sendRequest=function(e,t){return fetch(e,t).then((function(e){return parent!==window&&([401].includes(e.status)&&(parent.location.href="/auth"),(400===e.status||e.status>401)&&o.Transport.send(r.TransportEvent.ExtRequestError,e)),e}))}},299:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.translite=void 0;var n={а:"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.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:n[e]||""})).join("")}},495: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)});Object.defineProperty(t,"__esModule",{value:!0}),t.NextBox=void 0;var i=n(970),a=n(755),s=n(831),p=n(512),c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.init=function(e){var t=this,n=function(e){return t.state=e};if(!s.Transport.engineType){var o=(0,a.defaultState)();n(o),e&&e(o)}s.Transport.on(p.TransportEvent.AppReady,(function(t){n(t),e&&e(t)})),s.Transport.on(p.TransportEvent.AppReload,(function(){window.location.reload()})),s.Transport.on(p.TransportEvent.AppChangeState,n),s.Transport.send(p.TransportEvent.ExtInit)},t}(i.EventEmitter);t.NextBox=c},185:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TransportEmpty=void 0;var n=function(){function e(){}return e.prototype.send=function(e,t){},e.prototype.subscribe=function(e){},e}();t.TransportEmpty=n},176: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(595),t),r(n(831),t)},595:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},521:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TransportPostMessage=void 0;var n=function(){function e(){}return e.prototype.send=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)}},e.prototype.subscribe=function(e){window.addEventListener("message",(function(t){var n=t.data.event,o=t.data.payload;e(n,o)}))},e}();t.TransportPostMessage=n},831: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)});Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.NBTransport=t.EngineType=void 0;var i,a=n(512),s=n(970),p=n(521),c=n(424),u=n(742),l=n(185);!function(e){e.WebSocket="websocket",e.PostMessage="postmessage",e.Empty=""}(i=t.EngineType||(t.EngineType={}));var d=function(e){function n(t){var n,o=this;(o=e.call(this)||this).engineType=i.Empty,o.debug=!1;var r=new URLSearchParams((null===(n=(0,c.getGlobal)().location)||void 0===n?void 0:n.search)||"");return o.engineType=t||r.get("engine")||i.Empty,o.engine=new l.TransportEmpty,o.engineType===i.PostMessage&&(o.engine=new p.TransportPostMessage),o.engineType===i.WebSocket&&(o.engine=new u.TransportWebsocket),o}return r(n,e),n.prototype.send=function(e,t){this.engine.send(e,t)},n.prototype.subscribe=function(){var e=this;this.engine.subscribe((function(t,n){t&&(e.debug&&console.log("frame.message",t,n),e.emit(t,n))}))},n.prototype.changeContent=function(e){t.Transport.send(a.TransportEvent.ExtChangeContent,e)},n.prototype.navigate=function(e,n){t.Transport.send(a.TransportEvent.ExtNavigateTo,{path:e,queryParams:n})},n.prototype.close=function(){t.Transport.send(a.TransportEvent.ExtClose)},n.prototype.openModalFilesSelect=function(e){t.Transport.send(a.TransportEvent.ExtOpenModalFilesSelect,e)},n}(s.EventEmitter);t.NBTransport=d;var f=(0,c.getGlobal)();f._nb_transport instanceof d||(f._nb_transport=new d,f._nb_transport.subscribe()),t.Transport=f._nb_transport},742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TransportWebsocket=void 0;var n=Symbol("transport-socket"),o=function(){function e(){window[n]||this.init()}return e.prototype.init=function(){var e=new URLSearchParams(window.location.search),t=e.get("host")||"localhost",o=e.get("port")||8999;window[n]=new WebSocket("ws://".concat(t,":").concat(o)),window[n].onopen=function(){},window[n].onclose=function(e){e.wasClean?console.log("Соединение закрыто"):console.log("Обрыв соединения"),console.log("Код: "+e.code+" причина: "+e.reason)},window[n].onerror=function(e){console.log("Ошибка подключения ws: "+e.message)}},e.prototype.send=function(e,t){var o=this;window[n].readyState?window[n].send(JSON.stringify({event:e,payload:t})):setTimeout((function(){o.send(e,t)}),100)},e.prototype.subscribe=function(e){window[n].onmessage=function(t){try{var n=JSON.parse(t.data),o=n.event,r=n.payload;e(o,r)}catch(e){}}},e}();t.TransportWebsocket=o},85:(e,t)=>{var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensionFileMode=t.ExtensionType=void 0,(o=t.ExtensionType||(t.ExtensionType={})).App="app",o.File="file",o.WorkDir="work_dir",(n=t.ExtensionFileMode||(t.ExtensionFileMode={})).Read="read",n.Write="write",n.ReadAndWrite="read_and_write"},745:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},796: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(85),t),r(n(492),t),r(n(517),t),r(n(512),t),r(n(745),t)},492:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ViewState=void 0,(n=t.ViewState||(t.ViewState={})).view="view",n.edit="edit"},517:(e,t)=>{var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.StorageElementContentType=t.StorageElementType=void 0,(o=t.StorageElementType||(t.StorageElementType={})).Dir="dir",o.File="file",o.WorkDir="work_dir",(n=t.StorageElementContentType||(t.StorageElementContentType={})).Any="any",n.Dir="dir",n.Code="code",n.Image="image",n.Audio="audio",n.Video="video",n.Text="text",n.Doc="doc",n.Xls="xls",n.Ppt="ppt"},512:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.TransportEvent=void 0,(n=t.TransportEvent||(t.TransportEvent={})).ExtInit="ext-init",n.ExtChangeContent="ext-change-content",n.ExtOpenModalFilesSelect="ext-open-modal-files-select",n.ExtShowConfirm="ext-show-confirm",n.ExtNavigateTo="ext-navigate-to",n.ExtRequestError="ext-request-error",n.ExtClose="ext-close",n.AppReload="ext-reload",n.AppReady="app-ready",n.AppChangeState="app-change-state",n.AppSaveAndClose="app-save-and-close",n.AppFilesSelected="app-files-selected",n.AppConfirmAccept="app-confirm-accept",n.AppConfirmReject="app-confirm-reject"},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(495),t),r(n(796),t),r(n(176),t),r(n(462),t),r(n(534),t),r(n(181),t)}},t={};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}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(607)})()));
|