@machinemetrics/mm-react-embeddable 0.10.0 → 0.10.1-1

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