@machinemetrics/mm-react-embeddable 0.9.13 → 0.10.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.
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),b=require("prop-types"),h=require("styled-components"),g=e.createContext(null),w=({children:r})=>{const[n,i]=e.useState({}),o=e.useRef({}),u=e.useCallback((s,t,c)=>{i(a=>({...a,[s]:{origin:t,frameRef:c}}))},[]);e.useEffect(()=>{const s=t=>{var a,l;if(!((a=t==null?void 0:t.data)!=null&&a.instanceId))return;(((l=o.current[t.data.instanceId])==null?void 0:l[t.data.type])||[]).forEach(M=>M(t.data))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},[n]);const d=e.useCallback((s,t,c)=>{const a=n[s];if(!a){console.warn(`Origin not set for id: ${s}. Unable to send message.`);return}a.frameRef.current.contentWindow.postMessage({type:t,...c,instanceId:s},a.origin)},[n]),f={testIsEmbeddable:R,registerFrame:u,sendMessage:d,addListener:(s,t,c)=>(o.current[s]||(o.current[s]={}),o.current[s][t]||(o.current[s][t]=[]),o.current[s][t].push(c),()=>{o.current[s][t]=o.current[s][t].filter(a=>a!==c)})};return e.createElement(g.Provider,{value:f},r)},E={},R=async r=>{try{const n=new URL(r).origin;if(E[n]!==void 0)return E[n];if(!(await(await fetch(`${n}/mm-app-manifest.json`)).json()).version)throw new Error("Invalid manifest");return E[n]=!0,!0}catch{}return E[origin]=!1,!1},I=(r,n,i)=>{const o=e.useContext(g);if(o===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const u=e.useRef(i);return e.useEffect(()=>{u.current=i},[i]),e.useEffect(()=>{if(!(!r||!n))return o.addListener(r,n,(...d)=>u.current(...d))},[o,r,n]),e.useCallback((d,f)=>o.sendMessage(r,d,f),[o,r])};w.propTypes={children:b.node.isRequired};const P=h.default||h,S=P.iframe`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),m=require("prop-types"),R=require("styled-components"),p=t.createContext(null),I=({children:n})=>{const[o,c]=t.useState({}),s=t.useRef({}),u=t.useCallback((r,e,d)=>{c(a=>({...a,[r]:{origin:e,frameRef:d}}))},[]);t.useEffect(()=>{const r=e=>{var a,f;if(!((a=e==null?void 0:e.data)!=null&&a.instanceId))return;(((f=s.current[e.data.instanceId])==null?void 0:f[e.data.type])||[]).forEach(M=>M(e.data))};return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},[o]);const i=t.useCallback((r,e,d)=>{const a=o[r];if(!a){console.warn(`Origin not set for id: ${r}. Unable to send message.`);return}a.frameRef.current.contentWindow.postMessage({type:e,...d,instanceId:r},a.origin)},[o]),b=t.useCallback((r,e)=>{i(r,"load-options",e)},[i]),l=t.useCallback((r,e)=>{i(r,"validate",e)},[i]),y={registerFrame:u,sendMessage:i,loadOptions:b,validate:l,addListener:(r,e,d)=>(s.current[r]||(s.current[r]={}),s.current[r][e]||(s.current[r][e]=[]),s.current[r][e].push(d),()=>{s.current[r][e]=s.current[r][e].filter(a=>a!==d)})};return t.createElement(p.Provider,{value:y},n)},g={},v=async n=>{try{const o=new URL(n).origin;if(g[o]!==void 0)return g[o];const s=await(await fetch(`${o}/mm-app-manifest.json`)).json();if(!s.version)throw new Error("Invalid manifest");return g[o]=s,s}catch{}return g[origin]=!1,!1},C=async n=>!!await v(n),x=(n,o,c)=>{const s=t.useContext(p);if(s===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const u=t.useRef(c);return t.useEffect(()=>{u.current=c},[c]),t.useEffect(()=>{if(!(!n||!o))return s.addListener(n,o,(...i)=>u.current(...i))},[s,n,o]),t.useCallback((i,b)=>s.sendMessage(n,i,b),[s,n])};I.propTypes={children:m.node.isRequired};const S=R.default||R,Z=S.iframe`
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  border: none;
5
- visibility: ${r=>r.isready?"visible":"hidden"};
6
- `,C=({id:r,src:n,path:i,onInit:o=()=>{},...u})=>{const d=e.useRef(),[f,s]=e.useState(),[t,c]=e.useState(0),{registerFrame:a,sendMessage:l,testIsEmbeddable:M}=e.useContext(g),[v,x]=e.useState(!0),[p,L]=e.useState();return e.useEffect(()=>{i!==void 0&&L(i)},[i]),e.useEffect(()=>{p===void 0||!t||l(r,"navigate",{path:p})},[p,t,r,l]),e.useEffect(()=>{!n||!r||!d||(async()=>{const m=M(n);if(x(m),m){const y=new URL(n);a(r,y.origin,d),o(),s(`${y.origin}/mm-embedded-interop?id=${r}`);return}})()},[n,r,a,d]),I(r,"ready",()=>c(m=>m+1)),v?e.createElement(S,{isready:t,ref:d,src:f,...u}):e.createElement("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("div",{style:{textAlign:"center"}},"Application must adhere to the MM App Manifest specification to be embedded."))};C.propTypes={id:b.string,src:b.string.isRequired,path:b.string,onInit:b.func};exports.MMEmbeddableZone=C;exports.MMEmbeddableZoneContext=g;exports.MMEmbeddableZoneProvider=w;exports.testIsEmbeddable=R;exports.useEmbeddedEffect=I;
5
+ visibility: ${n=>n.$isReady?"visible":"hidden"};
6
+ `,L=({id:n,src:o,path:c,onInit:s=()=>{},context:u,isConfiguring:i,...b})=>{const l=t.useRef(),[y,r]=t.useState(),[e,d]=t.useState(0),{registerFrame:a,sendMessage:f}=t.useContext(p),[M,P]=t.useState(!0),[w,$]=t.useState();return t.useEffect(()=>{e&&f(n,"set-context",{context:u})},[u,n,e]),t.useEffect(()=>{c!==void 0&&$(c)},[c]),t.useEffect(()=>{w===void 0||!e||f(n,"navigate",{path:w})},[w,e,n,f]),t.useEffect(()=>{e&&f(n,"set-configuring",{isConfiguring:i})},[e,i]),t.useEffect(()=>{!o||!n||!l||(async()=>{const E=await C(o);if(P(E),E){const h=new URL(o);a(n,h.origin,l),s(),r(`${h.origin}/mm-embedded-interop?id=${n}&origin=${window.location.origin}`);return}})()},[o,n,a,l]),x(n,"ready",()=>d(E=>E+1)),M?t.createElement(Z,{$isReady:e,ref:l,src:y,...b}):t.createElement("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},t.createElement("div",{style:{textAlign:"center"}},"Application must adhere to the MM App Manifest specification to be embedded."))};L.propTypes={id:m.string,src:m.string.isRequired,path:m.string,onInit:m.func};exports.MMEmbeddableZone=L;exports.MMEmbeddableZoneContext=p;exports.MMEmbeddableZoneProvider=I;exports.getAppInfo=v;exports.testIsEmbeddable=C;exports.useEmbeddedEffect=x;
@@ -1,102 +1,126 @@
1
- import E, { createContext as $, useState as m, useRef as M, useCallback as w, useEffect as u, useContext as x } from "react";
1
+ import y, { createContext as C, useState as g, useRef as I, useCallback as p, useEffect as d, useContext as x } from "react";
2
2
  import b from "prop-types";
3
- import L from "styled-components";
4
- const R = $(null), F = ({ children: t }) => {
5
- const [r, i] = m({}), s = M({}), c = w((n, e, d) => {
6
- i((o) => ({ ...o, [n]: { origin: e, frameRef: d } }));
3
+ import $ from "styled-components";
4
+ const v = C(null), F = ({ children: t }) => {
5
+ const [s, a] = g({}), n = I({}), u = p((r, e, c) => {
6
+ a((o) => ({ ...o, [r]: { origin: e, frameRef: c } }));
7
7
  }, []);
8
- u(() => {
9
- const n = (e) => {
10
- var o, l;
8
+ d(() => {
9
+ const r = (e) => {
10
+ var o, f;
11
11
  if (!((o = e == null ? void 0 : e.data) != null && o.instanceId))
12
12
  return;
13
- (((l = s.current[e.data.instanceId]) == null ? void 0 : l[e.data.type]) || []).forEach((h) => h(e.data));
13
+ (((f = n.current[e.data.instanceId]) == null ? void 0 : f[e.data.type]) || []).forEach((M) => M(e.data));
14
14
  };
15
- return window.addEventListener("message", n), () => {
16
- window.removeEventListener("message", n);
15
+ return window.addEventListener("message", r), () => {
16
+ window.removeEventListener("message", r);
17
17
  };
18
- }, [r]);
19
- const a = w(
20
- (n, e, d) => {
21
- const o = r[n];
18
+ }, [s]);
19
+ const i = p(
20
+ (r, e, c) => {
21
+ const o = s[r];
22
22
  if (!o) {
23
- console.warn(`Origin not set for id: ${n}. Unable to send message.`);
23
+ console.warn(`Origin not set for id: ${r}. Unable to send message.`);
24
24
  return;
25
25
  }
26
26
  o.frameRef.current.contentWindow.postMessage(
27
- { type: e, ...d, instanceId: n },
27
+ { type: e, ...c, instanceId: r },
28
28
  o.origin
29
29
  );
30
30
  },
31
- [r]
32
- ), f = {
33
- testIsEmbeddable: U,
34
- registerFrame: c,
35
- sendMessage: a,
36
- addListener: (n, e, d) => (s.current[n] || (s.current[n] = {}), s.current[n][e] || (s.current[n][e] = []), s.current[n][e].push(d), () => {
37
- s.current[n][e] = s.current[n][e].filter((o) => o !== d);
31
+ [s]
32
+ ), m = p(
33
+ (r, e) => {
34
+ i(r, "load-options", e);
35
+ },
36
+ [i]
37
+ ), l = p(
38
+ (r, e) => {
39
+ i(r, "validate", e);
40
+ },
41
+ [i]
42
+ ), h = {
43
+ registerFrame: u,
44
+ sendMessage: i,
45
+ loadOptions: m,
46
+ validate: l,
47
+ addListener: (r, e, c) => (n.current[r] || (n.current[r] = {}), n.current[r][e] || (n.current[r][e] = []), n.current[r][e].push(c), () => {
48
+ n.current[r][e] = n.current[r][e].filter((o) => o !== c);
38
49
  })
39
50
  };
40
- return /* @__PURE__ */ E.createElement(R.Provider, { value: f }, t);
41
- }, p = {}, U = async (t) => {
51
+ return /* @__PURE__ */ y.createElement(v.Provider, { value: h }, t);
52
+ }, w = {}, U = async (t) => {
42
53
  try {
43
- const r = new URL(t).origin;
44
- if (p[r] !== void 0)
45
- return p[r];
46
- if (!(await (await fetch(`${r}/mm-app-manifest.json`)).json()).version)
54
+ const s = new URL(t).origin;
55
+ if (w[s] !== void 0)
56
+ return w[s];
57
+ const n = await (await fetch(`${s}/mm-app-manifest.json`)).json();
58
+ if (!n.version)
47
59
  throw new Error("Invalid manifest");
48
- return p[r] = !0, !0;
60
+ return w[s] = n, n;
49
61
  } catch {
50
62
  }
51
- return p[origin] = !1, !1;
52
- }, Z = (t, r, i) => {
53
- const s = x(R);
54
- if (s === null)
63
+ return w[origin] = !1, !1;
64
+ }, Z = async (t) => !!await U(t), j = (t, s, a) => {
65
+ const n = x(v);
66
+ if (n === null)
55
67
  throw new Error(
56
68
  "useEmbeddedEffect must be used within a MMEmbeddableZoneProvider"
57
69
  );
58
- const c = M(i);
59
- return u(() => {
60
- c.current = i;
61
- }, [i]), u(() => {
62
- if (!(!t || !r))
63
- return s.addListener(
70
+ const u = I(a);
71
+ return d(() => {
72
+ u.current = a;
73
+ }, [a]), d(() => {
74
+ if (!(!t || !s))
75
+ return n.addListener(
64
76
  t,
65
- r,
66
- (...a) => c.current(...a)
77
+ s,
78
+ (...i) => u.current(...i)
67
79
  );
68
- }, [s, t, r]), w(
69
- (a, f) => s.sendMessage(t, a, f),
70
- [s, t]
80
+ }, [n, t, s]), p(
81
+ (i, m) => n.sendMessage(t, i, m),
82
+ [n, t]
71
83
  );
72
84
  };
73
85
  F.propTypes = {
74
86
  children: b.node.isRequired
75
87
  };
76
- const j = L.default || L, A = j.iframe`
88
+ const O = $.default || $, T = O.iframe`
77
89
  width: 100%;
78
90
  height: 100%;
79
91
  border: none;
80
- visibility: ${(t) => t.isready ? "visible" : "hidden"};
81
- `, T = ({ id: t, src: r, path: i, onInit: s = () => {
82
- }, ...c }) => {
83
- const a = M(), [f, n] = m(), [e, d] = m(0), { registerFrame: o, sendMessage: l, testIsEmbeddable: h } = x(
84
- R
85
- ), [v, P] = m(!0), [y, C] = m();
86
- return u(() => {
87
- i !== void 0 && C(i);
88
- }, [i]), u(() => {
89
- y === void 0 || !e || l(t, "navigate", { path: y });
90
- }, [y, e, t, l]), u(() => {
91
- !r || !t || !a || (async () => {
92
- const g = h(r);
93
- if (P(g), g) {
94
- const I = new URL(r);
95
- o(t, I.origin, a), s(), n(`${I.origin}/mm-embedded-interop?id=${t}`);
92
+ visibility: ${(t) => t.$isReady ? "visible" : "hidden"};
93
+ `, q = ({
94
+ id: t,
95
+ src: s,
96
+ path: a,
97
+ onInit: n = () => {
98
+ },
99
+ context: u,
100
+ isConfiguring: i,
101
+ ...m
102
+ }) => {
103
+ const l = I(), [h, r] = g(), [e, c] = g(0), { registerFrame: o, sendMessage: f } = x(v), [M, P] = g(!0), [R, A] = g();
104
+ return d(() => {
105
+ e && f(t, "set-context", { context: u });
106
+ }, [u, t, e]), d(() => {
107
+ a !== void 0 && A(a);
108
+ }, [a]), d(() => {
109
+ R === void 0 || !e || f(t, "navigate", { path: R });
110
+ }, [R, e, t, f]), d(() => {
111
+ e && f(t, "set-configuring", { isConfiguring: i });
112
+ }, [e, i]), d(() => {
113
+ !s || !t || !l || (async () => {
114
+ const E = await Z(s);
115
+ if (P(E), E) {
116
+ const L = new URL(s);
117
+ o(t, L.origin, l), n(), r(
118
+ `${L.origin}/mm-embedded-interop?id=${t}&origin=${window.location.origin}`
119
+ );
96
120
  return;
97
121
  }
98
122
  })();
99
- }, [r, t, o, a]), Z(t, "ready", () => d((g) => g + 1)), v ? /* @__PURE__ */ E.createElement(A, { isready: e, ref: a, src: f, ...c }) : /* @__PURE__ */ E.createElement(
123
+ }, [s, t, o, l]), j(t, "ready", () => c((E) => E + 1)), M ? /* @__PURE__ */ y.createElement(T, { $isReady: e, ref: l, src: h, ...m }) : /* @__PURE__ */ y.createElement(
100
124
  "div",
101
125
  {
102
126
  style: {
@@ -106,19 +130,20 @@ const j = L.default || L, A = j.iframe`
106
130
  justifyContent: "center"
107
131
  }
108
132
  },
109
- /* @__PURE__ */ E.createElement("div", { style: { textAlign: "center" } }, "Application must adhere to the MM App Manifest specification to be embedded.")
133
+ /* @__PURE__ */ y.createElement("div", { style: { textAlign: "center" } }, "Application must adhere to the MM App Manifest specification to be embedded.")
110
134
  );
111
135
  };
112
- T.propTypes = {
136
+ q.propTypes = {
113
137
  id: b.string,
114
138
  src: b.string.isRequired,
115
139
  path: b.string,
116
140
  onInit: b.func
117
141
  };
118
142
  export {
119
- T as MMEmbeddableZone,
120
- R as MMEmbeddableZoneContext,
143
+ q as MMEmbeddableZone,
144
+ v as MMEmbeddableZoneContext,
121
145
  F as MMEmbeddableZoneProvider,
122
- U as testIsEmbeddable,
123
- Z as useEmbeddedEffect
146
+ U as getAppInfo,
147
+ Z as testIsEmbeddable,
148
+ j as useEmbeddedEffect
124
149
  };
@@ -1,6 +1,6 @@
1
- (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react"),require("prop-types"),require("styled-components")):typeof define=="function"&&define.amd?define(["exports","react","prop-types","styled-components"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o["mm-react-embeddable"]={},o.React,o.PropTypes,o.styled))})(this,function(o,e,l,M){"use strict";const E=e.createContext(null),w=({children:n})=>{const[r,u]=e.useState({}),i=e.useRef({}),c=e.useCallback((s,t,a)=>{u(d=>({...d,[s]:{origin:t,frameRef:a}}))},[]);e.useEffect(()=>{const s=t=>{var d,b;if(!((d=t==null?void 0:t.data)!=null&&d.instanceId))return;(((b=i.current[t.data.instanceId])==null?void 0:b[t.data.type])||[]).forEach(y=>y(t.data))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},[r]);const f=e.useCallback((s,t,a)=>{const d=r[s];if(!d){console.warn(`Origin not set for id: ${s}. Unable to send message.`);return}d.frameRef.current.contentWindow.postMessage({type:t,...a,instanceId:s},d.origin)},[r]),m={testIsEmbeddable:I,registerFrame:c,sendMessage:f,addListener:(s,t,a)=>(i.current[s]||(i.current[s]={}),i.current[s][t]||(i.current[s][t]=[]),i.current[s][t].push(a),()=>{i.current[s][t]=i.current[s][t].filter(d=>d!==a)})};return e.createElement(E.Provider,{value:m},n)},g={},I=async n=>{try{const r=new URL(n).origin;if(g[r]!==void 0)return g[r];if(!(await(await fetch(`${r}/mm-app-manifest.json`)).json()).version)throw new Error("Invalid manifest");return g[r]=!0,!0}catch{}return g[origin]=!1,!1},C=(n,r,u)=>{const i=e.useContext(E);if(i===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const c=e.useRef(u);return e.useEffect(()=>{c.current=u},[u]),e.useEffect(()=>{if(!(!n||!r))return i.addListener(n,r,(...f)=>c.current(...f))},[i,n,r]),e.useCallback((f,m)=>i.sendMessage(n,f,m),[i,n])};w.propTypes={children:l.node.isRequired};const S=(M.default||M).iframe`
1
+ (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react"),require("prop-types"),require("styled-components")):typeof define=="function"&&define.amd?define(["exports","react","prop-types","styled-components"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o["mm-react-embeddable"]={},o.React,o.PropTypes,o.styled))})(this,function(o,e,b,I){"use strict";const g=e.createContext(null),v=({children:n})=>{const[i,a]=e.useState({}),s=e.useRef({}),c=e.useCallback((r,t,f)=>{a(d=>({...d,[r]:{origin:t,frameRef:f}}))},[]);e.useEffect(()=>{const r=t=>{var d,l;if(!((d=t==null?void 0:t.data)!=null&&d.instanceId))return;(((l=s.current[t.data.instanceId])==null?void 0:l[t.data.type])||[]).forEach(M=>M(t.data))};return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},[i]);const u=e.useCallback((r,t,f)=>{const d=i[r];if(!d){console.warn(`Origin not set for id: ${r}. Unable to send message.`);return}d.frameRef.current.contentWindow.postMessage({type:t,...f,instanceId:r},d.origin)},[i]),E=e.useCallback((r,t)=>{u(r,"load-options",t)},[u]),m=e.useCallback((r,t)=>{u(r,"validate",t)},[u]),h={registerFrame:c,sendMessage:u,loadOptions:E,validate:m,addListener:(r,t,f)=>(s.current[r]||(s.current[r]={}),s.current[r][t]||(s.current[r][t]=[]),s.current[r][t].push(f),()=>{s.current[r][t]=s.current[r][t].filter(d=>d!==f)})};return e.createElement(g.Provider,{value:h},n)},p={},C=async n=>{try{const i=new URL(n).origin;if(p[i]!==void 0)return p[i];const s=await(await fetch(`${i}/mm-app-manifest.json`)).json();if(!s.version)throw new Error("Invalid manifest");return p[i]=s,s}catch{}return p[origin]=!1,!1},L=async n=>!!await C(n),$=(n,i,a)=>{const s=e.useContext(g);if(s===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const c=e.useRef(a);return e.useEffect(()=>{c.current=a},[a]),e.useEffect(()=>{if(!(!n||!i))return s.addListener(n,i,(...u)=>c.current(...u))},[s,n,i]),e.useCallback((u,E)=>s.sendMessage(n,u,E),[s,n])};v.propTypes={children:b.node.isRequired};const j=(I.default||I).iframe`
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  border: none;
5
- visibility: ${n=>n.isready?"visible":"hidden"};
6
- `,v=({id:n,src:r,path:u,onInit:i=()=>{},...c})=>{const f=e.useRef(),[m,s]=e.useState(),[t,a]=e.useState(0),{registerFrame:d,sendMessage:b,testIsEmbeddable:y}=e.useContext(E),[Z,x]=e.useState(!0),[h,j]=e.useState();return e.useEffect(()=>{u!==void 0&&j(u)},[u]),e.useEffect(()=>{h===void 0||!t||b(n,"navigate",{path:h})},[h,t,n,b]),e.useEffect(()=>{!r||!n||!f||(async()=>{const p=y(r);if(x(p),p){const L=new URL(r);d(n,L.origin,f),i(),s(`${L.origin}/mm-embedded-interop?id=${n}`);return}})()},[r,n,d,f]),C(n,"ready",()=>a(p=>p+1)),Z?e.createElement(S,{isready:t,ref:f,src:m,...c}):e.createElement("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("div",{style:{textAlign:"center"}},"Application must adhere to the MM App Manifest specification to be embedded."))};v.propTypes={id:l.string,src:l.string.isRequired,path:l.string,onInit:l.func},o.MMEmbeddableZone=v,o.MMEmbeddableZoneContext=E,o.MMEmbeddableZoneProvider=w,o.testIsEmbeddable=I,o.useEmbeddedEffect=C,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
5
+ visibility: ${n=>n.$isReady?"visible":"hidden"};
6
+ `,S=({id:n,src:i,path:a,onInit:s=()=>{},context:c,isConfiguring:u,...E})=>{const m=e.useRef(),[h,r]=e.useState(),[t,f]=e.useState(0),{registerFrame:d,sendMessage:l}=e.useContext(g),[M,q]=e.useState(!0),[w,x]=e.useState();return e.useEffect(()=>{t&&l(n,"set-context",{context:c})},[c,n,t]),e.useEffect(()=>{a!==void 0&&x(a)},[a]),e.useEffect(()=>{w===void 0||!t||l(n,"navigate",{path:w})},[w,t,n,l]),e.useEffect(()=>{t&&l(n,"set-configuring",{isConfiguring:u})},[t,u]),e.useEffect(()=>{!i||!n||!m||(async()=>{const y=await L(i);if(q(y),y){const Z=new URL(i);d(n,Z.origin,m),s(),r(`${Z.origin}/mm-embedded-interop?id=${n}&origin=${window.location.origin}`);return}})()},[i,n,d,m]),$(n,"ready",()=>f(y=>y+1)),M?e.createElement(j,{$isReady:t,ref:m,src:h,...E}):e.createElement("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("div",{style:{textAlign:"center"}},"Application must adhere to the MM App Manifest specification to be embedded."))};S.propTypes={id:b.string,src:b.string.isRequired,path:b.string,onInit:b.func},o.MMEmbeddableZone=S,o.MMEmbeddableZoneContext=g,o.MMEmbeddableZoneProvider=v,o.getAppInfo=C,o.testIsEmbeddable=L,o.useEmbeddedEffect=$,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinemetrics/mm-react-embeddable",
3
- "version": "0.9.13",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "module": "dist/mm-react-embeddable.es.js",
6
6
  "main": "dist/mm-react-embeddable.cjs.js",