@akinon/app-client 0.3.2 → 0.4.0
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/dist/app-client-provider.d.ts +4 -2
- package/dist/app-client-provider.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +170 -155
- package/package.json +3 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ApplicationData, FullpageApplicationConfig, PluginApplicationConfig, RegisteredApp, RegisteredAppType } from '@akinon/app-shared';
|
|
1
|
+
import { ApplicationData, ApplicationNavigation, ApplicationParams, FullpageApplicationConfig, PluginApplicationConfig, RegisteredApp, RegisteredAppType } from '@akinon/app-shared';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Defines the context state for the AppClient, including application data,
|
|
5
5
|
* loading status, and methods for invoking actions and navigating.
|
|
6
6
|
* @typedef {Object} AppClientContextState
|
|
7
7
|
* @property {ApplicationData} [data] - Optional application data shared across micro frontends.
|
|
8
|
+
* @property {ApplicationParams} [params] - Optional. Additional parameters to be passed to the application.
|
|
8
9
|
* @property {boolean} isLoading - Indicates whether the application data is currently loading.
|
|
9
10
|
* @property {Function} invokeAction - Method to invoke an action defined in the AppShell.
|
|
10
11
|
* @property {Function} navigate - Method to navigate to a specified path within the application.
|
|
@@ -12,6 +13,7 @@ import React from 'react';
|
|
|
12
13
|
*/
|
|
13
14
|
interface AppClientContextState {
|
|
14
15
|
data?: ApplicationData;
|
|
16
|
+
params?: ApplicationParams;
|
|
15
17
|
isLoading: boolean;
|
|
16
18
|
invokeAction: <T = any>(actionKey: string, ...args: any[]) => Promise<T>;
|
|
17
19
|
navigate: (path: string) => void;
|
|
@@ -42,5 +44,5 @@ declare const useAppClient: () => AppClientContextState;
|
|
|
42
44
|
*/
|
|
43
45
|
declare const AppClientProvider: ({ children, config }: AppClientProviderProps) => React.JSX.Element;
|
|
44
46
|
export { AppClientProvider, useAppClient };
|
|
45
|
-
export type { FullpageApplicationConfig, PluginApplicationConfig, RegisteredApp, RegisteredAppType };
|
|
47
|
+
export type { ApplicationNavigation, FullpageApplicationConfig, PluginApplicationConfig, RegisteredApp, RegisteredAppType };
|
|
46
48
|
//# sourceMappingURL=app-client-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-client-provider.d.ts","sourceRoot":"","sources":["../src/app-client-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAyD,MAAM,OAAO,CAAC;AAE9E
|
|
1
|
+
{"version":3,"file":"app-client-provider.d.ts","sourceRoot":"","sources":["../src/app-client-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAyD,MAAM,OAAO,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,UAAU,qBAAqB;IAC7B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACrE,SAAS,CAAC,EAAE,CACV,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,KAC1D,IAAI,CAAC;IACV,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7D;AAED;;;;;GAKG;AACH,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,yBAAyB,GAAG,uBAAuB,CAAC;CAC7D;AAaD;;;GAGG;AACH,QAAA,MAAM,YAAY,6BAAqC,CAAC;AA6ExD;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,yBAA0B,sBAAsB,sBAoGtE,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAC;AAC3C,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EAClB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react/jsx-runtime"),v=require("react");var b=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function H(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var j={},h={},S;function Q(){if(S)return h;S=1,Object.defineProperty(h,"__esModule",{value:!0}),h.detach=h.attach=void 0;var r=d(),o=!1;function n(){o||typeof window>"u"||(o=!0,window.addEventListener("message",r.onMessage,!1))}h.attach=n;function t(){o=!1,window.removeEventListener("message",r.onMessage,!1)}return h.detach=t,h}var y={},I;function X(){if(I)return y;I=1,Object.defineProperty(y,"__esModule",{value:!0}),y.broadcastToChildWindows=void 0;var r=d();function o(n,t,e){for(var i=r.childWindows.length-1;i>=0;i--){var s=r.childWindows[i];s.closed?r.childWindows.splice(i,1):e!==s&&(0,r.broadcast)(n,{origin:t,frame:s.top})}}return y.broadcastToChildWindows=o,y}var m={},q;function Y(){if(q)return m;q=1,Object.defineProperty(m,"__esModule",{value:!0}),m.broadcast=void 0;var r=d();function o(n,t){var e=0,i,s=t.origin,a=t.frame;try{for(a.postMessage(n,s),(0,r.hasOpener)(a)&&a.opener.top!==window.top&&o(n,{origin:s,frame:a.opener.top});i=a.frames[e];)o(n,{origin:s,frame:i}),e++}catch{}}return m.broadcast=o,m}var l={};Object.defineProperty(l,"__esModule",{value:!0});l.subscribers=l.childWindows=l.prefix=void 0;l.prefix="/*framebus*/";l.childWindows=[];l.subscribers={};var _={},R;function Z(){if(R)return _;R=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var r=d();function o(n,t,e,i,s){if(r.subscribers[n]&&r.subscribers[n][t]){var a=[];e&&a.push(e),i&&a.push(i);for(var u=0;u<r.subscribers[n][t].length;u++)r.subscribers[n][t][u].apply(s,a)}}return _.dispatch=o,_}var D={};Object.defineProperty(D,"__esModule",{value:!0});D.hasOpener=void 0;function ee(r){return!(r.top!==r||r.opener==null||r.opener===r||r.opener.closed===!0)}D.hasOpener=ee;var F={};Object.defineProperty(F,"__esModule",{value:!0});F.isntString=void 0;function re(r){return typeof r!="string"}F.isntString=re;var w={},k;function te(){if(k)return w;k=1,Object.defineProperty(w,"__esModule",{value:!0}),w.onMessage=void 0;var r=d();function o(n){if(!(0,r.isntString)(n.data)){var t=(0,r.unpackPayload)(n);if(t){var e=t.eventData,i=t.reply;(0,r.dispatch)("*",t.event,e,i,n),(0,r.dispatch)(n.origin,t.event,e,i,n),(0,r.broadcastToChildWindows)(n.data,t.origin,n.source)}}}return w.onMessage=o,w}var P={},L;function ie(){if(L)return P;L=1,Object.defineProperty(P,"__esModule",{value:!0}),P.packagePayload=void 0;var r=d();function o(n,t,e,i){var s,a={event:n,origin:t};typeof i=="function"&&(a.reply=(0,r.subscribeReplier)(i,t)),a.eventData=e;try{s=r.prefix+JSON.stringify(a)}catch(u){throw new Error("Could not stringify event: ".concat(u.message))}return s}return P.packagePayload=o,P}var x={};Object.defineProperty(x,"__esModule",{value:!0});x.sendMessage=void 0;function ne(r,o,n){try{r.postMessage(o,n)}catch{}}x.sendMessage=ne;var A={},O={},B;function U(){if(B)return O;B=1,Object.defineProperty(O,"__esModule",{value:!0}),O.Framebus=void 0;var r=d(),o=typeof window<"u"&&window.Promise,n=function(){function t(e){e===void 0&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=!!e.targetFrames,this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=!!(this.verifyDomain||this.limitBroadcastToFramesArray)}return t.setPromise=function(e){t.Promise=e},t.target=function(e){return new t(e)},t.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},t.prototype.include=function(e){return e==null||e.Window==null||e.constructor!==e.Window?!1:(r.childWindows.push(e),!0)},t.prototype.target=function(e){return t.target(e)},t.prototype.emit=function(e,i,s){if(this.isDestroyed)return!1;var a=this.origin;if(e=this.namespaceEvent(e),(0,r.isntString)(e)||(0,r.isntString)(a))return!1;typeof i=="function"&&(s=i,i=void 0);var u=(0,r.packagePayload)(e,a,i,s);return u?(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(f){(0,r.sendMessage)(f,u,a)}):(0,r.broadcast)(u,{origin:a,frame:window.top||window.self}),!0):!1},t.prototype.emitAsPromise=function(e,i){var s=this;return new t.Promise(function(a,u){var f=s.emit(e,i,function(c){a(c)});f||u(new Error('Listener not added for "'.concat(e,'"')))})},t.prototype.on=function(e,i){if(this.isDestroyed)return!1;var s=this,a=this.origin,u=i;return e=this.namespaceEvent(e),(0,r.subscriptionArgsInvalid)(e,u,a)?!1:(this.hasAdditionalChecksForOnListeners&&(u=function(){for(var f=[],c=0;c<arguments.length;c++)f[c]=arguments[c];s.passesVerifyDomainCheck(this&&this.origin)&&s.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,f)}),this.listeners.push({eventName:e,handler:u,originalHandler:i}),r.subscribers[a]=r.subscribers[a]||{},r.subscribers[a][e]=r.subscribers[a][e]||[],r.subscribers[a][e].push(u),!0)},t.prototype.off=function(e,i){var s=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var a=0;a<this.listeners.length;a++){var u=this.listeners[a];u.originalHandler===i&&(s=u.handler)}e=this.namespaceEvent(e);var f=this.origin;if((0,r.subscriptionArgsInvalid)(e,s,f))return!1;var c=r.subscribers[f]&&r.subscribers[f][e];if(!c)return!1;for(var a=0;a<c.length;a++)if(c[a]===s)return c.splice(a,1),!0;return!1},t.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var i=this.listeners[e];this.off(i.eventName,i.handler)}this.listeners.length=0}},t.prototype.passesVerifyDomainCheck=function(e){return this.verifyDomain?this.checkOrigin(e):!0},t.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map(function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e}).filter(function(e){return e}):[]},t.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var i=this.targetFramesAsWindows().find(function(s){return s===e});return!!i},t.prototype.checkOrigin=function(e){var i,s=document.createElement("a");s.href=location.href,s.protocol==="https:"?i=s.host.replace(/:443$/,""):s.protocol==="http:"?i=s.host.replace(/:80$/,""):i=s.host;var a=s.protocol+"//"+i;return a===e?!0:this.verifyDomain?this.verifyDomain(e):!0},t.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},t.Promise=o,t}();return O.Framebus=n,O}function ae(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var o=Math.random()*16|0,n=r==="x"?o:o&3|8;return n.toString(16)})}var se=ae,W;function oe(){if(W)return A;W=1;var r=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(A,"__esModule",{value:!0}),A.subscribeReplier=void 0;var o=U(),n=r(se);function t(e,i){var s=(0,n.default)();function a(u,f){e(u,f),o.Framebus.target({origin:i}).off(s,a)}return o.Framebus.target({origin:i}).on(s,a),s}return A.subscribeReplier=t,A}var M={},$;function ue(){if($)return M;$=1,Object.defineProperty(M,"__esModule",{value:!0}),M.subscriptionArgsInvalid=void 0;var r=d();function o(n,t,e){return(0,r.isntString)(n)||typeof t!="function"?!0:(0,r.isntString)(e)}return M.subscriptionArgsInvalid=o,M}var N={};Object.defineProperty(N,"__esModule",{value:!0});var T={},K;function ce(){if(K)return T;K=1,Object.defineProperty(T,"__esModule",{value:!0}),T.unpackPayload=void 0;var r=d();function o(n){var t;if(n.data.slice(0,r.prefix.length)!==r.prefix)return!1;try{t=JSON.parse(n.data.slice(r.prefix.length))}catch{return!1}if(t.reply){var e=n.origin,i=n.source,s=t.reply;t.reply=function(u){if(i){var f=(0,r.packagePayload)(s,e,u);f&&i.postMessage(f,e)}}}return t}return T.unpackPayload=o,T}var V;function d(){return V||(V=1,function(r){var o=b&&b.__createBinding||(Object.create?function(t,e,i,s){s===void 0&&(s=i);var a=Object.getOwnPropertyDescriptor(e,i);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,a)}:function(t,e,i,s){s===void 0&&(s=i),t[s]=e[i]}),n=b&&b.__exportStar||function(t,e){for(var i in t)i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i)&&o(e,t,i)};Object.defineProperty(r,"__esModule",{value:!0}),n(Q(),r),n(X(),r),n(Y(),r),n(l,r),n(Z(),r),n(D,r),n(F,r),n(te(),r),n(ie(),r),n(x,r),n(oe(),r),n(ue(),r),n(N,r),n(ce(),r)}(j)),j}var fe=d(),de=U();(0,fe.attach)();var le=de.Framebus;const p=H(le),he={isLoading:!0,invokeAction:async()=>Promise.reject("Action functionality not initialized."),navigate:()=>{}},G=v.createContext(he),pe=()=>v.useContext(G),ve=r=>{new p().emit("NAVIGATE",{path:r})},be=(r,o)=>{new p().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showModalDialog",args:[r,o]})},ge=(r,o)=>new p().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showConfirmationDialog",args:[r,o]}),ye=(r,o)=>{new p().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showToast",args:[r,o]})},me=(r,o)=>{new p().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showErrorMessage",args:[r,o]})},_e=({children:r,config:o})=>{const[n,t]=v.useState(void 0),[e,i]=v.useState(void 0),[s,a]=v.useState(!0),u=(c,...g)=>new Promise((E,J)=>{new p().emit("INVOKE_ACTION",{actionKey:c,args:g},C=>{C.success?E(C.result):J(new Error(C.error))})});v.useEffect(()=>{if(o.forceRedirect&&!o.isDev&&window.self===window.top){console.error("This app must be run inside an iframe when forceRedirect is true.");return}const c=new p;return c.emit("REQUEST_DATA",{config:o}),c.on("DATA_RESPONSE",g=>{i(g),a(!1)}),c.on("SET_APP_ID",g=>{const{appId:E}=g;t(E)}),()=>{c.teardown()}},[o]);const f={data:e,isLoading:s,invokeAction:u,navigate:ve,showModalDialog:be,showConfirmationDialog:ge,showToast:ye,showErrorMessage:me};return z.jsx(G.Provider,{value:f,children:r})};exports.AppClientProvider=_e;exports.useAppClient=pe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("react/jsx-runtime"),b=require("react");var m=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Z(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var R={},g={},q;function ee(){if(q)return g;q=1,Object.defineProperty(g,"__esModule",{value:!0}),g.detach=g.attach=void 0;var r=d(),o=!1;function n(){o||typeof window>"u"||(o=!0,window.addEventListener("message",r.onMessage,!1))}g.attach=n;function t(){o=!1,window.removeEventListener("message",r.onMessage,!1)}return g.detach=t,g}var w={},L;function re(){if(L)return w;L=1,Object.defineProperty(w,"__esModule",{value:!0}),w.broadcastToChildWindows=void 0;var r=d();function o(n,t,e){for(var i=r.childWindows.length-1;i>=0;i--){var s=r.childWindows[i];s.closed?r.childWindows.splice(i,1):e!==s&&(0,r.broadcast)(n,{origin:t,frame:s.top})}}return w.broadcastToChildWindows=o,w}var P={},k;function te(){if(k)return P;k=1,Object.defineProperty(P,"__esModule",{value:!0}),P.broadcast=void 0;var r=d();function o(n,t){var e=0,i,s=t.origin,a=t.frame;try{for(a.postMessage(n,s),(0,r.hasOpener)(a)&&a.opener.top!==window.top&&o(n,{origin:s,frame:a.opener.top});i=a.frames[e];)o(n,{origin:s,frame:i}),e++}catch{}}return P.broadcast=o,P}var p={};Object.defineProperty(p,"__esModule",{value:!0});p.subscribers=p.childWindows=p.prefix=void 0;p.prefix="/*framebus*/";p.childWindows=[];p.subscribers={};var A={},B;function ie(){if(B)return A;B=1,Object.defineProperty(A,"__esModule",{value:!0}),A.dispatch=void 0;var r=d();function o(n,t,e,i,s){if(r.subscribers[n]&&r.subscribers[n][t]){var a=[];e&&a.push(e),i&&a.push(i);for(var u=0;u<r.subscribers[n][t].length;u++)r.subscribers[n][t][u].apply(s,a)}}return A.dispatch=o,A}var S={};Object.defineProperty(S,"__esModule",{value:!0});S.hasOpener=void 0;function ne(r){return!(r.top!==r||r.opener==null||r.opener===r||r.opener.closed===!0)}S.hasOpener=ne;var j={};Object.defineProperty(j,"__esModule",{value:!0});j.isntString=void 0;function ae(r){return typeof r!="string"}j.isntString=ae;var O={},W;function se(){if(W)return O;W=1,Object.defineProperty(O,"__esModule",{value:!0}),O.onMessage=void 0;var r=d();function o(n){if(!(0,r.isntString)(n.data)){var t=(0,r.unpackPayload)(n);if(t){var e=t.eventData,i=t.reply;(0,r.dispatch)("*",t.event,e,i,n),(0,r.dispatch)(n.origin,t.event,e,i,n),(0,r.broadcastToChildWindows)(n.data,t.origin,n.source)}}}return O.onMessage=o,O}var M={},$;function oe(){if($)return M;$=1,Object.defineProperty(M,"__esModule",{value:!0}),M.packagePayload=void 0;var r=d();function o(n,t,e,i){var s,a={event:n,origin:t};typeof i=="function"&&(a.reply=(0,r.subscribeReplier)(i,t)),a.eventData=e;try{s=r.prefix+JSON.stringify(a)}catch(u){throw new Error("Could not stringify event: ".concat(u.message))}return s}return M.packagePayload=o,M}var I={};Object.defineProperty(I,"__esModule",{value:!0});I.sendMessage=void 0;function ue(r,o,n){try{r.postMessage(o,n)}catch{}}I.sendMessage=ue;var T={},D={},V;function H(){if(V)return D;V=1,Object.defineProperty(D,"__esModule",{value:!0}),D.Framebus=void 0;var r=d(),o=typeof window<"u"&&window.Promise,n=function(){function t(e){e===void 0&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=!!e.targetFrames,this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=!!(this.verifyDomain||this.limitBroadcastToFramesArray)}return t.setPromise=function(e){t.Promise=e},t.target=function(e){return new t(e)},t.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},t.prototype.include=function(e){return e==null||e.Window==null||e.constructor!==e.Window?!1:(r.childWindows.push(e),!0)},t.prototype.target=function(e){return t.target(e)},t.prototype.emit=function(e,i,s){if(this.isDestroyed)return!1;var a=this.origin;if(e=this.namespaceEvent(e),(0,r.isntString)(e)||(0,r.isntString)(a))return!1;typeof i=="function"&&(s=i,i=void 0);var u=(0,r.packagePayload)(e,a,i,s);return u?(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(c){(0,r.sendMessage)(c,u,a)}):(0,r.broadcast)(u,{origin:a,frame:window.top||window.self}),!0):!1},t.prototype.emitAsPromise=function(e,i){var s=this;return new t.Promise(function(a,u){var c=s.emit(e,i,function(f){a(f)});c||u(new Error('Listener not added for "'.concat(e,'"')))})},t.prototype.on=function(e,i){if(this.isDestroyed)return!1;var s=this,a=this.origin,u=i;return e=this.namespaceEvent(e),(0,r.subscriptionArgsInvalid)(e,u,a)?!1:(this.hasAdditionalChecksForOnListeners&&(u=function(){for(var c=[],f=0;f<arguments.length;f++)c[f]=arguments[f];s.passesVerifyDomainCheck(this&&this.origin)&&s.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,c)}),this.listeners.push({eventName:e,handler:u,originalHandler:i}),r.subscribers[a]=r.subscribers[a]||{},r.subscribers[a][e]=r.subscribers[a][e]||[],r.subscribers[a][e].push(u),!0)},t.prototype.off=function(e,i){var s=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var a=0;a<this.listeners.length;a++){var u=this.listeners[a];u.originalHandler===i&&(s=u.handler)}e=this.namespaceEvent(e);var c=this.origin;if((0,r.subscriptionArgsInvalid)(e,s,c))return!1;var f=r.subscribers[c]&&r.subscribers[c][e];if(!f)return!1;for(var a=0;a<f.length;a++)if(f[a]===s)return f.splice(a,1),!0;return!1},t.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var i=this.listeners[e];this.off(i.eventName,i.handler)}this.listeners.length=0}},t.prototype.passesVerifyDomainCheck=function(e){return this.verifyDomain?this.checkOrigin(e):!0},t.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map(function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e}).filter(function(e){return e}):[]},t.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var i=this.targetFramesAsWindows().find(function(s){return s===e});return!!i},t.prototype.checkOrigin=function(e){var i,s=document.createElement("a");s.href=location.href,s.protocol==="https:"?i=s.host.replace(/:443$/,""):s.protocol==="http:"?i=s.host.replace(/:80$/,""):i=s.host;var a=s.protocol+"//"+i;return a===e?!0:this.verifyDomain?this.verifyDomain(e):!0},t.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},t.Promise=o,t}();return D.Framebus=n,D}function ce(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var o=Math.random()*16|0,n=r==="x"?o:o&3|8;return n.toString(16)})}var fe=ce,K;function de(){if(K)return T;K=1;var r=m&&m.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(T,"__esModule",{value:!0}),T.subscribeReplier=void 0;var o=H(),n=r(fe);function t(e,i){var s=(0,n.default)();function a(u,c){e(u,c),o.Framebus.target({origin:i}).off(s,a)}return o.Framebus.target({origin:i}).on(s,a),s}return T.subscribeReplier=t,T}var F={},U;function le(){if(U)return F;U=1,Object.defineProperty(F,"__esModule",{value:!0}),F.subscriptionArgsInvalid=void 0;var r=d();function o(n,t,e){return(0,r.isntString)(n)||typeof t!="function"?!0:(0,r.isntString)(e)}return F.subscriptionArgsInvalid=o,F}var J={};Object.defineProperty(J,"__esModule",{value:!0});var E={},N;function he(){if(N)return E;N=1,Object.defineProperty(E,"__esModule",{value:!0}),E.unpackPayload=void 0;var r=d();function o(n){var t;if(n.data.slice(0,r.prefix.length)!==r.prefix)return!1;try{t=JSON.parse(n.data.slice(r.prefix.length))}catch{return!1}if(t.reply){var e=n.origin,i=n.source,s=t.reply;t.reply=function(u){if(i){var c=(0,r.packagePayload)(s,e,u);c&&i.postMessage(c,e)}}}return t}return E.unpackPayload=o,E}var G;function d(){return G||(G=1,function(r){var o=m&&m.__createBinding||(Object.create?function(t,e,i,s){s===void 0&&(s=i);var a=Object.getOwnPropertyDescriptor(e,i);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,s,a)}:function(t,e,i,s){s===void 0&&(s=i),t[s]=e[i]}),n=m&&m.__exportStar||function(t,e){for(var i in t)i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i)&&o(e,t,i)};Object.defineProperty(r,"__esModule",{value:!0}),n(ee(),r),n(re(),r),n(te(),r),n(p,r),n(ie(),r),n(S,r),n(j,r),n(se(),r),n(oe(),r),n(I,r),n(de(),r),n(le(),r),n(J,r),n(he(),r)}(R)),R}var pe=d(),ve=H();(0,pe.attach)();var ge=ve.Framebus;const v=Z(ge),be={isLoading:!0,invokeAction:async()=>Promise.reject("Action functionality not initialized."),navigate:()=>{}},z=b.createContext(be),ye=()=>b.useContext(z),me=r=>{new v().emit("NAVIGATE",{path:r})},_e=(r,o)=>{new v().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showModalDialog",args:[r,o]})},we=(r,o)=>new v().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showConfirmationDialog",args:[r,o]}),Pe=(r,o)=>{new v().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showToast",args:[r,o]})},Ae=(r,o)=>{new v().emit("INVOKE_DEFAULT_ACTION",{actionKey:"showErrorMessage",args:[r,o]})},Oe=({children:r,config:o})=>{const[,n]=b.useState(void 0),[t,e]=b.useState(void 0),[i,s]=b.useState(void 0),[a,u]=b.useState(!0),c=(x,...C)=>new Promise((l,h)=>{new v().emit("INVOKE_ACTION",{actionKey:x,args:C},y=>{y.success?l(y.result):h(new Error(y.error))})}),f=()=>{const x=o;return Array.isArray(x.menu)};b.useEffect(()=>{if(o.forceRedirect&&!o.isDev&&window.self===window.top){console.error("This app must be run inside an iframe when forceRedirect is true.");return}const C=new URL(window.location.href).searchParams.get("c");let l;return l=C?new v({channel:C}):new v,l.emit("REQUEST_DATA",{config:o}),l.on("DATA_RESPONSE",h=>{e(h),u(!1)}),l.on("PARAMS_RESPONSE",h=>{s(h)}),l.on("SET_APP_ID",h=>{const{appId:_}=h;n(_)}),f()&&l.on("NAVIGATE_CHILD",h=>{const{path:_}=h,{navigation:y}=o;if(y){const{navigate:X}=y;X(_)}}),()=>{l.teardown()}},[o]);const Q={data:t,params:i,isLoading:a,invokeAction:c,navigate:me,showModalDialog:_e,showConfirmationDialog:we,showToast:Pe,showErrorMessage:Ae};return Y.jsx(z.Provider,{value:Q,children:r})};exports.AppClientProvider=Oe;exports.useAppClient=ye;
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
import { jsx as Y } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Z, useContext as ee, useState as C, useEffect as re } from "react";
|
|
3
|
+
var y = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
4
|
+
function te(r) {
|
|
5
5
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
6
6
|
}
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
11
|
-
|
|
7
|
+
var R = {}, g = {}, q;
|
|
8
|
+
function ie() {
|
|
9
|
+
if (q)
|
|
10
|
+
return g;
|
|
11
|
+
q = 1, Object.defineProperty(g, "__esModule", { value: !0 }), g.detach = g.attach = void 0;
|
|
12
12
|
var r = d(), o = !1;
|
|
13
13
|
function n() {
|
|
14
14
|
o || typeof window > "u" || (o = !0, window.addEventListener("message", r.onMessage, !1));
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
g.attach = n;
|
|
17
17
|
function t() {
|
|
18
18
|
o = !1, window.removeEventListener("message", r.onMessage, !1);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return g.detach = t, g;
|
|
21
21
|
}
|
|
22
|
-
var
|
|
23
|
-
function
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
26
|
-
|
|
22
|
+
var _ = {}, L;
|
|
23
|
+
function ne() {
|
|
24
|
+
if (L)
|
|
25
|
+
return _;
|
|
26
|
+
L = 1, Object.defineProperty(_, "__esModule", { value: !0 }), _.broadcastToChildWindows = void 0;
|
|
27
27
|
var r = d();
|
|
28
28
|
function o(n, t, e) {
|
|
29
29
|
for (var i = r.childWindows.length - 1; i >= 0; i--) {
|
|
@@ -34,13 +34,13 @@ function ee() {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return _.broadcastToChildWindows = o, _;
|
|
38
38
|
}
|
|
39
|
-
var
|
|
40
|
-
function
|
|
41
|
-
if (
|
|
42
|
-
return
|
|
43
|
-
|
|
39
|
+
var w = {}, k;
|
|
40
|
+
function ae() {
|
|
41
|
+
if (k)
|
|
42
|
+
return w;
|
|
43
|
+
k = 1, Object.defineProperty(w, "__esModule", { value: !0 }), w.broadcast = void 0;
|
|
44
44
|
var r = d();
|
|
45
45
|
function o(n, t) {
|
|
46
46
|
var e = 0, i, s = t.origin, a = t.frame;
|
|
@@ -56,19 +56,19 @@ function re() {
|
|
|
56
56
|
} catch {
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return w.broadcast = o, w;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
62
|
-
Object.defineProperty(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var
|
|
68
|
-
function
|
|
69
|
-
if (
|
|
70
|
-
return
|
|
71
|
-
|
|
61
|
+
var p = {};
|
|
62
|
+
Object.defineProperty(p, "__esModule", { value: !0 });
|
|
63
|
+
p.subscribers = p.childWindows = p.prefix = void 0;
|
|
64
|
+
p.prefix = "/*framebus*/";
|
|
65
|
+
p.childWindows = [];
|
|
66
|
+
p.subscribers = {};
|
|
67
|
+
var P = {}, B;
|
|
68
|
+
function se() {
|
|
69
|
+
if (B)
|
|
70
|
+
return P;
|
|
71
|
+
B = 1, Object.defineProperty(P, "__esModule", { value: !0 }), P.dispatch = void 0;
|
|
72
72
|
var r = d();
|
|
73
73
|
function o(n, t, e, i, s) {
|
|
74
74
|
if (r.subscribers[n] && r.subscribers[n][t]) {
|
|
@@ -78,27 +78,27 @@ function te() {
|
|
|
78
78
|
r.subscribers[n][t][u].apply(s, a);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
return
|
|
81
|
+
return P.dispatch = o, P;
|
|
82
82
|
}
|
|
83
|
-
var
|
|
84
|
-
Object.defineProperty(
|
|
85
|
-
|
|
86
|
-
function
|
|
83
|
+
var I = {};
|
|
84
|
+
Object.defineProperty(I, "__esModule", { value: !0 });
|
|
85
|
+
I.hasOpener = void 0;
|
|
86
|
+
function oe(r) {
|
|
87
87
|
return !(r.top !== r || r.opener == null || r.opener === r || r.opener.closed === !0);
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
Object.defineProperty(
|
|
92
|
-
|
|
93
|
-
function
|
|
89
|
+
I.hasOpener = oe;
|
|
90
|
+
var S = {};
|
|
91
|
+
Object.defineProperty(S, "__esModule", { value: !0 });
|
|
92
|
+
S.isntString = void 0;
|
|
93
|
+
function ue(r) {
|
|
94
94
|
return typeof r != "string";
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
var
|
|
98
|
-
function
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
101
|
-
|
|
96
|
+
S.isntString = ue;
|
|
97
|
+
var A = {}, W;
|
|
98
|
+
function ce() {
|
|
99
|
+
if (W)
|
|
100
|
+
return A;
|
|
101
|
+
W = 1, Object.defineProperty(A, "__esModule", { value: !0 }), A.onMessage = void 0;
|
|
102
102
|
var r = d();
|
|
103
103
|
function o(n) {
|
|
104
104
|
if (!(0, r.isntString)(n.data)) {
|
|
@@ -109,13 +109,13 @@ function ae() {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
return
|
|
112
|
+
return A.onMessage = o, A;
|
|
113
113
|
}
|
|
114
|
-
var
|
|
115
|
-
function
|
|
116
|
-
if (
|
|
117
|
-
return
|
|
118
|
-
|
|
114
|
+
var O = {}, $;
|
|
115
|
+
function fe() {
|
|
116
|
+
if ($)
|
|
117
|
+
return O;
|
|
118
|
+
$ = 1, Object.defineProperty(O, "__esModule", { value: !0 }), O.packagePayload = void 0;
|
|
119
119
|
var r = d();
|
|
120
120
|
function o(n, t, e, i) {
|
|
121
121
|
var s, a = {
|
|
@@ -130,23 +130,23 @@ function se() {
|
|
|
130
130
|
}
|
|
131
131
|
return s;
|
|
132
132
|
}
|
|
133
|
-
return
|
|
133
|
+
return O.packagePayload = o, O;
|
|
134
134
|
}
|
|
135
|
-
var
|
|
136
|
-
Object.defineProperty(
|
|
137
|
-
|
|
138
|
-
function
|
|
135
|
+
var j = {};
|
|
136
|
+
Object.defineProperty(j, "__esModule", { value: !0 });
|
|
137
|
+
j.sendMessage = void 0;
|
|
138
|
+
function de(r, o, n) {
|
|
139
139
|
try {
|
|
140
140
|
r.postMessage(o, n);
|
|
141
141
|
} catch {
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
var
|
|
146
|
-
function
|
|
147
|
-
if (
|
|
148
|
-
return
|
|
149
|
-
|
|
144
|
+
j.sendMessage = de;
|
|
145
|
+
var M = {}, T = {}, V;
|
|
146
|
+
function H() {
|
|
147
|
+
if (V)
|
|
148
|
+
return T;
|
|
149
|
+
V = 1, Object.defineProperty(T, "__esModule", { value: !0 }), T.Framebus = void 0;
|
|
150
150
|
var r = d(), o = typeof window < "u" && window.Promise, n = (
|
|
151
151
|
/** @class */
|
|
152
152
|
function() {
|
|
@@ -171,8 +171,8 @@ function U() {
|
|
|
171
171
|
return !1;
|
|
172
172
|
typeof i == "function" && (s = i, i = void 0);
|
|
173
173
|
var u = (0, r.packagePayload)(e, a, i, s);
|
|
174
|
-
return u ? (this.limitBroadcastToFramesArray ? this.targetFramesAsWindows().forEach(function(
|
|
175
|
-
(0, r.sendMessage)(
|
|
174
|
+
return u ? (this.limitBroadcastToFramesArray ? this.targetFramesAsWindows().forEach(function(c) {
|
|
175
|
+
(0, r.sendMessage)(c, u, a);
|
|
176
176
|
}) : (0, r.broadcast)(u, {
|
|
177
177
|
origin: a,
|
|
178
178
|
frame: window.top || window.self
|
|
@@ -180,19 +180,19 @@ function U() {
|
|
|
180
180
|
}, t.prototype.emitAsPromise = function(e, i) {
|
|
181
181
|
var s = this;
|
|
182
182
|
return new t.Promise(function(a, u) {
|
|
183
|
-
var
|
|
184
|
-
a(
|
|
183
|
+
var c = s.emit(e, i, function(f) {
|
|
184
|
+
a(f);
|
|
185
185
|
});
|
|
186
|
-
|
|
186
|
+
c || u(new Error('Listener not added for "'.concat(e, '"')));
|
|
187
187
|
});
|
|
188
188
|
}, t.prototype.on = function(e, i) {
|
|
189
189
|
if (this.isDestroyed)
|
|
190
190
|
return !1;
|
|
191
191
|
var s = this, a = this.origin, u = i;
|
|
192
192
|
return e = this.namespaceEvent(e), (0, r.subscriptionArgsInvalid)(e, u, a) ? !1 : (this.hasAdditionalChecksForOnListeners && (u = function() {
|
|
193
|
-
for (var
|
|
194
|
-
f
|
|
195
|
-
s.passesVerifyDomainCheck(this && this.origin) && s.hasMatchingTargetFrame(this && this.source) && i.apply(void 0,
|
|
193
|
+
for (var c = [], f = 0; f < arguments.length; f++)
|
|
194
|
+
c[f] = arguments[f];
|
|
195
|
+
s.passesVerifyDomainCheck(this && this.origin) && s.hasMatchingTargetFrame(this && this.source) && i.apply(void 0, c);
|
|
196
196
|
}), this.listeners.push({
|
|
197
197
|
eventName: e,
|
|
198
198
|
handler: u,
|
|
@@ -208,15 +208,15 @@ function U() {
|
|
|
208
208
|
u.originalHandler === i && (s = u.handler);
|
|
209
209
|
}
|
|
210
210
|
e = this.namespaceEvent(e);
|
|
211
|
-
var
|
|
212
|
-
if ((0, r.subscriptionArgsInvalid)(e, s,
|
|
211
|
+
var c = this.origin;
|
|
212
|
+
if ((0, r.subscriptionArgsInvalid)(e, s, c))
|
|
213
213
|
return !1;
|
|
214
|
-
var
|
|
215
|
-
if (!
|
|
214
|
+
var f = r.subscribers[c] && r.subscribers[c][e];
|
|
215
|
+
if (!f)
|
|
216
216
|
return !1;
|
|
217
|
-
for (var a = 0; a <
|
|
218
|
-
if (
|
|
219
|
-
return
|
|
217
|
+
for (var a = 0; a < f.length; a++)
|
|
218
|
+
if (f[a] === s)
|
|
219
|
+
return f.splice(a, 1), !0;
|
|
220
220
|
return !1;
|
|
221
221
|
}, t.prototype.teardown = function() {
|
|
222
222
|
if (!this.isDestroyed) {
|
|
@@ -252,28 +252,28 @@ function U() {
|
|
|
252
252
|
}, t.Promise = o, t;
|
|
253
253
|
}()
|
|
254
254
|
);
|
|
255
|
-
return
|
|
255
|
+
return T.Framebus = n, T;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function le() {
|
|
258
258
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
|
|
259
259
|
var o = Math.random() * 16 | 0, n = r === "x" ? o : o & 3 | 8;
|
|
260
260
|
return n.toString(16);
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
|
-
var
|
|
264
|
-
function
|
|
265
|
-
if (
|
|
266
|
-
return
|
|
267
|
-
|
|
268
|
-
var r =
|
|
263
|
+
var he = le, K;
|
|
264
|
+
function pe() {
|
|
265
|
+
if (K)
|
|
266
|
+
return M;
|
|
267
|
+
K = 1;
|
|
268
|
+
var r = y && y.__importDefault || function(e) {
|
|
269
269
|
return e && e.__esModule ? e : { default: e };
|
|
270
270
|
};
|
|
271
|
-
Object.defineProperty(
|
|
272
|
-
var o =
|
|
271
|
+
Object.defineProperty(M, "__esModule", { value: !0 }), M.subscribeReplier = void 0;
|
|
272
|
+
var o = H(), n = r(he);
|
|
273
273
|
function t(e, i) {
|
|
274
274
|
var s = (0, n.default)();
|
|
275
|
-
function a(u,
|
|
276
|
-
e(u,
|
|
275
|
+
function a(u, c) {
|
|
276
|
+
e(u, c), o.Framebus.target({
|
|
277
277
|
origin: i
|
|
278
278
|
}).off(s, a);
|
|
279
279
|
}
|
|
@@ -281,26 +281,26 @@ function fe() {
|
|
|
281
281
|
origin: i
|
|
282
282
|
}).on(s, a), s;
|
|
283
283
|
}
|
|
284
|
-
return
|
|
284
|
+
return M.subscribeReplier = t, M;
|
|
285
285
|
}
|
|
286
|
-
var
|
|
287
|
-
function
|
|
288
|
-
if (
|
|
289
|
-
return
|
|
290
|
-
|
|
286
|
+
var D = {}, U;
|
|
287
|
+
function ve() {
|
|
288
|
+
if (U)
|
|
289
|
+
return D;
|
|
290
|
+
U = 1, Object.defineProperty(D, "__esModule", { value: !0 }), D.subscriptionArgsInvalid = void 0;
|
|
291
291
|
var r = d();
|
|
292
292
|
function o(n, t, e) {
|
|
293
293
|
return (0, r.isntString)(n) || typeof t != "function" ? !0 : (0, r.isntString)(e);
|
|
294
294
|
}
|
|
295
|
-
return
|
|
295
|
+
return D.subscriptionArgsInvalid = o, D;
|
|
296
296
|
}
|
|
297
|
-
var
|
|
298
|
-
Object.defineProperty(
|
|
299
|
-
var
|
|
300
|
-
function
|
|
301
|
-
if (
|
|
302
|
-
return
|
|
303
|
-
|
|
297
|
+
var J = {};
|
|
298
|
+
Object.defineProperty(J, "__esModule", { value: !0 });
|
|
299
|
+
var F = {}, N;
|
|
300
|
+
function ge() {
|
|
301
|
+
if (N)
|
|
302
|
+
return F;
|
|
303
|
+
N = 1, Object.defineProperty(F, "__esModule", { value: !0 }), F.unpackPayload = void 0;
|
|
304
304
|
var r = d();
|
|
305
305
|
function o(n) {
|
|
306
306
|
var t;
|
|
@@ -315,19 +315,19 @@ function le() {
|
|
|
315
315
|
var e = n.origin, i = n.source, s = t.reply;
|
|
316
316
|
t.reply = function(u) {
|
|
317
317
|
if (i) {
|
|
318
|
-
var
|
|
319
|
-
|
|
318
|
+
var c = (0, r.packagePayload)(s, e, u);
|
|
319
|
+
c && i.postMessage(c, e);
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
return t;
|
|
324
324
|
}
|
|
325
|
-
return
|
|
325
|
+
return F.unpackPayload = o, F;
|
|
326
326
|
}
|
|
327
|
-
var
|
|
327
|
+
var G;
|
|
328
328
|
function d() {
|
|
329
|
-
return
|
|
330
|
-
var o =
|
|
329
|
+
return G || (G = 1, function(r) {
|
|
330
|
+
var o = y && y.__createBinding || (Object.create ? function(t, e, i, s) {
|
|
331
331
|
s === void 0 && (s = i);
|
|
332
332
|
var a = Object.getOwnPropertyDescriptor(e, i);
|
|
333
333
|
(!a || ("get" in a ? !e.__esModule : a.writable || a.configurable)) && (a = { enumerable: !0, get: function() {
|
|
@@ -335,77 +335,92 @@ function d() {
|
|
|
335
335
|
} }), Object.defineProperty(t, s, a);
|
|
336
336
|
} : function(t, e, i, s) {
|
|
337
337
|
s === void 0 && (s = i), t[s] = e[i];
|
|
338
|
-
}), n =
|
|
338
|
+
}), n = y && y.__exportStar || function(t, e) {
|
|
339
339
|
for (var i in t)
|
|
340
340
|
i !== "default" && !Object.prototype.hasOwnProperty.call(e, i) && o(e, t, i);
|
|
341
341
|
};
|
|
342
|
-
Object.defineProperty(r, "__esModule", { value: !0 }), n(
|
|
343
|
-
}(
|
|
342
|
+
Object.defineProperty(r, "__esModule", { value: !0 }), n(ie(), r), n(ne(), r), n(ae(), r), n(p, r), n(se(), r), n(I, r), n(S, r), n(ce(), r), n(fe(), r), n(j, r), n(pe(), r), n(ve(), r), n(J, r), n(ge(), r);
|
|
343
|
+
}(R)), R;
|
|
344
344
|
}
|
|
345
|
-
var
|
|
346
|
-
(0,
|
|
347
|
-
var
|
|
348
|
-
const
|
|
345
|
+
var be = d(), ye = H();
|
|
346
|
+
(0, be.attach)();
|
|
347
|
+
var me = ye.Framebus;
|
|
348
|
+
const v = /* @__PURE__ */ te(me), _e = {
|
|
349
349
|
isLoading: !0,
|
|
350
350
|
invokeAction: async () => Promise.reject("Action functionality not initialized."),
|
|
351
351
|
navigate: () => {
|
|
352
352
|
}
|
|
353
|
-
},
|
|
354
|
-
new
|
|
355
|
-
},
|
|
356
|
-
new
|
|
353
|
+
}, z = Z(_e), Fe = () => ee(z), we = (r) => {
|
|
354
|
+
new v().emit("NAVIGATE", { path: r });
|
|
355
|
+
}, Pe = (r, o) => {
|
|
356
|
+
new v().emit("INVOKE_DEFAULT_ACTION", {
|
|
357
357
|
actionKey: "showModalDialog",
|
|
358
358
|
args: [r, o]
|
|
359
359
|
});
|
|
360
|
-
},
|
|
360
|
+
}, Ae = (r, o) => new v().emit("INVOKE_DEFAULT_ACTION", {
|
|
361
361
|
actionKey: "showConfirmationDialog",
|
|
362
362
|
args: [r, o]
|
|
363
|
-
}),
|
|
364
|
-
new
|
|
363
|
+
}), Oe = (r, o) => {
|
|
364
|
+
new v().emit("INVOKE_DEFAULT_ACTION", {
|
|
365
365
|
actionKey: "showToast",
|
|
366
366
|
args: [r, o]
|
|
367
367
|
});
|
|
368
|
-
},
|
|
369
|
-
new
|
|
368
|
+
}, Me = (r, o) => {
|
|
369
|
+
new v().emit("INVOKE_DEFAULT_ACTION", {
|
|
370
370
|
actionKey: "showErrorMessage",
|
|
371
371
|
args: [r, o]
|
|
372
372
|
});
|
|
373
|
-
},
|
|
374
|
-
const [
|
|
375
|
-
|
|
376
|
-
|
|
373
|
+
}, Ee = ({ children: r, config: o }) => {
|
|
374
|
+
const [, n] = C(void 0), [t, e] = C(void 0), [i, s] = C(
|
|
375
|
+
void 0
|
|
376
|
+
), [a, u] = C(!0), c = (E, ...x) => new Promise((l, h) => {
|
|
377
|
+
new v().emit("INVOKE_ACTION", { actionKey: E, args: x }, (b) => {
|
|
378
|
+
b.success ? l(b.result) : h(new Error(b.error));
|
|
377
379
|
});
|
|
378
|
-
})
|
|
379
|
-
|
|
380
|
+
}), f = () => {
|
|
381
|
+
const E = o;
|
|
382
|
+
return Array.isArray(E.menu);
|
|
383
|
+
};
|
|
384
|
+
re(() => {
|
|
380
385
|
if (o.forceRedirect && !o.isDev && window.self === window.top) {
|
|
381
386
|
console.error(
|
|
382
387
|
"This app must be run inside an iframe when forceRedirect is true."
|
|
383
388
|
);
|
|
384
389
|
return;
|
|
385
390
|
}
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
391
|
+
const x = new URL(window.location.href).searchParams.get("c");
|
|
392
|
+
let l;
|
|
393
|
+
return l = x ? new v({ channel: x }) : new v(), l.emit("REQUEST_DATA", { config: o }), l.on("DATA_RESPONSE", (h) => {
|
|
394
|
+
e(h), u(!1);
|
|
395
|
+
}), l.on("PARAMS_RESPONSE", (h) => {
|
|
396
|
+
s(h);
|
|
397
|
+
}), l.on("SET_APP_ID", (h) => {
|
|
398
|
+
const { appId: m } = h;
|
|
399
|
+
n(m);
|
|
400
|
+
}), f() && l.on("NAVIGATE_CHILD", (h) => {
|
|
401
|
+
const { path: m } = h, { navigation: b } = o;
|
|
402
|
+
if (b) {
|
|
403
|
+
const { navigate: X } = b;
|
|
404
|
+
X(m);
|
|
405
|
+
}
|
|
392
406
|
}), () => {
|
|
393
|
-
|
|
407
|
+
l.teardown();
|
|
394
408
|
};
|
|
395
409
|
}, [o]);
|
|
396
|
-
const
|
|
397
|
-
data:
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
410
|
+
const Q = {
|
|
411
|
+
data: t,
|
|
412
|
+
params: i,
|
|
413
|
+
isLoading: a,
|
|
414
|
+
invokeAction: c,
|
|
415
|
+
navigate: we,
|
|
416
|
+
showModalDialog: Pe,
|
|
417
|
+
showConfirmationDialog: Ae,
|
|
418
|
+
showToast: Oe,
|
|
419
|
+
showErrorMessage: Me
|
|
405
420
|
};
|
|
406
|
-
return /* @__PURE__ */ z
|
|
421
|
+
return /* @__PURE__ */ Y(z.Provider, { value: Q, children: r });
|
|
407
422
|
};
|
|
408
423
|
export {
|
|
409
|
-
|
|
410
|
-
|
|
424
|
+
Ee as AppClientProvider,
|
|
425
|
+
Fe as useAppClient
|
|
411
426
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/app-client",
|
|
3
3
|
"description": "Akinon UI App Client. This library is used to create a new plugin or an application which will reside in Akinon's applications.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"framebus": "^6.0.0",
|
|
14
14
|
"postmate": "^1.5.2",
|
|
15
15
|
"use-immer": "^0.9.0",
|
|
16
|
-
"@akinon/app-shared": "^0.
|
|
16
|
+
"@akinon/app-shared": "^0.3.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/postmate": "^1.5.3",
|
|
20
20
|
"clean-package": "2.2.0",
|
|
21
|
-
"eslint-config-custom": "0.1.0",
|
|
22
21
|
"@akinon/vite-config": "^0.1.1",
|
|
22
|
+
"eslint-config-custom": "0.1.0",
|
|
23
23
|
"tsconfig": "0.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|