New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@uniformdev/mesh-sdk

Package Overview
Dependencies
Maintainers
8
Versions
711
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniformdev/mesh-sdk - npm Package Compare versions

Comparing version

to
14.1.2-alpha.99

2

dist/index.esm.js

@@ -1,1 +0,1 @@

var w=()=>import("@datadog/framepost");async function u({dialogResponseHandlers:t}){let r=await w(),a=new r.ChildClient,s=await a.request("initialize");return a.onRequest("dialog-value",async e=>{let i=t[e.dialogId];!i||(e.value?i.resolve({value:e.value,dialogId:e.dialogId}):e.error&&i.reject(e.error),delete t[e.dialogId])}),{initData:s,parent:{resize:async e=>{a.request("resize",{height:e})},getValue:async()=>{let e=await a.request("getValue");return e==null?void 0:e.data},setValue:async e=>{await a.request("setValue",e)},getMetadata:async()=>{let e=await a.request("getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:i,options:o})=>{if(m(o==null?void 0:o.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let n=await a.request("openDialog",{dialogType:e,dialogData:i,options:o}),l=n==null?void 0:n.dialogId;if(!!l)return new Promise((D,f)=>{t[l]={resolve:D,reject:f}})},closeDialog:async({dialogId:e,dialogType:i,dialogData:o})=>{await a.request("closeDialog",{dialogId:e,dialogType:i,dialogData:o})}}}}function m(t){if(!t||typeof Blob=="undefined")return 0;try{let r=JSON.stringify(t);return new Blob([r]).size}catch(r){throw new Error("Error calculating object size: "+r.message)}}var d,p=({onHeightChange:t,autoResizingDisabled:r})=>{if(typeof window=="undefined")return;let a=window,s=n=>{if(n&&n!==d){d=n,t==null||t(n);return}let l=`${Math.ceil(a.document.documentElement.getBoundingClientRect().height)}px`;l!==d&&(d=l,t==null||t(l))},e=()=>{s()},i=r?void 0:new MutationObserver(e),o={instance:a,height:a.document.documentElement.getBoundingClientRect().height,observer:i,enableAutoResizing:()=>{i==null||i.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),a.addEventListener("resize",e)},disableAutoResizing:()=>{i==null||i.disconnect(),a.removeEventListener("resize",e)},updateHeight:s};return r||o.enableAutoResizing(),o};var y={};async function I({autoResizingDisabled:t}={}){var r;if(typeof window!="undefined"&&typeof window.UniformMeshSDK=="undefined"){if(typeof window.parent=="undefined"||window.parent==window)throw new Error("It appears you are trying to connect with the Uniform Mesh SDK outside of an iframe. Be sure you are loading your app via a location URL configured in the Uniform dashboard.");let a=await u({dialogResponseHandlers:y}),{initData:s,parent:e}=a,i={getCurrentLocation:()=>({getValue:()=>s.locationValue,setValue:async o=>{await e.setValue(o),s.locationValue=o},getMetadata:()=>s.locationMetadata}),currentWindow:p({onHeightChange:o=>{e.resize(o)},autoResizingDisabled:((r=s.dialogContext)==null?void 0:r.contentHeight)?!0:t}),version:s.uniformApiVersion,openLocationDialog:async({locationKey:o,options:n})=>{let l=await e.openDialog({dialogType:"location",data:{locationKey:o},options:n});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await e.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:o})=>{await e.closeDialog({dialogId:o,dialogType:"location"})},openConfirmationDialog:async({titleText:o,bodyText:n})=>{let l=await e.openDialog({dialogType:"confirm",data:{titleText:o,bodyText:n}});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:o})=>{let n=await e.openDialog({dialogType:"location",data:{},options:o});if(!!n)return{dialogId:n.dialogId,value:n.value,closeDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:s.dialogContext};return window.UniformMeshSDK=i,i}}export{I as initializeUniformMeshSDK};
var R=(n,e)=>e?{log(o,...t){return console.log(`${n}: ${o}`,...t)},error(o,...t){return console.error(`${n}: ${o}`,...t)}}:{log(){},error(){}};var T=5e3;var c=class extends Error{constructor(){super("Request timed out");Object.setPrototypeOf(this,c.prototype),this.name="RequestTimeoutError"}},u=class extends Error{constructor(){super("Client destroyed");Object.setPrototypeOf(this,u.prototype),this.name="ClientDestroyedError"}};var b=()=>{let n=()=>{},e=()=>{},o=new Promise((t,i)=>{n=t,e=i});return{resolve:n,reject:e,promise:o}},m=(n=16)=>[...Array(n)].map(()=>(~~(Math.random()*36)).toString(36)).join(""),h=(n,e)=>{let{[e]:o,...t}=n;return t},L=n=>({message:n.message,name:n.name,stack:n.stack}),V=({name:n,message:e,stack:o})=>{switch(n){case c.name:return new c;default:{let t=new Error(e);return t.name=n,t.stack=o,t}}},D=n=>{let e=n.data,o="none";return e instanceof Error&&(o="error",e=L(e)),{...n,serialization:o,data:e}},v=n=>n.serialization==="error"?{...n,data:V(n.data)}:n;var w=class{constructor({debug:e=!1,requestTimeout:o=T}={}){this.debug=e,this.requestTimeout=o,this.channel=b(),this.eventSubscriptions={},this.responseSubscriptions={},this.requestSubscriptions={},this.onDestroyRequestHandlers={},this.destroyed=!1,this.logger=this.getLogger(),this.getChannel().then(()=>{this.logger.log("Secure parent <-> child channel established")}).catch(t=>{this.logger.log(t)})}async send(e,o){return this.postMessage("event",e,o)}on(e,o){this.eventSubscriptions[e]||(this.eventSubscriptions[e]={});let t=m(8);return this.eventSubscriptions[e][t]=o,this.logger.log(`Registered handler for event "${e}"`),()=>{this.eventSubscriptions[e]=h(this.eventSubscriptions[e],t),this.logger.log(`Unsubscribed handler for event ${e}`)}}async request(e,o,t={}){let r=(await this.postMessage("request",e,o)).id,s=()=>{this.responseSubscriptions=h(this.responseSubscriptions,r)},a=()=>{this.onDestroyRequestHandlers=h(this.responseSubscriptions,r)};return new Promise((l,p)=>{let y,x=(S,O)=>{clearTimeout(y),s(),a(),O.type==="error_response"?p(S):l(S)},I=()=>{clearTimeout(y),p(new u)};this.responseSubscriptions[r]=x,this.onDestroyRequestHandlers[r]=I,y=setTimeout(()=>{s(),a(),p(new c)},t.timeout||this.requestTimeout)})}onRequest(e,o){let t=async(i,r)=>{try{let s=await o(i,r);this.postMessage("response",e,s,r.id)}catch(s){this.postMessage("error_response",e,s,r.id)}};return this.requestSubscriptions[e]=t,()=>{this.requestSubscriptions=h(this.requestSubscriptions,e)}}async getChannel(){if(await this.channel.promise,this.destroyed)throw new u;return this.channel.promise}async messageListener(e){try{await this.getChannel();let o=this.isValidMessage(e),t=v(e.data);if(o)switch(t.type){case"event":{this.handleEvent(t);break}case"request":{this.handleRequest(t);break}case"error_response":case"response":{this.handleResponse(t);break}}else this.logger.error("Invalid message format. Skipping.")}catch(o){this.logger.error(o)}}handleEvent(e){let o=this.eventSubscriptions[e.key];o&&Object.values(o).forEach(t=>t(e.data,e))}handleRequest(e){let o=this.requestSubscriptions[e.key];o&&(o(e.data,e),this.logger.log(`Handled request type ${e.key}`))}handleResponse(e){let o=e.requestId,t=o&&this.responseSubscriptions[o];t&&t(e.data,e)}async postMessage(e,o,t,i){let{port:r}=await this.getChannel();if(this.destroyed)throw new u;let s=D({type:e,apiVersion:"framepost/v1",key:o,data:t,id:m(),requestId:i});return this.logger.log("posting message from child to parent",s),r.postMessage(s),s}initListener(e){this.isInitMessage(e)?(this.onChannelInit(e),this.messagePort&&(this.messagePort.onmessage=this.messageListener.bind(this)),this.resolveChannel(e)):this.logger.error("Invalid message format. Skipping.")}isValidMessage(e){let o=e.data;return o.type&&o.id&&o.apiVersion==="framepost/v1"}isInitMessage(e){return this.isValidMessage(e)&&e.data.type==="channel_init"}resolveChannel(e){if(this.messagePort){let o={port:this.messagePort,origin:e.origin,context:e.data.data};this.channel.resolve(o)}}getInitMessage(e){return D({type:"channel_init",apiVersion:"framepost/v1",key:"",data:e,id:m()})}destroy(){this.destroyed=!0,this.channel.reject(new u),this.messagePort&&this.messagePort.close(),Object.values(this.onDestroyRequestHandlers).forEach(e=>e())}};var E=class extends w{constructor(e={}){super(e);this.context=e.context||null,this.initListener=this.initListener.bind(this),window.addEventListener("message",this.initListener)}getLogger(){return R("child-client",this.debug)}onChannelInit(e){window.removeEventListener("message",this.initListener),this.messagePort=e.ports[0];let o=this.getInitMessage(this.context);this.logger.log("channel init, posting init message from child to parent",o),this.messagePort.postMessage(o)}destroy(){super.destroy(),window.removeEventListener("message",this.initListener)}};async function M({dialogResponseHandlers:n}){let e=new E({debug:!1});window.parent.postMessage("parents just don't understand","*");let o=await e.request("initialize");return e.onRequest("dialog-value",async t=>{let i=n[t.dialogId];!i||(t.value?i.resolve({value:t.value,dialogId:t.dialogId}):t.error&&i.reject(t.error),delete n[t.dialogId])}),{initData:o,parent:{resize:async t=>{e.request("resize",{height:t})},getValue:async()=>{let t=await e.request("getValue");return t==null?void 0:t.data},setValue:async t=>{await e.request("setValue",t)},getMetadata:async()=>{let t=await e.request("getMetadata");return t==null?void 0:t.data},openDialog:async({dialogType:t,data:i,options:r})=>{if(P(r==null?void 0:r.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let s=await e.request("openDialog",{dialogType:t,dialogData:i,options:r}),a=s==null?void 0:s.dialogId;if(!!a)return new Promise((l,p)=>{n[a]={resolve:l,reject:p}})},closeDialog:async({dialogId:t,dialogType:i,dialogData:r})=>{await e.request("closeDialog",{dialogId:t,dialogType:i,dialogData:r})}}}}function P(n){if(!n||typeof Blob=="undefined")return 0;try{let e=JSON.stringify(n);return new Blob([e]).size}catch(e){throw new Error("Error calculating object size: "+e.message)}}var f,C=({onHeightChange:n,autoResizingDisabled:e})=>{if(typeof window=="undefined")return;let o=window,t=a=>{if(a&&a!==f){f=a,n==null||n(a);return}let l=`${Math.ceil(o.document.documentElement.getBoundingClientRect().height)}px`;l!==f&&(f=l,n==null||n(l))},i=()=>{t()},r=e?void 0:new MutationObserver(i),s={instance:o,height:o.document.documentElement.getBoundingClientRect().height,observer:r,enableAutoResizing:()=>{r==null||r.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),o.addEventListener("resize",i)},disableAutoResizing:()=>{r==null||r.disconnect(),o.removeEventListener("resize",i)},updateHeight:t};return e||s.enableAutoResizing(),s};var q={};async function oe({autoResizingDisabled:n}={}){var e;if(typeof window!="undefined"&&typeof window.UniformMeshSDK=="undefined"){if(typeof window.parent=="undefined"||window.parent==window)throw new Error("It appears you are trying to connect with the Uniform Mesh SDK outside of an iframe. Be sure you are loading your app via a location URL configured in the Uniform dashboard.");let o=await M({dialogResponseHandlers:q}),{initData:t,parent:i}=o,r={getCurrentLocation:()=>({getValue:()=>t.locationValue,setValue:async s=>{await i.setValue(s),t.locationValue=s},getMetadata:()=>t.locationMetadata}),currentWindow:C({onHeightChange:s=>{i.resize(s)},autoResizingDisabled:((e=t.dialogContext)==null?void 0:e.contentHeight)?!0:n}),version:t.uniformApiVersion,openLocationDialog:async({locationKey:s,options:a})=>{let l=await i.openDialog({dialogType:"location",data:{locationKey:s},options:a});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await i.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:s})=>{await i.closeDialog({dialogId:s,dialogType:"location"})},openConfirmationDialog:async({titleText:s,bodyText:a})=>{let l=await i.openDialog({dialogType:"confirm",data:{titleText:s,bodyText:a}});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:s})=>{let a=await i.openDialog({dialogType:"location",data:{},options:s});if(!!a)return{dialogId:a.dialogId,value:a.value,closeDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:t.dialogContext};return window.UniformMeshSDK=r,r}}export{oe as initializeUniformMeshSDK};

@@ -1,1 +0,1 @@

var y=Object.create;var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var u=o=>d(o,"__esModule",{value:!0});var h=(o,i)=>{for(var a in i)d(o,a,{get:i[a],enumerable:!0})},p=(o,i,a,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of S(i))!V.call(o,e)&&(a||e!=="default")&&d(o,e,{get:()=>i[e],enumerable:!(s=T(i,e))||s.enumerable});return o},I=(o,i)=>p(u(d(o!=null?y(v(o)):{},"default",!i&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o),x=(o=>(i,a)=>o&&o.get(i)||(a=p(u({}),i,1),o&&o.set(i,a),a))(typeof WeakMap!="undefined"?new WeakMap:0);var R={};h(R,{initializeUniformMeshSDK:()=>M});var b=()=>import("@datadog/framepost");async function D({dialogResponseHandlers:o}){let i=await b(),a=new i.ChildClient,s=await a.request("initialize");return a.onRequest("dialog-value",async e=>{let t=o[e.dialogId];!t||(e.value?t.resolve({value:e.value,dialogId:e.dialogId}):e.error&&t.reject(e.error),delete o[e.dialogId])}),{initData:s,parent:{resize:async e=>{a.request("resize",{height:e})},getValue:async()=>{let e=await a.request("getValue");return e==null?void 0:e.data},setValue:async e=>{await a.request("setValue",e)},getMetadata:async()=>{let e=await a.request("getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:t,options:n})=>{if(C(n==null?void 0:n.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let l=await a.request("openDialog",{dialogType:e,dialogData:t,options:n}),r=l==null?void 0:l.dialogId;if(!!r)return new Promise((w,m)=>{o[r]={resolve:w,reject:m}})},closeDialog:async({dialogId:e,dialogType:t,dialogData:n})=>{await a.request("closeDialog",{dialogId:e,dialogType:t,dialogData:n})}}}}function C(o){if(!o||typeof Blob=="undefined")return 0;try{let i=JSON.stringify(o);return new Blob([i]).size}catch(i){throw new Error("Error calculating object size: "+i.message)}}var g,f=({onHeightChange:o,autoResizingDisabled:i})=>{if(typeof window=="undefined")return;let a=window,s=l=>{if(l&&l!==g){g=l,o==null||o(l);return}let r=`${Math.ceil(a.document.documentElement.getBoundingClientRect().height)}px`;r!==g&&(g=r,o==null||o(r))},e=()=>{s()},t=i?void 0:new MutationObserver(e),n={instance:a,height:a.document.documentElement.getBoundingClientRect().height,observer:t,enableAutoResizing:()=>{t==null||t.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),a.addEventListener("resize",e)},disableAutoResizing:()=>{t==null||t.disconnect(),a.removeEventListener("resize",e)},updateHeight:s};return i||n.enableAutoResizing(),n};var k={};async function M({autoResizingDisabled:o}={}){var i;if(typeof window!="undefined"&&typeof window.UniformMeshSDK=="undefined"){if(typeof window.parent=="undefined"||window.parent==window)throw new Error("It appears you are trying to connect with the Uniform Mesh SDK outside of an iframe. Be sure you are loading your app via a location URL configured in the Uniform dashboard.");let a=await D({dialogResponseHandlers:k}),{initData:s,parent:e}=a,t={getCurrentLocation:()=>({getValue:()=>s.locationValue,setValue:async n=>{await e.setValue(n),s.locationValue=n},getMetadata:()=>s.locationMetadata}),currentWindow:f({onHeightChange:n=>{e.resize(n)},autoResizingDisabled:((i=s.dialogContext)==null?void 0:i.contentHeight)?!0:o}),version:s.uniformApiVersion,openLocationDialog:async({locationKey:n,options:l})=>{let r=await e.openDialog({dialogType:"location",data:{locationKey:n},options:l});if(!!r)return{dialogId:r.dialogId,value:r.value,closeDialog:async()=>{await e.closeDialog({dialogId:r.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:n})=>{await e.closeDialog({dialogId:n,dialogType:"location"})},openConfirmationDialog:async({titleText:n,bodyText:l})=>{let r=await e.openDialog({dialogType:"confirm",data:{titleText:n,bodyText:l}});if(!!r)return{dialogId:r.dialogId,value:r.value,closeDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:n})=>{let l=await e.openDialog({dialogType:"location",data:{},options:n});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await e.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:s.dialogContext};return window.UniformMeshSDK=t,t}}module.exports=x(R);0&&(module.exports={initializeUniformMeshSDK});
var y=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var q=n=>y(n,"__esModule",{value:!0});var k=(n,e)=>{for(var o in e)y(n,o,{get:e[o],enumerable:!0})},z=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of V(e))!P.call(n,i)&&(o||i!=="default")&&y(n,i,{get:()=>e[i],enumerable:!(t=L(e,i))||t.enumerable});return n};var H=(n=>(e,o)=>n&&n.get(e)||(o=z(q({}),e,1),n&&n.set(e,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var _={};k(_,{initializeUniformMeshSDK:()=>A});var R=(n,e)=>e?{log(o,...t){return console.log(`${n}: ${o}`,...t)},error(o,...t){return console.error(`${n}: ${o}`,...t)}}:{log(){},error(){}};var T=5e3;var g=class extends Error{constructor(){super("Request timed out");Object.setPrototypeOf(this,g.prototype),this.name="RequestTimeoutError"}},c=class extends Error{constructor(){super("Client destroyed");Object.setPrototypeOf(this,c.prototype),this.name="ClientDestroyedError"}};var b=()=>{let n=()=>{},e=()=>{},o=new Promise((t,i)=>{n=t,e=i});return{resolve:n,reject:e,promise:o}},h=(n=16)=>[...Array(n)].map(()=>(~~(Math.random()*36)).toString(36)).join(""),p=(n,e)=>{let{[e]:o,...t}=n;return t},N=n=>({message:n.message,name:n.name,stack:n.stack}),U=({name:n,message:e,stack:o})=>{switch(n){case g.name:return new g;default:{let t=new Error(e);return t.name=n,t.stack=o,t}}},D=n=>{let e=n.data,o="none";return e instanceof Error&&(o="error",e=N(e)),{...n,serialization:o,data:e}},v=n=>n.serialization==="error"?{...n,data:U(n.data)}:n;var w=class{constructor({debug:e=!1,requestTimeout:o=T}={}){this.debug=e,this.requestTimeout=o,this.channel=b(),this.eventSubscriptions={},this.responseSubscriptions={},this.requestSubscriptions={},this.onDestroyRequestHandlers={},this.destroyed=!1,this.logger=this.getLogger(),this.getChannel().then(()=>{this.logger.log("Secure parent <-> child channel established")}).catch(t=>{this.logger.log(t)})}async send(e,o){return this.postMessage("event",e,o)}on(e,o){this.eventSubscriptions[e]||(this.eventSubscriptions[e]={});let t=h(8);return this.eventSubscriptions[e][t]=o,this.logger.log(`Registered handler for event "${e}"`),()=>{this.eventSubscriptions[e]=p(this.eventSubscriptions[e],t),this.logger.log(`Unsubscribed handler for event ${e}`)}}async request(e,o,t={}){let r=(await this.postMessage("request",e,o)).id,s=()=>{this.responseSubscriptions=p(this.responseSubscriptions,r)},a=()=>{this.onDestroyRequestHandlers=p(this.responseSubscriptions,r)};return new Promise((l,u)=>{let f,x=(S,O)=>{clearTimeout(f),s(),a(),O.type==="error_response"?u(S):l(S)},I=()=>{clearTimeout(f),u(new c)};this.responseSubscriptions[r]=x,this.onDestroyRequestHandlers[r]=I,f=setTimeout(()=>{s(),a(),u(new g)},t.timeout||this.requestTimeout)})}onRequest(e,o){let t=async(i,r)=>{try{let s=await o(i,r);this.postMessage("response",e,s,r.id)}catch(s){this.postMessage("error_response",e,s,r.id)}};return this.requestSubscriptions[e]=t,()=>{this.requestSubscriptions=p(this.requestSubscriptions,e)}}async getChannel(){if(await this.channel.promise,this.destroyed)throw new c;return this.channel.promise}async messageListener(e){try{await this.getChannel();let o=this.isValidMessage(e),t=v(e.data);if(o)switch(t.type){case"event":{this.handleEvent(t);break}case"request":{this.handleRequest(t);break}case"error_response":case"response":{this.handleResponse(t);break}}else this.logger.error("Invalid message format. Skipping.")}catch(o){this.logger.error(o)}}handleEvent(e){let o=this.eventSubscriptions[e.key];o&&Object.values(o).forEach(t=>t(e.data,e))}handleRequest(e){let o=this.requestSubscriptions[e.key];o&&(o(e.data,e),this.logger.log(`Handled request type ${e.key}`))}handleResponse(e){let o=e.requestId,t=o&&this.responseSubscriptions[o];t&&t(e.data,e)}async postMessage(e,o,t,i){let{port:r}=await this.getChannel();if(this.destroyed)throw new c;let s=D({type:e,apiVersion:"framepost/v1",key:o,data:t,id:h(),requestId:i});return this.logger.log("posting message from child to parent",s),r.postMessage(s),s}initListener(e){this.isInitMessage(e)?(this.onChannelInit(e),this.messagePort&&(this.messagePort.onmessage=this.messageListener.bind(this)),this.resolveChannel(e)):this.logger.error("Invalid message format. Skipping.")}isValidMessage(e){let o=e.data;return o.type&&o.id&&o.apiVersion==="framepost/v1"}isInitMessage(e){return this.isValidMessage(e)&&e.data.type==="channel_init"}resolveChannel(e){if(this.messagePort){let o={port:this.messagePort,origin:e.origin,context:e.data.data};this.channel.resolve(o)}}getInitMessage(e){return D({type:"channel_init",apiVersion:"framepost/v1",key:"",data:e,id:h()})}destroy(){this.destroyed=!0,this.channel.reject(new c),this.messagePort&&this.messagePort.close(),Object.values(this.onDestroyRequestHandlers).forEach(e=>e())}};var E=class extends w{constructor(e={}){super(e);this.context=e.context||null,this.initListener=this.initListener.bind(this),window.addEventListener("message",this.initListener)}getLogger(){return R("child-client",this.debug)}onChannelInit(e){window.removeEventListener("message",this.initListener),this.messagePort=e.ports[0];let o=this.getInitMessage(this.context);this.logger.log("channel init, posting init message from child to parent",o),this.messagePort.postMessage(o)}destroy(){super.destroy(),window.removeEventListener("message",this.initListener)}};async function M({dialogResponseHandlers:n}){let e=new E({debug:!1});window.parent.postMessage("parents just don't understand","*");let o=await e.request("initialize");return e.onRequest("dialog-value",async t=>{let i=n[t.dialogId];!i||(t.value?i.resolve({value:t.value,dialogId:t.dialogId}):t.error&&i.reject(t.error),delete n[t.dialogId])}),{initData:o,parent:{resize:async t=>{e.request("resize",{height:t})},getValue:async()=>{let t=await e.request("getValue");return t==null?void 0:t.data},setValue:async t=>{await e.request("setValue",t)},getMetadata:async()=>{let t=await e.request("getMetadata");return t==null?void 0:t.data},openDialog:async({dialogType:t,data:i,options:r})=>{if(W(r==null?void 0:r.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let s=await e.request("openDialog",{dialogType:t,dialogData:i,options:r}),a=s==null?void 0:s.dialogId;if(!!a)return new Promise((l,u)=>{n[a]={resolve:l,reject:u}})},closeDialog:async({dialogId:t,dialogType:i,dialogData:r})=>{await e.request("closeDialog",{dialogId:t,dialogType:i,dialogData:r})}}}}function W(n){if(!n||typeof Blob=="undefined")return 0;try{let e=JSON.stringify(n);return new Blob([e]).size}catch(e){throw new Error("Error calculating object size: "+e.message)}}var m,C=({onHeightChange:n,autoResizingDisabled:e})=>{if(typeof window=="undefined")return;let o=window,t=a=>{if(a&&a!==m){m=a,n==null||n(a);return}let l=`${Math.ceil(o.document.documentElement.getBoundingClientRect().height)}px`;l!==m&&(m=l,n==null||n(l))},i=()=>{t()},r=e?void 0:new MutationObserver(i),s={instance:o,height:o.document.documentElement.getBoundingClientRect().height,observer:r,enableAutoResizing:()=>{r==null||r.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),o.addEventListener("resize",i)},disableAutoResizing:()=>{r==null||r.disconnect(),o.removeEventListener("resize",i)},updateHeight:t};return e||s.enableAutoResizing(),s};var Q={};async function A({autoResizingDisabled:n}={}){var e;if(typeof window!="undefined"&&typeof window.UniformMeshSDK=="undefined"){if(typeof window.parent=="undefined"||window.parent==window)throw new Error("It appears you are trying to connect with the Uniform Mesh SDK outside of an iframe. Be sure you are loading your app via a location URL configured in the Uniform dashboard.");let o=await M({dialogResponseHandlers:Q}),{initData:t,parent:i}=o,r={getCurrentLocation:()=>({getValue:()=>t.locationValue,setValue:async s=>{await i.setValue(s),t.locationValue=s},getMetadata:()=>t.locationMetadata}),currentWindow:C({onHeightChange:s=>{i.resize(s)},autoResizingDisabled:((e=t.dialogContext)==null?void 0:e.contentHeight)?!0:n}),version:t.uniformApiVersion,openLocationDialog:async({locationKey:s,options:a})=>{let l=await i.openDialog({dialogType:"location",data:{locationKey:s},options:a});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await i.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:s})=>{await i.closeDialog({dialogId:s,dialogType:"location"})},openConfirmationDialog:async({titleText:s,bodyText:a})=>{let l=await i.openDialog({dialogType:"confirm",data:{titleText:s,bodyText:a}});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:s})=>{let a=await i.openDialog({dialogType:"location",data:{},options:s});if(!!a)return{dialogId:a.dialogId,value:a.value,closeDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await i.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:t.dialogContext};return window.UniformMeshSDK=r,r}}module.exports=H(_);0&&(module.exports={initializeUniformMeshSDK});
{
"name": "@uniformdev/mesh-sdk",
"version": "14.1.2-alpha.94+ae67f1b3",
"version": "14.1.2-alpha.99+0e111aa4",
"description": "Uniform Mesh Framework SDK",

@@ -27,5 +27,2 @@ "license": "SEE LICENSE IN LICENSE.txt",

},
"dependencies": {
"@datadog/framepost": "0.3.1"
},
"devDependencies": {

@@ -47,3 +44,3 @@ "@types/jest": "27.4.1",

},
"gitHead": "ae67f1b3366c3615afb6b9cd70f2d977c32c9e18"
"gitHead": "0e111aa47ed0c8581baf1b049738f0967ab50a31"
}

Sorry, the diff of this file is not supported yet