@myop/vue 0.0.25 → 0.0.27
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 +290 -111
- package/dist/components/MyopComponent.vue.d.ts +27 -0
- package/dist/components/MyopFallback.vue.d.ts +12 -0
- package/dist/components/MyopLoader.vue.d.ts +19 -0
- package/dist/index.d.ts +44 -1
- package/dist/index.js +633 -1990
- package/dist/index.umd.cjs +11 -110
- package/dist/types.d.ts +75 -0
- package/package.json +18 -4
package/dist/index.umd.cjs
CHANGED
|
@@ -1,116 +1,17 @@
|
|
|
1
|
-
(function(F,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],m):(F=typeof globalThis<"u"?globalThis:F||self,m(F["@myop/vue"]={},F.Vue))})(this,function(F,m){"use strict";var Jt=Object.defineProperty,Yt=(e,t,s)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,p=(e,t,s)=>Yt(e,typeof t!="symbol"?t+"":t,s),z=(e,t,s)=>new Promise((n,i)=>{var o=l=>{try{c(s.next(l))}catch(d){i(d)}},r=l=>{try{c(s.throw(l))}catch(d){i(d)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,r);c((s=s.apply(e,t)).next())}),k=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),Xt=class{constructor(){p(this,"id",k()),p(this,"myop",!0),p(this,"content"),p(this,"source"),p(this,"destination"),p(this,"route"),p(this,"ref"),p(this,"direction"),p(this,"cleanable",!1)}static create(...t){return new this(...t)}isTypeof(t){return t.messageType===this.messageType}},Qt=class extends Xt{constructor(t){super(),this.handler=t,p(this,"handlerUniqueId",k())}},Zt="ExecuteScriptReplyMessage",es=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,ts=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,ss=e=>{let t=e.match(es);if(t)return t[1]||t[3];{let s=e.match(ts);if(s)return s[1].trim()}},Fe=class extends Qt{constructor(t,s=()=>{},n){super(s),this.scriptInputs=n,p(this,"replyMessageKey",Zt),p(this,"messageType","ExecuteScriptMessage"),p(this,"script",""),this.script=t.toString(),this.content=t.toString(),this.content=ss(this.content)}};p(Fe,"replierKey","send"),p(Fe,"completeStreamKey","completeStream");var Pe=class{constructor(){p(this,"_runTimeInstanceId","runtime-instance-id-"+k()),p(this,"_runTimeId","runtime-id-"+k()),p(this,"_runTimeName","runtime-name-"+k()),p(this,"id",this._runTimeId),p(this,"name",this._runTimeName),p(this,"description",""),p(this,"loader",null),p(this,"withLoader",t=>(this.loader=t,this)),p(this,"withHTMLLoader",t=>(t.type="HTMLLoader",this.loader=t,this)),p(this,"build",()=>this)}};p(Pe,"create",()=>new Pe);var Le=class{constructor(){p(this,"_runTimeInstanceId","runtime-instance-id-"+k()),p(this,"_runTimeId","runtime-id-"+k()),p(this,"_runTimeName","runtime-name-"+k()),p(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null}),p(this,"name",this._runTimeName),p(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0}),p(this,"withInstance",t=>(this.instance=t,this)),p(this,"withType",t=>(this.type=t,this)),p(this,"withName",t=>(this.name=t,this)),p(this,"withDefaultSkin",t=>(this.type.skins.push(t),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:t.id}},this)),p(this,"withRef",t=>(this.type.refs.push(t),this)),p(this,"withBasicRef",t=>{const s={id:"",name:t,description:"",selectorType:"id-attribute",selector:t,behavior:{type:"code"}};return this.type.refs.push(s),this}),p(this,"build",()=>JSON.parse(JSON.stringify(this)))}};p(Le,"create",()=>new Le);var de=class{constructor(t="https://cloud.myop.dev"){this._baseUrl=t,p(this,"userFlows",{})}fetchComponent(t,s){return z(this,null,function*(){return s?(yield this.fetchFlow(s)).components.find(i=>i.type.id===t):(yield this.fetchAutoFlow(t)).components[0]})}fetchAutoFlow(t){return z(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>z(this,null,function*(){try{const o=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&auto=true`)).json();s(o.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}fetchFlow(t){return z(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>z(this,null,function*(){try{const o=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&resolve=components`)).json();s(o.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}};p(de,"Main",new de);var ns=de,Ae=Object.defineProperty,is=Object.defineProperties,os=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,rs=Object.prototype.hasOwnProperty,as=Object.prototype.propertyIsEnumerable,ue=(e,t,s)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,w=(e,t)=>{for(var s in t||(t={}))rs.call(t,s)&&ue(e,s,t[s]);if(Ve)for(var s of Ve(t))as.call(t,s)&&ue(e,s,t[s]);return e},q=(e,t)=>is(e,os(t)),cs=(e,t)=>{for(var s in t)Ae(e,s,{get:t[s],enumerable:!0})},a=(e,t,s)=>ue(e,typeof t!="symbol"?t+"":t,s),g=(e,t,s)=>new Promise((n,i)=>{var o=l=>{try{c(s.next(l))}catch(d){i(d)}},r=l=>{try{c(s.throw(l))}catch(d){i(d)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,r);c((s=s.apply(e,t)).next())}),Y="__federation__",Be="onLoad",Ke=(e,t)=>{window[Y]&&window[Y][e]&&window[Y][e][Be]&&window[Y][e][Be]({[e]:t})},y={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",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",CleanupMessage:"CleanupMessage",In:{MutationObserverMessage:"MutationObserverMessage",ResizeObserverMessage:"ResizeObserverMessage"}},he={};cs(he,{AddEventListenerMessage:()=>ws,BaseMyopMessage:()=>M,BindClickMessage:()=>fs,ChangeTextMessage:()=>ms,CleanupMessage:()=>at,CleanupReplayMessage:()=>ct,ClickReplayMessage:()=>ze,CreateRefComponentMessage:()=>tt,CustomRefMessage:()=>pe,DetectMyopRefsMessage:()=>Es,DetectedMyopRefsMessage:()=>it,DisposeMessage:()=>lt,ElementValueReplayMessage:()=>Xe,EnvelopedMessage:()=>st,EventListenerCallbackMessage:()=>Je,ExecuteComponentMethod:()=>O,ExecuteScriptMessage:()=>H,ExecuteScriptReplyMessage:()=>We,GetAttributeMessage:()=>bs,GetAttributeReplayMessage:()=>Cs,GetElementValueMessage:()=>Ms,InitMessage:()=>fe,InitRequest:()=>Ze,InitResponse:()=>Qe,MessageDirection:()=>b,MutationObserverMessage:()=>Is,MyopBindMessage:()=>T,MyopBindReplayMessage:()=>I,MyopElementMessage:()=>ps,Ref:()=>j,RefComponentCreatedMessage:()=>me,ResizeObserverMessage:()=>xs,SetAttributeMessage:()=>vs,SetInnerHtml:()=>_s,SetMutationObserverMessage:()=>Ss,SetResizeObserverMessage:()=>Ts,stripFunction:()=>je});var L=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),ls=e=>{const t=[...e].map(s=>s.toString(16).padStart(2,"0")).join("");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")},ds=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";const s=atob(t);return Uint8Array.from(s,n=>n.charCodeAt(0))},us=e=>{const t=ds(e);if(t.length%16!==0)throw new Error("Invalid input length");const s=[];for(let n=0;n<t.length;n+=16)s.push(ls(t.slice(n,n+16)));return s},hs=e=>new Promise(t=>setTimeout(t,e)),b=class{};a(b,"down","down"),a(b,"up","up");var M=class{constructor(){a(this,"id",L()),a(this,"myop",!0),a(this,"content"),a(this,"source"),a(this,"destination"),a(this,"route"),a(this,"ref"),a(this,"direction"),a(this,"cleanable",!1)}static create(...e){return new this(...e)}isTypeof(e){return e.messageType===this.messageType}},ps=class extends M{constructor(e){super(),this.ref=e}},I=class extends M{constructor(e){super(),this.replayToHandler=e}},T=class extends M{constructor(e){super(),this.handler=e,a(this,"handlerUniqueId",L())}},j=class Gt{constructor(t,s){this.refConfig=t,this.component=s,a(this,"myop",!0),a(this,"__nonProxied"),this.__nonProxied=q(w({},this),{component:null})}static create(t,s,n){let i=s;return i||(i={id:"",name:"",description:"",selectorType:"id-attribute",selector:t,behavior:{type:"code"}}),new Gt(i,n)}},Ue="ClickReplayMessage",fs=class extends T{constructor(e,t){super(t),this.ref=e,a(this,"replyMessageKey",Ue),a(this,"messageType","BindClickMessage"),a(this,"cleanable",!0)}},ze=class extends I{constructor(){super(...arguments),a(this,"messageType",Ue)}},ms=class extends M{constructor(e,t){super(),this.ref=e,a(this,"messageType","ChangeTextMessage"),this.content=t}},qe="ExecuteScriptReplyMessage",gs=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,ys=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,je=e=>{let t=e.match(gs);if(t)return t[1]||t[3];{let s=e.match(ys);if(s)return s[1].trim()}},H=class extends T{constructor(e,t=()=>{},s){super(t),this.scriptInputs=s,a(this,"replyMessageKey",qe),a(this,"messageType","ExecuteScriptMessage"),a(this,"script",""),this.script=e.toString(),this.content=e.toString(),this.content=je(this.content)}};a(H,"replierKey","send"),a(H,"completeStreamKey","completeStream");var We=class extends I{constructor(e,t){super(e),this.replayToHandler=e,this.content=t,a(this,"messageType",qe)}},pe=class extends H{constructor(e,t,s=()=>{}){super(({rootRef:n,elementId:i,_script:o,__scriptInputs:r})=>{const c=(n.shadowRoot||n.container).querySelectorAll(`[myop-id='${i}']`);return c.length?(r.ref=c[0],new Function(`return (${o})(...arguments)`)(r)):null},s),this.scriptInputs=t,this.scriptInputs=q(w({},t),{_script:e.toString()})}},Ge="EventListenerCallbackMessage",ws=class extends T{constructor(e,t,s){super(s),this.ref=e,this.type=t,this.handler=s,a(this,"replyMessageKey",Ge),a(this,"messageType","AddEventListenerMessage"),a(this,"cleanable",!0),a(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},Je=class extends I{constructor(e,t){super(e),this.replayToHandler=e,this.e=t,a(this,"messageType",Ge),this.content={e:t}}},vs=class extends M{constructor(e,t,s){super(),this.ref=e,this.name=t,this.value=s,a(this,"messageType","SetAttributeMessage")}},Ye="ElementValueReplayMessage",Ms=class extends T{constructor(e,t){super(t),this.ref=e,a(this,"replyMessageKey",Ye),a(this,"messageType","GetElementValueMessage")}},Xe=class extends I{constructor(e){super(),this.content=e,a(this,"messageType",Ye)}},_s=class extends M{constructor(e,t){super(),this.ref=e,a(this,"messageType","SetInnerHtml"),this.content=t}},fe=class extends M{constructor(e){super(),a(this,"messageType","InitMessage"),this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},Qe=class extends fe{constructor(){super(...arguments),a(this,"messageType","InitResponse")}},Ze=class extends M{constructor(){super(...arguments),a(this,"messageType","InitRequest")}},et="RefComponentCreatedMessage",tt=class extends T{constructor(e,t,s,n){super(n),this.refConfig=e,this.nestedComponentConfig=t,this.options=s,a(this,"replyMessageKey",et),a(this,"messageType","CreateRefComponentMessage")}},me=class extends I{constructor(e,t,s){super(e),this.replayToHandler=e,this.nestedRefs=t,this.failed=s,a(this,"messageType",et)}},st=class extends M{constructor(e,t){super(),this.destination=e,this.message=t,a(this,"messageType","EnvelopedMessage");const s=t;this.route=[e,...s.route?s.route:[]]}},nt="DetectedMyopRefsMessage",Es=class extends T{constructor(){super(...arguments),a(this,"messageType","DetectMyopRefsMessage"),a(this,"replyMessageKey",nt)}},it=class extends I{constructor(e,t){super(e),this.replayToHandler=e,a(this,"messageType",nt),this.content=t}isTypeof(e){return e.messageType===this.messageType}},ot="GetAttributeReplayMessage",bs=class extends T{constructor(e,t,s){super(s),this.ref=e,this.name=t,a(this,"replyMessageKey",ot),a(this,"messageType","GetAttributeMessage")}},Cs=class extends I{constructor(e){super(),this.content=e,a(this,"messageType",ot)}},O=class extends M{constructor(e){super(),this.method=e,a(this,"messageType","ExecuteComponentMethod")}},Ss=class extends M{constructor(){super(...arguments),a(this,"messageType","SetMutationObserverMessage")}},Is=class extends M{constructor(){super(...arguments),a(this,"messageType","MutationObserverMessage")}},rt="CleanupReplayMessage",at=class extends T{constructor(e,t){super(t),this.cleanupForMessageId=e,a(this,"replyMessageKey",rt),a(this,"messageType","CleanupMessage")}},ct=class extends I{constructor(e){super(),this.customCleanup=e,a(this,"messageType",rt)}},lt=class extends M{constructor(){super(...arguments),a(this,"messageType","DisposeMessage")}},Ts=class extends M{constructor(){super(...arguments),a(this,"cleanable",!0),a(this,"messageType","SetResizeObserverMessage")}},xs=class extends M{constructor(){super(...arguments),a(this,"messageType","ResizeObserverMessage")}},ge=class{constructor(e,t,s){this.componentDefinition=e,this.container=t,a(this,"id",""),a(this,"messageHandlers",{}),a(this,"element"),a(this,"_markedForDisposed",!1),a(this,"bind",(i,o)=>{this.messageHandlers[i]||(this.messageHandlers[i]=[]),this.messageHandlers[i].includes(o)||this.messageHandlers[i].push(o)}),a(this,"bindWhen",(i,o,r)=>{if(!r)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[i]||(this.messageHandlers[i]=[]);const c=this.messageHandlers[i],l=d=>o(d)?(r(d),!0):!1;return c.push(l),()=>{const d=c.indexOf(l);d>-1&&c.splice(d,1)}}),a(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()}),a(this,"isInitiated",!1),a(this,"_whenInitiatedResolve"),a(this,"_whenInitiatedReject"),a(this,"_whenInitiated",new Promise((i,o)=>{this._whenInitiatedResolve=i,this._whenInitiatedReject=o})),a(this,"initiated",()=>this._whenInitiated),a(this,"props",{}),a(this,"refs",{}),this.id=(s==null?void 0:s.id)||Z.Instance().assignId(e);const n=s!=null&&s.timeout?s==null?void 0:s.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject(`timeout_${n} ${this.id}`)},n),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(e){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=e}onMessageReceived(e){if(e.messageType===y.ExecuteComponentMethod){const s=e;return this[s.method]?this[s.method](s.content):console.log(`method not found ${s.method} on component`,this),!0}const t=this.messageHandlers[e.messageType];if(t&&t.length){let s=!1;return t.forEach(n=>{s=s||n(e)}),s}return!1}sendCleanupMessage(e){e.source=this.id,e.destination=this.id,e.direction=b.down;const t=this.bindWhen(e.replyMessageKey,n=>n.replayToHandler===e.handlerUniqueId,n=>{e.handler(n),t()}),s=e.handler;delete e.handler,this.send(e),e.handler=s}send(e){e.source||(e.source=this.id),e.destination||(e.destination=this.id),e.direction=b.down;let t;if(e.handler){const s=e;t=this.bindWhen(s.replyMessageKey,n=>n.replayToHandler===s.handlerUniqueId,s.handler),delete e.handler}return e.ref&&(e.ref=e.ref.__nonProxied||e.ref),e.cleanable?()=>{this.sendCleanupMessage(new at(e.id,s=>{})),t&&t()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new lt);const e=this.messageHandlers.onDispose;e&&e.forEach(t=>{t(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}},Rs=class{constructor(e,t,s,n,i){this.myopId=e,this.htmlTagName=t,this.BoundingRect=s,this.offsetTop=n,this.offsetLeft=i,a(this,"type","MyopElementRef")}},ks=e=>g(void 0,null,function*(){if(typeof e=="function")e();else if(e instanceof Promise){const t=yield e;typeof t=="function"&&t()}}),Hs=class{constructor(e){this.messageToHost=e}},Os=class extends Hs{constructor(e,t){super(e),this.messageToHost=e,this.context=t}},Ds=class{constructor(e,t){this.id=e,this.context=t,a(this,"send",s=>{})}},Ns=class{constructor(){a(this,"messageToHandleAfterInit",[]),a(this,"components",{}),a(this,"alwaysPassEnvelopesToHost",!1),a(this,"messageCleanupCache",{})}handleIncomeMessages(e){const t=e.data?e.data:e.detail;if(!(!t||!t.myop)){let s=t;if(s.direction!==b.down)return;if(s.messageType===y.DisposeMessage){s.destination&&delete this.components[s.destination];return}if(s.messageType===y.InitMessage){const n=s.content.id;if(this.components[n])return;this.components[n]=new Ds(n),this.messageToHost(new Qe(n));return}if(s.messageType===y.EnvelopedMessage){const n=s,i=n.message;if(s=i,this.alwaysPassEnvelopesToHost||this.components[s.destination]){const o=myop.hostSDK.components.find(c=>c.id===i.destination);if(o){o.send(i);return}const r=myop.hostSDK.components.find(c=>c.id===n.destination);if(r){r.send(i);return}}else return}if(s.messageType){if(s.messageType===y.CleanupMessage){const n=s,i=this.messageCleanupCache[n.cleanupForMessageId],o=new ct(!!i);o.destination=s.destination,i?(delete this.messageCleanupCache[n.cleanupForMessageId],ks(i).then(()=>{this.messageToHost(o,n)}).catch(()=>{})):this.messageToHost(o,n);return}this.supportedHandlers.forEach(n=>{if(n.messageType===s.messageType){const i=n.executor(s);if(s.cleanable&&i&&(this.messageCleanupCache[s.id]=i),i&&!s.cleanable)throw new Error(`Cleanup handler generated for non-cleanable message.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Please review the message definition object & message handler.
|
|
5
|
-
To ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers.`);if(!i&&s.cleanable)throw new Error(`No cleanup handler generated for a cleanable message.
|
|
6
|
-
messageType - ${s.messageType}, handler executor was - ${n.executor}
|
|
7
|
-
|
|
8
|
-
Please review the message definition object & message handler.
|
|
9
|
-
To ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers.`)}})}else console.log("unsupported message type")}}},ye={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"},we={open:"open",none:"none",localFrame:"localFrame"},ve=class{};a(ve,"code","code"),a(ve,"component","component");var X={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},dt={Segment:"Segment",Promo:"Promo",AB:"AB"},$s=class{constructor(e,t){this.container=e,this.shadowRoot=t,a(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div")),a(this,"getRoot",()=>this.shadowRoot||this.container)}},Me=e=>e!==Object(e),Fs=e=>typeof e=="function",ut=e=>{if(Me(e))return!0;if(Fs(e)||Object.getPrototypeOf(e))return!1;for(const t in e){const s=e[t];if(typeof s=="object"){if(!ut(s))return!1}else{if(Me(s))continue;return!1}}return!0},A=(e,t={},s=!0,n=new WeakMap)=>{if(Me(e))return e;if(Array.isArray(e)){if(n.has(e))return n.get(e);const i=[];n.set(e,i);for(let o=0;o<e.length;o++){const r=e[o];i[o]=A(r,t,s,n)}return i}if(e!==null&&typeof e=="object"){if(n.has(e))return n.get(e);const i={};n.set(e,i);for(const o in e){const r=typeof t=="boolean"?t:t[o];r&&(r===!0?(s?e[o]!==void 0:e[o])&&(i[o]=A(e[o],!0,s,n)):typeof r=="object"&&(i[o]=A(e[o],r,s,n)))}return i}return{}},Ps={notSerializableRefCall:(e,t)=>{throw new Error(`
|
|
10
|
-
The input provided to '${e.toString()}' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation.
|
|
11
|
-
The following types of data are considered non-serializable and cannot be processed:
|
|
12
|
-
|
|
13
|
-
- Functions
|
|
14
|
-
- DOM elements
|
|
15
|
-
- Class instances
|
|
16
|
-
- Circular references
|
|
17
|
-
- Symbols
|
|
18
|
-
- BigInt values
|
|
19
|
-
|
|
20
|
-
In the following execution we detected :
|
|
21
|
-
~~~~~~~~
|
|
22
|
-
${t}
|
|
23
|
-
~~~~~~~~
|
|
24
|
-
as not serializable.
|
|
25
|
-
|
|
26
|
-
To resolve this issue, please ensure that all inputs passed to '${e.toString()}' are in a serializable format.
|
|
27
|
-
This typically includes primitive types (strings, numbers, booleans), arrays, and plain objects.
|
|
28
|
-
If you need to include complex data types, consider converting them to a serializable structure before passing them to the function.
|
|
29
|
-
Or use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.
|
|
30
|
-
|
|
31
|
-
Suggested Fix:
|
|
32
|
-
1. Remove or replace non-serializable values from your input.
|
|
33
|
-
2. If using objects, ensure they do not contain any functions or circular references.
|
|
34
|
-
3. Convert any class instances to plain objects or JSON-compatible formats.
|
|
35
|
-
4. Use dedicated Myop message.
|
|
36
|
-
|
|
37
|
-
For more details on serialization and Myop message examples, refer to https://docs.myop.dev.
|
|
38
|
-
|
|
39
|
-
`)}},ht=class extends ge{constructor(e,t,s){super(e,t.container,s),this.componentDefinition=e,this.parent=t,a(this,"send",n=>{const i=n.handler,o=super.send(n);return this.parent.send(new st(this.id,n)),n.handler=i,o}),a(this,"dispose",()=>{this.isInitiated&&this.send(new O("dispose")),super.dispose()})}hide(){this.send(new O("hide"))}show(){this.send(new O("show"))}inspect(){return this.send(new O("inspect"))}setHeightBasedOnDocumentElement(){this.send(new O("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new O("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}},Ls=(e,t,s)=>{const n=document.createElement("a");return n.textContent=e,n.style.position="relative",n.style.padding="0 5px",n.style.fontSize="14px",n.style.top="0",n.style.top=`${t}px`,n.style.transform="translateX(-50%)",n.target="_blank",n.href=`https://dashboard.myop.dev/dashboard/component/${s.id}`,n},pt=(e,t,s,n,i,o)=>{const r=Ls(`${o.name} : ${t}`,s,o);return n.insertBefore(r,i),i.style.border="1px solid #007BFF",i.style.display="block",()=>{i.style.border="unset",n.removeChild(r)}},As=(e,t)=>{const s=t.reduce((i,o)=>q(w({},i),{[o.name]:w({},o)}),{}),n={get:(i,o)=>{const r=s[o];return r.mode==="output"?new Promise(c=>{const l=[];r.behavior.ref&&l.push(j.create(r.behavior.ref)),l.push(u=>{c(u)}),r.behavior.params&&l.push(...r.behavior.params);const d=he[r.behavior.message];e.send(new d(...l))}):null},set:(i,o,r)=>{const c=s[o];if(!c)throw new Error(`Error: Undefined Prop
|
|
40
|
-
|
|
41
|
-
It looks like you've tried to use a prop that hasn't been defined.
|
|
42
|
-
Please check the prop name for any typos or ensure that it is properly defined in the component's prop list.
|
|
43
|
-
|
|
44
|
-
Prop Name: ${o}
|
|
45
|
-
Component: ${e.componentDefinition.name}, ID: ${e.componentDefinition.id}
|
|
46
|
-
|
|
47
|
-
For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/${e.componentDefinition.id} or consult the developer guide.`);if(c.mode==="input")if(c.behavior.type==="message"){const l=[];c.behavior.ref&&l.push(j.create(c.behavior.ref)),l.push(r),c.behavior.params&&l.push(...c.behavior.params);const d=he[c.behavior.message];return e.send(new d(...l)),!0}else throw new Error(`Error: Unsupported Behavior
|
|
48
|
-
|
|
49
|
-
The 'behavior' field provided is not supported.
|
|
50
|
-
Component: ${e.componentDefinition.name}, ID: ${e.componentDefinition.id}
|
|
51
|
-
|
|
52
|
-
Prop Name: ${o}
|
|
53
|
-
Behavior Field: ${c.behavior.type}
|
|
54
|
-
|
|
55
|
-
Check the documentation for valid behavior options.`);return!1}};return e.props={},e.props=new Proxy(e.props,n),e},Vs=(e,t)=>new Proxy(e,{get(s,n){return s[n]?s[n]:(...o)=>new Promise(r=>{o.forEach(c=>{ut(c)||Ps.notSerializableRefCall(n,c)}),t.send(new pe(({ref:c,propName:l,functionArgs:d,makeSerializable:u})=>{if(c){const h=c[l];return u(typeof h=="function"?c[l](...d):h,!0)}return null},{elementId:s.refConfig.selector,propName:n,functionArgs:o},c=>{r(c.content)}))})},set(s,n,i){return t.send(new pe(({ref:o,propName:r,propValue:c})=>{o&&(o[r]=c)},{elementId:s.refConfig.selector,propValue:i,propName:n},o=>{})),!0}}),ft=(e,t,s,n)=>g(void 0,null,function*(){const i=e.component;if(!i)throw new Error("cant createRefComponent with detached ref");return new Promise((o,r)=>g(void 0,null,function*(){const c=new ht(t.type,i,n);s.push(c),yield i.initiated();const l=setTimeout(()=>{r("timeout")},5e3);i.send(new tt(e.refConfig,t,q(w({},n||{}),{id:c.id,_hasParent:!0}),d=>g(void 0,null,function*(){if(clearTimeout(l),d.failed){r("CreateRefComponentMessage failed");return}const u=s.find(h=>h.id==c.id);if(u!==c){i.refs[e.refConfig.name]=u,o(u);return}else c.setInitiated(),i.refs[e.refConfig.name]=c;d.nestedRefs.forEach(h=>{const f=t.instance.resolvedNestedComponents.find(_=>_.type.id===h.componentDefinitionId).type,v=new ht(f,c);v.setInitiated(),c.refs[h.refName]=v,s.push(v)});try{yield mt(c,t,s,!0),i.setHeightBasedOnScrollHeight&&i.setHeightBasedOnScrollHeight(),o(c)}catch(h){r(h)}})))}))}),mt=(e,t,s,n=!1)=>g(void 0,null,function*(){e.refs||(e.refs={});const i=Object.values(e.componentDefinition.refs).map(o=>new Promise((r,c)=>g(void 0,null,function*(){var l;if(o.behavior.type==ve.component){if(n){r();return}let d=o.behavior.componentId;d||(d=o.behavior.instance.componentId);const u=(l=t.instance.resolvedNestedComponents)==null?void 0:l.find(f=>f.type.id===d);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");const h=j.create("",o,e);try{const f=yield ft(h,u,s);e.refs[o.name]=f,r()}catch(f){c(f)}}else try{const d=j.create("",o,e);e.refs[o.name]=Vs(d,e),r()}catch{}})));try{yield Promise.all(i)}catch(o){throw o}}),gt=class extends ge{constructor(e,t,s,n,i){super(e,s,i),this.componentConfig=e,this.container=s,this.IframeElement=n,a(this,"cleanupInspect"),a(this,"setHeightBasedOnDocumentElement",()=>{const o=this.send(new H(()=>window.document.documentElement.scrollHeight,r=>{this.IframeElement.style.height=`${r.content}px`,o()}))}),a(this,"observeSizeBasedOnDocumentElement",()=>{this.send(new H(({send:o})=>{const{height:r,width:c}=document.documentElement.getBoundingClientRect(),l=new ResizeObserver(()=>{const{height:d,width:u}=document.documentElement.getBoundingClientRect();o({height:d,width:u})});return l.observe(document.documentElement),l.observe(document.body),{height:r,width:c}},o=>{this.IframeElement.style.width=`${o.content.width}px`,this.IframeElement.style.height=`${o.content.height}px`}))}),a(this,"setSizeBasedOnDocumentElement",()=>{const o=this.send(new H(()=>{const{height:r,width:c}=document.documentElement.getBoundingClientRect();return{height:r,width:c}},r=>{this.IframeElement.style.width=`${r.content.width}px`,this.IframeElement.style.height=`${r.content.height}px`,o()}))}),a(this,"setHeightBasedOnScrollHeight",()=>{const o=this.send(new H(()=>{let c=0;return c++,c--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+c+"px"},r=>{this.IframeElement.style.height=r.content,o()}))}),a(this,"send",o=>{var r,c;let l=w({},o);if(l.messageType===y.ExecuteComponentMethod)return this[l.method](),()=>{};l.direction=b.down;const d=super.send(l);return(c=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||c.postMessage(l,"*"),d}),a(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=pt(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===y.In.MutationObserverMessage||e.messageType===y.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}},_e=class{constructor(){a(this,"appendChild",(e,t,s)=>{var n;if(s!=null&&s.relative){if(s.relative.direction==="before")return e.insertBefore(t,s.relative.child);if(s.relative.direction==="after"){const i=(n=s.relative.child)==null?void 0:n.nextSibling;return e.insertBefore(t,i||null)}}else return e.appendChild(t)})}},Bs=(e,t,s)=>{const n=new URL(e);return n.searchParams.append(t,s),n.toString()},Ks=class extends _e{constructor(){super(...arguments),a(this,"type",ye.IframeLoader),a(this,"load",(e,t,s,n)=>g(this,null,function*(){let i;const o=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",o.url,s),i=s,i.src=o.url;else{const r=L(),c=`myop-comp-${r}`;i=document.createElement("iframe"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),n!=null&&n.hidden&&(i.style.visibility="hidden"),i=this.appendChild(s,i,n);let l=t.loader.url;n!=null&&n._hasParent&&(l=Bs(l,"_myop-comp",r));let d="";n!=null&&n.elementAttributes&&(d=Object.entries(n==null?void 0:n.elementAttributes).map(([u,h])=>h===""||h===null||h===void 0?u:`${u}="${String(h)}"`).join(" ")),i.outerHTML=`<iframe
|
|
56
|
-
id="${c}"
|
|
57
|
-
style="
|
|
58
|
-
padding: 0;
|
|
59
|
-
margin: 0;
|
|
60
|
-
height: ${o.autoHeight||!o.height?"":o.height};
|
|
61
|
-
width : 100%;
|
|
62
|
-
overflow: hidden;
|
|
63
|
-
border: none;
|
|
64
|
-
opacity: ${n!=null&&n.hidden?"0":"1"};
|
|
65
|
-
position: ${n!=null&&n.hidden?"absolute":"static"};
|
|
66
|
-
pointer-events: ${n!=null&&n.hidden?"none":"all"};
|
|
67
|
-
"
|
|
68
|
-
src="${l}"
|
|
69
|
-
${d}
|
|
70
|
-
></iframe>`,i=s.querySelector(`#${c}`)}return new gt(e,t,s,i,n)}))}},yt={webcomponent_message_key:"myop_webcomponent_message"},wt=class extends ge{constructor(e,t,s,n,i){super(e,s,i),this.container=s,this.customElement=n,a(this,"cleanupInspect",()=>{}),a(this,"send",o=>{let r=w({},o);const c=super.send(r),l=new CustomEvent(yt.webcomponent_message_key,{detail:r});try{this.customElement.dispatchEvent(l)}catch(d){console.log("error while trying to dispatchEvent",d)}return c}),a(this,"dispose",()=>{var o;super.dispose(),(o=this.customElement.parentNode)==null||o.removeChild(this.customElement)}),this.element=n}inspect(){return this.cleanupInspect=pt(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=""}},Ee={},Us=class extends _e{constructor(){super(...arguments),a(this,"type",ye.WebComponentLoader),a(this,"load",(e,t,s,n)=>g(this,null,function*(){const i=t.loader;Ee[i.url]?console.log("Module alreday loaded or in loading process"):Ee[i.url]=new Promise((c,l)=>{const d=i.url,u=document.createElement("script");u.type="module",u.src=d,u.onload=()=>{c()},u.onerror=()=>{l()},document.head.appendChild(u)}),yield Ee[i.url],yield hs(1);let o=`myop-comp-${L()}`;const r=document.createElement(i.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r.id=o,n!=null&&n.hidden&&(r.style.opacity="0",r.style.position="absolute",r.style.height="0",r.style.width="0",r.style.pointerEvents="none",r.style.visibility="hidden"),n!=null&&n._environment&&(r._myopEnvironment=n==null?void 0:n._environment),this.appendChild(s,r,n),new wt(e,t,s,r,n)}))}},zs="0.1.42",x=class extends Os{constructor(e,t){super(e),this.context=t,a(this,"executor",s=>{if(s.destination){const n=s.destination;if(this.context[n].context){const i=(o,r)=>{this.messageToHost(q(w({},o),{source:s.destination?s.destination:s.source,destination:s.source?s.source:s.destination}),r)};return this.innerExecutor(s,this.context[n].context,i)}else debugger}else debugger})}},W={id:"myop-id"},V=(e,t)=>t.querySelectorAll(`[${W.id}='${e.refConfig.selector}']`),qs=class extends x{constructor(){super(...arguments),a(this,"messageType",y.BindClickMessage),a(this,"innerExecutor",(e,t,s)=>{const n=V(e.ref,t.shadowRoot),i=[];return n.forEach(o=>{const r=()=>{s(new ze(e.handlerUniqueId))};o.addEventListener("click",r),i.push(()=>{o.removeEventListener("click",r)})}),()=>{i.forEach(o=>o())}})}},js=class extends x{constructor(){super(...arguments),a(this,"messageType",y.ChangeTextMessage),a(this,"innerExecutor",(e,t)=>{V(e.ref,t.shadowRoot).forEach(n=>{n.textContent=e.content})})}},Ws=class extends $s{constructor(e,t){super(e,t),this.container=e,this.shadowRoot=t}},Gs=class extends x{constructor(){super(...arguments),a(this,"innerExecutor",(e,t)=>{const s=t.shadowRoot.querySelectorAll(`[${W.id}]`);let n=[];s.forEach(i=>{const o=i.getAttribute(W.id);o&&n.push(new Rs(o,i.tagName,i.getBoundingClientRect(),i.offsetTop,i.offsetLeft))}),this.messageToHost(new it(e.handlerUniqueId,n))}),a(this,"messageType",y.DetectMyopRefsMessage)}},Js=class extends x{constructor(){super(...arguments),a(this,"messageType",y.SetAttributeMessage),a(this,"innerExecutor",(e,t)=>{V(e.ref,t.shadowRoot).forEach(n=>{n.setAttribute(e.name,e.value)})})}},Ys=class extends x{constructor(){super(...arguments),a(this,"messageType",y.AddEventListenerMessage),a(this,"innerExecutor",(e,t,s)=>{const n=V(e.ref,t.shadowRoot),i=[];return n.forEach(o=>{const r=c=>{s(new Je(e.handlerUniqueId,A(c,e.serializableSkeleton)))};o.addEventListener(e.type,r),i.push(()=>{o.removeEventListener(e.type,r)})}),()=>{i.forEach(o=>o())}})}},Xs=class extends x{constructor(){super(...arguments),a(this,"messageType",y.CreateRefComponentMessage),a(this,"innerExecutor",(e,t,s)=>{g(this,null,function*(){const i=t.shadowRoot.querySelectorAll(`[${W.id}='${e.refConfig.selector}']`);if(i.length===1){const o=Z.Instance(),r=o.components.find(u=>u.id===e.options.id);r&&r.dispose();const c=o.components.indexOf(r);c!==-1&&o.components.splice(c,1);const l=yield o.loadComponent(e.nestedComponentConfig,i.item(0),e.options),d=[];Object.keys(l.refs).forEach(u=>{let h=l.refs[u];h=h.__nonProxied||h,h.componentDefinition&&d.push({refName:u,componentDefinitionId:h.componentDefinition.id})}),s(new me(e.handlerUniqueId,d))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new me(e.handlerUniqueId,[],!0));debugger}}).then()})}},Qs=(e,t,s)=>{const n=e.scriptInputs?e.scriptInputs:{};n.makeSerializable=A,n.send=t,n.rootRef=s,n.__scriptInputs=n;const o=new Function(`return (${e.script})(...arguments)`)(n);t(o)},Zs=class extends x{constructor(){super(...arguments),a(this,"messageType",y.ExecuteScriptMessage),a(this,"innerExecutor",(e,t,s)=>{Qs(e,i=>{s(new We(e.handlerUniqueId,i))},t)})}},vt=e=>{if(!e)return null;if(e.tagName==="FORM"){new FormData(e);const t={formData:{},unmappedData:[]};return e.querySelectorAll("input, select, textarea").forEach(n=>{if(typeof n.value=="string"){const i=n.getAttribute(W.id);let o=n.getAttribute("name");const r={id:n.id,name:o,value:vt(n),required:n.required,validity:A(n.validity,!0),myopId:i};o?t.formData[o]?t.formData[o].value?t.unmappedData.push(r):(t.unmappedData.push(t.formData[o]),t.formData[o]=r):t.formData[o]=r:t.unmappedData.push(r)}}),t}return e.type==="checkbox"||e.type==="radio"?e.checked?e.value:null:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?e.value:e.isContentEditable?e.innerText||e.textContent:null},en=class extends x{constructor(){super(...arguments),a(this,"messageType",y.GetElementValueMessage),a(this,"innerExecutor",(e,t,s)=>{V(e.ref,t.shadowRoot).forEach(i=>{s(new Xe(vt(i)),e)})})}},tn=class extends x{constructor(){super(...arguments),a(this,"messageType",y.SetInnerHtml),a(this,"innerExecutor",(e,t)=>{V(e.ref,t.shadowRoot).forEach(n=>{n.innerHTML=e.content})})}},Mt=class extends Ns{constructor(){super(...arguments),a(this,"alwaysPassEnvelopesToHost",!0),a(this,"connectedCallback",(e,t)=>{e.addEventListener(yt.webcomponent_message_key,s=>{const n=s.data?s.data:s.detail;if(!n||!n.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{const i=n;if(this.handleIncomeMessages(s),i.messageType===y.InitMessage){const o=i.content.id;this.components[o].context=new Ws(e,t)}}}),setTimeout(()=>{this.messageToHost(new Ze)},1)}),a(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)}),a(this,"supportedHandlers",[new js(this.messageToHost,this.components),new tn(this.messageToHost,this.components),new qs(this.messageToHost,this.components),new Gs(this.messageToHost,this.components),new Js(this.messageToHost,this.components),new Ys(this.messageToHost,this.components),new Zs(this.messageToHost,this.components),new en(this.messageToHost,this.components),new Xs(this.messageToHost,this.components)]),a(this,"init",()=>{})}};Ke("WebComponentSDK",Mt);var _t=[],Q,Et=()=>g(void 0,null,function*(){return Q||(Q=new Mt,Q.init()),Q});function sn(e,t){return class extends HTMLElement{connectedCallback(){const s=t===we.open?"open":"closed",n=this.attachShadow({mode:s});Et().then(i=>{i.connectedCallback(this,n),n.innerHTML=e})}}}var nn=(e,t,s)=>{customElements.define(e,sn(t,s)),console.log(`define('${e}') was called, web component ready to use`)},on=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),rn=e=>(e=on(e),e.replace(/_/g,"-")),an=class extends _e{constructor(){super(...arguments),a(this,"type",ye.HTMLLoader),a(this,"load",(e,t,s,n)=>g(this,null,function*(){const i=t.loader;let o=`myop-comp-${L()}`,r;if(i.shadowRootMode===we.localFrame){const l=`myop-comp-${L()}`;let d=document.createElement("iframe");s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),n!=null&&n.hidden&&(d.style.visibility="hidden"),d=this.appendChild(s,d,n),d.id=l,d.setAttribute("style",`
|
|
71
|
-
padding: 0;
|
|
72
|
-
margin: 0;
|
|
73
|
-
overflow: hidden;
|
|
74
|
-
border: none;
|
|
75
|
-
opacity: ${n!=null&&n.hidden?"0":"1"};
|
|
76
|
-
width: 100%;
|
|
77
|
-
height: 100%;
|
|
78
|
-
position: ${n!=null&&n.hidden?"absolute":"static"};
|
|
79
|
-
pointer-events: ${n!=null&&n.hidden?"none":"all"};
|
|
80
|
-
`),s.appendChild(d);const u=d.contentDocument||d.contentWindow.document;u.open();let h=i.HTML;if(n!=null&&n._inspection){const _=new DOMParser().parseFromString(i.HTML,"text/html"),jt=_.implementation.createHTMLDocument();jt.body.innerHTML=`<script>
|
|
81
|
-
const beforeKeysWindow = new Set(Object.keys(window));
|
|
82
|
-
window.myopState = {
|
|
83
|
-
beforeKeysWindow,
|
|
84
|
-
};
|
|
85
|
-
<\/script>`;const Wt=jt.body.firstChild;Wt&&_.head&&_.head.insertBefore(_.importNode(Wt,!0),_.head.firstChild),h=_.documentElement.outerHTML}u.writeln(h),u.writeln(`<script src="${window.myop.__ROOT_SDK_PUBLIC_URL__}"><\/script>
|
|
86
|
-
<script>
|
|
87
|
-
window.__federation__ =
|
|
88
|
-
{ ...window.__federation__,
|
|
89
|
-
//TODO : get from ENV at build time,
|
|
90
|
-
// inject value to module at build time
|
|
91
|
-
// today we doing so just for the CJS version
|
|
92
|
-
__public_path__ :'https://cdn.myop.dev/sdk/next',
|
|
93
|
-
...${JSON.stringify(window.__federation__)}};
|
|
94
|
-
const init = async () => {
|
|
95
|
-
const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());
|
|
96
|
-
const sdk = new IframeSDK()
|
|
97
|
-
sdk.init();
|
|
98
|
-
}
|
|
99
|
-
init().then();
|
|
100
|
-
<\/script>`),u.close();const f=new gt(e,t,s,d,n);return d.onload=()=>{f.observeSizeBasedOnDocumentElement()},f}if(i.shadowRootMode===we.none){const c=document.createElement("template");c.innerHTML=i.HTML,r=c.content.firstElementChild,Et().then(l=>{l.connectedCallback(r,r)})}else{const c=rn(e.name+t.id);_t.includes(c)||(nn(c,i.HTML,i.shadowRootMode),_t.push(c)),r=document.createElement(c)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r.id=o,n!=null&&n.hidden&&(r.style.opacity="0",r.style.position="absolute",r.style.height="0",r.style.width="0",r.style.pointerEvents="none",r.style.visibility="hidden"),this.appendChild(s,r,n),new wt(e,t,s,r,n)}))}},be=class{constructor(t="https://cloud.myop.dev"){this._baseUrl=t,a(this,"userFlows",{})}fetchComponent(t,s){return g(this,null,function*(){return s?(yield this.fetchFlow(s)).components.find(i=>i.type.id===t):(yield this.fetchAutoFlow(t)).components[0]})}fetchAutoFlow(t){return g(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>g(this,null,function*(){try{const o=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&auto=true`)).json();s(o.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}fetchFlow(t){return g(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>g(this,null,function*(){try{const o=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&resolve=components`)).json();s(o.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}};a(be,"Main",new be);var cn=be,ln=e=>g(void 0,null,function*(){try{const t=new URL(window.location.href),n=new URLSearchParams(t.search).get("myopOverride");if(n){const[i,o]=us(n),c=(yield cn.Main.fetchFlow(i)).components.find(l=>l.type.id===e.type.id);if(c&&c.instance.skinSelector.type===X.Segmented&&c.instance.resolvedExperiences){const l=c.instance.resolvedExperiences.find(d=>d.id===o);if((l==null?void 0:l.type)===dt.Segment){const d=l,h=c.instance.skinSelector.segments.find(f=>f.segmentId===d.segment.id);if(h)return c.instance.skinSelector=h==null?void 0:h.skinSelector,c}}}}catch{return null}}),bt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",Z=class{constructor(){a(this,"components2init",[]),a(this,"components",[]),a(this,"componentsLoaders",[]),a(this,"initiated",!1),a(this,"version",zs),a(this,"type2InstanceCount",{}),a(this,"assignId",e=>(this.type2InstanceCount[e.id]||(this.type2InstanceCount[e.id]=0),`${e.id}_${++this.type2InstanceCount[e.id]}`)),a(this,"inspected",!1),a(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(e=>{e.inspect&&e.inspect()}))}),a(this,"incomingMessageHandler",e=>{if(e.origin,document.location.origin,e.data.myop){if(e.data.direction!==b.up&&e.data.messageType!==y.EnvelopedMessage)return;const t=e.data;if(t.messageType===y.InitRequest){this.components2init.forEach(n=>{n.send(new fe(n.id))});return}if(t.messageType===y.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==t.content.id);const n=this.components.find(i=>{var o;return i.id===((o=t.content)==null?void 0:o.id)});n==null||n.setInitiated();return}if(t.messageType===y.EnvelopedMessage){const n=t,i=this.components.find(o=>o.id===n.destination);if(i){if(n.direction===b.down){n.message.messageType===O.name?i.onMessageReceived(n.message):(n.message.route=n.route,i.send(n.message));return}}else{const o=this.components.find(r=>r.id===n.message.destination);o&&o.send(n.message)}return}const s=this.components.find(n=>n.id===t.destination);if(!s){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(s){if(s.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}}),a(this,"send",e=>{const t=new MessageEvent("",{data:e});this.incomingMessageHandler(t)}),a(this,"init",e=>{if(this.initiated)throw new Error("hostSDK already initiated");const t=[new Ks,new Us,new an];if(this.componentsLoaders=[...t],e){const s={};e.forEach(n=>{const i=new n(this.componentsLoaders);s[i.type]=i}),this.componentsLoaders.forEach(n=>{s[n.type]||(s[n.type]=n)}),this.componentsLoaders=Object.values(s)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0}),a(this,"_getSkinIdBySkinSelector",(e,...t)=>g(this,[e,...t],function*(s,n=[],i){var o;function r(c,l){return g(this,null,function*(){for(const d of c)if(yield l(d))return d})}switch(s.type){case"DedicatedSkin":case X.Dedicated:return((o=s.skin)==null?void 0:o.id)||s.skins[0].id;case X.Segmented:{const l=yield r(s.segments,d=>g(this,null,function*(){if(d.segmentId==="Default")return!0;const u=n.find(_=>_.type===dt.Segment?_.segment.id===d.segmentId:!1);if(!u)throw new Error("experience not found");const f=u.segment,v=(i||{})[f.function];return v?yield v():(console.warn(`segmentId:${d.segmentId}, ${f.function} function not provided !`),!1)}));if(l)return this._getSkinIdBySkinSelector(l.skinSelector,n);debugger}break;default:debugger}return""})),a(this,"runSkinSelector",(e,t)=>g(this,null,function*(){const s=yield this._getSkinIdBySkinSelector(e.instance.skinSelector,e.instance.resolvedExperiences,t);return e.type.skins.find(n=>n.id===s)})),a(this,"loaderHooks"),a(this,"loadComponent",(e,t,s)=>g(this,null,function*(){var n,i,o,r;if(!t){debugger;throw new Error("no container was found for this component")}const c=yield ln(e);c&&(e=c);const l=t;if(l.myop)if(l.component){e=w({},e),e.instance=w({},e.instance);const f=w(w({},(n=this.loaderHooks)!=null?n:{}),(i=s==null?void 0:s.hooks)!=null?i:{});let v=yield this.runSkinSelector(e,f);if(!v)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(o=s==null?void 0:s.hooks)!=null&&o.afterSkinSelected&&(v=yield s.hooks.afterSkinSelected(w({},v))),e.instance.skinSelector={type:X.Dedicated,skin:v},s&&(s=w({},s),delete s.hooks),yield ft(l,e,this.components,s)}else throw new Error("load component got a detached ref.");t=t;let d=yield this.runSkinSelector(e,s==null?void 0:s.hooks);if(!d)throw new Error("runSkinSelector failed to choose skin, check the provided config");(r=s==null?void 0:s.hooks)!=null&&r.afterSkinSelected&&(d=yield s.hooks.afterSkinSelected(w({},d)));const u=this.componentsLoaders.find(f=>f.type===d.loader.type);if(!u){debugger;throw new Error(`no loader "${d.loader.type}" was found for component`)}let h=yield u.load(e.type,d,t,s);h.isInitiated||this.components2init.push(h),h.bind("onDispose",()=>(this.components=this.components.filter(f=>f!==h),this.components2init=this.components2init.filter(f=>f!==h),!0)),this.components.push(h),s!=null&&s.connectProps&&(h=As(h,e.type.props));try{yield mt(h,e,this.components)}catch(f){throw f}return s!=null&&s.skipInit||(yield h.initiated()),h})),a(this,"navigate",(e,t,s)=>g(this,null,function*(){if(e.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(s!=null&&s.staged){let n=yield this.loadComponent(t,e.container,w({hidden:!0,relative:{direction:"after",child:e.element}},s));return s.init&&(yield s.init(n)),n.show(),e.dispose(),n}else{const n=e.element.nextSibling;return e.dispose(),this.loadComponent(t,e.container,w({relative:{direction:"before",child:n}},s))}}))}};if(a(Z,"Instance",()=>window.myop.hostSDK),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:bt}),!window.myop.hostSDK){const e=new Z;e.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:bt}),window.myop.hostSDK=e}var Ct=window.myop.hostSDK;Ke("hostSDK",Ct);/**
|
|
101
|
-
* @vue/shared v3.5.17
|
|
1
|
+
(function(d,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue"),require("@myop/sdk/host"),require("@myop/sdk/helpers")):typeof define=="function"&&define.amd?define(["exports","vue","@myop/sdk/host","@myop/sdk/helpers"],l):(d=typeof globalThis<"u"?globalThis:d||self,l(d["@myop/vue"]={},d.Vue,d.host,d.helpers))})(this,(function(d,l,V,P){"use strict";const Be=["innerHTML"],he=l.defineComponent({__name:"MyopLoader",props:{opacity:{default:1},fadeDuration:{default:200}},setup(e){const t=e,n=l.useSlots(),o=a=>!a||a.length===0?!1:a.some(u=>typeof u.children=="string"?u.children.trim()!=="":Array.isArray(u.children)?o(u.children):!!(u.type&&typeof u.type!="symbol"||u.children)),s=l.computed(()=>{const a=n.default;if(!a)return!1;const u=a();return o(u)}),r=l.computed(()=>({...V.containerStyleObject,opacity:t.opacity,transition:`opacity ${t.fadeDuration}ms ease-out`})),i=l.computed(()=>({...V.loaderStyleObject,opacity:t.opacity,transition:`opacity ${t.fadeDuration}ms ease-out`})),c=V.getMyopLogoHtml();return(a,u)=>s.value?(l.openBlock(),l.createElementBlock("div",{key:0,style:l.normalizeStyle(r.value)},[l.renderSlot(a.$slots,"default")],4)):(l.openBlock(),l.createElementBlock("div",{key:1,style:l.normalizeStyle(i.value),innerHTML:l.unref(c)},null,12,Be))}}),Je=["innerHTML"],ye=l.defineComponent({__name:"MyopFallback",setup(e){const t=l.useSlots(),n=c=>!c||c.length===0?!1:c.some(a=>typeof a.children=="string"?a.children.trim()!=="":Array.isArray(a.children)?n(a.children):!!(a.type&&typeof a.type!="symbol"||a.children)),o=l.computed(()=>{const c=t.default;if(!c)return!1;const a=c();return n(a)}),s={position:"absolute",top:"0",left:"0",right:"0",bottom:"0"},r={...V.fallbackStyleObject},i=V.getMyopLogoHtml();return(c,a)=>o.value?(l.openBlock(),l.createElementBlock("div",{key:0,style:s},[l.renderSlot(c.$slots,"default")])):(l.openBlock(),l.createElementBlock("div",{key:1,style:r,innerHTML:l.unref(i)},null,8,Je))}}),We=l.defineComponent({name:"MyopComponent",__name:"MyopComponent",props:{componentId:{},componentConfig:{},data:{},fadeDuration:{default:200},autoSize:{type:Boolean,default:!1},environment:{},preview:{type:Boolean},on:{}},emits:["load","error","sizeChange","cta"],setup(e,{expose:t,emit:n}){const o=l.useSlots(),s=f=>!f||f.length===0?!1:f.some(p=>typeof p.children=="string"?p.children.trim()!=="":Array.isArray(p.children)?s(p.children):!!(p.type&&typeof p.type!="symbol"||p.children)),r=l.computed(()=>{const f=o.loader;if(!f)return!1;const p=f();return s(p)});l.computed(()=>{const f=o.fallback;if(!f)return!1;const p=f();return s(p)});const i=e,c=n,a=l.ref(null),u=l.shallowRef(null),m=i.componentId?xe(i.componentId):!1,g=l.ref(!m),R=l.ref(1),b=l.ref(!1),A=l.ref(!1),D=l.ref(void 0),ue=l.ref(!1),Y=l.ref(null),fe=l.ref(!1);let M=null;const pe=()=>{R.value=0,setTimeout(()=>{g.value=!1},i.fadeDuration)},de=f=>{console.error("[MyopComponent] Error:",f),pe(),b.value=!0,c("error",f)},me=async f=>{var O,G;ue.value=!0;let p=!1;try{const y=JSON.parse(JSON.stringify({componentId:f.componentId,data:f.data,environment:f.environment,preview:f.preview,autoSize:f.autoSize}));if(!y.componentId&&!f.componentConfig){de("No component configuration provided");return}const Yt=y.preview===!0?!0:void 0,Gt=f.componentConfig?JSON.parse(JSON.stringify(f.componentConfig)):await Pe().fetchComponentV2(y.componentId,y.environment,Yt);if(!a.value){de("Container element not found");return}const Qt=l.markRaw({data:y.data,_environment:{props:y}}),Ue=await V.hostSDK.loadComponent(Gt,a.value,Qt);if(p){Ue.dispose();return}if(u.value=l.markRaw(Ue),await u.value.initiated(),p){(O=u.value)==null||O.dispose();return}if(await new Promise(Q=>requestAnimationFrame(Q)),p||!u.value||u.value.markedForDisposed){u.value&&!u.value.markedForDisposed&&u.value.dispose();return}A.value=!0,i.autoSize||pe(),(G=u.value)!=null&&G.props&&(u.value.props.myop_cta_handler=(Q,ve)=>{i.on&&i.on(Q,ve),c("cta",Q,ve)}),c("load",u.value)}catch(y){p||de((y==null?void 0:y.message)||"Unknown error")}finally{if(ue.value=!1,Y.value!==null&&!p){const y=Y.value;Y.value=null,await me(y)}}return()=>{p=!0}},Wt=()=>{var p;if(!A.value||!((p=u.value)!=null&&p.observeAutoSize))return;let f=!0;M=u.value.observeAutoSize({explicitWidth:void 0,explicitHeight:void 0,forceAutoSize:i.autoSize,loaderMinHeight:50,onSizeChange:O=>{c("sizeChange",O),D.value=O,f&&(f=!1,pe())}})};l.watch(()=>i.componentId,async(f,p)=>{f!==p&&(fe.value=!1,A.value=!1,b.value=!1,g.value=!0,R.value=1,u.value&&(u.value.dispose(),u.value=null),M&&(M(),M=null),ue.value?Y.value={...i}:await me(i))}),l.watch(()=>i.data,f=>{var p;if(A.value&&f!==void 0&&u.value){if(!fe.value){fe.value=!0;return}const O=(p=u.value.props)==null?void 0:p.myop_init_interface;if(O){const G=JSON.parse(JSON.stringify(f));O(G)}}},{deep:!0}),l.watch(()=>A.value,f=>{f&&i.autoSize&&Wt()}),l.onMounted(async()=>{(i.componentId||i.componentConfig)&&await me(i)}),l.onUnmounted(()=>{M&&M(),u.value&&u.value.dispose()});const Le=l.computed(()=>{var f,p;return((f=D.value)==null?void 0:f.autoSizingWidth)||((p=D.value)==null?void 0:p.autoSizingHeight)}),je=l.computed(()=>g.value?50:void 0),qt=l.computed(()=>{var f,p;return{position:"relative",width:(f=D.value)!=null&&f.autoSizingWidth?`${D.value.width}px`:"100%",height:(p=D.value)!=null&&p.autoSizingHeight?`${D.value.height}px`:"100%",minHeight:je.value?`${je.value}px`:void 0,overflow:Le.value?"hidden":"inherit"}}),Kt=l.computed(()=>({position:"absolute",inset:"0",overflow:Le.value?"hidden":void 0}));return t({myopComponent:u,isLoaded:A}),(f,p)=>(l.openBlock(),l.createElementBlock("div",{style:l.normalizeStyle(qt.value)},[l.createElementVNode("div",{ref_key:"myopContainer",ref:a,style:l.normalizeStyle(Kt.value)},null,4),g.value&&r.value?(l.openBlock(),l.createBlock(he,{key:0,opacity:R.value,"fade-duration":e.fadeDuration},{default:l.withCtx(()=>[l.renderSlot(f.$slots,"loader")]),_:3},8,["opacity","fade-duration"])):l.createCommentVNode("",!0),b.value?(l.openBlock(),l.createBlock(ye,{key:1},{default:l.withCtx(()=>[l.renderSlot(f.$slots,"fallback")]),_:3})):l.createCommentVNode("",!0)],4))}});/**
|
|
2
|
+
* @vue/shared v3.5.27
|
|
102
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
103
4
|
* @license MIT
|
|
104
|
-
**/const
|
|
105
|
-
* @vue/reactivity v3.5.
|
|
5
|
+
**/const qe=process.env.NODE_ENV!=="production"?Object.freeze({}):{};process.env.NODE_ENV!=="production"&&Object.freeze([]);const ge=()=>{},Ke=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),X=Object.assign,_=Array.isArray,C=e=>typeof e=="function",S=e=>typeof e=="string",Ye=e=>typeof e=="symbol",H=e=>e!==null&&typeof e=="object",Ge=e=>(H(e)||C(e))&&C(e.then)&&C(e.catch),_e=e=>{const t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},Qe=_e(e=>e.charAt(0).toUpperCase()+e.slice(1)),Xe=_e(e=>e?`on${Qe(e)}`:"");let Ce;const x=()=>Ce||(Ce=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Z(e){if(_(e)){const t={};for(let n=0;n<e.length;n++){const o=e[n],s=S(o)?nt(o):Z(o);if(s)for(const r in s)t[r]=s[r]}return t}else if(S(e)||H(e))return e}const Ze=/;(?![^(]*\))/g,et=/:([^]+)/,tt=/\/\*[^]*?\*\//g;function nt(e){const t={};return e.replace(tt,"").split(Ze).forEach(n=>{if(n){const o=n.split(et);o.length>1&&(t[o[0].trim()]=o[1].trim())}}),t}function ee(e){let t="";if(S(e))t=e;else if(_(e))for(let n=0;n<e.length;n++){const o=ee(e[n]);o&&(t+=o+" ")}else if(H(e))for(const n in e)e[n]&&(t+=n+" ");return t.trim()}/**
|
|
6
|
+
* @vue/reactivity v3.5.27
|
|
106
7
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
107
8
|
* @license MIT
|
|
108
|
-
**/
|
|
109
|
-
* @vue/runtime-core v3.5.
|
|
9
|
+
**/process.env.NODE_ENV,process.env.NODE_ENV,process.env.NODE_ENV,new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(Ye));function te(e){return e?!!e.__v_raw:!1}function L(e){const t=e&&e.__v_raw;return t?L(t):e}function Ee(e){return e?e.__v_isRef===!0:!1}/**
|
|
10
|
+
* @vue/runtime-core v3.5.27
|
|
110
11
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
111
12
|
* @license MIT
|
|
112
|
-
**/const
|
|
113
|
-
`),
|
|
114
|
-
`,...
|
|
115
|
-
`],...
|
|
116
|
-
Component that was made reactive: `,e)),
|
|
13
|
+
**/const I=[];function ot(e){I.push(e)}function rt(){I.pop()}let ne=!1;function N(e,...t){if(ne)return;ne=!0;const n=I.length?I[I.length-1].component:null,o=n&&n.appContext.config.warnHandler,s=st();if(o)j(o,n,11,[e+t.map(r=>{var i,c;return(c=(i=r.toString)==null?void 0:i.call(r))!=null?c:JSON.stringify(r)}).join(""),n&&n.proxy,s.map(({vnode:r})=>`at <${He(n,r.type)}>`).join(`
|
|
14
|
+
`),s]);else{const r=[`[Vue warn]: ${e}`,...t];s.length&&r.push(`
|
|
15
|
+
`,...lt(s)),console.warn(...r)}ne=!1}function st(){let e=I[I.length-1];if(!e)return[];const t=[];for(;e;){const n=t[0];n&&n.vnode===e?n.recurseCount++:t.push({vnode:e,recurseCount:0});const o=e.component&&e.component.parent;e=o&&o.vnode}return t}function lt(e){const t=[];return e.forEach((n,o)=>{t.push(...o===0?[]:[`
|
|
16
|
+
`],...it(n))}),t}function it({vnode:e,recurseCount:t}){const n=t>0?`... (${t} recursive calls)`:"",o=e.component?e.component.parent==null:!1,s=` at <${He(e.component,e.type,o)}`,r=">"+n;return e.props?[s,...at(e.props),r]:[s+r]}function at(e){const t=[],n=Object.keys(e);return n.slice(0,3).forEach(o=>{t.push(...Se(o,e[o]))}),n.length>3&&t.push(" ..."),t}function Se(e,t,n){return S(t)?(t=JSON.stringify(t),n?t:[`${e}=${t}`]):typeof t=="number"||typeof t=="boolean"||t==null?n?t:[`${e}=${t}`]:Ee(t)?(t=Se(e,L(t.value),!0),n?t:[`${e}=Ref<`,t,">"]):C(t)?[`${e}=fn${t.name?`<${t.name}>`:""}`]:(t=L(t),n?t:[`${e}=`,t])}const oe={sp:"serverPrefetch hook",bc:"beforeCreate hook",c:"created hook",bm:"beforeMount hook",m:"mounted hook",bu:"beforeUpdate hook",u:"updated",bum:"beforeUnmount hook",um:"unmounted hook",a:"activated hook",da:"deactivated hook",ec:"errorCaptured hook",rtc:"renderTracked hook",rtg:"renderTriggered hook",0:"setup function",1:"render function",2:"watcher getter",3:"watcher callback",4:"watcher cleanup function",5:"native event handler",6:"component event handler",7:"vnode hook",8:"directive hook",9:"transition hook",10:"app errorHandler",11:"app warnHandler",12:"ref function",13:"async component loader",14:"scheduler flush",15:"component update",16:"app unmount cleanup function"};function j(e,t,n,o){try{return o?e(...o):e()}catch(s){re(s,t,n)}}function Ne(e,t,n,o){if(C(e)){const s=j(e,t,n,o);return s&&Ge(s)&&s.catch(r=>{re(r,t,n)}),s}if(_(e)){const s=[];for(let r=0;r<e.length;r++)s.push(Ne(e[r],t,n,o));return s}else process.env.NODE_ENV!=="production"&&N(`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof e}`)}function re(e,t,n,o=!0){const s=t?t.vnode:null,{errorHandler:r,throwUnhandledErrorInProduction:i}=t&&t.appContext.config||qe;if(t){let c=t.parent;const a=t.proxy,u=process.env.NODE_ENV!=="production"?oe[n]:`https://vuejs.org/error-reference/#runtime-${n}`;for(;c;){const m=c.ec;if(m){for(let g=0;g<m.length;g++)if(m[g](e,a,u)===!1)return}c=c.parent}if(r){j(r,null,10,[e,a,u]);return}}ct(e,n,s,o,i)}function ct(e,t,n,o=!0,s=!1){if(process.env.NODE_ENV!=="production"){const r=oe[t];if(n&&ot(n),N(`Unhandled error${r?` during execution of ${r}`:""}`),n&&rt(),o)throw e;console.error(e)}else{if(s)throw e;console.error(e)}}const h=[];let E=-1;const F=[];let w=null,T=0;const ut=Promise.resolve();let se=null;const ft=100;function pt(e){let t=E+1,n=h.length;for(;t<n;){const o=t+n>>>1,s=h[o],r=z(s);r<e||r===e&&s.flags&2?t=o+1:n=o}return t}function dt(e){if(!(e.flags&1)){const t=z(e),n=h[h.length-1];!n||!(e.flags&2)&&t>=z(n)?h.push(e):h.splice(pt(t),0,e),e.flags|=1,we()}}function we(){se||(se=ut.then(ke))}function mt(e){_(e)?F.push(...e):w&&e.id===-1?w.splice(T+1,0,e):e.flags&1||(F.push(e),e.flags|=1),we()}function ht(e){if(F.length){const t=[...new Set(F)].sort((n,o)=>z(n)-z(o));if(F.length=0,w){w.push(...t);return}for(w=t,process.env.NODE_ENV!=="production"&&(e=e||new Map),T=0;T<w.length;T++){const n=w[T];process.env.NODE_ENV!=="production"&&be(e,n)||(n.flags&4&&(n.flags&=-2),n.flags&8||n(),n.flags&=-2)}w=null,T=0}}const z=e=>e.id==null?e.flags&2?-1:1/0:e.id;function ke(e){process.env.NODE_ENV!=="production"&&(e=e||new Map);const t=process.env.NODE_ENV!=="production"?n=>be(e,n):ge;try{for(E=0;E<h.length;E++){const n=h[E];if(n&&!(n.flags&8)){if(process.env.NODE_ENV!=="production"&&t(n))continue;n.flags&4&&(n.flags&=-2),j(n,n.i,n.i?15:14),n.flags&4||(n.flags&=-2)}}}finally{for(;E<h.length;E++){const n=h[E];n&&(n.flags&=-2)}E=-1,h.length=0,ht(e),se=null,(h.length||F.length)&&ke(e)}}function be(e,t){const n=e.get(t)||0;if(n>ft){const o=t.i,s=o&&Me(o.type);return re(`Maximum recursive updates exceeded${s?` in component <${s}>`:""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,null,10),!0}return e.set(t,n+1),!1}const le=new Map;process.env.NODE_ENV!=="production"&&(x().__VUE_HMR_RUNTIME__={createRecord:ie(yt),rerender:ie(gt),reload:ie(_t)});const U=new Map;function yt(e,t){return U.has(e)?!1:(U.set(e,{initialDef:v(t),instances:new Set}),!0)}function v(e){return ze(e)?e.__vccOpts:e}function gt(e,t){const n=U.get(e);n&&(n.initialDef.render=t,[...n.instances].forEach(o=>{t&&(o.render=t,v(o.type).render=t),o.renderCache=[],o.job.flags&8||o.update()}))}function _t(e,t){const n=U.get(e);if(!n)return;t=v(t),Oe(n.initialDef,t);const o=[...n.instances];for(let s=0;s<o.length;s++){const r=o[s],i=v(r.type);let c=le.get(i);c||(i!==n.initialDef&&Oe(i,t),le.set(i,c=new Set)),c.add(r),r.appContext.propsCache.delete(r.type),r.appContext.emitsCache.delete(r.type),r.appContext.optionsCache.delete(r.type),r.ceReload?(c.add(r),r.ceReload(t.styles),c.delete(r)):r.parent?dt(()=>{r.job.flags&8||(r.parent.update(),c.delete(r))}):r.appContext.reload?r.appContext.reload():typeof window<"u"?window.location.reload():console.warn("[HMR] Root or manually mounted instance modified. Full reload required."),r.root.ce&&r!==r.root&&r.root.ce._removeChildStyle(i)}mt(()=>{le.clear()})}function Oe(e,t){X(e,t);for(const n in e)n!=="__file"&&!(n in t)&&delete e[n]}function ie(e){return(t,n)=>{try{return e(t,n)}catch(o){console.error(o),console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required.")}}}let $,B=[];function Ve(e,t){var n,o;$=e,$?($.enabled=!0,B.forEach(({event:s,args:r})=>$.emit(s,...r)),B=[]):typeof window<"u"&&window.HTMLElement&&!((o=(n=window.navigator)==null?void 0:n.userAgent)!=null&&o.includes("jsdom"))?((t.__VUE_DEVTOOLS_HOOK_REPLAY__=t.__VUE_DEVTOOLS_HOOK_REPLAY__||[]).push(r=>{Ve(r,t)}),setTimeout(()=>{$||(t.__VUE_DEVTOOLS_HOOK_REPLAY__=null,B=[])},3e3)):B=[]}let J=null,Ct=null;const Et=e=>e.__isTeleport;function Ie(e,t){e.shapeFlag&6&&e.component?(e.transition=t,Ie(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}x().requestIdleCallback,x().cancelIdleCallback;function St(e,t,n=K,o=!1){if(n){const s=n[e]||(n[e]=[]),r=t.__weh||(t.__weh=(...i)=>{const c=Ht(n),a=Ne(t,n,e,i);return c(),a});return o?s.unshift(r):s.push(r),r}else if(process.env.NODE_ENV!=="production"){const s=Xe(oe[e].replace(/ hook$/,""));N(`${s} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`)}}const Nt=(e=>(t,n=K)=>{(!Ae||e==="sp")&&St(e,(...o)=>t(...o),n)})("u"),wt=Symbol.for("v-ndc"),kt={};process.env.NODE_ENV!=="production"&&(kt.ownKeys=e=>(N("Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead."),Reflect.ownKeys(e)));const bt={},Re=e=>Object.getPrototypeOf(e)===bt,Ot=e=>e.__isSuspense,De=Symbol.for("v-fgt"),Vt=Symbol.for("v-txt"),It=Symbol.for("v-cmt");function Rt(e){return e?e.__v_isVNode===!0:!1}const Dt=(...e)=>Te(...e),Fe=({key:e})=>e??null,W=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?S(e)||Ee(e)||C(e)?{i:J,r:e,k:t,f:!!n}:e:null);function Ft(e,t=null,n=null,o=0,s=null,r=e===De?0:1,i=!1,c=!1){const a={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&Fe(t),ref:t&&W(t),scopeId:Ct,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:r,patchFlag:o,dynamicProps:s,dynamicChildren:null,appContext:null,ctx:J};return c?(ae(a,n),r&128&&e.normalize(a)):n&&(a.shapeFlag|=S(n)?8:16),process.env.NODE_ENV!=="production"&&a.key!==a.key&&N("VNode created with invalid key (NaN). VNode type:",a.type),a}const Tt=process.env.NODE_ENV!=="production"?Dt:Te;function Te(e,t=null,n=null,o=0,s=null,r=!1){if((!e||e===wt)&&(process.env.NODE_ENV!=="production"&&!e&&N(`Invalid vnode type when creating vnode: ${e}.`),e=It),Rt(e)){const c=q(e,t,!0);return n&&ae(c,n),c.patchFlag=-2,c}if(ze(e)&&(e=e.__vccOpts),t){t=$t(t);let{class:c,style:a}=t;c&&!S(c)&&(t.class=ee(c)),H(a)&&(te(a)&&!_(a)&&(a=X({},a)),t.style=Z(a))}const i=S(e)?1:Ot(e)?128:Et(e)?64:H(e)?4:C(e)?2:0;return process.env.NODE_ENV!=="production"&&i&4&&te(e)&&(e=L(e),N("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.",`
|
|
17
|
+
Component that was made reactive: `,e)),Ft(e,t,n,o,s,i,r,!0)}function $t(e){return e?te(e)||Re(e)?X({},e):e:null}function q(e,t,n=!1,o=!1){const{props:s,ref:r,patchFlag:i,children:c,transition:a}=e,u=t?Mt(s||{},t):s,m={__v_isVNode:!0,__v_skip:!0,type:e.type,props:u,key:u&&Fe(u),ref:t&&t.ref?n&&r?_(r)?r.concat(W(t)):[r,W(t)]:W(t):r,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:process.env.NODE_ENV!=="production"&&i===-1&&_(c)?c.map($e):c,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==De?i===-1?16:i|16:i,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:a,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&q(e.ssContent),ssFallback:e.ssFallback&&q(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return a&&o&&Ie(m,a.clone(m)),m}function $e(e){const t=q(e);return _(e.children)&&(t.children=e.children.map($e)),t}function At(e=" ",t=0){return Tt(Vt,null,e,t)}function ae(e,t){let n=0;const{shapeFlag:o}=e;if(t==null)t=null;else if(_(t))n=16;else if(typeof t=="object")if(o&65){const s=t.default;s&&(s._c&&(s._d=!1),ae(e,s()),s._c&&(s._d=!0));return}else n=32,!t._&&!Re(t)&&(t._ctx=J);else C(t)?(t={default:t,_ctx:J},n=32):(t=String(t),o&64?(n=16,t=[At(t)]):n=8);e.children=t,e.shapeFlag|=n}function Mt(...e){const t={};for(let n=0;n<e.length;n++){const o=e[n];for(const s in o)if(s==="class")t.class!==o.class&&(t.class=ee([t.class,o.class]));else if(s==="style")t.style=Z([t.style,o.style]);else if(Ke(s)){const r=t[s],i=o[s];i&&r!==i&&!(_(r)&&r.includes(i))&&(t[s]=r?[].concat(r,i):i)}else s!==""&&(t[s]=o[s])}return t}let K=null,ce;{const e=x(),t=(n,o)=>{let s;return(s=e[n])||(s=e[n]=[]),s.push(o),r=>{s.length>1?s.forEach(i=>i(r)):s[0](r)}};ce=t("__VUE_INSTANCE_SETTERS__",n=>K=n),t("__VUE_SSR_SETTERS__",n=>Ae=n)}const Ht=e=>{const t=K;return ce(e),e.scope.on(),()=>{e.scope.off(),ce(t)}};let Ae=!1;process.env.NODE_ENV;const zt=/(?:^|[-_])\w/g,Pt=e=>e.replace(zt,t=>t.toUpperCase()).replace(/[-_]/g,"");function Me(e,t=!0){return C(e)?e.displayName||e.name:e.name||t&&e.__name}function He(e,t,n=!1){let o=Me(t);if(!o&&t.__file){const s=t.__file.match(/([^/\\]+)\.\w+$/);s&&(o=s[1])}if(!o&&e){const s=r=>{for(const i in r)if(r[i]===t)return i};o=s(e.components)||e.parent&&s(e.parent.type.components)||s(e.appContext.components)}return o?Pt(o):n?"App":"Anonymous"}function ze(e){return C(e)&&"__vccOpts"in e}process.env.NODE_ENV,process.env.NODE_ENV,process.env.NODE_ENV;const xt=l.defineComponent({inheritAttrs:!0,__name:"MyopVueComponent",props:{flowId:{},componentId:{},onReady:{type:Function}},setup(e,{expose:t}){const n=e,o=l.useAttrs(),s=l.useSlots(),r=l.ref(null),i=l.ref(!0),c=l.ref(null),a=l.ref(null),u=l.getCurrentInstance(),m=l.ref(null);Nt(()=>{a&&a.value&&a.value(o)}),l.onMounted(async()=>{if(r.value){const R=await P.CloudRepository.Main.fetchComponent(n.componentId,n.flowId);c.value=await V.hostSDK.loadComponent(R,r==null?void 0:r.value,{_environment:{props:o,slots:s,context:u==null?void 0:u.appContext,vueContainerRef:r,defineUpdater:b=>{a.value=b},defineInnerVueComponentRef:b=>{m.value=b.value}}}),i.value=!1,n.onReady&&n.onReady(c.value,m.value)}});const g=l.reactive({});return t(g),l.watchEffect(()=>{Object.assign(g,m.value)}),(R,b)=>(l.openBlock(),l.createElementBlock(l.Fragment,null,[l.createElementVNode("div",l.mergeProps(l.unref(o),{ref_key:"myopContainer",ref:r}),null,16),i.value?l.renderSlot(R.$slots,"loading",{key:0}):l.createCommentVNode("",!0)],64))}});let k=P.CloudRepository.Main;const Pe=()=>k,xe=(e,t,n)=>k.isPreloaded(e,t,n),Lt=e=>k.getPreloadedParams(e),jt=()=>{k=new P.CloudRepository("http://localhost:9292")},Ut=e=>{k=new P.CloudRepository(e)},vt=e=>{k=e},Bt=e=>{k.setEnvironment(e)},Jt=async(e,t,n)=>Promise.allSettled(e.map(o=>k.fetchComponentV2(o,t,n)));d.MyopComponent=We,d.MyopContainer=xt,d.MyopFallback=ye,d.MyopLoader=he,d.enableLocalDev=jt,d.getCloudRepository=Pe,d.getPreloadedParams=Lt,d.isPreloaded=xe,d.preloadComponents=Jt,d.setCloudRepository=vt,d.setCloudRepositoryUrl=Ut,d.setEnvironment=Bt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { IMyopComponent } from "@myop/sdk/host";
|
|
2
|
+
export interface IComponentInstanceConfig {
|
|
3
|
+
id: string;
|
|
4
|
+
componentId: string;
|
|
5
|
+
componentName: string;
|
|
6
|
+
skinSelector: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
nestedComponents?: IComponentInstanceConfig[];
|
|
10
|
+
resolvedExperiences?: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}[];
|
|
13
|
+
resolvedNestedComponents?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}[];
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
export interface SizeInfo {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
autoSizingWidth: boolean;
|
|
22
|
+
autoSizingHeight: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts kebab-case string to PascalCase
|
|
26
|
+
* e.g., 'column-reordered' -> 'ColumnReordered'
|
|
27
|
+
*/
|
|
28
|
+
export type KebabToPascal<S extends string> = S extends `${infer First}-${infer Rest}` ? `${Capitalize<First>}${KebabToPascal<Rest>}` : Capitalize<S>;
|
|
29
|
+
/**
|
|
30
|
+
* Generates typed event handler props from CTA payloads.
|
|
31
|
+
* e.g., `{ 'row-clicked': { rowIndex: number } }` -> `{ onRowClicked?: (payload: { rowIndex: number }) => void }`
|
|
32
|
+
*/
|
|
33
|
+
export type EventHandlerProps<TPayloads extends Record<string, any>> = string extends keyof TPayloads ? {} : {
|
|
34
|
+
[K in keyof TPayloads as `on${KebabToPascal<K & string>}`]?: (payload: TPayloads[K]) => void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Type for the `on` callback prop.
|
|
38
|
+
*/
|
|
39
|
+
export type OnCallback<TPayloads extends Record<string, any>> = string extends keyof TPayloads ? (action: string, payload: any) => void : <K extends keyof TPayloads>(action: K, payload: TPayloads[K]) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Typed props interface for accessing component.props with autocomplete.
|
|
42
|
+
* Contains myop_init_interface and myop_cta_handler with proper types.
|
|
43
|
+
*/
|
|
44
|
+
export interface IMyopComponentProps<TDataType = any, TPayloads extends Record<string, any> = Record<string, any>> {
|
|
45
|
+
/** Initialize the component with data */
|
|
46
|
+
myop_init_interface?: (data: TDataType) => void;
|
|
47
|
+
/** Handle CTA events from the component */
|
|
48
|
+
myop_cta_handler?: <K extends keyof TPayloads>(action: K, payload: TPayloads[K]) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Typed Myop component interface with typed props.
|
|
52
|
+
* Use this type for the component returned in load event.
|
|
53
|
+
*/
|
|
54
|
+
export type ITypedMyopComponent<TDataType = any, TPayloads extends Record<string, any> = Record<string, any>> = Omit<IMyopComponent, 'props'> & {
|
|
55
|
+
/** Typed props for the component */
|
|
56
|
+
props: IMyopComponentProps<TDataType, TPayloads> | null;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Base props for MyopComponent
|
|
60
|
+
*/
|
|
61
|
+
export interface IBaseProps<TDataType = any, TPayloads extends Record<string, any> = Record<string, any>> {
|
|
62
|
+
componentId?: string;
|
|
63
|
+
componentConfig?: IComponentInstanceConfig;
|
|
64
|
+
data?: TDataType;
|
|
65
|
+
fadeDuration?: number;
|
|
66
|
+
autoSize?: boolean;
|
|
67
|
+
environment?: string;
|
|
68
|
+
preview?: boolean;
|
|
69
|
+
on?: OnCallback<TPayloads>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Full props type including generated event handlers.
|
|
73
|
+
* Supports both generic `on` callback and individual typed handlers like `onRowClicked`.
|
|
74
|
+
*/
|
|
75
|
+
export type IPropTypes<TDataType = any, TPayloads extends Record<string, any> = Record<string, any>> = IBaseProps<TDataType, TPayloads> & EventHandlerProps<TPayloads>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myop/vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.umd.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -24,13 +24,12 @@
|
|
|
24
24
|
"preview": "vite preview",
|
|
25
25
|
"release": "npm publish --access public"
|
|
26
26
|
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@myop/sdk": "^0.1.42"
|
|
29
|
-
},
|
|
30
27
|
"peerDependencies": {
|
|
28
|
+
"@myop/sdk": "*",
|
|
31
29
|
"vue": "^3.5.13"
|
|
32
30
|
},
|
|
33
31
|
"devDependencies": {
|
|
32
|
+
"@myop/sdk": "^0.3.13",
|
|
34
33
|
"@types/node": "^22.14.0",
|
|
35
34
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
36
35
|
"@vue/tsconfig": "^0.7.0",
|
|
@@ -39,6 +38,21 @@
|
|
|
39
38
|
"vite": "^6.2.0",
|
|
40
39
|
"vue-tsc": "^2.2.4"
|
|
41
40
|
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"myop",
|
|
43
|
+
"vue",
|
|
44
|
+
"vue3",
|
|
45
|
+
"components",
|
|
46
|
+
"dynamic-ui",
|
|
47
|
+
"real-time",
|
|
48
|
+
"no-deploy",
|
|
49
|
+
"remote-components",
|
|
50
|
+
"micro-frontend",
|
|
51
|
+
"ab-testing",
|
|
52
|
+
"feature-flags",
|
|
53
|
+
"sandboxed",
|
|
54
|
+
"ai-components"
|
|
55
|
+
],
|
|
42
56
|
"files": [
|
|
43
57
|
"./dist/*"
|
|
44
58
|
]
|