next-box 1.1.1 → 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 +12 -0
- package/app.d.ts +9 -1
- package/index.js +1 -1
- package/interfaces.d.ts +15 -0
- package/package.json +1 -1
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
|
|
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,8 +26,16 @@ 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;
|
|
37
|
+
file_name: string;
|
|
38
|
+
file_path: string;
|
|
24
39
|
file_download_uri: string;
|
|
25
40
|
file_download_method: string;
|
|
26
41
|
file_replace_uri: string;
|