@akinon/app-client
Advanced tools
Comparing version 0.5.1 to 0.5.3
@@ -0,3 +1,4 @@ | ||
import { default as React } from 'react'; | ||
import { ApplicationData, ApplicationNavigation, ApplicationParams, FullpageApplicationConfig, PluginApplicationConfig, RegisteredApp, RegisteredAppType, ShellNavigation, ShellNavigationPayload } from '@akinon/app-shared'; | ||
import React from 'react'; | ||
/** | ||
@@ -4,0 +5,0 @@ * Defines the context state for the AppClient, including application data, |
@@ -1,28 +0,98 @@ | ||
import { jsx as Y } from "react/jsx-runtime"; | ||
import { createContext as Z, useContext as ee, useState as C, useEffect as re } from "react"; | ||
var y = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; | ||
function te(r) { | ||
import { jsx as ee } from "react/jsx-runtime"; | ||
import { createContext as re, useContext as te, useState as S, useEffect as ie } from "react"; | ||
const l = { | ||
/** | ||
* The event that is emitted when the AppShell sends | ||
* the application ID to the client application. | ||
* | ||
* AppShell → AppClient | ||
*/ | ||
SET_APP_ID: "SET_APP_ID", | ||
/** | ||
* The event that is emitted when client applications | ||
* sends their configuration to the AppShell. | ||
* | ||
* AppClient → AppShell | ||
*/ | ||
SET_CONFIG: "SET_CONFIG", | ||
/** | ||
* The event that is emitted when the AppShell sends | ||
* data to the client application. | ||
* | ||
* AppShell → AppClient | ||
*/ | ||
SET_DATA: "SET_DATA", | ||
/** | ||
* The event that is emitted when client applications | ||
* loads and sends their css height information to the AppShell. | ||
* | ||
* AppClient → AppShell | ||
*/ | ||
SET_HEIGHT: "SET_HEIGHT", | ||
/** | ||
* The event that is emitted to client applications when params property | ||
* passed to the PluginRenderer component is received or changed. | ||
* | ||
* AppShell → AppClient | ||
*/ | ||
SET_PARAMS: "SET_PARAMS", | ||
/** | ||
* The event that is emitted when client applications trigger | ||
* custom actions defined on the AppShell. | ||
* | ||
* AppClient → AppShell | ||
*/ | ||
INVOKE_ACTION: "INVOKE_ACTION", | ||
/** | ||
* The event that is emitted when client applications trigger | ||
* default actions defined on the AppShell. | ||
* | ||
* AppClient → AppShell | ||
*/ | ||
INVOKE_DEFAULT_ACTION: "INVOKE_DEFAULT_ACTION", | ||
/** | ||
* The event that is emitted when client applications trigger | ||
* navigation for their shell application. | ||
* | ||
* AppClient → AppShell | ||
*/ | ||
NAVIGATE: "NAVIGATE", | ||
/** | ||
* The event that is emitted when shell applications trigger | ||
* navigation for their child applications. | ||
* | ||
* AppShell → AppClient | ||
*/ | ||
NAVIGATE_CHILD: "NAVIGATE_CHILD" | ||
}, x = { | ||
showConfirmationDialog: "showConfirmationDialog", | ||
showModalDialog: "showModalDialog", | ||
showToast: "showToast", | ||
showErrorMessage: "showErrorMessage" | ||
}; | ||
var m = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; | ||
function ne(r) { | ||
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; | ||
} | ||
var R = {}, g = {}, q; | ||
function ie() { | ||
if (q) | ||
return g; | ||
q = 1, Object.defineProperty(g, "__esModule", { value: !0 }), g.detach = g.attach = void 0; | ||
var r = l(), o = !1; | ||
var q = {}, b = {}, N; | ||
function ae() { | ||
if (N) | ||
return b; | ||
N = 1, Object.defineProperty(b, "__esModule", { value: !0 }), b.detach = b.attach = void 0; | ||
var r = h(), o = !1; | ||
function n() { | ||
o || typeof window > "u" || (o = !0, window.addEventListener("message", r.onMessage, !1)); | ||
} | ||
g.attach = n; | ||
b.attach = n; | ||
function t() { | ||
o = !1, window.removeEventListener("message", r.onMessage, !1); | ||
} | ||
return g.detach = t, g; | ||
return b.detach = t, b; | ||
} | ||
var _ = {}, L; | ||
function ne() { | ||
if (L) | ||
return _; | ||
L = 1, Object.defineProperty(_, "__esModule", { value: !0 }), _.broadcastToChildWindows = void 0; | ||
var r = l(); | ||
var w = {}, V; | ||
function se() { | ||
if (V) | ||
return w; | ||
V = 1, Object.defineProperty(w, "__esModule", { value: !0 }), w.broadcastToChildWindows = void 0; | ||
var r = h(); | ||
function o(n, t, e) { | ||
@@ -37,10 +107,10 @@ for (var i = r.childWindows.length - 1; i >= 0; i--) { | ||
} | ||
return _.broadcastToChildWindows = o, _; | ||
return w.broadcastToChildWindows = o, w; | ||
} | ||
var w = {}, k; | ||
function ae() { | ||
var A = {}, k; | ||
function oe() { | ||
if (k) | ||
return w; | ||
k = 1, Object.defineProperty(w, "__esModule", { value: !0 }), w.broadcast = void 0; | ||
var r = l(); | ||
return A; | ||
k = 1, Object.defineProperty(A, "__esModule", { value: !0 }), A.broadcast = void 0; | ||
var r = h(); | ||
function o(n, t) { | ||
@@ -60,16 +130,16 @@ var e = 0, i, s = t.origin, a = t.frame; | ||
} | ||
return w.broadcast = o, w; | ||
return A.broadcast = o, A; | ||
} | ||
var p = {}; | ||
Object.defineProperty(p, "__esModule", { value: !0 }); | ||
p.subscribers = p.childWindows = p.prefix = void 0; | ||
p.prefix = "/*framebus*/"; | ||
p.childWindows = []; | ||
p.subscribers = {}; | ||
var P = {}, B; | ||
function se() { | ||
var v = {}; | ||
Object.defineProperty(v, "__esModule", { value: !0 }); | ||
v.subscribers = v.childWindows = v.prefix = void 0; | ||
v.prefix = "/*framebus*/"; | ||
v.childWindows = []; | ||
v.subscribers = {}; | ||
var T = {}, B; | ||
function ue() { | ||
if (B) | ||
return P; | ||
B = 1, Object.defineProperty(P, "__esModule", { value: !0 }), P.dispatch = void 0; | ||
var r = l(); | ||
return T; | ||
B = 1, Object.defineProperty(T, "__esModule", { value: !0 }), T.dispatch = void 0; | ||
var r = h(); | ||
function o(n, t, e, i, s) { | ||
@@ -83,24 +153,24 @@ if (r.subscribers[n] && r.subscribers[n][t]) { | ||
} | ||
return P.dispatch = o, P; | ||
return T.dispatch = o, T; | ||
} | ||
var I = {}; | ||
Object.defineProperty(I, "__esModule", { value: !0 }); | ||
I.hasOpener = void 0; | ||
function oe(r) { | ||
var j = {}; | ||
Object.defineProperty(j, "__esModule", { value: !0 }); | ||
j.hasOpener = void 0; | ||
function ce(r) { | ||
return !(r.top !== r || r.opener == null || r.opener === r || r.opener.closed === !0); | ||
} | ||
I.hasOpener = oe; | ||
var S = {}; | ||
Object.defineProperty(S, "__esModule", { value: !0 }); | ||
S.isntString = void 0; | ||
function ue(r) { | ||
j.hasOpener = ce; | ||
var R = {}; | ||
Object.defineProperty(R, "__esModule", { value: !0 }); | ||
R.isntString = void 0; | ||
function fe(r) { | ||
return typeof r != "string"; | ||
} | ||
S.isntString = ue; | ||
var A = {}, W; | ||
function ce() { | ||
if (W) | ||
return A; | ||
W = 1, Object.defineProperty(A, "__esModule", { value: !0 }), A.onMessage = void 0; | ||
var r = l(); | ||
R.isntString = fe; | ||
var P = {}, G; | ||
function de() { | ||
if (G) | ||
return P; | ||
G = 1, Object.defineProperty(P, "__esModule", { value: !0 }), P.onMessage = void 0; | ||
var r = h(); | ||
function o(n) { | ||
@@ -115,10 +185,10 @@ if (!(0, r.isntString)(n.data)) { | ||
} | ||
return A.onMessage = o, A; | ||
return P.onMessage = o, P; | ||
} | ||
var O = {}, $; | ||
function fe() { | ||
if ($) | ||
return O; | ||
$ = 1, Object.defineProperty(O, "__esModule", { value: !0 }), O.packagePayload = void 0; | ||
var r = l(); | ||
var E = {}, K; | ||
function le() { | ||
if (K) | ||
return E; | ||
K = 1, Object.defineProperty(E, "__esModule", { value: !0 }), E.packagePayload = void 0; | ||
var r = h(); | ||
function o(n, t, e, i) { | ||
@@ -137,8 +207,8 @@ var s, a = { | ||
} | ||
return O.packagePayload = o, O; | ||
return E.packagePayload = o, E; | ||
} | ||
var j = {}; | ||
Object.defineProperty(j, "__esModule", { value: !0 }); | ||
j.sendMessage = void 0; | ||
function de(r, o, n) { | ||
var L = {}; | ||
Object.defineProperty(L, "__esModule", { value: !0 }); | ||
L.sendMessage = void 0; | ||
function he(r, o, n) { | ||
try { | ||
@@ -149,9 +219,9 @@ r.postMessage(o, n); | ||
} | ||
j.sendMessage = de; | ||
var M = {}, T = {}, V; | ||
function G() { | ||
if (V) | ||
return T; | ||
V = 1, Object.defineProperty(T, "__esModule", { value: !0 }), T.Framebus = void 0; | ||
var r = l(), o = typeof window < "u" && window.Promise, n = ( | ||
L.sendMessage = he; | ||
var O = {}, D = {}, W; | ||
function z() { | ||
if (W) | ||
return D; | ||
W = 1, Object.defineProperty(D, "__esModule", { value: !0 }), D.Framebus = void 0; | ||
var r = h(), o = typeof window < "u" && window.Promise, n = ( | ||
/** @class */ | ||
@@ -261,5 +331,5 @@ function() { | ||
); | ||
return T.Framebus = n, T; | ||
return D.Framebus = n, D; | ||
} | ||
function le() { | ||
function pe() { | ||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) { | ||
@@ -270,12 +340,12 @@ var o = Math.random() * 16 | 0, n = r === "x" ? o : o & 3 | 8; | ||
} | ||
var he = le, K; | ||
function pe() { | ||
if (K) | ||
return M; | ||
K = 1; | ||
var r = y && y.__importDefault || function(e) { | ||
var ve = pe, $; | ||
function ge() { | ||
if ($) | ||
return O; | ||
$ = 1; | ||
var r = m && m.__importDefault || function(e) { | ||
return e && e.__esModule ? e : { default: e }; | ||
}; | ||
Object.defineProperty(M, "__esModule", { value: !0 }), M.subscribeReplier = void 0; | ||
var o = G(), n = r(he); | ||
Object.defineProperty(O, "__esModule", { value: !0 }), O.subscribeReplier = void 0; | ||
var o = z(), n = r(ve); | ||
function t(e, i) { | ||
@@ -292,23 +362,23 @@ var s = (0, n.default)(); | ||
} | ||
return M.subscribeReplier = t, M; | ||
return O.subscribeReplier = t, O; | ||
} | ||
var D = {}, U; | ||
function ve() { | ||
if (U) | ||
return D; | ||
U = 1, Object.defineProperty(D, "__esModule", { value: !0 }), D.subscriptionArgsInvalid = void 0; | ||
var r = l(); | ||
var I = {}, H; | ||
function be() { | ||
if (H) | ||
return I; | ||
H = 1, Object.defineProperty(I, "__esModule", { value: !0 }), I.subscriptionArgsInvalid = void 0; | ||
var r = h(); | ||
function o(n, t, e) { | ||
return (0, r.isntString)(n) || typeof t != "function" ? !0 : (0, r.isntString)(e); | ||
} | ||
return D.subscriptionArgsInvalid = o, D; | ||
return I.subscriptionArgsInvalid = o, I; | ||
} | ||
var J = {}; | ||
Object.defineProperty(J, "__esModule", { value: !0 }); | ||
var E = {}, N; | ||
function ge() { | ||
if (N) | ||
return E; | ||
N = 1, Object.defineProperty(E, "__esModule", { value: !0 }), E.unpackPayload = void 0; | ||
var r = l(); | ||
var Q = {}; | ||
Object.defineProperty(Q, "__esModule", { value: !0 }); | ||
var M = {}, U; | ||
function ye() { | ||
if (U) | ||
return M; | ||
U = 1, Object.defineProperty(M, "__esModule", { value: !0 }), M.unpackPayload = void 0; | ||
var r = h(); | ||
function o(n) { | ||
@@ -334,8 +404,8 @@ var t; | ||
} | ||
return E.unpackPayload = o, E; | ||
return M.unpackPayload = o, M; | ||
} | ||
var H; | ||
function l() { | ||
return H || (H = 1, function(r) { | ||
var o = y && y.__createBinding || (Object.create ? function(t, e, i, s) { | ||
var J; | ||
function h() { | ||
return J || (J = 1, function(r) { | ||
var o = m && m.__createBinding || (Object.create ? function(t, e, i, s) { | ||
s === void 0 && (s = i); | ||
@@ -348,13 +418,13 @@ var a = Object.getOwnPropertyDescriptor(e, i); | ||
s === void 0 && (s = i), t[s] = e[i]; | ||
}), n = y && y.__exportStar || function(t, e) { | ||
}), 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(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); | ||
}(R)), R; | ||
Object.defineProperty(r, "__esModule", { value: !0 }), n(ae(), r), n(se(), r), n(oe(), r), n(v, r), n(ue(), r), n(j, r), n(R, r), n(de(), r), n(le(), r), n(L, r), n(ge(), r), n(be(), r), n(Q, r), n(ye(), r); | ||
}(q)), q; | ||
} | ||
var be = l(), ye = G(); | ||
(0, be.attach)(); | ||
var me = ye.Framebus; | ||
const v = /* @__PURE__ */ te(me), _e = { | ||
var me = h(), _e = z(); | ||
(0, me.attach)(); | ||
var we = _e.Framebus; | ||
const g = /* @__PURE__ */ ne(we), Ae = { | ||
isLoading: !0, | ||
@@ -364,28 +434,28 @@ invokeAction: async () => Promise.reject("Action functionality not initialized."), | ||
} | ||
}, z = Z(_e), Ee = () => ee(z), we = (r) => { | ||
new v().emit("NAVIGATE", { ...r }); | ||
}, X = re(Ae), Fe = () => te(X), Te = (r) => { | ||
new g().emit(l.NAVIGATE, { ...r }); | ||
}, Pe = (r, o) => { | ||
new v().emit("INVOKE_DEFAULT_ACTION", { | ||
actionKey: "showModalDialog", | ||
new g().emit(l.INVOKE_DEFAULT_ACTION, { | ||
actionKey: x.showModalDialog, | ||
args: [r, o] | ||
}); | ||
}, Ae = (r, o) => new v().emit("INVOKE_DEFAULT_ACTION", { | ||
actionKey: "showConfirmationDialog", | ||
}, Ee = (r, o) => new g().emit(l.INVOKE_DEFAULT_ACTION, { | ||
actionKey: x.showConfirmationDialog, | ||
args: [r, o] | ||
}), Oe = (r, o) => { | ||
new v().emit("INVOKE_DEFAULT_ACTION", { | ||
actionKey: "showToast", | ||
new g().emit(l.INVOKE_DEFAULT_ACTION, { | ||
actionKey: x.showToast, | ||
args: [r, o] | ||
}); | ||
}, Me = (r, o) => { | ||
new v().emit("INVOKE_DEFAULT_ACTION", { | ||
actionKey: "showErrorMessage", | ||
}, De = (r, o) => { | ||
new g().emit(l.INVOKE_DEFAULT_ACTION, { | ||
actionKey: x.showErrorMessage, | ||
args: [r, o] | ||
}); | ||
}, Fe = ({ children: r, config: o }) => { | ||
const [, n] = C(void 0), [t, e] = C(void 0), [i, s] = C( | ||
}, Ce = ({ children: r, config: o }) => { | ||
const [, n] = S(void 0), [t, e] = S(void 0), [i, s] = S( | ||
void 0 | ||
), [a, u] = C(!0), c = (F, ...x) => new Promise((h, d) => { | ||
new v().emit("INVOKE_ACTION", { actionKey: F, args: x }, (b) => { | ||
b.success ? h(b.result) : d(new Error(b.error)); | ||
), [a, u] = S(!0), c = (F, ...C) => new Promise((p, d) => { | ||
new g().emit(l.INVOKE_ACTION, { actionKey: F, args: C }, (y) => { | ||
y.success ? p(y.result) : d(new Error(y.error)); | ||
}); | ||
@@ -396,3 +466,3 @@ }), f = () => { | ||
}; | ||
re(() => { | ||
ie(() => { | ||
if (o.forceRedirect && !o.isDev && window.self === window.top) { | ||
@@ -404,25 +474,25 @@ console.error( | ||
} | ||
const x = new URL(window.location.href).searchParams.get("c"), h = x ? new v({ channel: x }) : new v(); | ||
if (h.emit("REQUEST_DATA", { config: o }), h.on("DATA_RESPONSE", (d) => { | ||
const C = new URL(window.location.href).searchParams.get("c"), p = C ? new g({ channel: C }) : new g(); | ||
if (p.emit(l.SET_CONFIG, { config: o }), p.on(l.SET_DATA, (d) => { | ||
e(d), u(!1); | ||
}), h.on("PARAMS_RESPONSE", (d) => { | ||
}), p.on(l.SET_PARAMS, (d) => { | ||
s(d); | ||
}), h.on("SET_APP_ID", (d) => { | ||
const { appId: m } = d; | ||
n(m); | ||
}), p.on(l.SET_APP_ID, (d) => { | ||
const { appId: _ } = d; | ||
n(_); | ||
}), !f()) { | ||
const d = document.getElementsByTagName("html")[0].offsetHeight; | ||
d > 0 && window.name && h.emit("SET_HEIGHT", { height: d, id: window.name }); | ||
d > 0 && window.name && p.emit(l.SET_HEIGHT, { height: d, id: window.name }); | ||
} | ||
return f() && h.on("NAVIGATE_CHILD", (d) => { | ||
const { path: m } = d, { navigation: b } = o; | ||
if (b) { | ||
const { navigate: X } = b; | ||
X({ path: m }); | ||
return f() && p.on(l.NAVIGATE_CHILD, (d) => { | ||
const { path: _ } = d, { navigation: y } = o; | ||
if (y) { | ||
const { navigate: Z } = y; | ||
Z({ path: _ }); | ||
} | ||
}), () => { | ||
h.teardown(); | ||
p.teardown(); | ||
}; | ||
}, [o]); | ||
const Q = { | ||
const Y = { | ||
data: t, | ||
@@ -432,13 +502,13 @@ params: i, | ||
invokeAction: c, | ||
navigate: we, | ||
navigate: Te, | ||
showModalDialog: Pe, | ||
showConfirmationDialog: Ae, | ||
showConfirmationDialog: Ee, | ||
showToast: Oe, | ||
showErrorMessage: Me | ||
showErrorMessage: De | ||
}; | ||
return /* @__PURE__ */ Y(z.Provider, { value: Q, children: r }); | ||
return /* @__PURE__ */ ee(X.Provider, { value: Y, children: r }); | ||
}; | ||
export { | ||
Fe as AppClientProvider, | ||
Ee as useAppClient | ||
Ce as AppClientProvider, | ||
Fe as useAppClient | ||
}; |
{ | ||
"name": "@akinon/app-client", | ||
"description": "Akinon UI App Client. This library is used to create a new plugin or an application which will reside in Akinon's applications.", | ||
"version": "0.5.1", | ||
"description": "Akinon AppClient library. This library is used to create a new plugin or an application which will reside in Akinon's applications.", | ||
"version": "0.5.3", | ||
"private": false, | ||
@@ -14,17 +14,12 @@ "type": "module", | ||
"framebus": "^6.0.0", | ||
"postmate": "^1.5.2", | ||
"use-immer": "^0.9.0", | ||
"@akinon/app-shared": "^0.4.1" | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"@akinon/app-shared": "^0.5.1" | ||
}, | ||
"devDependencies": { | ||
"@types/postmate": "^1.5.3", | ||
"clean-package": "2.2.0", | ||
"@akinon/vite-config": "^0.1.1", | ||
"eslint-config-custom": "0.1.0", | ||
"@akinon/vite-config": "^0.1.1", | ||
"tsconfig": "0.0.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "18.x", | ||
"react-dom": "18.x" | ||
}, | ||
"clean-package": "../../clean-package.config.json", | ||
@@ -31,0 +26,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34092
4
4
590
+ Addedreact@^18.2.0
+ Addedreact-dom@^18.2.0
+ Added@akinon/app-shared@0.5.1(transitive)
- Removedpostmate@^1.5.2
- Removeduse-immer@^0.9.0
- Removed@akinon/app-shared@0.4.1(transitive)
- Removedimmer@10.1.1(transitive)
- Removedpostmate@1.5.2(transitive)
- Removeduse-immer@0.9.0(transitive)
Updated@akinon/app-shared@^0.5.1