@myop/sdk 0.2.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/bundled-declarations.d.ts +92 -7
- package/dist/cjs/{_IframeSDK.2793f0c2.js → _IframeSDK.3a01f95a.js} +192 -34
- package/dist/cjs/_IframeSDK.3a01f95a.js.map +7 -0
- package/dist/cjs/_IframeSDK.75aeb332.min.js +1 -0
- package/dist/cjs/{_MyopHelpers.7baba8b8.js → _MyopHelpers.02c01d3a.js} +96 -11
- package/dist/cjs/{_MyopHelpers.7baba8b8.js.map → _MyopHelpers.02c01d3a.js.map} +3 -3
- package/dist/cjs/_MyopHelpers.abd584e8.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.ba6c3d1b.js → _WebComponentSDK.abdb86a3.js} +192 -34
- package/dist/cjs/_WebComponentSDK.abdb86a3.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.e345ed2a.min.js +1 -0
- package/dist/cjs/_hostSDK.881787f6.min.js +1 -0
- package/dist/cjs/{_hostSDK.71e17cf2.js → _hostSDK.9dbd966e.js} +192 -34
- package/dist/cjs/_hostSDK.9dbd966e.js.map +7 -0
- package/dist/cjs/myop_sdk.js +14 -14
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +202 -36
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +224 -69
- package/dist/module/Iframe/index.js.map +3 -3
- package/dist/module/SDK.js +226 -70
- package/dist/module/SDK.js.map +2 -2
- package/dist/module/helpers/CloudRepository.d.ts +15 -6
- package/dist/module/helpers/index.js +97 -12
- package/dist/module/helpers/index.js.map +3 -3
- package/dist/module/host/components/IMyopComponent.d.ts +43 -0
- package/dist/module/host/components/myopIframeComponent.d.ts +8 -1
- package/dist/module/host/components/myopRefComponent.d.ts +2 -2
- package/dist/module/host/embeddedSDK.d.ts +23 -0
- package/dist/module/host/index.d.ts +1 -0
- package/dist/module/host/index.js +224 -69
- package/dist/module/host/index.js.map +3 -3
- package/dist/module/webcomponent/index.js +224 -69
- package/dist/module/webcomponent/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.2793f0c2.js.map +0 -7
- package/dist/cjs/_IframeSDK.fb84c8eb.min.js +0 -1
- package/dist/cjs/_MyopHelpers.3d50ac48.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.0fee50b6.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.ba6c3d1b.js.map +0 -7
- package/dist/cjs/_hostSDK.159c1adb.min.js +0 -1
- package/dist/cjs/_hostSDK.71e17cf2.js.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var kt=Object.defineProperty,sn=Object.defineProperties;var rn=Object.getOwnPropertyDescriptors;var vt=Object.getOwnPropertySymbols;var an=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable;var st=(o,n,e)=>n in o?kt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,y=(o,n)=>{for(var e in n||(n={}))an.call(n,e)&&st(o,e,n[e]);if(vt)for(var e of vt(n))pn.call(n,e)&&st(o,e,n[e]);return o},_=(o,n)=>sn(o,rn(n));var cn=(o,n)=>{for(var e in n)kt(o,e,{get:n[e],enumerable:!0})};var s=(o,n,e)=>st(o,typeof n!="symbol"?n+"":n,e);var Y=class{constructor(n,e,t,r,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=r;this.offsetLeft=i;s(this,"type","MyopElementRef")}};var Ht=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},h=class{constructor(n){this.messageToHost=n}},Se=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var d={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var we={};cn(we,{AddEventListenerMessage:()=>ct,BaseMyopMessage:()=>M,BindClickMessage:()=>at,ChangeTextMessage:()=>pt,CleanupMessage:()=>ge,CleanupReplayMessage:()=>ue,ClickReplayMessage:()=>F,CreateRefComponentMessage:()=>me,CustomRefMessage:()=>U,DetectMyopRefsMessage:()=>ft,DetectedMyopRefsMessage:()=>q,DisposeMessage:()=>ye,ElementValueReplayMessage:()=>W,EnvelopedMessage:()=>de,EventListenerCallbackMessage:()=>N,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>R,ExecuteScriptReplyMessage:()=>$,GetAttributeMessage:()=>gt,GetAttributeReplayMessage:()=>le,GetElementValueMessage:()=>dt,InitMessage:()=>Z,InitRequest:()=>V,InitResponse:()=>ce,MessageDirection:()=>b,MutationObserverMessage:()=>fe,MyopBindMessage:()=>w,MyopBindReplayMessage:()=>S,MyopElementMessage:()=>it,Ref:()=>A,RefComponentCreatedMessage:()=>O,ResizeObserverMessage:()=>he,SetAttributeMessage:()=>mt,SetInnerHtml:()=>lt,SetMutationObserverMessage:()=>ut,SetResizeObserverMessage:()=>yt,stripFunction:()=>_t});var H=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var mn=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var dn=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var rt=o=>{let n=dn(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(mn(n.slice(t,t+16)));return e};var Dt=o=>new Promise(n=>setTimeout(n,o));var b=class{};s(b,"down","down"),s(b,"up","up");var M=class{constructor(){s(this,"id",H());s(this,"myop",!0);s(this,"content");s(this,"source");s(this,"destination");s(this,"route");s(this,"ref");s(this,"direction");s(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},it=class extends M{constructor(e){super();this.ref=e}},S=class extends M{constructor(e){super();this.replayToHandler=e}},w=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",H())}},A=class o{constructor(n,e){this.refConfig=n;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=_(y({},this),{component:null})}static create(n,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(r,t)}};var Bt="ClickReplayMessage",at=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Bt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},F=class extends S{constructor(){super(...arguments);s(this,"messageType",Bt)}};var pt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var Lt="ExecuteScriptReplyMessage",ln=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,fn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,_t=o=>{let n=o.match(ln);if(n)return n[1]||n[3];{let e=o.match(fn);if(e)return e[1].trim()}},R=class extends w{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",Lt);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=_t(this.content)}};s(R,"replierKey","send"),s(R,"completeStreamKey","completeStream");var $=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",Lt)}};var U=class extends R{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:c})=>{let m=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return m.length?(c.ref=m[0],new Function("return (".concat(p,")(...arguments)"))(c)):null},r);this.scriptInputs=t;this.scriptInputs=_(y({},t),{_script:e.toString()})}};var Ot="EventListenerCallbackMessage",ct=class extends w{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",Ot);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},N=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",Ot);this.content={e:t}}};var mt=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var Pt="ElementValueReplayMessage",dt=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Pt);s(this,"messageType","GetElementValueMessage")}},W=class extends S{constructor(e){super();this.content=e;s(this,"messageType",Pt)}};var lt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var Z=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ce=class extends Z{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},V=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var At="RefComponentCreatedMessage",me=class extends w{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",At);s(this,"messageType","CreateRefComponentMessage")}},O=class extends S{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",At)}};var de=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Kt="DetectedMyopRefsMessage",ft=class extends w{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Kt)}},q=class extends S{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Kt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var zt="GetAttributeReplayMessage",gt=class extends w{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",zt);s(this,"messageType","GetAttributeMessage")}},le=class extends S{constructor(e){super();this.content=e;s(this,"messageType",zt)}};var D=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var ut=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},fe=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var Ft="CleanupReplayMessage",ge=class extends w{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",Ft);s(this,"messageType","CleanupMessage")}},ue=class extends S{constructor(e){super();this.customCleanup=e;s(this,"messageType",Ft)}};var ye=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var yt=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},he=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var ht=class{constructor(n,e){this.id=n;this.context=e;s(this,"send",n=>{})}},ee=class{constructor(){s(this,"messageToHandleAfterInit",[]);s(this,"components",{});s(this,"alwaysPassEnvelopesToHost",!1);s(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===d.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===d.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new ht(r),this.messageToHost(new ce(r));return}if(t.messageType===d.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(c=>c.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(c=>c.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===d.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ue(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],Ht(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let r=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){r=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var P={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var j={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var oe={message:"message",code:"code"},te=class{};s(te,"code","code"),s(te,"component","component");var G={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Te={Segment:"Segment",Promo:"Promo",AB:"AB"},ne=class{constructor(n,e){this.container=n;this.shadowRoot=e;s(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));s(this,"getRoot",()=>this.shadowRoot||this.container)}};var T={id:"myop-id"};var Ee=class extends h{constructor(){super(...arguments);s(this,"messageType",d.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(T.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(T.id);a&&r.push(new Y(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new q(e.handlerUniqueId,r))})}};var I=(o,n)=>n.querySelectorAll("[".concat(T.id,"='").concat(o.refConfig.selector,"']")),$t=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var Re=class extends h{constructor(){super(...arguments);s(this,"messageType",d.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new F,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var ve=class extends h{constructor(){super(...arguments);s(this,"messageType",d.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var Mt=o=>o!==Object(o),gn=o=>typeof o=="function",It=o=>{if(Mt(o))return!0;if(gn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!It(e))return!1}else{if(Mt(e))continue;return!1}}return!0},v=(o,n={},e=!0,t=new WeakMap)=>{if(Mt(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let r=[];t.set(o,r);for(let i=0;i<o.length;i++){let a=o[i];r[i]=v(a,n,e,t)}return r}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let r={};t.set(o,r);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(r[i]=v(o[i],!0,e,t)):typeof a=="object"&&(r[i]=v(o[i],a,e,t)))}return r}return{}};var ke=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=v,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var He=class extends h{constructor(){super(...arguments);s(this,"messageType",d.ExecuteScriptMessage);s(this,"executor",e=>{ke(e,r=>{this.messageToHost(new $(e.handlerUniqueId,r))},new ne(document.documentElement))})}};var De="__federation__",Ut="onLoad";var se=(o,n)=>{window[De]&&window[De][o]&&window[De][o][Ut]&&window[De][o][Ut]({[o]:n})};var Be=class extends h{constructor(){super(...arguments);s(this,"messageType",d.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new N(e.handlerUniqueId,v(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Le=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var K=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;s(this,"id","");s(this,"messageHandlers",{});s(this,"element");s(this,"_markedForDisposed",!1);s(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});s(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let r=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return r.push(i),()=>{let a=r.indexOf(i);a>-1&&r.splice(a,1)}});s(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});s(this,"isInitiated",!1);s(this,"_whenInitiatedResolve");s(this,"_whenInitiatedReject");s(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));s(this,"initiated",()=>this._whenInitiated);s(this,"props",{});s(this,"refs",{});this.id=(t==null?void 0:t.id)||B.Instance().assignId(n);let r=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(r," ").concat(this.id))},r),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===d.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(r=>{t=t||r(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,r=>r.replayToHandler===n.handlerUniqueId,r=>{n.handler(r),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=b.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,r=>r.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new ge(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ye);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Nt={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var Me=class extends K{constructor(e,t,r){super(e,t.container,r);this.componentDefinition=e;this.parent=t;s(this,"send",e=>{let t=e.handler,r=super.send(e);return this.parent.send(new de(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new D("dispose")),super.dispose()})}hide(){this.send(new D("hide"))}show(){this.send(new D("show"))}inspect(){return this.send(new D("inspect"))}setHeightBasedOnDocumentElement(){this.send(new D("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new D("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var un=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},_e=(o,n,e,t,r,i)=>{let a=un("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,r),r.style.border="1px solid #007BFF",r.style.display="block",()=>{r.style.border="unset",t.removeChild(a)}},Wt=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),Vt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},qt=(o,n,e)=>{let t=n.reduce((i,a)=>_(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Wt(p,a,o))return!1;if(p.behavior.type===oe.code){if(e.loader.type===P.HTMLLoader&&e.loader.shadowRootMode===j.localFrame){let m=p.behavior;return o.element.contentWindow[m.remap||a]}return Vt(p,a,o),!1}return p.mode==="output"?new Promise(c=>{let m=[];p.behavior.ref&&m.push(A.create(p.behavior.ref)),m.push(l=>{c(l)}),p.behavior.params&&m.push(...p.behavior.params);let f=we[p.behavior.message];o.send(new f(...m))}):null},set:(i,a,p)=>{let c=t[a];if(Wt(c,a,o))return!1;if(c.behavior.type===oe.code){if(e.loader.type===P.HTMLLoader&&e.loader.shadowRootMode===j.localFrame){let f=c.behavior;return o.element.contentWindow[f.remap||a]=p,!0}return Vt(c,a,o),!1}else if(c.mode==="input")if(c.behavior.type==="message"){let m=[];c.behavior.ref&&m.push(A.create(c.behavior.ref)),m.push(p),c.behavior.params&&m.push(...c.behavior.params);let f=we[c.behavior.message];return o.send(new f(...m)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(c.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,r),o},yn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{It(p)||Nt.notSerializableRefCall(t,p)}),n.send(new U(({ref:p,propName:c,functionArgs:m,makeSerializable:f})=>{if(p){let l=p[c];return f(typeof l=="function"?p[c](...m):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return n.send(new U(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),Ct=async(o,n,e,t)=>{let r=o.component;if(!r)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new Me(n.type,r,t);e.push(p),await r.initiated();let c=setTimeout(()=>{a("timeout")},5e3);r.send(new me(o.refConfig,n,_(y({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){a("CreateRefComponentMessage failed");return}let f=e.find(l=>l.id==p.id);if(f!==p){r.refs[o.refConfig.name]=f,i(f);return}else p.setInitiated(),r.refs[o.refConfig.name]=p;m.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(C=>C.type.id===l.componentDefinitionId).type,u=new Me(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await xt(p,n,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},xt=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let r=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var c;if(i.behavior.type==te.component){if(t){a();return}let m=i.behavior.componentId;m||(m=i.behavior.instance.componentId);let f=(c=n.instance.resolvedNestedComponents)==null?void 0:c.find(g=>g.type.id===m);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=A.create("",i,o);try{let g=await Ct(l,f,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let m=A.create("",i,o);o.refs[i.name]=yn(m,o),a()}catch(m){}}));try{await Promise.all(r)}catch(i){throw i}};var re=class extends K{constructor(e,t,r,i,a){super(e,r,a);this.componentConfig=e;this.container=r;this.IframeElement=i;s(this,"cleanupInspect");s(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new R(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new R(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:c}=document.documentElement.getBoundingClientRect();t({height:p,width:c})});return a.observe(document.documentElement),a.observe(document.body),{height:r,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));s(this,"observeAutoSize",e=>{var pe;let t=this.IframeElement,r=t.contentDocument;if(!r)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(E,L,Q)=>L!==void 0&&E<L?L:Q!==void 0&&E>Q?Q:E,a=E=>{if(E===void 0)return;if(typeof E=="number")return E;let L=parseFloat(E);return isNaN(L)?void 0:L},p=a(e==null?void 0:e.minWidth),c=a(e==null?void 0:e.maxWidth),m=a(e==null?void 0:e.minHeight),f=a(e==null?void 0:e.maxHeight),l=(pe=e==null?void 0:e.loaderMinHeight)!=null?pe:50,g=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,C=this.container.getBoundingClientRect(),xe=C.width===0,be=C.height===0||C.height===l,ae=(e!=null&&e.forceAutoSize||xe)&&!g,k=(e!=null&&e.forceAutoSize||be)&&!u;if(!ae&&!k)return()=>{};let X=()=>{var L;let E=t.contentDocument;if(E){let Q=E.documentElement.getBoundingClientRect(),wt=Math.ceil(Q.width),Tt=Math.ceil(Q.height),Et=i(wt,p,c),Rt=i(Tt,m,f);ae&&(t.style.width="".concat(Et,"px")),k&&(t.style.height="".concat(Rt,"px"));let nn=ae&&c!==void 0&&wt>c,on=k&&f!==void 0&&Tt>f;E.documentElement.style.overflowX=nn?"auto":"hidden",E.documentElement.style.overflowY=on?"auto":"hidden",(L=e==null?void 0:e.onSizeChange)==null||L.call(e,{width:Et,height:Rt,autoSizingWidth:ae,autoSizingHeight:k})}};X();let J=new ResizeObserver(X);return J.observe(r.body),J.observe(r.documentElement),()=>{J.disconnect()}});s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new R(()=>{let{height:t,width:r}=document.documentElement.getBoundingClientRect();return{height:t,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});s(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new R(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===d.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let r=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),r});s(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=_e(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===d.In.MutationObserverMessage||e.messageType===d.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var z=class{constructor(){s(this,"appendChild",(n,e,t)=>{var r;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(r=t.relative.child)==null?void 0:r.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var hn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Oe=class extends z{constructor(){super(...arguments);s(this,"type",P.IframeLoader);s(this,"load",async(e,t,r,i)=>{let a,p=t.loader;if((r==null?void 0:r.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,r),a=r,a.src=p.url;else{let c=H(),m="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=m;let f="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=f,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([g,u])=>{u===""||u===null||u===void 0?a.setAttribute(g,""):a.setAttribute(g,String(u))});let l=t.loader.url;i!=null&&i._hasParent&&(l=hn(l,"_myop-comp",c)),a.src=l,r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),a=this.appendChild(r,a,i)}return new re(e,t,r,a,i)})}};var Pe={webcomponent_message_key:"myop_webcomponent_message"};var ie=class extends K{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Pe.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return r});s(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=_e(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var bt={},Ae=class extends z{constructor(){super(...arguments);s(this,"type",P.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;bt[a.url]?console.log("Module alreday loaded or in loading process"):bt[a.url]=new Promise((m,f)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{m()},g.onerror=()=>{f()},document.head.appendChild(g)}),await bt[a.url],await Dt(1);let p="myop-comp-".concat(H()),c=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),i!=null&&i._environment&&(c._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,c,i),new ie(e,t,r,c,i)})}};var Ke="0.3.8";var x=class extends Se{constructor(e,t){super(e);this.context=t;s(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let r=(i,a)=>{this.messageToHost(_(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var ze=class extends x{constructor(){super(...arguments);s(this,"messageType",d.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=()=>{r(new F(e.handlerUniqueId))};p.addEventListener("click",c),a.push(()=>{p.removeEventListener("click",c)})}),()=>{a.forEach(p=>p())}})}};var Fe=class extends x{constructor(){super(...arguments);s(this,"messageType",d.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var $e=class extends ne{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Ue=class extends x{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(T.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(T.id);p&&i.push(new Y(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new q(e.handlerUniqueId,i))});s(this,"messageType",d.DetectMyopRefsMessage)}};var Ne=class extends x{constructor(){super(...arguments);s(this,"messageType",d.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var We=class extends x{constructor(){super(...arguments);s(this,"messageType",d.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=m=>{r(new N(e.handlerUniqueId,v(m,e.serializableSkeleton)))};p.addEventListener(e.type,c),a.push(()=>{p.removeEventListener(e.type,c)})}),()=>{a.forEach(p=>p())}})}};var Ve=class extends x{constructor(){super(...arguments);s(this,"messageType",d.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(T.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=B.Instance(),c=p.components.find(g=>g.id===e.options.id);c&&c.dispose();let m=p.components.indexOf(c);m!==-1&&p.components.splice(m,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(f.refs).forEach(g=>{let u=f.refs[g];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new O(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var qe=class extends x{constructor(){super(...arguments);s(this,"messageType",d.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{ke(e,a=>{r(new $(e.handlerUniqueId,a))},t)})}};var jt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(T.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:jt(i),required:i.required,validity:v(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(c):(e.unmappedData.push(e.formData[p]),e.formData[p]=c):e.formData[p]=c:e.unmappedData.push(c)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},je=class extends x{constructor(){super(...arguments);s(this,"messageType",d.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new W(jt(a)),e)})})}};var Ge=class extends x{constructor(){super(...arguments);s(this,"messageType",d.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var Ie=class extends ee{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Pe.webcomponent_message_key,r=>{let i=r.data?r.data:r.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(r),a.messageType===d.InitMessage){let p=a.content.id;this.components[p].context=new $e(e,t)}}}),setTimeout(()=>{this.messageToHost(new V)},1)});s(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});s(this,"supportedHandlers",[new Fe(this.messageToHost,this.components),new Ge(this.messageToHost,this.components),new ze(this.messageToHost,this.components),new Ue(this.messageToHost,this.components),new Ne(this.messageToHost,this.components),new We(this.messageToHost,this.components),new qe(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Ve(this.messageToHost,this.components)]);s(this,"init",()=>{})}};se("WebComponentSDK",Ie);var Gt="";var Jt=[],Xe,Qt=async()=>(Xe||(Xe=new Ie,Xe.init()),Xe);function Mn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===j.open?"open":"closed",t=this.attachShadow({mode:e});Qt().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var In=(o,n,e)=>{customElements.define(o,Mn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Cn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),xn=o=>(o=Cn(o),o.replace(/_/g,"-"));var Je=class extends z{constructor(){super(...arguments);s(this,"type",P.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(H()),c;if(a.shadowRootMode===j.localFrame){let m=H(),f="myop-comp-".concat(m),l=document.createElement("iframe");l.id=f,l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),l=this.appendChild(r,l,i);let g=l.contentDocument||l.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let k=new DOMParser().parseFromString(a.HTML,"text/html"),X=k.getElementById("myop_preview");X==null||X.removeAttribute("type");let J=k.implementation.createHTMLDocument();J.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let pe=J.body.firstChild;pe&&k.head&&k.head.insertBefore(k.importNode(pe,!0),k.head.firstChild),u=k.documentElement.outerHTML}g.writeln(u);let C='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),xe="<script>\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK();\n sdk.init();\n }\n __myop_init().then();\n <\/script>";g.writeln("".concat(C).concat(xe)),g.close();let be=new re(e,t,r,l,i);return a.autoHeight&&(l.onload=()=>{be.observeSizeBasedOnDocumentElement()}),be}if(a.shadowRootMode===j.none){let m=document.createElement("template");m.innerHTML=a.HTML,c=m.content.firstElementChild,Qt().then(f=>{f.connectedCallback(c,c)})}else{let m=xn(e.name+t.id);Jt.includes(m)||(In(m,a.HTML,a.shadowRootMode),Jt.push(m)),c=document.createElement(m)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),this.appendChild(r,c,i),new ie(e,t,r,c,i)})}};var bn=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:oe.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:oe.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Qe=class Qe{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"variants",{});s(this,"userFlows",{});s(this,"_defaultEnv","production")}setEnvironment(n){this._defaultEnv=n}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants}async fetchComponentV2(n,e,t){let r=e||this._defaultEnv,i="".concat(n,":").concat(r,":").concat(t?"preview":"live");return this.variants[i]||(this.variants[i]=new Promise(async(a,p)=>{try{let c="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(r);t&&(c+="&preview=true");let l=(await(await fetch(c)).json()).item;if(!l){p(new Error('Component "'.concat(n,'" not found')));return}if(!l.consume_variant||!l.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(r,'"')));return}let g=bn(l);a(g)}catch(c){p(c)}})),await this.variants[i]}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(r=>r.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};s(Qe,"Main",new Qe);var Ce=Qe;var Yt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[r,...i]=rt(t);switch(r){case"component":{let[a,p]=i,c=await Ce.Main.fetchComponent(a);if(c&&c.type.skins.find(f=>f.id===p))return c.instance.skinSelector={type:G.Dedicated,skin:{id:p}},c}break;default:{let[a,p]=rt(t),m=(await Ce.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(m&&m.instance.skinSelector.type===G.Segmented&&m.instance.resolvedExperiences){let f=m.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===Te.Segment){let l=f,u=m.instance.skinSelector.segments.find(C=>C.segmentId===l.segment.id);if(u)return m.instance.skinSelector=u==null?void 0:u.skinSelector,m}}}break}}}finally{return null}};var Zt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",B=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",Ke);s(this,"type2InstanceCount",{});s(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});s(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==d.EnvelopedMessage)return;let e=n.data;if(e.messageType===d.InitRequest){this.components2init.forEach(r=>{r.send(new Z(r.id))});return}if(e.messageType===d.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let r=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});r==null||r.setInitiated();return}if(e.messageType===d.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===D.name?i.onMessageReceived(r.message):(r.message.route=r.route,i.send(r.message));return}}else{let a=this.components.find(p=>p.id===r.message.destination);a&&a.send(r.message)}return}let t=this.components.find(r=>r.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});s(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});s(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Oe,new Ae,new Je];if(this.componentsLoaders=[...e],n){let t={};n.forEach(r=>{let i=new r(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(r=>{t[r.type]||(t[r.type]=r)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});s(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function r(a,p){for(let c of a)if(await p(c))return c}switch(n.type){case"DedicatedSkin":case G.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case G.Segmented:{let p=await r(n.segments,async c=>{if(c.segmentId==="Default")return!0;let m=e.find(u=>u.type===Te.Segment?u.segment.id===c.segmentId:!1);if(!m)throw new Error("experience not found");let l=m.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(c.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});s(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(r=>r.id===t)});s(this,"loaderHooks");s(this,"loadComponent",async(n,e,t)=>{var f,l,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Yt(n);r&&(n=r);let i=y(y({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=y({},n),n.instance=y({},n.instance);let C=await this.runSkinSelector(n,i);if(!C)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(C=await t.hooks.afterSkinSelected(y({},C))),n.instance.skinSelector={type:G.Dedicated,skin:C},t&&(t=y({},t),delete t.hooks),await Ct(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let c=this.componentsLoaders.find(C=>C.type===p.loader.type);if(!c){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let m=await c.load(n.type,p,e,t);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(C=>C!==m),this.components2init=this.components2init.filter(C=>C!==m),!0)),this.components.push(m),(!t||t.connectProps!==!1)&&(m=qt(m,n.type.props,p));try{await xt(m,n,this.components)}catch(C){throw C}return t!=null&&t.skipInit||await m.initiated(),m});s(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,n.container,y({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(r),r.show(),n.dispose(),r}else{let r=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,y({relative:{direction:"before",child:r}},t))}})}};s(B,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Zt});if(!window.myop.hostSDK){let o=new B;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Zt}),window.myop.hostSDK=o}var Sn=window.myop.hostSDK;se("hostSDK",Sn);var Ye=class extends h{constructor(){super(...arguments);s(this,"messageType",d.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(T.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await B.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(c=>{let m=a.refs[c];m=m.__nonProxied||m,m.componentDefinition&&p.push({refName:c,componentDefinitionId:m.componentDefinition.id})}),this.messageToHost(new O(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var en=(o,n)=>{if(!o){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!o||o.nodeType!==1))if(e){let t=new e(n),r={attributes:!0,childList:!0,subtree:!0};return t.observe(o,r),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",n,!1),o.addEventListener("DOMNodeRemoved",n,!1))};var Ze=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&en(document.body,()=>{this.messageToHost(new fe)})})}};var tn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(T.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:tn(i),required:i.required,validity:v(i.validity,!0),myopId:a};e.unmappedData.push(c),p&&(!e.formData[p]||!e.formData[p].value||c.value)&&(e.formData[p]=c)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},et=class extends h{constructor(){super(...arguments);s(this,"messageType",d.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new W(tn(r)),e)})})}};var tt=class extends h{constructor(){super(...arguments);s(this,"messageType",d.GetAttributeMessage);s(this,"executor",e=>{let t=$t(e.ref,document);t&&this.messageToHost(new le(t.getAttribute(e.name)),e)})}};var nt=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new he)});return t.observe(document.body),()=>{t.disconnect()}})}};var ot=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var St=class extends ee{constructor(){super();s(this,"version",Ke);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new ve(this.messageToHost),new ot(this.messageToHost),new Re(this.messageToHost),new Ee(this.messageToHost),new He(this.messageToHost),new Be(this.messageToHost),new Le(this.messageToHost),new et(this.messageToHost),new Ze(this.messageToHost),new nt(this.messageToHost),new tt(this.messageToHost),new Ye(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new V)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};se("IframeSDK",St);export{St as IframeSDK};
|
|
@@ -340,7 +340,64 @@ __publicField(_ComponentConfig, "create", () => {
|
|
|
340
340
|
});
|
|
341
341
|
var ComponentConfig = _ComponentConfig;
|
|
342
342
|
|
|
343
|
+
// src/common/index.ts
|
|
344
|
+
var PropConfigBehaviorTypes = {
|
|
345
|
+
"message": "message",
|
|
346
|
+
"code": "code"
|
|
347
|
+
};
|
|
348
|
+
|
|
343
349
|
// src/helpers/CloudRepository.ts
|
|
350
|
+
var convertV2VariantToComponentConfig = (config) => {
|
|
351
|
+
return {
|
|
352
|
+
instance: {
|
|
353
|
+
id: "auto",
|
|
354
|
+
componentId: config.componentId,
|
|
355
|
+
componentName: config.name,
|
|
356
|
+
skinSelector: {
|
|
357
|
+
type: "Dedicated",
|
|
358
|
+
skin: {
|
|
359
|
+
id: "skin_auto_v2_converted"
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
type: {
|
|
364
|
+
id: config.id,
|
|
365
|
+
name: config.name,
|
|
366
|
+
description: config.description,
|
|
367
|
+
props: [
|
|
368
|
+
{
|
|
369
|
+
id: "in_auto_v2_converted",
|
|
370
|
+
name: "myop_init_interface",
|
|
371
|
+
type: "any",
|
|
372
|
+
behavior: {
|
|
373
|
+
type: PropConfigBehaviorTypes.code
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: "out_auto_v2_converted",
|
|
378
|
+
name: "myop_cta_handler",
|
|
379
|
+
type: "any",
|
|
380
|
+
behavior: {
|
|
381
|
+
type: PropConfigBehaviorTypes.code
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
],
|
|
385
|
+
refs: [],
|
|
386
|
+
skins: [
|
|
387
|
+
{
|
|
388
|
+
id: "skin_auto_v2_converted",
|
|
389
|
+
name: "auto_v2_converted",
|
|
390
|
+
description: "",
|
|
391
|
+
//TODO : handle empty :
|
|
392
|
+
// @ts-ignore
|
|
393
|
+
loader: config.consume_variant[0].loader
|
|
394
|
+
}
|
|
395
|
+
],
|
|
396
|
+
defaultSkin: 0
|
|
397
|
+
},
|
|
398
|
+
name: config.name
|
|
399
|
+
};
|
|
400
|
+
};
|
|
344
401
|
var _CloudRepository = class _CloudRepository {
|
|
345
402
|
constructor(_baseUrl = "https://cloud.myop.dev") {
|
|
346
403
|
this._baseUrl = _baseUrl;
|
|
@@ -348,34 +405,62 @@ var _CloudRepository = class _CloudRepository {
|
|
|
348
405
|
__publicField(this, "variants", {});
|
|
349
406
|
// v1 cache
|
|
350
407
|
__publicField(this, "userFlows", {});
|
|
408
|
+
__publicField(this, "_defaultEnv", "production");
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Set the default environment for this CloudRepository instance
|
|
412
|
+
*/
|
|
413
|
+
setEnvironment(env) {
|
|
414
|
+
this._defaultEnv = env;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Get the current default environment
|
|
418
|
+
*/
|
|
419
|
+
getDefaultEnvironment() {
|
|
420
|
+
return this._defaultEnv;
|
|
351
421
|
}
|
|
352
422
|
// ============ V2 Methods (Default) ============
|
|
353
423
|
/**
|
|
354
424
|
* Check if a component is already cached/preloaded (v2)
|
|
355
425
|
*/
|
|
356
|
-
isPreloaded(componentId) {
|
|
357
|
-
|
|
426
|
+
isPreloaded(componentId, env, preview) {
|
|
427
|
+
const cacheKey = "".concat(componentId, ":").concat(env || this._defaultEnv, ":").concat(preview ? "preview" : "live");
|
|
428
|
+
return cacheKey in this.variants;
|
|
358
429
|
}
|
|
359
430
|
/**
|
|
360
|
-
* Fetch a v2 component
|
|
431
|
+
* Fetch a v2 component config
|
|
361
432
|
*/
|
|
362
|
-
async fetchComponentV2(componentId, environmentIdentifier) {
|
|
363
|
-
|
|
364
|
-
|
|
433
|
+
async fetchComponentV2(componentId, environmentIdentifier, preview) {
|
|
434
|
+
const env = environmentIdentifier || this._defaultEnv;
|
|
435
|
+
const cacheKey = "".concat(componentId, ":").concat(env, ":").concat(preview ? "preview" : "live");
|
|
436
|
+
if (!this.variants[cacheKey]) {
|
|
437
|
+
this.variants[cacheKey] = new Promise(
|
|
365
438
|
async (resolve, reject) => {
|
|
366
439
|
try {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
440
|
+
let url = "".concat(this._baseUrl, "/consume?id=").concat(componentId, "&env=").concat(env);
|
|
441
|
+
if (preview) {
|
|
442
|
+
url += "&preview=true";
|
|
443
|
+
}
|
|
444
|
+
const res = await fetch(url);
|
|
370
445
|
const json = await res.json();
|
|
371
|
-
|
|
446
|
+
const variant = json.item;
|
|
447
|
+
if (!variant) {
|
|
448
|
+
reject(new Error('Component "'.concat(componentId, '" not found')));
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (!variant.consume_variant || !variant.consume_variant.length) {
|
|
452
|
+
reject(new Error('Component "'.concat(componentId, '" has no implementation for environment "').concat(env, '"')));
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const componentConfig = convertV2VariantToComponentConfig(variant);
|
|
456
|
+
resolve(componentConfig);
|
|
372
457
|
} catch (e) {
|
|
373
458
|
reject(e);
|
|
374
459
|
}
|
|
375
460
|
}
|
|
376
461
|
);
|
|
377
462
|
}
|
|
378
|
-
return await this.variants[
|
|
463
|
+
return await this.variants[cacheKey];
|
|
379
464
|
}
|
|
380
465
|
// ============ V1 Methods (Legacy) ============
|
|
381
466
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dynamicImport/defineDynamicImport.ts", "../../src/helpers/index.ts", "../../src/utils/uuid.ts", "../../src/messages/BaseMessage.ts", "../../src/messages/ExecuteScriptMessage.ts", "../../src/messages/CustomRefMessage.ts", "../../src/helpers/applyStylesheet.ts", "../../src/helpers/iframeSkinUrlTokenizer.ts", "../../src/helpers/classList.ts", "../../src/helpers/configBuilder.ts", "../../src/helpers/CloudRepository.ts", "../../src/helpers/exec.ts", "../../src/helpers/MyopHelpers.ts"],
|
|
4
|
-
"sourcesContent": ["export const __federation__ = \"__federation__\"\nexport const onLoadKey = \"onLoad\"\nexport const moduleInstanceKey = \"moduleInstance\"\n\nexport const defineDynamicImport = (globalName: string, module: any) => {\n // @ts-ignore\n if (window[__federation__] && window[__federation__][globalName] && window[__federation__][globalName][onLoadKey]) {\n // @ts-ignore\n window[__federation__][globalName][onLoadKey]({[globalName]: module})\n } else {\n //console.log('__federation__ loader not defined for module', module);\n }\n}", "export * from \"./applyStylesheet\";\nexport * from \"./iframeSkinUrlTokenizer\";\nexport * from \"./classList\";\nexport * from \"./configBuilder\";\nexport * from \"./CloudRepository\";\nexport * from \"./exec\";", "//TODO : reuse from one place.\n// needs to be used in myop-sdk, myop-dashbaord, myop-server, myop-cli ..\n\nexport const uuidv4 = () => {\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, c =>\n (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)\n );\n}\n\n// Convert UUID string to bytes\nexport const uuidToBytes = (uuid: string): Uint8Array => {\n return Uint8Array.from(\n uuid.replace(/-/g, '').match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))\n );\n};\n\n// Convert bytes to UUID string\nexport const bytesToUuid = (bytes: Uint8Array): string => {\n const hex = [...bytes].map(b => b.toString(16).padStart(2, '0')).join('');\n return [\n hex.slice(0, 8),\n hex.slice(8, 12),\n hex.slice(12, 16),\n hex.slice(16, 20),\n hex.slice(20)\n ].join('-');\n};\n\n// Base64 URL-safe encode\nexport const base64UrlEncode = (bytes: Uint8Array): string => {\n const base64 = btoa(String.fromCharCode(...bytes));\n return base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n};\n\n// Base64 URL-safe decode\nexport const base64UrlDecode = (str: string): Uint8Array => {\n let base64 = str.replace(/-/g, '+').replace(/_/g, '/');\n while (base64.length % 4) base64 += '=';\n const binary = atob(base64);\n return Uint8Array.from(binary, char => char.charCodeAt(0));\n};\n\n// Compress an array of UUIDs into a short URL-safe string\nexport const compressUUIDs = (uuids: string[]): string => {\n const allBytes = uuids.flatMap(uuid => Array.from(uuidToBytes(uuid)));\n return base64UrlEncode(new Uint8Array(allBytes));\n};\n\n// Decompress from URL-safe string back to an array of UUIDs\nexport const decompressUUIDs = (encoded: string): string[] => {\n const bytes = base64UrlDecode(encoded);\n if (bytes.length % 16 !== 0) throw new Error('Invalid input length');\n\n const uuids: string[] = [];\n for (let i = 0; i < bytes.length; i += 16) {\n uuids.push(bytesToUuid(bytes.slice(i, i + 16)));\n }\n return uuids;\n};\n", "import {MyopMessageKey} from \"../common/MyopMessages\";\nimport {uuidv4} from \"../utils/utils\";\nimport {IMyopComponent} from \"../host\";\nimport {IRefConfig} from \"../common\";\n\nexport class MessageDirection {\n static down = 'down' as const\n static up = 'up' as const\n}\n\nexport type MessageDirectionOption = 'up' | 'down';\n\nexport abstract class BaseMyopMessage<T = any> {\n id = uuidv4()\n\n static create<T, U extends new (...args: ConstructorParameters<U>) => T = typeof this>(\n this: U,\n ...args: ConstructorParameters<U>\n ): InstanceType<typeof this> {\n // @ts-ignore\n return new this(...args);\n }\n\n constructor() {\n //console.log('meesage id created', this.id, document.location.href);\n }\n\n myop = true\n\n abstract messageType: MyopMessageKey | string;\n\n content?: T\n\n // TODO : cant be optional \n source?: string\n destination?: string\n\n route?: string[]\n\n ref?: Ref\n\n direction?: MessageDirectionOption\n\n cleanable: boolean = false\n\n isTypeof(msg: BaseMyopMessage): boolean {\n return msg.messageType === this.messageType\n }\n}\n\nexport abstract class MyopElementMessage<T = any> extends BaseMyopMessage<T> {\n constructor(public ref: Ref) {\n super()\n }\n}\n\nexport abstract class MyopBindReplayMessage<T = any> extends BaseMyopMessage<T> {\n constructor(public replayToHandler?: string) {\n super();\n }\n}\n\nexport abstract class MyopBindMessage<T = any, R extends MyopBindReplayMessage = any> extends BaseMyopMessage<T> {\n\n public abstract replyMessageKey: MyopMessageKey;\n\n public handlerUniqueId = uuidv4()\n\n constructor(public handler: (message: R) => void) {\n super()\n }\n}\n\nexport class Ref {\n public myop = true;\n\n public __nonProxied?: Ref;\n\n static create(selector: string, refConfig?: IRefConfig, component?: IMyopComponent) {\n let _refConfig = refConfig;\n if (!_refConfig) {\n _refConfig = {\n id: '',\n name: '',\n description: '',\n selectorType: 'id-attribute',\n selector: selector,\n behavior: {\n type: 'code'\n }\n } as IRefConfig\n }\n return new Ref(_refConfig, component);\n }\n\n constructor(public refConfig: IRefConfig, public component?: IMyopComponent) {\n this.__nonProxied = {\n ...this,\n component: null // in order to be serializable\n }\n }\n}\n", "import {MyopBindMessage, MyopBindReplayMessage} from \"./BaseMessage\";\nimport {MyopMessageKey} from \"../common/MyopMessages\";\nimport {RootRef} from \"../common\";\nimport {makeSerializable} from \"../common/utils/serialization.ts\";\n\nconst ReplayMessageKey = 'ExecuteScriptReplyMessage'\n\nconst functionBodyRegex = /(?:function\\s*\\w*\\s*\\([^)]*\\)\\s*\\{([\\s\\S]*?)\\}|(\\([^)]*\\)\\s*=>\\s*\\{([\\s\\S]*?)\\}))\\s*$/;\nconst expressionBodyRegex = /\\(\\s*[^)]+\\s*\\)\\s*=>\\s*(.+)/;\n\nexport const stripFunction = (content: string) => {\n let match = content.match(functionBodyRegex);\n if (match) {\n return match[1] || match[3];\n } else {\n let match = content.match(expressionBodyRegex);\n if (match)\n return match[1].trim();\n }\n}\n\nexport type scriptInputs = {\n [key: string]: string | number | boolean\n} | {};\n\nexport type scriptVars<T> = {\n send: (data: T) => void;\n // completeStream: () => void;\n rootRef: RootRef;\n makeSerializable: typeof makeSerializable\n}\n\nexport type extendedScriptVars<T, I> = {\n [K in keyof I]: I[K];\n} & scriptVars<T>\n\nexport class ExecuteScriptMessage<T = any, I extends scriptInputs = any> extends MyopBindMessage<string, ExecuteScriptReplyMessage<T>> {\n\n replyMessageKey: MyopMessageKey = ReplayMessageKey;\n messageType = 'ExecuteScriptMessage';\n script: string = ''\n\n static replierKey = 'send';\n static completeStreamKey = 'completeStream';\n\n constructor(script: (vars: extendedScriptVars<T, I>) => T, handler: (message: ExecuteScriptReplyMessage<T>) => void = () => {\n }, public scriptInputs?: I) {\n super(handler);\n this.script = script.toString();\n\n //TODO: can be remove\n this.content = script.toString()\n this.content = stripFunction(this.content);\n }\n}\n\nexport class ExecuteScriptReplyMessage<T = any> extends MyopBindReplayMessage<T> {\n\n messageType = ReplayMessageKey;\n\n constructor(public replayToHandler: string, public content: T) {\n super(replayToHandler);\n }\n}\n", "import {\n ExecuteScriptMessage,\n ExecuteScriptReplyMessage,\n extendedScriptVars,\n scriptInputs, stripFunction\n} from \"./ExecuteScriptMessage.ts\";\n\nexport type customRefScriptInputs = {\n elementId: string,\n ref?: HTMLElement,\n _script?: string,\n __scriptInputs?: Object\n};\n\nexport class CustomRefMessage<T = any, I extends scriptInputs = customRefScriptInputs> extends ExecuteScriptMessage<T, I & customRefScriptInputs> {\n\n constructor(script: (vars: extendedScriptVars<T, I & customRefScriptInputs>) => T,\n public scriptInputs: I & customRefScriptInputs,\n handler: (message: ExecuteScriptReplyMessage<T>) => void = () => {\n }) {\n\n //mock vars\n // let rootRef, elementId, _script, __scriptInputs;\n super(({rootRef, elementId, _script, __scriptInputs}) => {\n const refs = (rootRef.shadowRoot || rootRef.container).querySelectorAll(`[${'myop-id'}='${elementId}']`);\n if (refs.length) {\n // const ref = refs[0];\n\n //TODO : think about exposing \"refs\" and not only \"ref\"\n //for cases where the Ref has multiplate implementations\n\n // @ts-ignore\n __scriptInputs.ref = refs[0];\n\n const dynamicFunction = new Function(`return (${_script})(...arguments)`);\n return dynamicFunction(__scriptInputs);\n\n // @ts-ignore\n //return Function('ref', 'rootRef', ...Object.keys(__scriptInputs), _script!)(ref, rootRef, ...Object.values(__scriptInputs))\n }\n return null as T;\n }, handler);\n\n this.scriptInputs = {\n ...scriptInputs,\n //_script: stripFunction(script.toString()),\n _script: script.toString()\n };\n }\n}\n", "import type * as CSS from \"csstype\";\nimport {IMyopComponent} from \"../host\";\nimport {uuidv4} from \"../utils/utils.ts\";\nimport {ExecuteScriptMessage} from \"../messages\";\n\n// ignoring documentation\n/** @ignore */\nexport interface CSSProperties extends CSS.Properties<string | number> {\n}\n\nexport type StylesheetDefinition = { [key: string]: CSSProperties };\n\nexport const applyStylesheet = (component: IMyopComponent, stylesheet: StylesheetDefinition, css?: string) => {\n const tagId = `myop-css-${uuidv4()}`;\n component.send(new ExecuteScriptMessage(({rootRef, _stylesheet, _tagId, _css}) => {\n const styleTag = document.createElement('style');\n styleTag.type = 'text/css';\n\n // Build the CSS string from the styles object\n let cssString = _css;\n\n for (const selector in _stylesheet) {\n cssString += `${selector} { `;\n const properties = _stylesheet[selector];\n for (const property in properties) {\n cssString += `${property}: ${properties[property]}; `;\n }\n cssString += '} ';\n }\n\n // Set the CSS string as the content of the <style> element\n styleTag.appendChild(document.createTextNode(cssString));\n styleTag.id = _tagId;\n // Append the <style> element\n (rootRef.shadowRoot || rootRef.container).appendChild(styleTag);\n\n }, () => {\n }, {\n _stylesheet: stylesheet,\n _css : css ? css : '',\n _tagId: tagId\n }));\n\n return () => {\n component.send(new ExecuteScriptMessage(({rootRef, _tagId}) => {\n const element = (rootRef.shadowRoot || document).getElementById(_tagId);\n if (element) {\n element.remove();\n }\n }, () => {\n }, {\n _tagId: tagId\n }))\n }\n}\n\nexport const applyStylesheetLink = (component: IMyopComponent, link: string) => {\n const tagId = `myop-css-${uuidv4()}`;\n component.send(new ExecuteScriptMessage(({rootRef, _tagId, _link}) => {\n const linkElement = document.createElement('link');\n linkElement.id = _tagId;\n linkElement.rel = 'stylesheet';\n linkElement.href = _link;\n document.head.appendChild(linkElement);\n\n // Append the <style> element\n (rootRef.shadowRoot || rootRef.container).appendChild(linkElement);\n }, () => {\n }, {\n _link : link,\n _tagId: tagId\n }));\n\n return () => {\n component.send(new ExecuteScriptMessage(({rootRef, _tagId}) => {\n const element = (rootRef.shadowRoot || document).getElementById(_tagId);\n if (element) {\n element.remove();\n }\n }, () => {\n }, {\n _tagId: tagId\n }))\n }\n}\n", "import {IIframeLoaderConfig, ISkinConfig} from \"../common\";\n\nexport type TokenMap = Record<string, string| number>\n\nconst replaceTokens = (input: string, tokenMap: TokenMap): string => {\n // Create a regex pattern from the keys of the tokenMap\n const pattern = new RegExp(Object.keys(tokenMap).join('|'), 'g');\n\n // Replace tokens in the input string using the regex\n return input.replace(pattern, (matched) => {\n // Return the replacement value from the tokenMap\n return (tokenMap[matched] || matched).toString();\n });\n}\n\nexport const createIframeSkinByTokenizer = (selectedSkin: ISkinConfig, tokenMap: TokenMap) => {\n const typedSkinConfig = (selectedSkin.loader as IIframeLoaderConfig)\n if (typedSkinConfig.type !== 'IframeLoader') {\n throw new Error(`iframeSkinUrlTokenizer received skin with loader type \"${typedSkinConfig.type}\", currently only \"IframeLoader\" is supported`)\n }\n\n selectedSkin.loader = {\n ...selectedSkin.loader\n }\n\n selectedSkin.loader.url = replaceTokens(selectedSkin.loader.url, tokenMap);\n\n return selectedSkin;\n}\n\nexport const changeSkinUrlByTokenizer = (tokenMap: TokenMap) => {\n return async (selectedSkin: ISkinConfig) => {\n return createIframeSkinByTokenizer(selectedSkin, tokenMap);\n }\n}", "import {CustomRefMessage} from \"../messages\";\nimport {IMyopComponent} from \"../host\";\n\n// const space = ' ';\n// export const getClasses = async (connectedRef: Ref): Promise<string[]> => (await exec(actAs<HTMLDivElement>(connectedRef).classList)).value.split(space);\n// export const addClass = async (connectedRef: Ref, className: string) => {\n// const classes = await getClasses(connectedRef);\n// classes.includes(className) || classes.push(className);\n// // @ts-ignore\n// connectedRef.classList = classes.join(space);\n// }\n// export const removeClass = async (connectedRef: Ref, className: string,) => {\n// let classes = await getClasses(connectedRef);\n// // @ts-ignore\n// connectedRef.classList = classes.filter(c => c !== className).join(space);\n// }\n//\n//\n\nexport const addClass = (component: IMyopComponent, className: string, myopId: string) => {\n component.send(new CustomRefMessage(({ref, _className}) => {\n ref?.classList.add(_className);\n }, {\n elementId: myopId,\n _className: className\n }));\n}\n\nexport const removeClass = (component: IMyopComponent, className: string, myopId: string) => {\n component.send(new CustomRefMessage(({ref, _className}) => {\n ref?.classList.remove(_className);\n }, {\n elementId: myopId,\n _className: className\n }));\n}", "import {\n IComponentConfig,\n IComponentDefinitionConfig,\n IComponentInstanceConfig, IHTMLLoaderConfig, IRefConfig,\n ISkinLoaderConfig,\n ISkinSelectorConfig,\n IDedicatedSkinConfig, ISkinConfig\n} from \"../common\";\nimport {uuidv4} from \"../utils/utils.ts\";\n\nexport class SkinConfig implements ISkinConfig {\n _runTimeInstanceId = 'runtime-instance-id-' + uuidv4();\n _runTimeId = 'runtime-id-' + uuidv4();\n _runTimeName = 'runtime-name-' + uuidv4();\n\n static create = () => {\n return new SkinConfig();\n }\n\n id = this._runTimeId;\n name = this._runTimeName;\n description = '';\n loader = null as unknown as ISkinLoaderConfig;\n\n withLoader = (loader: ISkinLoaderConfig) => {\n this.loader = loader;\n return this;\n }\n\n withHTMLLoader = (loader: Omit<IHTMLLoaderConfig, 'type'>) => {\n loader.type = 'HTMLLoader';\n this.loader = loader as IHTMLLoaderConfig;\n return this;\n }\n\n build = () => {\n return this;\n }\n}\n\nexport class ComponentConfig implements IComponentConfig {\n _runTimeInstanceId = 'runtime-instance-id-' + uuidv4();\n _runTimeId = 'runtime-id-' + uuidv4();\n _runTimeName = 'runtime-name-' + uuidv4();\n\n static create = () => {\n return new ComponentConfig();\n }\n\n instance = {\n id: this._runTimeInstanceId,\n componentId: this._runTimeId,\n componentName: this._runTimeName,\n skinSelector: null as unknown as ISkinSelectorConfig\n } as IComponentInstanceConfig;\n\n name = this._runTimeName\n type = {\n id: this._runTimeId,\n name: this._runTimeName,\n description: '',\n props: [],\n refs: [],\n skins: [],\n defaultSkin: 0\n } as IComponentDefinitionConfig\n\n withInstance = (instance: IComponentInstanceConfig) => {\n this.instance = instance;\n return this;\n }\n\n withType = (type: IComponentDefinitionConfig) => {\n this.type = type;\n return this;\n }\n\n withName = (name: string) => {\n this.name = name;\n return this;\n }\n\n withDefaultSkin = (defaultSkin: ISkinConfig) => {\n this.type.skins.push(defaultSkin);\n this.type.defaultSkin = this.type.skins.length - 1;\n this.instance.skinSelector = {\n type: 'Dedicated',\n skin: {\n id: defaultSkin.id\n }\n } as IDedicatedSkinConfig\n\n return this;\n }\n\n withRef = (ref: IRefConfig) => {\n this.type.refs.push(ref);\n return this;\n }\n\n withBasicRef = (refSelector: string) => {\n const newBasicRef = {\n id: '',\n name: refSelector,\n description: '',\n selectorType: 'id-attribute',\n selector: refSelector,\n behavior: {\n type: 'code'\n }\n } as IRefConfig\n\n this.type.refs.push(newBasicRef);\n return this;\n }\n\n build = () => {\n return JSON.parse(JSON.stringify(this))\n }\n}\n", "import {IUserFlow, v2_IVariantConfig} from \"../common\";\n\n/**\n * CloudRepository - Unified cloud data access layer for Myop components\n *\n * Supports both v2 (default) and v1 modes:\n * - v2: Uses /consume endpoint for fetching variants\n * - v1: Uses /flow endpoint for fetching user flows\n */\nexport class CloudRepository {\n static Main = new CloudRepository();\n\n // v2 cache\n private variants: Record<string, Promise<v2_IVariantConfig>> = {};\n\n // v1 cache\n private userFlows: Record<string, Promise<IUserFlow>> = {};\n\n constructor(private _baseUrl = 'https://cloud.myop.dev') {\n }\n\n // ============ V2 Methods (Default) ============\n\n /**\n * Check if a component is already cached/preloaded (v2)\n */\n isPreloaded(componentId: string): boolean {\n return componentId in this.variants;\n }\n\n /**\n * Fetch a v2 component variant\n */\n async fetchComponentV2(componentId: string, environmentIdentifier?: string): Promise<v2_IVariantConfig> {\n if (!this.variants[componentId]) {\n // eslint-disable-next-line no-async-promise-executor\n this.variants[componentId] = new Promise(\n async (resolve, reject) => {\n try {\n const res = await fetch(\n `${this._baseUrl}/consume?id=${componentId}&env=${environmentIdentifier}`\n );\n const json = await res.json();\n resolve(json.item);\n } catch (e) {\n reject(e);\n }\n }\n );\n }\n\n return await this.variants[componentId];\n }\n\n // ============ V1 Methods (Legacy) ============\n\n /**\n * Fetch a v1 component from a flow\n */\n async fetchComponentV1(componentId: string, flowId?: string) {\n if (flowId) {\n const flow = await this.fetchFlow(flowId);\n return flow.components.find(c => c.type.id === componentId);\n } else {\n const flow = await this.fetchAutoFlow(componentId);\n return flow.components[0];\n }\n }\n\n async fetchAutoFlow(componentId: string) {\n if (!this.userFlows[componentId]) {\n // eslint-disable-next-line no-async-promise-executor\n this.userFlows[componentId] = new Promise(\n async (resolve, reject) => {\n try {\n const res = await fetch(\n `${this._baseUrl}/flow?id=${componentId}&auto=true`\n );\n const json = await res.json();\n resolve(json.item);\n } catch (e) {\n reject(e);\n }\n }\n );\n }\n\n return await this.userFlows[componentId];\n }\n\n async fetchFlow(flowId: string) {\n if (!this.userFlows[flowId]) {\n // eslint-disable-next-line no-async-promise-executor\n this.userFlows[flowId] = new Promise(\n async (resolve, reject) => {\n try {\n const res = await fetch(\n `${this._baseUrl}/flow?id=${flowId}&resolve=components`\n );\n const json = await res.json();\n resolve(json.item);\n } catch (e) {\n reject(e);\n }\n }\n );\n }\n\n return await this.userFlows[flowId];\n }\n\n // ============ Backward Compatibility ============\n\n /**\n * @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly\n * Defaults to v1 behavior for backward compatibility with existing code\n */\n async fetchComponent(componentId: string, flowId?: string) {\n return this.fetchComponentV1(componentId, flowId);\n }\n}\n\n/**\n * @deprecated Use CloudRepository instead\n */\nexport const v2_CloudRepository = CloudRepository;\n", "export const exec = async (getter: any) => {\n return await getter()\n}\n", "import {defineDynamicImport} from \"../dynamicImport/defineDynamicImport.ts\";\nimport * as MyopHelpers from \"./index.ts\";\n\nexport * from \"./index.ts\";\n\ndefineDynamicImport('MyopHelpers', MyopHelpers);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,iBAAiB;AACvB,IAAM,YAAY;AAGlB,IAAM,sBAAsB,CAAC,YAAoB,WAAgB;AAEpE,MAAI,OAAO,cAAc,KAAK,OAAO,cAAc,EAAE,UAAU,KAAK,OAAO,cAAc,EAAE,UAAU,EAAE,SAAS,GAAG;AAE/G,WAAO,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,EAAC,CAAC,UAAU,GAAG,OAAM,CAAC;AAAA,EACxE,OAAO;AAAA,EAEP;AACJ;;;ACZA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,SAAS,MAAM;AACxB,SAAO,uCAAuC;AAAA,IAAQ;AAAA,IAAU,QAC3D,CAAC,IAAI,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,SAAS,EAAE;AAAA,EAClF;AACJ;;;ACKO,IAAe,kBAAf,MAAwC;AAAA,EAW3C,cAAc;AAVd,8BAAK,OAAO;AAcZ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G,IAAM,kBAAN;;;
|
|
3
|
+
"sources": ["../../src/dynamicImport/defineDynamicImport.ts", "../../src/helpers/index.ts", "../../src/utils/uuid.ts", "../../src/messages/BaseMessage.ts", "../../src/messages/ExecuteScriptMessage.ts", "../../src/messages/CustomRefMessage.ts", "../../src/helpers/applyStylesheet.ts", "../../src/helpers/iframeSkinUrlTokenizer.ts", "../../src/helpers/classList.ts", "../../src/helpers/configBuilder.ts", "../../src/common/index.ts", "../../src/helpers/CloudRepository.ts", "../../src/helpers/exec.ts", "../../src/helpers/MyopHelpers.ts"],
|
|
4
|
+
"sourcesContent": ["export const __federation__ = \"__federation__\"\nexport const onLoadKey = \"onLoad\"\nexport const moduleInstanceKey = \"moduleInstance\"\n\nexport const defineDynamicImport = (globalName: string, module: any) => {\n // @ts-ignore\n if (window[__federation__] && window[__federation__][globalName] && window[__federation__][globalName][onLoadKey]) {\n // @ts-ignore\n window[__federation__][globalName][onLoadKey]({[globalName]: module})\n } else {\n //console.log('__federation__ loader not defined for module', module);\n }\n}", "export * from \"./applyStylesheet\";\nexport * from \"./iframeSkinUrlTokenizer\";\nexport * from \"./classList\";\nexport * from \"./configBuilder\";\nexport * from \"./CloudRepository\";\nexport * from \"./exec\";", "//TODO : reuse from one place.\n// needs to be used in myop-sdk, myop-dashbaord, myop-server, myop-cli ..\n\nexport const uuidv4 = () => {\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, c =>\n (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)\n );\n}\n\n// Convert UUID string to bytes\nexport const uuidToBytes = (uuid: string): Uint8Array => {\n return Uint8Array.from(\n uuid.replace(/-/g, '').match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))\n );\n};\n\n// Convert bytes to UUID string\nexport const bytesToUuid = (bytes: Uint8Array): string => {\n const hex = [...bytes].map(b => b.toString(16).padStart(2, '0')).join('');\n return [\n hex.slice(0, 8),\n hex.slice(8, 12),\n hex.slice(12, 16),\n hex.slice(16, 20),\n hex.slice(20)\n ].join('-');\n};\n\n// Base64 URL-safe encode\nexport const base64UrlEncode = (bytes: Uint8Array): string => {\n const base64 = btoa(String.fromCharCode(...bytes));\n return base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n};\n\n// Base64 URL-safe decode\nexport const base64UrlDecode = (str: string): Uint8Array => {\n let base64 = str.replace(/-/g, '+').replace(/_/g, '/');\n while (base64.length % 4) base64 += '=';\n const binary = atob(base64);\n return Uint8Array.from(binary, char => char.charCodeAt(0));\n};\n\n// Compress an array of UUIDs into a short URL-safe string\nexport const compressUUIDs = (uuids: string[]): string => {\n const allBytes = uuids.flatMap(uuid => Array.from(uuidToBytes(uuid)));\n return base64UrlEncode(new Uint8Array(allBytes));\n};\n\n// Decompress from URL-safe string back to an array of UUIDs\nexport const decompressUUIDs = (encoded: string): string[] => {\n const bytes = base64UrlDecode(encoded);\n if (bytes.length % 16 !== 0) throw new Error('Invalid input length');\n\n const uuids: string[] = [];\n for (let i = 0; i < bytes.length; i += 16) {\n uuids.push(bytesToUuid(bytes.slice(i, i + 16)));\n }\n return uuids;\n};\n", "import {MyopMessageKey} from \"../common/MyopMessages\";\nimport {uuidv4} from \"../utils/utils\";\nimport {IMyopComponent} from \"../host\";\nimport {IRefConfig} from \"../common\";\n\nexport class MessageDirection {\n static down = 'down' as const\n static up = 'up' as const\n}\n\nexport type MessageDirectionOption = 'up' | 'down';\n\nexport abstract class BaseMyopMessage<T = any> {\n id = uuidv4()\n\n static create<T, U extends new (...args: ConstructorParameters<U>) => T = typeof this>(\n this: U,\n ...args: ConstructorParameters<U>\n ): InstanceType<typeof this> {\n // @ts-ignore\n return new this(...args);\n }\n\n constructor() {\n //console.log('meesage id created', this.id, document.location.href);\n }\n\n myop = true\n\n abstract messageType: MyopMessageKey | string;\n\n content?: T\n\n // TODO : cant be optional \n source?: string\n destination?: string\n\n route?: string[]\n\n ref?: Ref\n\n direction?: MessageDirectionOption\n\n cleanable: boolean = false\n\n isTypeof(msg: BaseMyopMessage): boolean {\n return msg.messageType === this.messageType\n }\n}\n\nexport abstract class MyopElementMessage<T = any> extends BaseMyopMessage<T> {\n constructor(public ref: Ref) {\n super()\n }\n}\n\nexport abstract class MyopBindReplayMessage<T = any> extends BaseMyopMessage<T> {\n constructor(public replayToHandler?: string) {\n super();\n }\n}\n\nexport abstract class MyopBindMessage<T = any, R extends MyopBindReplayMessage = any> extends BaseMyopMessage<T> {\n\n public abstract replyMessageKey: MyopMessageKey;\n\n public handlerUniqueId = uuidv4()\n\n constructor(public handler: (message: R) => void) {\n super()\n }\n}\n\nexport class Ref {\n public myop = true;\n\n public __nonProxied?: Ref;\n\n static create(selector: string, refConfig?: IRefConfig, component?: IMyopComponent) {\n let _refConfig = refConfig;\n if (!_refConfig) {\n _refConfig = {\n id: '',\n name: '',\n description: '',\n selectorType: 'id-attribute',\n selector: selector,\n behavior: {\n type: 'code'\n }\n } as IRefConfig\n }\n return new Ref(_refConfig, component);\n }\n\n constructor(public refConfig: IRefConfig, public component?: IMyopComponent) {\n this.__nonProxied = {\n ...this,\n component: null // in order to be serializable\n }\n }\n}\n", "import {MyopBindMessage, MyopBindReplayMessage} from \"./BaseMessage\";\nimport {MyopMessageKey} from \"../common/MyopMessages\";\nimport {RootRef} from \"../common\";\nimport {makeSerializable} from \"../common/utils/serialization.ts\";\n\nconst ReplayMessageKey = 'ExecuteScriptReplyMessage'\n\nconst functionBodyRegex = /(?:function\\s*\\w*\\s*\\([^)]*\\)\\s*\\{([\\s\\S]*?)\\}|(\\([^)]*\\)\\s*=>\\s*\\{([\\s\\S]*?)\\}))\\s*$/;\nconst expressionBodyRegex = /\\(\\s*[^)]+\\s*\\)\\s*=>\\s*(.+)/;\n\nexport const stripFunction = (content: string) => {\n let match = content.match(functionBodyRegex);\n if (match) {\n return match[1] || match[3];\n } else {\n let match = content.match(expressionBodyRegex);\n if (match)\n return match[1].trim();\n }\n}\n\nexport type scriptInputs = {\n [key: string]: string | number | boolean\n} | {};\n\nexport type scriptVars<T> = {\n send: (data: T) => void;\n // completeStream: () => void;\n rootRef: RootRef;\n makeSerializable: typeof makeSerializable\n}\n\nexport type extendedScriptVars<T, I> = {\n [K in keyof I]: I[K];\n} & scriptVars<T>\n\nexport class ExecuteScriptMessage<T = any, I extends scriptInputs = any> extends MyopBindMessage<string, ExecuteScriptReplyMessage<T>> {\n\n replyMessageKey: MyopMessageKey = ReplayMessageKey;\n messageType = 'ExecuteScriptMessage';\n script: string = ''\n\n static replierKey = 'send';\n static completeStreamKey = 'completeStream';\n\n constructor(script: (vars: extendedScriptVars<T, I>) => T, handler: (message: ExecuteScriptReplyMessage<T>) => void = () => {\n }, public scriptInputs?: I) {\n super(handler);\n this.script = script.toString();\n\n //TODO: can be remove\n this.content = script.toString()\n this.content = stripFunction(this.content);\n }\n}\n\nexport class ExecuteScriptReplyMessage<T = any> extends MyopBindReplayMessage<T> {\n\n messageType = ReplayMessageKey;\n\n constructor(public replayToHandler: string, public content: T) {\n super(replayToHandler);\n }\n}\n", "import {\n ExecuteScriptMessage,\n ExecuteScriptReplyMessage,\n extendedScriptVars,\n scriptInputs, stripFunction\n} from \"./ExecuteScriptMessage.ts\";\n\nexport type customRefScriptInputs = {\n elementId: string,\n ref?: HTMLElement,\n _script?: string,\n __scriptInputs?: Object\n};\n\nexport class CustomRefMessage<T = any, I extends scriptInputs = customRefScriptInputs> extends ExecuteScriptMessage<T, I & customRefScriptInputs> {\n\n constructor(script: (vars: extendedScriptVars<T, I & customRefScriptInputs>) => T,\n public scriptInputs: I & customRefScriptInputs,\n handler: (message: ExecuteScriptReplyMessage<T>) => void = () => {\n }) {\n\n //mock vars\n // let rootRef, elementId, _script, __scriptInputs;\n super(({rootRef, elementId, _script, __scriptInputs}) => {\n const refs = (rootRef.shadowRoot || rootRef.container).querySelectorAll(`[${'myop-id'}='${elementId}']`);\n if (refs.length) {\n // const ref = refs[0];\n\n //TODO : think about exposing \"refs\" and not only \"ref\"\n //for cases where the Ref has multiplate implementations\n\n // @ts-ignore\n __scriptInputs.ref = refs[0];\n\n const dynamicFunction = new Function(`return (${_script})(...arguments)`);\n return dynamicFunction(__scriptInputs);\n\n // @ts-ignore\n //return Function('ref', 'rootRef', ...Object.keys(__scriptInputs), _script!)(ref, rootRef, ...Object.values(__scriptInputs))\n }\n return null as T;\n }, handler);\n\n this.scriptInputs = {\n ...scriptInputs,\n //_script: stripFunction(script.toString()),\n _script: script.toString()\n };\n }\n}\n", "import type * as CSS from \"csstype\";\nimport {IMyopComponent} from \"../host\";\nimport {uuidv4} from \"../utils/utils.ts\";\nimport {ExecuteScriptMessage} from \"../messages\";\n\n// ignoring documentation\n/** @ignore */\nexport interface CSSProperties extends CSS.Properties<string | number> {\n}\n\nexport type StylesheetDefinition = { [key: string]: CSSProperties };\n\nexport const applyStylesheet = (component: IMyopComponent, stylesheet: StylesheetDefinition, css?: string) => {\n const tagId = `myop-css-${uuidv4()}`;\n component.send(new ExecuteScriptMessage(({rootRef, _stylesheet, _tagId, _css}) => {\n const styleTag = document.createElement('style');\n styleTag.type = 'text/css';\n\n // Build the CSS string from the styles object\n let cssString = _css;\n\n for (const selector in _stylesheet) {\n cssString += `${selector} { `;\n const properties = _stylesheet[selector];\n for (const property in properties) {\n cssString += `${property}: ${properties[property]}; `;\n }\n cssString += '} ';\n }\n\n // Set the CSS string as the content of the <style> element\n styleTag.appendChild(document.createTextNode(cssString));\n styleTag.id = _tagId;\n // Append the <style> element\n (rootRef.shadowRoot || rootRef.container).appendChild(styleTag);\n\n }, () => {\n }, {\n _stylesheet: stylesheet,\n _css : css ? css : '',\n _tagId: tagId\n }));\n\n return () => {\n component.send(new ExecuteScriptMessage(({rootRef, _tagId}) => {\n const element = (rootRef.shadowRoot || document).getElementById(_tagId);\n if (element) {\n element.remove();\n }\n }, () => {\n }, {\n _tagId: tagId\n }))\n }\n}\n\nexport const applyStylesheetLink = (component: IMyopComponent, link: string) => {\n const tagId = `myop-css-${uuidv4()}`;\n component.send(new ExecuteScriptMessage(({rootRef, _tagId, _link}) => {\n const linkElement = document.createElement('link');\n linkElement.id = _tagId;\n linkElement.rel = 'stylesheet';\n linkElement.href = _link;\n document.head.appendChild(linkElement);\n\n // Append the <style> element\n (rootRef.shadowRoot || rootRef.container).appendChild(linkElement);\n }, () => {\n }, {\n _link : link,\n _tagId: tagId\n }));\n\n return () => {\n component.send(new ExecuteScriptMessage(({rootRef, _tagId}) => {\n const element = (rootRef.shadowRoot || document).getElementById(_tagId);\n if (element) {\n element.remove();\n }\n }, () => {\n }, {\n _tagId: tagId\n }))\n }\n}\n", "import {IIframeLoaderConfig, ISkinConfig} from \"../common\";\n\nexport type TokenMap = Record<string, string| number>\n\nconst replaceTokens = (input: string, tokenMap: TokenMap): string => {\n // Create a regex pattern from the keys of the tokenMap\n const pattern = new RegExp(Object.keys(tokenMap).join('|'), 'g');\n\n // Replace tokens in the input string using the regex\n return input.replace(pattern, (matched) => {\n // Return the replacement value from the tokenMap\n return (tokenMap[matched] || matched).toString();\n });\n}\n\nexport const createIframeSkinByTokenizer = (selectedSkin: ISkinConfig, tokenMap: TokenMap) => {\n const typedSkinConfig = (selectedSkin.loader as IIframeLoaderConfig)\n if (typedSkinConfig.type !== 'IframeLoader') {\n throw new Error(`iframeSkinUrlTokenizer received skin with loader type \"${typedSkinConfig.type}\", currently only \"IframeLoader\" is supported`)\n }\n\n selectedSkin.loader = {\n ...selectedSkin.loader\n }\n\n selectedSkin.loader.url = replaceTokens(selectedSkin.loader.url, tokenMap);\n\n return selectedSkin;\n}\n\nexport const changeSkinUrlByTokenizer = (tokenMap: TokenMap) => {\n return async (selectedSkin: ISkinConfig) => {\n return createIframeSkinByTokenizer(selectedSkin, tokenMap);\n }\n}", "import {CustomRefMessage} from \"../messages\";\nimport {IMyopComponent} from \"../host\";\n\n// const space = ' ';\n// export const getClasses = async (connectedRef: Ref): Promise<string[]> => (await exec(actAs<HTMLDivElement>(connectedRef).classList)).value.split(space);\n// export const addClass = async (connectedRef: Ref, className: string) => {\n// const classes = await getClasses(connectedRef);\n// classes.includes(className) || classes.push(className);\n// // @ts-ignore\n// connectedRef.classList = classes.join(space);\n// }\n// export const removeClass = async (connectedRef: Ref, className: string,) => {\n// let classes = await getClasses(connectedRef);\n// // @ts-ignore\n// connectedRef.classList = classes.filter(c => c !== className).join(space);\n// }\n//\n//\n\nexport const addClass = (component: IMyopComponent, className: string, myopId: string) => {\n component.send(new CustomRefMessage(({ref, _className}) => {\n ref?.classList.add(_className);\n }, {\n elementId: myopId,\n _className: className\n }));\n}\n\nexport const removeClass = (component: IMyopComponent, className: string, myopId: string) => {\n component.send(new CustomRefMessage(({ref, _className}) => {\n ref?.classList.remove(_className);\n }, {\n elementId: myopId,\n _className: className\n }));\n}", "import {\n IComponentConfig,\n IComponentDefinitionConfig,\n IComponentInstanceConfig, IHTMLLoaderConfig, IRefConfig,\n ISkinLoaderConfig,\n ISkinSelectorConfig,\n IDedicatedSkinConfig, ISkinConfig\n} from \"../common\";\nimport {uuidv4} from \"../utils/utils.ts\";\n\nexport class SkinConfig implements ISkinConfig {\n _runTimeInstanceId = 'runtime-instance-id-' + uuidv4();\n _runTimeId = 'runtime-id-' + uuidv4();\n _runTimeName = 'runtime-name-' + uuidv4();\n\n static create = () => {\n return new SkinConfig();\n }\n\n id = this._runTimeId;\n name = this._runTimeName;\n description = '';\n loader = null as unknown as ISkinLoaderConfig;\n\n withLoader = (loader: ISkinLoaderConfig) => {\n this.loader = loader;\n return this;\n }\n\n withHTMLLoader = (loader: Omit<IHTMLLoaderConfig, 'type'>) => {\n loader.type = 'HTMLLoader';\n this.loader = loader as IHTMLLoaderConfig;\n return this;\n }\n\n build = () => {\n return this;\n }\n}\n\nexport class ComponentConfig implements IComponentConfig {\n _runTimeInstanceId = 'runtime-instance-id-' + uuidv4();\n _runTimeId = 'runtime-id-' + uuidv4();\n _runTimeName = 'runtime-name-' + uuidv4();\n\n static create = () => {\n return new ComponentConfig();\n }\n\n instance = {\n id: this._runTimeInstanceId,\n componentId: this._runTimeId,\n componentName: this._runTimeName,\n skinSelector: null as unknown as ISkinSelectorConfig\n } as IComponentInstanceConfig;\n\n name = this._runTimeName\n type = {\n id: this._runTimeId,\n name: this._runTimeName,\n description: '',\n props: [],\n refs: [],\n skins: [],\n defaultSkin: 0\n } as IComponentDefinitionConfig\n\n withInstance = (instance: IComponentInstanceConfig) => {\n this.instance = instance;\n return this;\n }\n\n withType = (type: IComponentDefinitionConfig) => {\n this.type = type;\n return this;\n }\n\n withName = (name: string) => {\n this.name = name;\n return this;\n }\n\n withDefaultSkin = (defaultSkin: ISkinConfig) => {\n this.type.skins.push(defaultSkin);\n this.type.defaultSkin = this.type.skins.length - 1;\n this.instance.skinSelector = {\n type: 'Dedicated',\n skin: {\n id: defaultSkin.id\n }\n } as IDedicatedSkinConfig\n\n return this;\n }\n\n withRef = (ref: IRefConfig) => {\n this.type.refs.push(ref);\n return this;\n }\n\n withBasicRef = (refSelector: string) => {\n const newBasicRef = {\n id: '',\n name: refSelector,\n description: '',\n selectorType: 'id-attribute',\n selector: refSelector,\n behavior: {\n type: 'code'\n }\n } as IRefConfig\n\n this.type.refs.push(newBasicRef);\n return this;\n }\n\n build = () => {\n return JSON.parse(JSON.stringify(this))\n }\n}\n", "import {MyopMessageKey} from \"./MyopMessages\";\n\nexport * from './MyopElementRef';\nexport * from './baseMessageHandler';\nexport * from './BaseMyopSDK';\n\nexport type CleanupHandler = () => void\n\nexport type Dictionary<T> = { [key: string]: T; };\n\n//export type SkinLoaderType = 'IframeLoader' | 'WebComponentLoader' | 'HTMLLoader' | string;\n\nexport const SkinLoaders = {\n \"IframeLoader\": \"IframeLoader\",\n \"WebComponentLoader\": \"WebComponentLoader\",\n \"HTMLLoader\": \"HTMLLoader\",\n \"MinimizedLoader\": \"MinimizedLoader\"\n} as const;\nexport type SkinLoaderType = keyof typeof SkinLoaders;\n\nexport type PropType = 'any' | 'string' | 'number' | string; // TODO : <\nexport type RefSelectorType = 'id-attribute' | 'css-selector' | 'xpath' | string;\n\nexport const LoaderFrameworks = {\n \"react\": \"react\",\n \"vue\": \"vue\",\n \"angular\": \"angular\",\n} as const\nexport type LoaderFrameworkType = keyof typeof LoaderFrameworks;\n\nexport interface IWebComponentLoaderConfig extends ISkinLoaderConfig {\n type: \"WebComponentLoader\";\n url: string,\n tag: string,\n framework?: LoaderFrameworkType\n}\n\nexport interface IIframeLoaderConfig extends ISkinLoaderConfig {\n type: \"IframeLoader\";\n url: string\n autoHeight: boolean\n height?: string\n width?: string\n}\n\nexport const ShadowRootModeType = {\n \"open\": \"open\",\n \"closed\": \"closed\",\n \"none\": \"none\",\n \"localFrame\": \"localFrame\"\n} as const;\n\n\nexport interface IHTMLLoaderConfig extends ISkinLoaderConfig {\n type: \"HTMLLoader\";\n HTML: string;\n //TODO: rename(rootMode/customElementMode) + db migration\n shadowRootMode?: keyof typeof ShadowRootModeType;\n autoHeight?: boolean;\n height?: string;\n width?: string;\n}\n\n//for internal dashboard usage\nexport interface IMinimizedLoaderConfig extends ISkinLoaderConfig {\n type: \"MinimizedLoader\";\n}\n\ninterface DashboardObject {\n _temp_client_id?: string,\n}\n\ntype Extend<T, U> = T & U;\n\ntype ExtendRecursively<T, E> = {\n [K in keyof E]: E[K];\n} & {\n [K in keyof T]: T[K] extends object\n ? ExtendRecursively<T[K], E>\n : T[K];\n};\n\nexport type IDashboard<T> = ExtendRecursively<T, DashboardObject>;\n\nexport interface ISkinLoaderConfig {\n type: SkinLoaderType\n\n [key: string]: any; // Allows any additional properties\n}\n\nexport interface v2_IReleaseMetadata {\n environmentId: string;\n environmentIdentifier: string;\n //\n // updatedOn?: string\n // updatedBy?: string\n}\n\nexport interface v2_IVariantConfig extends v2_IMyopStoredObject {\n loader: ISkinLoaderConfig\n componentId: string;\n\n releases?: v2_IReleaseMetadata[]\n}\n\nexport interface ISkinConfig {\n id: string\n name: string\n description: string\n loader: ISkinLoaderConfig\n createdBy?: string\n createdOn?: string\n}\n\nexport interface v2_ISkinConfig extends ISkinConfig {\n componentId: string\n}\n\nexport interface IMessagePropConfig extends IPropConfig {\n type: PropType\n messageType: MyopMessageKey\n}\n\nexport interface IBindMessagePropConfig extends IPropConfig {\n type: PropType\n messageType: MyopMessageKey\n}\n\nexport const PropMessageModes = {\n \"input\": \"input\",\n \"output\": \"output\"\n} as const;\n\nexport const PropConfigBehaviorTypes = {\n \"message\": \"message\",\n \"code\": \"code\"\n} as const;\n\nexport interface IPropMessageBehaviorParam {\n value: string\n}\n\nexport interface IPropBehavior {\n type: keyof typeof PropConfigBehaviorTypes\n}\n\nexport interface IPropCodeBehavior extends IPropBehavior {\n type: \"code\"\n remap?: string\n}\n\nexport interface IPropMessageBehavior extends IPropBehavior {\n type: \"message\"\n message: MyopMessageKey\n ref: string, //TODO make it id\n params: IPropMessageBehaviorParam[]\n mode: keyof typeof PropMessageModes\n}\n\nexport interface IPropConfig {\n id: string\n name: string\n description: string\n type: PropType\n behavior: IPropBehavior\n}\n\n\nexport class RefBehaviorType {\n static code = 'code' as const\n static component = 'component' as const\n}\n\nexport type IRefBehaviorType = 'code' | 'component';\n\nexport interface IRefBehavior {\n type: IRefBehaviorType\n}\n\nexport interface IComponentRefBehavior extends IRefBehavior {\n type: 'component'\n componentId: string\n\n /**\n * @deprecated\n * Property instance is deprecated and will be removed in future versions.\n */\n instance: IComponentInstanceConfig\n}\n\nexport interface ICodeRefBehavior extends IRefBehavior {\n type: 'code'\n}\n\nexport interface IRefConfig {\n id: string\n name: string\n description: string\n selectorType: RefSelectorType\n selector: string\n behavior: IRefBehavior\n}\n\n/**\n * Experience segment rule\n */\nexport interface IExperienceSegmentRule {\n property: string;\n operator: string;\n value: string;\n}\n\n/**\n * Experience A/B split version\n */\nexport interface IExperienceABSplitVersion {\n id: string;\n percentage: number;\n}\n\n/**\n * Experience A/B split configuration\n */\nexport interface IExperienceABSplit {\n versions: IExperienceABSplitVersion[];\n}\n\n/**\n * Experience segment configuration\n */\nexport interface IExperienceSegment {\n id: string;\n name: string;\n description: string;\n rules: IExperienceSegmentRule[];\n useAb: boolean;\n componentVariants: Record<string, string | Record<string, string>>;\n abSplit?: IExperienceABSplit;\n stickyProperties?: string[];\n}\n\n/**\n * Experience definition config (v2)\n */\nexport interface IExperienceDefinitionConfig extends v2_IMyopStoredObject {\n /** Selected component IDs */\n components: string[];\n /** Segment configurations */\n segments: IExperienceSegment[];\n /** Fallback variant per component */\n fallback: Record<string, string>;\n /** Tags */\n tags: string[];\n}\n\nexport interface IComponentDefinitionConfig {\n id: string;\n name: string,\n description: string,\n // props: Record<string, IPropConfig> //id - type\n // refs: Record<string, IRefConfig>,\n // skins: Record<string, ISkinConfig>\n props: IPropConfig[],\n refs: IRefConfig[],\n skins: ISkinConfig[],\n defaultSkin: number;\n\n //TODO : think about that\n //resolvedDefinitions?: IComponentDefinitionConfig[]\n //TODO : move to base class ( IStorableItem or so...)\n\n createdOn?: string\n createdBy?: string\n updatedBy?: string\n}\n\n\nexport interface v2_IBaseMyopObject {\n id: string,\n name: string,\n description: string,\n}\n\nexport interface v2_IMyopStoredObject extends v2_IBaseMyopObject {\n updatedOn?: string\n updatedBy?: string\n}\n\nexport interface v2_IComponentDefinitionConfig extends v2_IMyopStoredObject {\n variants_ids: string[],\n DTOs: v2_IDTO[],\n tags: string[],\n\n //\n variants_names: string[],\n variants_data: {\n name: string;\n id: string\n updatedOn?: string\n updatedBy?: string\n has_releases?: boolean\n }[],\n\n preview_variant: v2_IVariantConfig;\n extra?: {\n firstVariant: v2_IVariantConfig; //when new component creates at the client\n }\n}\n\nexport interface v2_IDTO extends v2_IMyopStoredObject {\n data: object\n methodName: string\n}\n\nexport interface ISkinInstanceConfig {\n id: string\n}\n\nexport interface ISkinSelectorConfig {\n type: keyof typeof SkinSelectorTypes,\n //skins: ISkinInstanceConfig[]\n}\n\nexport const SegmentType = {\n \"FunctionResult\": \"FunctionResult\",\n} as const;\n\nexport interface ISegmentInstance {\n segmentId: string;\n skinSelector: ISkinSelectorConfig\n}\n\nexport interface ISegmentDefinition {\n id: string;\n type: keyof typeof SegmentType\n}\n\nexport interface IFunctionResultsSegment extends ISegmentDefinition {\n id: string;\n type: typeof SegmentType.FunctionResult\n name: string\n description: string\n function: string\n}\n\nexport const SkinSelectorTypes = {\n \"Segmented\": \"Segmented\",\n \"Dedicated\": \"Dedicated\",\n\n /**\n * This Selector Type is not yet supported but will be added in a future release.\n * Please check the documentation for updates.\n *\n * @type {string}\n */\n \"Default\": \"Default\"\n} as const;\n\n\n/**\n * This Skin Config Type is not yet supported but will be added in a future release.\n * Please check the documentation for updates.\n *\n * @type {IDefaultSkinConfig}\n */\nexport interface IDefaultSkinConfig extends ISkinSelectorConfig {\n type: typeof SkinSelectorTypes.Default,\n}\n\nexport interface ISegmentedSkinConfig extends ISkinSelectorConfig {\n type: typeof SkinSelectorTypes.Segmented,\n segments: ISegmentInstance[]\n}\n\nexport interface IDedicatedSkinConfig extends ISkinSelectorConfig {\n type: typeof SkinSelectorTypes.Dedicated,\n\n /**\n * @deprecated Use {@link skin} instead.\n * Property skins is deprecated and will be removed in future versions.\n * Please update your code to use {@link skin} for better compatibility.\n *\n * @type {string}\n */\n skins?: ISkinInstanceConfig[] // deprecated\n skin: ISkinInstanceConfig\n}\n\nexport interface IComponentInstanceConfig {\n id: string;\n componentId: string;\n\n //TODO :\n // RefID ? to support more than 1 component from the same type in composites ?\n\n //TODO : remove\n componentName: string; // << check\n\n skinSelector: ISkinSelectorConfig\n\n // storing the nested config for ref components\n nestedComponents?: IComponentInstanceConfig[]\n\n //only on GET?\n //TODO : think about that\n resolvedExperiences?: IExperience[]\n // will include instance and def config in order to render in production\n resolvedNestedComponents?: IComponentConfig[]\n}\n\nexport const ExperienceTypes = {\n \"Segment\": \"Segment\",\n \"Promo\": \"Promo\",\n \"AB\": \"AB\"\n} as const;\n\nexport interface IExperience {\n id: string\n name: string\n description: string\n type: keyof typeof ExperienceTypes\n experiences: IExperience[]\n //stickinessFactor\n //EndDate\n}\n\n// export interface IABExperienceGroup {\n// id: string\n// name: string\n// percentage: number\n// }\n\nexport interface IABExperience extends IExperience {\n type: typeof ExperienceTypes.AB\n // groups: IABExperienceGroup[]\n experiences: IExperience[]\n percentage: number\n}\n\nexport interface IDateRange {\n id: string\n start: Date\n end: Date\n timezone: string\n}\n\nexport interface ISegmentExperience extends IExperience {\n type: keyof typeof ExperienceTypes\n segment: ISegmentDefinition\n dateRange?: IDateRange\n}\n\nexport interface IUserFlowDefinition {\n id: string;\n name: string;\n description: string;\n components: IComponentInstanceConfig[];\n origins: string[],\n experiences: IExperience[]\n branch?: string\n}\n\nexport interface IComponentConfig {\n instance: IComponentInstanceConfig\n type: IComponentDefinitionConfig\n\n // TODO : verify uniqueness (dashboard & server)\n name: string\n}\n\ninterface IBranchable {\n branch?: string\n}\n\nexport interface IUserFlow extends Omit<IUserFlowDefinition, 'components'>, IBranchable {\n components: IComponentConfig[]\n}\n\nexport class RootRef {\n constructor(public container: HTMLElement, public shadowRoot?: ShadowRoot) {\n\n }\n\n getRootDiv = () => {\n return (this.shadowRoot || this.container).querySelector('div')\n }\n\n getRoot = () => {\n return (this.shadowRoot || this.container);\n }\n}\n", "import {\n IComponentConfig,\n IComponentDefinitionConfig,\n IComponentInstanceConfig,\n IDedicatedSkinConfig,\n IPropConfig,\n ISkinConfig,\n IUserFlow,\n PropConfigBehaviorTypes,\n v2_IVariantConfig\n} from \"../common\";\n\nconst convertV2VariantToComponentConfig = (config: v2_IVariantConfig): IComponentConfig => {\n return {\n instance: {\n id: 'auto',\n componentId: config.componentId,\n componentName: config.name,\n\n skinSelector: {\n type: 'Dedicated',\n skin: {\n id: 'skin_auto_v2_converted'\n }\n } as IDedicatedSkinConfig\n\n } as IComponentInstanceConfig,\n type: {\n id: config.id,\n name: config.name,\n description: config.description,\n props: [\n {\n id: 'in_auto_v2_converted',\n name: 'myop_init_interface',\n type: 'any',\n behavior: {\n type: PropConfigBehaviorTypes.code\n }\n } as IPropConfig,\n\n {\n id: 'out_auto_v2_converted',\n name: 'myop_cta_handler',\n type: 'any',\n behavior: {\n type: PropConfigBehaviorTypes.code\n }\n } as IPropConfig\n ],\n refs: [],\n skins: [\n {\n id: 'skin_auto_v2_converted',\n name: 'auto_v2_converted',\n description: '',\n //TODO : handle empty :\n // @ts-ignore\n loader: config.consume_variant[0].loader\n } as ISkinConfig\n ],\n defaultSkin: 0\n } as IComponentDefinitionConfig,\n name: config.name\n } as IComponentConfig;\n};\n\n/**\n * CloudRepository - Unified cloud data access layer for Myop components\n *\n * Supports both v2 (default) and v1 modes:\n * - v2: Uses /consume endpoint for fetching variants\n * - v1: Uses /flow endpoint for fetching user flows\n */\nexport class CloudRepository {\n static Main = new CloudRepository();\n\n // v2 cache\n private variants: Record<string, Promise<IComponentConfig>> = {};\n\n // v1 cache\n private userFlows: Record<string, Promise<IUserFlow>> = {};\n\n private _defaultEnv = 'production';\n\n constructor(private _baseUrl = 'https://cloud.myop.dev') {\n }\n\n /**\n * Set the default environment for this CloudRepository instance\n */\n setEnvironment(env: string) {\n this._defaultEnv = env;\n }\n\n /**\n * Get the current default environment\n */\n getDefaultEnvironment(): string {\n return this._defaultEnv;\n }\n\n // ============ V2 Methods (Default) ============\n\n /**\n * Check if a component is already cached/preloaded (v2)\n */\n isPreloaded(componentId: string, env?: string, preview?: boolean): boolean {\n const cacheKey = `${componentId}:${env || this._defaultEnv}:${preview ? 'preview' : 'live'}`;\n return cacheKey in this.variants;\n }\n\n /**\n * Fetch a v2 component config\n */\n async fetchComponentV2(componentId: string, environmentIdentifier?: string, preview?: boolean): Promise<IComponentConfig> {\n const env = environmentIdentifier || this._defaultEnv;\n const cacheKey = `${componentId}:${env}:${preview ? 'preview' : 'live'}`;\n\n if (!this.variants[cacheKey]) {\n // eslint-disable-next-line no-async-promise-executor\n this.variants[cacheKey] = new Promise(\n async (resolve, reject) => {\n try {\n let url = `${this._baseUrl}/consume?id=${componentId}&env=${env}`;\n if (preview) {\n url += '&preview=true';\n }\n const res = await fetch(url);\n const json = await res.json();\n const variant = json.item;\n\n if (!variant) {\n reject(new Error(`Component \"${componentId}\" not found`));\n return;\n }\n\n if (!variant.consume_variant || !variant.consume_variant.length) {\n reject(new Error(`Component \"${componentId}\" has no implementation for environment \"${env}\"`));\n return;\n }\n\n const componentConfig = convertV2VariantToComponentConfig(variant);\n resolve(componentConfig);\n } catch (e) {\n reject(e);\n }\n }\n );\n }\n\n return await this.variants[cacheKey];\n }\n\n // ============ V1 Methods (Legacy) ============\n\n /**\n * Fetch a v1 component from a flow\n */\n async fetchComponentV1(componentId: string, flowId?: string) {\n if (flowId) {\n const flow = await this.fetchFlow(flowId);\n return flow.components.find(c => c.type.id === componentId);\n } else {\n const flow = await this.fetchAutoFlow(componentId);\n return flow.components[0];\n }\n }\n\n async fetchAutoFlow(componentId: string) {\n if (!this.userFlows[componentId]) {\n // eslint-disable-next-line no-async-promise-executor\n this.userFlows[componentId] = new Promise(\n async (resolve, reject) => {\n try {\n const res = await fetch(\n `${this._baseUrl}/flow?id=${componentId}&auto=true`\n );\n const json = await res.json();\n resolve(json.item);\n } catch (e) {\n reject(e);\n }\n }\n );\n }\n\n return await this.userFlows[componentId];\n }\n\n async fetchFlow(flowId: string) {\n if (!this.userFlows[flowId]) {\n // eslint-disable-next-line no-async-promise-executor\n this.userFlows[flowId] = new Promise(\n async (resolve, reject) => {\n try {\n const res = await fetch(\n `${this._baseUrl}/flow?id=${flowId}&resolve=components`\n );\n const json = await res.json();\n resolve(json.item);\n } catch (e) {\n reject(e);\n }\n }\n );\n }\n\n return await this.userFlows[flowId];\n }\n\n // ============ Backward Compatibility ============\n\n /**\n * @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly\n * Defaults to v1 behavior for backward compatibility with existing code\n */\n async fetchComponent(componentId: string, flowId?: string) {\n return this.fetchComponentV1(componentId, flowId);\n }\n}\n\n/**\n * @deprecated Use CloudRepository instead\n */\nexport const v2_CloudRepository = CloudRepository;\n", "export const exec = async (getter: any) => {\n return await getter()\n}\n", "import {defineDynamicImport} from \"../dyn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G,YAAK,UAAQ,aAAY,oBAAW;AAAA,YAC3C;AACA,kBAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,oBAAQ,KAAK,IAAI;AAAA,UACrB,SAAS,GAAG;AACR,mBAAO,CAAC;AAAA,UACZ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAEA,WAAO,MAAM,KAAK,UAAU,WAAW;AAAA,EAC3C;AAAA,EAEA,MAAM,UAAU,QAAgB;AAC5B,QAAI,CAAC,KAAK,UAAU,MAAM,GAAG;AAEzB,WAAK,UAAU,MAAM,IAAI,IAAI;AAAA,QACzB,OAAO,SAAS,WAAW;AACvB,cAAI;AACA,kBAAM,MAAM,MAAM;AAAA,cACd,GAAG,YAAK,UAAQ,aAAY,eAAM;AAAA,YACtC;AACA,kBAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,oBAAQ,KAAK,IAAI;AAAA,UACrB,SAAS,GAAG;AACR,mBAAO,CAAC;AAAA,UACZ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAEA,WAAO,MAAM,KAAK,UAAU,MAAM;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,eAAe,aAAqB,QAAiB;AACvD,WAAO,KAAK,iBAAiB,aAAa,MAAM;AAAA,EACpD;AACJ;AAjJI,cADS,kBACF,QAAO,IAAI,iBAAgB;AAD/B,IAAM,kBAAN;AAuJA,IAAM,qBAAqB;;;ACjO3B,IAAM,OAAO,OAAO,WAAgB;AACvC,SAAO,MAAM,OAAO;AACxB;;;ACGA,oBAAoB,eAAe,eAAW;",
|
|
6
6
|
"names": ["match", "scriptInputs", "scriptInputs"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var D=Object.defineProperty,F=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var R=(s,e,n)=>e in s?D(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n,M=(s,e)=>{for(var n in e||(e={}))A.call(e,n)&&R(s,n,e[n]);if(L)for(var n of L(e))U.call(e,n)&&R(s,n,e[n]);return s},k=(s,e)=>F(s,O(e));var V=(s,e)=>{for(var n in e)D(s,n,{get:e[n],enumerable:!0})};var t=(s,e,n)=>R(s,typeof e!="symbol"?e+"":e,n);var h="__federation__",K="onLoad";var P=(s,e)=>{window[h]&&window[h][s]&&window[h][s][K]&&window[h][s][K]({[s]:e})};var _={};V(_,{CloudRepository:()=>S,ComponentConfig:()=>E,SkinConfig:()=>w,addClass:()=>Q,applyStylesheet:()=>G,applyStylesheetLink:()=>q,changeSkinUrlByTokenizer:()=>J,createIframeSkinByTokenizer:()=>H,exec:()=>ee,removeClass:()=>X,v2_CloudRepository:()=>Z});var p=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+s/4).toString(16));var g=class{constructor(){t(this,"id",p());t(this,"myop",!0);t(this,"content");t(this,"source");t(this,"destination");t(this,"route");t(this,"ref");t(this,"direction");t(this,"cleanable",!1)}static create(...e){return new this(...e)}isTypeof(e){return e.messageType===this.messageType}};var m=class extends g{constructor(n){super();this.handler=n;t(this,"handlerUniqueId",p())}};var $="ExecuteScriptReplyMessage",z=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,j=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,N=s=>{let e=s.match(z);if(e)return e[1]||e[3];{let n=s.match(j);if(n)return n[1].trim()}},l=class extends m{constructor(n,o=()=>{},r){super(o);this.scriptInputs=r;t(this,"replyMessageKey",$);t(this,"messageType","ExecuteScriptMessage");t(this,"script","");this.script=n.toString(),this.content=n.toString(),this.content=N(this.content)}};t(l,"replierKey","send"),t(l,"completeStreamKey","completeStream");var x=class extends l{constructor(n,o,r=()=>{}){super(({rootRef:i,elementId:a,_script:y,__scriptInputs:c})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(c.ref=d[0],new Function("return (".concat(y,")(...arguments)"))(c)):null},r);this.scriptInputs=o;this.scriptInputs=k(M({},o),{_script:n.toString()})}};var G=(s,e,n)=>{let o="myop-css-".concat(p());return s.send(new l(({rootRef:r,_stylesheet:i,_tagId:a,_css:y})=>{let c=document.createElement("style");c.type="text/css";let d=y;for(let I in i){d+="".concat(I," { ");let f=i[I];for(let C in f)d+="".concat(C,": ").concat(f[C],"; ");d+="} "}c.appendChild(document.createTextNode(d)),c.id=a,(r.shadowRoot||r.container).appendChild(c)},()=>{},{_stylesheet:e,_css:n||"",_tagId:o})),()=>{s.send(new l(({rootRef:r,_tagId:i})=>{let a=(r.shadowRoot||document).getElementById(i);a&&a.remove()},()=>{},{_tagId:o}))}},q=(s,e)=>{let n="myop-css-".concat(p());return s.send(new l(({rootRef:o,_tagId:r,_link:i})=>{let a=document.createElement("link");a.id=r,a.rel="stylesheet",a.href=i,document.head.appendChild(a),(o.shadowRoot||o.container).appendChild(a)},()=>{},{_link:e,_tagId:n})),()=>{s.send(new l(({rootRef:o,_tagId:r})=>{let i=(o.shadowRoot||document).getElementById(r);i&&i.remove()},()=>{},{_tagId:n}))}};var W=(s,e)=>{let n=new RegExp(Object.keys(e).join("|"),"g");return s.replace(n,o=>(e[o]||o).toString())},H=(s,e)=>{let n=s.loader;if(n.type!=="IframeLoader")throw new Error('iframeSkinUrlTokenizer received skin with loader type "'.concat(n.type,'", currently only "IframeLoader" is supported'));return s.loader=M({},s.loader),s.loader.url=W(s.loader.url,e),s},J=s=>async e=>H(e,s);var Q=(s,e,n)=>{s.send(new x(({ref:o,_className:r})=>{o==null||o.classList.add(r)},{elementId:n,_className:e}))},X=(s,e,n)=>{s.send(new x(({ref:o,_className:r})=>{o==null||o.classList.remove(r)},{elementId:n,_className:e}))};var T=class T{constructor(){t(this,"_runTimeInstanceId","runtime-instance-id-"+p());t(this,"_runTimeId","runtime-id-"+p());t(this,"_runTimeName","runtime-name-"+p());t(this,"id",this._runTimeId);t(this,"name",this._runTimeName);t(this,"description","");t(this,"loader",null);t(this,"withLoader",e=>(this.loader=e,this));t(this,"withHTMLLoader",e=>(e.type="HTMLLoader",this.loader=e,this));t(this,"build",()=>this)}};t(T,"create",()=>new T);var w=T,b=class b{constructor(){t(this,"_runTimeInstanceId","runtime-instance-id-"+p());t(this,"_runTimeId","runtime-id-"+p());t(this,"_runTimeName","runtime-name-"+p());t(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null});t(this,"name",this._runTimeName);t(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0});t(this,"withInstance",e=>(this.instance=e,this));t(this,"withType",e=>(this.type=e,this));t(this,"withName",e=>(this.name=e,this));t(this,"withDefaultSkin",e=>(this.type.skins.push(e),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:e.id}},this));t(this,"withRef",e=>(this.type.refs.push(e),this));t(this,"withBasicRef",e=>{let n={id:"",name:e,description:"",selectorType:"id-attribute",selector:e,behavior:{type:"code"}};return this.type.refs.push(n),this});t(this,"build",()=>JSON.parse(JSON.stringify(this)))}};t(b,"create",()=>new b);var E=b;var B={message:"message",code:"code"};var Y=s=>({instance:{id:"auto",componentId:s.componentId,componentName:s.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:s.id,name:s.name,description:s.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:B.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:B.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:s.consume_variant[0].loader}],defaultSkin:0},name:s.name}),v=class v{constructor(e="https://cloud.myop.dev"){this._baseUrl=e;t(this,"variants",{});t(this,"userFlows",{});t(this,"_defaultEnv","production")}setEnvironment(e){this._defaultEnv=e}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(e,n,o){return"".concat(e,":").concat(n||this._defaultEnv,":").concat(o?"preview":"live")in this.variants}async fetchComponentV2(e,n,o){let r=n||this._defaultEnv,i="".concat(e,":").concat(r,":").concat(o?"preview":"live");return this.variants[i]||(this.variants[i]=new Promise(async(a,y)=>{try{let c="".concat(this._baseUrl,"/consume?id=").concat(e,"&env=").concat(r);o&&(c+="&preview=true");let f=(await(await fetch(c)).json()).item;if(!f){y(new Error('Component "'.concat(e,'" not found')));return}if(!f.consume_variant||!f.consume_variant.length){y(new Error('Component "'.concat(e,'" has no implementation for environment "').concat(r,'"')));return}let C=Y(f);a(C)}catch(c){y(c)}})),await this.variants[i]}async fetchComponentV1(e,n){return n?(await this.fetchFlow(n)).components.find(r=>r.type.id===e):(await this.fetchAutoFlow(e)).components[0]}async fetchAutoFlow(e){return this.userFlows[e]||(this.userFlows[e]=new Promise(async(n,o)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(e,"&auto=true"))).json();n(i.item)}catch(r){o(r)}})),await this.userFlows[e]}async fetchFlow(e){return this.userFlows[e]||(this.userFlows[e]=new Promise(async(n,o)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(e,"&resolve=components"))).json();n(i.item)}catch(r){o(r)}})),await this.userFlows[e]}async fetchComponent(e,n){return this.fetchComponentV1(e,n)}};t(v,"Main",new v);var S=v,Z=S;var ee=async s=>await s();P("MyopHelpers",_);export{S as CloudRepository,E as ComponentConfig,w as SkinConfig,Q as addClass,G as applyStylesheet,q as applyStylesheetLink,J as changeSkinUrlByTokenizer,H as createIframeSkinByTokenizer,ee as exec,X as removeClass,Z as v2_CloudRepository};
|