next-box 1.1.9 → 1.1.10

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/helpers.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { TransportEventPayload, AppEvents, AppState } from './interfaces';
1
+ import { TransportEventPayload, AppEvents, AppState, Lang } from './interfaces';
2
+ export declare function getLang(lang: Lang, locale?: string): string;
2
3
  export declare function sendEvent(event: AppEvents, payload?: TransportEventPayload): void;
3
4
  export declare function devState(state: Partial<AppState>): AppState;
4
5
  export declare function translite(value: string): string;
package/index.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PolymaticaApi=e():t.PolymaticaApi=e()}(globalThis,(()=>(()=>{"use strict";var t={752:function(t,e,n){var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var i,o=0,r=e.length;o<r;o++)!i&&o in e||(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return t.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.NextBox=void 0;var a=n(139),s=n(382),p=n(679),c=function(t){function e(){var e=t.call(this)||this;return e.debug=!1,e}return o(e,t),e.prototype.on=function(e,n){return t.prototype.on.call(this,e,n)},e.prototype.off=function(e,n){return t.prototype.off.call(this,e,n)},Object.defineProperty(e.prototype,"fileUrl",{get:function(){return this.state?this.relativePath(this.state.file_info.path,this.state.file_info.file):""},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.subscribeEvent(),(0,s.sendEvent)(p.AppEvents.Init)},e.prototype.readMeta=function(){return this.state?fetch(this.metaPath,{method:"GET"}).then((function(t){return t.json()})).catch((function(){return{}})):new Promise((function(){return{}}))},e.prototype.saveMeta=function(t){return this.state?fetch(this.metaPath,{method:"POST",body:JSON.stringify(t)}):new Promise((function(){return{}}))},e.prototype.changeContent=function(t){(0,s.sendEvent)(p.AppEvents.ChangeContent,t)},e.prototype.close=function(t){(0,s.sendEvent)(p.AppEvents.Close,t)},e.prototype.download=function(){return this.fileDownload()},e.prototype.fileDownload=function(){return this.state?fetch(this.relativePath("/file",this.state.file_info.path,this.state.file_info.name),{method:"GET"}):new Promise((function(t){return{text:function(){return""}}}))},e.prototype.replace=function(t){return this.fileReplace(t)},e.prototype.fileReplace=function(t){return this.state?fetch(this.relativePath("/file/replace",this.state.file_info.path,this.state.file_info.name),{method:"PUT",body:t}):new Promise((function(t){t(null)}))},Object.defineProperty(e.prototype,"metaPath",{get:function(){if(!this.state)throw"state not found";return this.relativePath(this.state.file_info.path,".",(0,s.translite)(this.state.extenstion.name))},enumerable:!1,configurable:!0}),e.prototype.relativePath=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return r([null===(t=this.state)||void 0===t?void 0:t.api_path],e,!0).join("")},e.prototype.subscribeEvent=function(){var t=this;window.addEventListener("message",(function(e){var n=e.data.event,i=e.data.payload;switch(t.debug&&console.log("frame.message",e.data),n){case p.ExtensionEvents.Ready:t.debug=i.debug,t.emit(p.ExtensionEvents.Ready);break;case p.ExtensionEvents.ChangeView:t.state&&(t.state.view=i)}}))},e}(a.EventEmitter);e.NextBox=c},139:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EventEmitter=void 0;var n=function(){function t(){this._handlers=new Map}return t.prototype.on=function(t,e){var n;this._handlers.has(t)||this._handlers.set(t,new Set),null===(n=this._handlers.get(t))||void 0===n||n.add(e)},t.prototype.off=function(t,e){var n;null===(n=this._handlers.get(t))||void 0===n||n.delete(e)},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this._handlers.get(t)},t}();e.EventEmitter=n},382:function(t,e,n){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.translite=e.devState=e.sendEvent=void 0;var o=n(679);e.sendEvent=function(t,e){parent!==window&&parent.postMessage({event:t,payload:e},window.location.origin)},e.devState=function(t){return i(i({debug:!0,view:o.ViewState.edit,api_path:""},t),{extenstion:i({id:0,name:"",type:o.ExtentionsType.File},t.extenstion),file_info:i({path:"",file:"",name:"",ext:""},t.file_info)})},e.translite=function(t){var e={а:"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",",":"","?":""," ":"-","~":"","!":"","@":"","#":"",$:"","%":"","^":"","&":"","*":"","(":"",")":"","=":"","+":"",":":"",";":"","<":"",">":"","'":"",'"':"","\\":"","/":"","№":"","[":"","]":"","{":"","}":"",ґ:"",ї:"",є:"",Ґ:"g",Ї:"i","—":"",".":"",Є:"e"};return(t=(t=(t=(t=(t=t.toLocaleLowerCase()).trim()).replace(/ -/gi,"-")).replace(/- /gi,"-")).replace(/\s{2,}/gi," ")).split("").map((function(t){return/[a-z]/i.test(t)?t:e[t]||""})).join("")}},607:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(679),e),o(n(178),e),o(n(139),e),o(n(382),e),o(n(752),e)},178:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.initFileApi=e.init=void 0;var i=n(752),o=n(679);function r(){var t=new i.NextBox;return t.init(),t}e.init=r,e.initFileApi=function(){return new Promise((function(t){var e=r();e.on(o.ExtensionEvents.Ready,(function(){t(e)}))}))}},679:(t,e)=>{var n,i,o,r;Object.defineProperty(e,"__esModule",{value:!0}),e.ViewState=e.ExtensionEvents=e.AppEvents=e.ExtentionsType=void 0,(r=e.ExtentionsType||(e.ExtentionsType={})).App="app",r.File="file",(o=e.AppEvents||(e.AppEvents={})).Init="init",o.ChangeContent="change-content",o.Close="close",(i=e.ExtensionEvents||(e.ExtensionEvents={})).Ready="ready",i.ChangeView="change-view",i.SaveAndClose="save-and-close",(n=e.ViewState||(e.ViewState={})).view="view",n.edit="edit"}},e={};return function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={exports:{}};return t[i].call(r.exports,r,r.exports,n),r.exports}(607)})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PolymaticaApi=e():t.PolymaticaApi=e()}(globalThis,(()=>(()=>{"use strict";var t={752:function(t,e,n){var i,o=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var i,o=0,r=e.length;o<r;o++)!i&&o in e||(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return t.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.NextBox=void 0;var a=n(139),s=n(382),p=n(679),c=function(t){function e(){var e=t.call(this)||this;return e.debug=!1,e}return o(e,t),e.prototype.on=function(e,n){return t.prototype.on.call(this,e,n)},e.prototype.off=function(e,n){return t.prototype.off.call(this,e,n)},Object.defineProperty(e.prototype,"fileUrl",{get:function(){return this.state?this.relativePath(this.state.file_info.path,this.state.file_info.file):""},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.subscribeEvent(),(0,s.sendEvent)(p.AppEvents.Init)},e.prototype.readMeta=function(){return this.state?fetch(this.metaPath,{method:"GET"}).then((function(t){return t.json()})).catch((function(){return{}})):new Promise((function(){return{}}))},e.prototype.saveMeta=function(t){return this.state?fetch(this.metaPath,{method:"POST",body:JSON.stringify(t)}):new Promise((function(){return{}}))},e.prototype.changeContent=function(t){(0,s.sendEvent)(p.AppEvents.ChangeContent,t)},e.prototype.close=function(t){(0,s.sendEvent)(p.AppEvents.Close,t)},e.prototype.download=function(){return this.fileDownload()},e.prototype.fileDownload=function(){return this.state?fetch(this.relativePath("/file",this.state.file_info.path,this.state.file_info.name),{method:"GET"}):new Promise((function(t){return{text:function(){return""}}}))},e.prototype.replace=function(t){return this.fileReplace(t)},e.prototype.fileReplace=function(t){return this.state?fetch(this.relativePath("/file/replace",this.state.file_info.path,this.state.file_info.name),{method:"PUT",body:t}):new Promise((function(t){t(null)}))},Object.defineProperty(e.prototype,"metaPath",{get:function(){if(!this.state)throw"state not found";return this.relativePath(this.state.file_info.path,".",(0,s.translite)((0,s.getLang)(this.state.extenstion.name)))},enumerable:!1,configurable:!0}),e.prototype.relativePath=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return r([null===(t=this.state)||void 0===t?void 0:t.api_path],e,!0).join("")},e.prototype.subscribeEvent=function(){var t=this;window.addEventListener("message",(function(e){var n=e.data.event,i=e.data.payload;switch(t.debug&&console.log("frame.message",e.data),n){case p.ExtensionEvents.Ready:t.debug=i.debug,t.emit(p.ExtensionEvents.Ready);break;case p.ExtensionEvents.ChangeView:t.state&&(t.state.view=i)}}))},e}(a.EventEmitter);e.NextBox=c},139:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EventEmitter=void 0;var n=function(){function t(){this._handlers=new Map}return t.prototype.on=function(t,e){var n;this._handlers.has(t)||this._handlers.set(t,new Set),null===(n=this._handlers.get(t))||void 0===n||n.add(e)},t.prototype.off=function(t,e){var n;null===(n=this._handlers.get(t))||void 0===n||n.delete(e)},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this._handlers.get(t)},t}();e.EventEmitter=n},382:function(t,e,n){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.translite=e.devState=e.sendEvent=e.getLang=void 0;var o=n(679);e.getLang=function(t,e){if(void 0===e&&(e="ru"),t[e])return t[e];var n=Object.keys(t).pop();return n&&t[n]?t[n]:""},e.sendEvent=function(t,e){parent!==window&&parent.postMessage({event:t,payload:e},window.location.origin)},e.devState=function(t){return i(i({debug:!0,view:o.ViewState.edit,api_path:""},t),{extenstion:i({id:0,name:{ru:""},type:o.ExtentionsType.File},t.extenstion),file_info:i({path:"",file:"",name:"",ext:""},t.file_info)})},e.translite=function(t){var e={а:"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",",":"","?":""," ":"-","~":"","!":"","@":"","#":"",$:"","%":"","^":"","&":"","*":"","(":"",")":"","=":"","+":"",":":"",";":"","<":"",">":"","'":"",'"':"","\\":"","/":"","№":"","[":"","]":"","{":"","}":"",ґ:"",ї:"",є:"",Ґ:"g",Ї:"i","—":"",".":"",Є:"e"};return(t=(t=(t=(t=(t=t.toLocaleLowerCase()).trim()).replace(/ -/gi,"-")).replace(/- /gi,"-")).replace(/\s{2,}/gi," ")).split("").map((function(t){return/[a-z]/i.test(t)?t:e[t]||""})).join("")}},607:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(679),e),o(n(178),e),o(n(139),e),o(n(382),e),o(n(752),e)},178:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.initFileApi=e.init=void 0;var i=n(752),o=n(679);function r(){var t=new i.NextBox;return t.init(),t}e.init=r,e.initFileApi=function(){return new Promise((function(t){var e=r();e.on(o.ExtensionEvents.Ready,(function(){t(e)}))}))}},679:(t,e)=>{var n,i,o,r;Object.defineProperty(e,"__esModule",{value:!0}),e.ViewState=e.ExtensionEvents=e.AppEvents=e.ExtentionsType=void 0,(r=e.ExtentionsType||(e.ExtentionsType={})).App="app",r.File="file",(o=e.AppEvents||(e.AppEvents={})).Init="init",o.ChangeContent="change-content",o.Close="close",(i=e.ExtensionEvents||(e.ExtensionEvents={})).Ready="ready",i.ChangeView="change-view",i.SaveAndClose="save-and-close",(n=e.ViewState||(e.ViewState={})).view="view",n.edit="edit"}},e={};return function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={exports:{}};return t[i].call(r.exports,r,r.exports,n),r.exports}(607)})()));
package/interfaces.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export type Lang = {
2
+ [key: string]: string;
3
+ };
1
4
  export declare enum ExtentionsType {
2
5
  App = "app",
3
6
  File = "file"
@@ -28,7 +31,7 @@ export type TransportEventPayload = AppState | ViewState | any;
28
31
  export interface AppState {
29
32
  extenstion: {
30
33
  id: number;
31
- name: string;
34
+ name: Lang;
32
35
  type: ExtentionsType;
33
36
  };
34
37
  api_path: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-box",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",