next-box 1.1.4 → 1.1.5

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/app.d.ts CHANGED
@@ -47,5 +47,7 @@ export declare class NextBox extends EventEmitter {
47
47
  * Submit a file change request
48
48
  */
49
49
  fileReplace(body: any): Promise<Response | null>;
50
+ private get metaPath();
51
+ private relativePath;
50
52
  private subscribeEvent;
51
53
  }
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 o,i=this&&this.__extends||(o=function(t,e){return o=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])},o(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}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.NextBox=void 0;var r=n(139),s=n(382),a=n(679),c=function(t){function e(){var e=t.call(this)||this;return e.debug=!1,e}return i(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(){var t;return(null===(t=this.state)||void 0===t?void 0:t.file_download_uri)||""},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.subscribeEvent(),(0,s.sendEvent)(a.AppEvents.Init)},e.prototype.readMeta=function(){return this.state?fetch("".concat(this.state.root,".").concat(this.state.extenstion.name),{method:"GET"}).then((function(t){return t.json()})).catch((function(){return{}})):new Promise((function(){return{}}))},e.prototype.saveMeta=function(t){return this.state?fetch("".concat(this.state.root,".").concat(this.state.extenstion.name),{method:"POST",body:JSON.stringify(t)}):new Promise((function(){return{}}))},e.prototype.changeContent=function(t){(0,s.sendEvent)(a.AppEvents.ChangeContent,t)},e.prototype.close=function(t){(0,s.sendEvent)(a.AppEvents.Close,t)},e.prototype.download=function(){return this.fileDownload()},e.prototype.fileDownload=function(){return this.state?fetch(this.state.file_download_uri,{method:this.state.file_download_method}):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.state.file_replace_uri,{method:this.state.file_replace_method,body:t}):new Promise((function(t){t(null)}))},e.prototype.subscribeEvent=function(){var t=this;window.addEventListener("message",(function(e){var n=e.data.event,o=e.data.payload;switch(t.debug&&console.log("frame.message",e.data),n){case a.ExtensionEvents.Ready:t.debug=o.debug,t.emit(a.ExtensionEvents.Ready);break;case a.ExtensionEvents.ChangeView:t.state&&(t.state.view=o)}}))},e}(r.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:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sendEvent=void 0,e.sendEvent=function(t,e){parent!==window&&parent.postMessage({event:t,payload:e},window.location.origin)}},607:function(t,e,n){var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(679),e),i(n(178),e),i(n(139),e),i(n(382),e),i(n(752),e)},178:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.initFileApi=e.init=void 0;var o=n(752),i=n(679);function r(){var t=new o.NextBox;return t.init(),t}e.init=r,e.initFileApi=function(){return new Promise((function(t){var e=r();e.on(i.ExtensionEvents.Ready,(function(){t(e)}))}))}},679:(t,e)=>{var n,o,i,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",(i=e.AppEvents||(e.AppEvents={})).Init="init",i.ChangeContent="change-content",i.Close="close",(o=e.ExtensionEvents||(e.ExtensionEvents={})).Ready="ready",o.ChangeView="change-view",o.SaveAndClose="save-and-close",(n=e.ViewState||(e.ViewState={})).view="view",n.edit="edit"}},e={};return function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={exports:{}};return t[o].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 o,i=this&&this.__extends||(o=function(t,e){return o=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])},o(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}o(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 o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||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 i(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_path):""},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_path),{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_path),{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.dir_path,".",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,o=e.data.payload;switch(t.debug&&console.log("frame.message",e.data),n){case p.ExtensionEvents.Ready:t.debug=o.debug,t.emit(p.ExtensionEvents.Ready);break;case p.ExtensionEvents.ChangeView:t.state&&(t.state.view=o)}}))},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:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sendEvent=void 0,e.sendEvent=function(t,e){parent!==window&&parent.postMessage({event:t,payload:e},window.location.origin)}},607:function(t,e,n){var o=this&&this.__createBinding||(Object.create?function(t,e,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,o,i)}:function(t,e,n,o){void 0===o&&(o=n),t[o]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(679),e),i(n(178),e),i(n(139),e),i(n(382),e),i(n(752),e)},178:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.initFileApi=e.init=void 0;var o=n(752),i=n(679);function r(){var t=new o.NextBox;return t.init(),t}e.init=r,e.initFileApi=function(){return new Promise((function(t){var e=r();e.on(i.ExtensionEvents.Ready,(function(){t(e)}))}))}},679:(t,e)=>{var n,o,i,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",(i=e.AppEvents||(e.AppEvents={})).Init="init",i.ChangeContent="change-content",i.Close="close",(o=e.ExtensionEvents||(e.ExtensionEvents={})).Ready="ready",o.ChangeView="change-view",o.SaveAndClose="save-and-close",(n=e.ViewState||(e.ViewState={})).view="view",n.edit="edit"}},e={};return function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={exports:{}};return t[o].call(r.exports,r,r.exports,n),r.exports}(607)})()));
package/interfaces.d.ts CHANGED
@@ -31,13 +31,10 @@ export interface AppState {
31
31
  name: string;
32
32
  type: ExtentionsType;
33
33
  };
34
- root: string;
35
- debug: boolean;
36
- view: ViewState;
34
+ api_path: string;
37
35
  file_name: string;
38
36
  file_path: string;
39
- file_download_uri: string;
40
- file_download_method: string;
41
- file_replace_uri: string;
42
- file_replace_method: string;
37
+ dir_path: string;
38
+ debug: boolean;
39
+ view: ViewState;
43
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-box",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",