next-box 1.1.2 → 1.1.3

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 CHANGED
@@ -60,6 +60,18 @@ app.on(ExtensionEvents.Ready, () => {
60
60
  * Send an event to close the editor
61
61
  */
62
62
  app.close();
63
+
64
+ /**
65
+ * Saving metadata extension
66
+ */
67
+ app.saveMeta({ my_key: 'value' });
68
+
69
+ /**
70
+ * Reading metadata extension
71
+ */
72
+ app.readMeta().then((data) => {
73
+ console.log(data.my_key);
74
+ });
63
75
  });
64
76
  ```
65
77
 
package/app.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter, EventHandler } from './event-emitter';
2
- import { AppState, ExtensionEvents } from './interfaces';
2
+ import { AppState, ExtensionEvents, MetaData } from './interfaces';
3
3
  export declare class NextBox extends EventEmitter {
4
4
  state?: AppState;
5
5
  debug: boolean;
@@ -14,6 +14,14 @@ export declare class NextBox extends EventEmitter {
14
14
  * Subscribe postMessage and send an initialization event
15
15
  */
16
16
  init(): void;
17
+ /**
18
+ * Reading metadata extension
19
+ */
20
+ readMeta(): Promise<MetaData>;
21
+ /**
22
+ * Saving metadata extension
23
+ */
24
+ saveMeta(body: MetaData): Promise<any>;
17
25
  /**
18
26
  * Submit a content change message
19
27
  * In the case when content is written before exiting the application or when writing large files
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,i=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 r=n(139),s=n(382),a=n(679),u=function(e){function t(){var t=e.call(this)||this;return t.debug=!1,t}return i(t,e),t.prototype.on=function(t,n){return e.prototype.on.call(this,t,n)},t.prototype.off=function(t,n){return e.prototype.off.call(this,t,n)},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e;return(null===(e=this.state)||void 0===e?void 0:e.file_download_uri)||""},enumerable:!1,configurable:!0}),t.prototype.init=function(){this.subscribeEvent(),(0,s.sendEvent)(a.AppEvents.Init)},t.prototype.changeContent=function(e){(0,s.sendEvent)(a.AppEvents.ChangeContent,e)},t.prototype.close=function(e){(0,s.sendEvent)(a.AppEvents.Close,e)},t.prototype.download=function(){return this.fileDownload()},t.prototype.fileDownload=function(){return this.state?fetch(this.state.file_download_uri,{method:this.state.file_download_method}):new Promise((function(e){return{text:function(){return""}}}))},t.prototype.replace=function(e){return this.fileReplace(e)},t.prototype.fileReplace=function(e){return this.state?fetch(this.state.file_replace_uri,{method:this.state.file_replace_method,body:e}):new Promise((function(e){e(null)}))},t.prototype.subscribeEvent=function(){var e=this;window.addEventListener("message",(function(t){var n=t.data.event,o=t.data.payload;switch(e.debug&&console.log("frame.message",t.data),n){case a.ExtensionEvents.Ready:e.debug=o.debug,e.emit(a.ExtensionEvents.Ready);break;case a.ExtensionEvents.ChangeView:e.state&&(e.state.view=o)}}))},t}(r.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=1;n<arguments.length;n++)t[n-1]=arguments[n];this._handlers.get(e)},e}();t.EventEmitter=n},382:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sendEvent=void 0,t.sendEvent=function(e,t){parent!==window&&parent.postMessage({event:e,payload:t},window.location.origin)}},607:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=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}),i(n(679),t),i(n(178),t),i(n(139),t),i(n(382),t),i(n(752),t)},178:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.initFileApi=t.init=void 0;var o=n(752),i=n(679);function r(){var e=new o.NextBox;return e.init(),e}t.init=r,t.initFileApi=function(){return new Promise((function(e){var t=r();t.on(i.ExtensionEvents.Ready,(function(){e(t)}))}))}},679:(e,t)=>{var n,o,i;Object.defineProperty(t,"__esModule",{value:!0}),t.ViewState=t.ExtensionEvents=t.AppEvents=void 0,(i=t.AppEvents||(t.AppEvents={})).Init="init",i.ChangeContent="change-content",i.Close="close",(o=t.ExtensionEvents||(t.ExtensionEvents={})).Ready="ready",o.ChangeView="change-view",o.SaveAndClose="save-and-close",(n=t.ViewState||(t.ViewState={})).view="view",n.edit="edit"}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[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)});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.AppTypes=void 0,(r=e.AppTypes||(e.AppTypes={})).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
@@ -1,3 +1,10 @@
1
+ export declare enum AppTypes {
2
+ App = "app",
3
+ File = "file"
4
+ }
5
+ export type MetaData = {
6
+ [key: string]: any;
7
+ };
1
8
  export declare enum AppEvents {
2
9
  Init = "init",
3
10
  ChangeContent = "change-content",
@@ -19,6 +26,12 @@ export declare enum ViewState {
19
26
  }
20
27
  export type TransportEventPayload = AppState | ViewState | any;
21
28
  export interface AppState {
29
+ extenstion: {
30
+ id: number;
31
+ name: string;
32
+ type: '';
33
+ };
34
+ root: string;
22
35
  debug: boolean;
23
36
  view: ViewState;
24
37
  file_name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-box",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",