@uniformdev/mesh-sdk 14.1.1-alpha.0 → 14.1.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -20,15 +20,13 @@ interface DialogResponseHandlers {
20
20
  [dialogId: string]: DialogResponseHandler;
21
21
  }
22
22
  interface DialogResponseHandler {
23
- resolve: (value: Pick<DialogResponseData['data'], 'value' | 'dialogId'>) => void;
23
+ resolve: (value: Pick<DialogResponseData, 'value' | 'dialogId'>) => void;
24
24
  reject: (reason?: unknown) => void;
25
25
  }
26
26
  interface DialogResponseData {
27
- data: {
28
- value?: unknown;
29
- dialogId: string;
30
- error?: string;
31
- };
27
+ value?: unknown;
28
+ dialogId: string;
29
+ error?: string;
32
30
  }
33
31
  declare type DialogType = 'location' | 'confirm';
34
32
  interface DialogOptions {
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var m=()=>import("@datadog/framepost");async function c({dialogResponseHandlers:t}){let r=await m(),a=new r.ChildClient({debug:!0,handshakeTimeout:1e4,requestTimeout:3e4}),n=await a.request("initialize");return a.onRequest("dialog-value",async({data:e})=>{let o=t[e.dialogId];!o||(e.value?o.resolve({value:e.value,dialogId:e.dialogId}):e.error&&o.reject(e.error),delete t[e.dialogId])}),{initData:n,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:o,options:i})=>{var g;if(y(i==null?void 0:i.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let l=await a.request("openDialog",{dialogType:e,dialogData:o,options:i}),u=(g=l==null?void 0:l.data)==null?void 0:g.dialogId;if(!!u)return new Promise((f,w)=>{t[u]={resolve:f,reject:w}})},closeDialog:async({dialogId:e,dialogType:o,dialogData:i})=>{await a.request("closeDialog",{dialogId:e,dialogType:o,dialogData:i})}}}}function y(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,n=()=>{let i=Math.ceil(a.document.documentElement.getBoundingClientRect().height);i!==D&&(D=i,t==null||t(i))},e=r?void 0:new MutationObserver(n),o={instance:a,observer:e,height:0,enableAutoResizing:()=>{e==null||e.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),a.addEventListener("resize",n)},disableAutoResizing:()=>{e==null||e.disconnect(),a.removeEventListener("resize",n)}};return r||o.enableAutoResizing(),o};var T={};async function k({autoResizingDisabled:t}={}){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 r=await c({dialogResponseHandlers:T}),{initData:a,parent:n}=r,e={getCurrentLocation:()=>({getValue:()=>a.locationValue,setValue:async o=>{await n.setValue(o),a.locationValue=o},getMetadata:()=>a.locationMetadata}),currentWindow:p({onHeightChange:o=>{n.resize(o)},autoResizingDisabled:t}),version:a.uniformApiVersion,openLocationDialog:async({locationKey:o,options:i})=>{let l=await n.openDialog({dialogType:"location",data:{locationKey:o},options:i});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:o})=>{await n.closeDialog({dialogId:o,dialogType:"location"})},openConfirmationDialog:async({titleText:o,bodyText:i})=>{let l=await n.openDialog({dialogType:"confirm",data:{titleText:o,bodyText:i}});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:o})=>{let i=await n.openDialog({dialogType:"location",data:{},options:o});if(!!i)return{dialogId:i.dialogId,value:i.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:a.dialogContext};return window.UniformMeshSDK=e,e}}export{k as initializeUniformMeshSDK};
1
+ var w=()=>import("@datadog/framepost");async function u({dialogResponseHandlers:t}){let r=await w(),i=new r.ChildClient,n=await i.request("initialize");return i.onRequest("dialog-value",async e=>{let o=t[e.dialogId];!o||(e.value?o.resolve({value:e.value,dialogId:e.dialogId}):e.error&&o.reject(e.error),delete t[e.dialogId])}),{initData:n,parent:{resize:async e=>{i.request("resize",{height:e})},getValue:async()=>{let e=await i.request("getValue");return e==null?void 0:e.data},setValue:async e=>{await i.request("setValue",e)},getMetadata:async()=>{let e=await i.request("getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:o,options:a})=>{if(m(a==null?void 0:a.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let l=await i.request("openDialog",{dialogType:e,dialogData:o,options:a}),g=l==null?void 0:l.dialogId;if(!!g)return new Promise((p,f)=>{t[g]={resolve:p,reject:f}})},closeDialog:async({dialogId:e,dialogType:o,dialogData:a})=>{await i.request("closeDialog",{dialogId:e,dialogType:o,dialogData:a})}}}}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 c,D=({onHeightChange:t,autoResizingDisabled:r})=>{if(typeof window=="undefined")return;let i=window,n=()=>{let a=Math.ceil(i.document.documentElement.getBoundingClientRect().height);a!==c&&(c=a,t==null||t(a))},e=r?void 0:new MutationObserver(n),o={instance:i,observer:e,height:0,enableAutoResizing:()=>{e==null||e.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),i.addEventListener("resize",n)},disableAutoResizing:()=>{e==null||e.disconnect(),i.removeEventListener("resize",n)}};return r||o.enableAutoResizing(),o};var y={};async function b({autoResizingDisabled:t}={}){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 r=await u({dialogResponseHandlers:y}),{initData:i,parent:n}=r,e={getCurrentLocation:()=>({getValue:()=>i.locationValue,setValue:async o=>{await n.setValue(o),i.locationValue=o},getMetadata:()=>i.locationMetadata}),currentWindow:D({onHeightChange:o=>{n.resize(o)},autoResizingDisabled:t}),version:i.uniformApiVersion,openLocationDialog:async({locationKey:o,options:a})=>{let l=await n.openDialog({dialogType:"location",data:{locationKey:o},options:a});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:o})=>{await n.closeDialog({dialogId:o,dialogType:"location"})},openConfirmationDialog:async({titleText:o,bodyText:a})=>{let l=await n.openDialog({dialogType:"confirm",data:{titleText:o,bodyText:a}});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:o})=>{let a=await n.openDialog({dialogType:"location",data:{},options:o});if(!!a)return{dialogId:a.dialogId,value:a.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:i.dialogContext};return window.UniformMeshSDK=e,e}}export{b as initializeUniformMeshSDK};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var T=Object.create;var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var c=o=>s(o,"__esModule",{value:!0});var b=(o,i)=>{for(var a in i)s(o,a,{get:i[a],enumerable:!0})},D=(o,i,a,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of V(i))!v.call(o,e)&&(a||e!=="default")&&s(o,e,{get:()=>i[e],enumerable:!(t=h(i,e))||t.enumerable});return o},k=(o,i)=>D(c(s(o!=null?T(I(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=D(c({}),i,1),o&&o.set(i,a),a))(typeof WeakMap!="undefined"?new WeakMap:0);var L={};b(L,{initializeUniformMeshSDK:()=>S});var M=()=>import("@datadog/framepost");async function p({dialogResponseHandlers:o}){let i=await M(),a=new i.ChildClient({debug:!0,handshakeTimeout:1e4,requestTimeout:3e4}),t=await a.request("initialize");return a.onRequest("dialog-value",async({data:e})=>{let n=o[e.dialogId];!n||(e.value?n.resolve({value:e.value,dialogId:e.dialogId}):e.error&&n.reject(e.error),delete o[e.dialogId])}),{initData:t,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:n,options:l})=>{var g;if(R(l==null?void 0:l.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let r=await a.request("openDialog",{dialogType:e,dialogData:n,options:l}),u=(g=r==null?void 0:r.data)==null?void 0:g.dialogId;if(!!u)return new Promise((m,y)=>{o[u]={resolve:m,reject:y}})},closeDialog:async({dialogId:e,dialogType:n,dialogData:l})=>{await a.request("closeDialog",{dialogId:e,dialogType:n,dialogData:l})}}}}function R(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 f,w=({onHeightChange:o,autoResizingDisabled:i})=>{if(typeof window=="undefined")return;let a=window,t=()=>{let l=Math.ceil(a.document.documentElement.getBoundingClientRect().height);l!==f&&(f=l,o==null||o(l))},e=i?void 0:new MutationObserver(t),n={instance:a,observer:e,height:0,enableAutoResizing:()=>{e==null||e.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),a.addEventListener("resize",t)},disableAutoResizing:()=>{e==null||e.disconnect(),a.removeEventListener("resize",t)}};return i||n.enableAutoResizing(),n};var z={};async function S({autoResizingDisabled:o}={}){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 i=await p({dialogResponseHandlers:z}),{initData:a,parent:t}=i,e={getCurrentLocation:()=>({getValue:()=>a.locationValue,setValue:async n=>{await t.setValue(n),a.locationValue=n},getMetadata:()=>a.locationMetadata}),currentWindow:w({onHeightChange:n=>{t.resize(n)},autoResizingDisabled:o}),version:a.uniformApiVersion,openLocationDialog:async({locationKey:n,options:l})=>{let r=await t.openDialog({dialogType:"location",data:{locationKey:n},options:l});if(!!r)return{dialogId:r.dialogId,value:r.value,closeDialog:async()=>{await t.closeDialog({dialogId:r.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:n})=>{await t.closeDialog({dialogId:n,dialogType:"location"})},openConfirmationDialog:async({titleText:n,bodyText:l})=>{let r=await t.openDialog({dialogType:"confirm",data:{titleText:n,bodyText:l}});if(!!r)return{dialogId:r.dialogId,value:r.value,closeDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:n})=>{let l=await t.openDialog({dialogType:"location",data:{},options:n});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:a.dialogContext};return window.UniformMeshSDK=e,e}}module.exports=x(L);0&&(module.exports={initializeUniformMeshSDK});
1
+ var y=Object.create;var s=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var u=o=>s(o,"__esModule",{value:!0});var v=(o,a)=>{for(var i in a)s(o,i,{get:a[i],enumerable:!0})},c=(o,a,i,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of h(a))!V.call(o,e)&&(i||e!=="default")&&s(o,e,{get:()=>a[e],enumerable:!(t=T(a,e))||t.enumerable});return o},b=(o,a)=>c(u(s(o!=null?y(I(o)):{},"default",!a&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o),x=(o=>(a,i)=>o&&o.get(a)||(i=c(u({}),a,1),o&&o.set(a,i),i))(typeof WeakMap!="undefined"?new WeakMap:0);var S={};v(S,{initializeUniformMeshSDK:()=>z});var M=()=>import("@datadog/framepost");async function D({dialogResponseHandlers:o}){let a=await M(),i=new a.ChildClient,t=await i.request("initialize");return i.onRequest("dialog-value",async e=>{let n=o[e.dialogId];!n||(e.value?n.resolve({value:e.value,dialogId:e.dialogId}):e.error&&n.reject(e.error),delete o[e.dialogId])}),{initData:t,parent:{resize:async e=>{i.request("resize",{height:e})},getValue:async()=>{let e=await i.request("getValue");return e==null?void 0:e.data},setValue:async e=>{await i.request("setValue",e)},getMetadata:async()=>{let e=await i.request("getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:n,options:l})=>{if(k(l==null?void 0:l.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let r=await i.request("openDialog",{dialogType:e,dialogData:n,options:l}),g=r==null?void 0:r.dialogId;if(!!g)return new Promise((w,m)=>{o[g]={resolve:w,reject:m}})},closeDialog:async({dialogId:e,dialogType:n,dialogData:l})=>{await i.request("closeDialog",{dialogId:e,dialogType:n,dialogData:l})}}}}function k(o){if(!o||typeof Blob=="undefined")return 0;try{let a=JSON.stringify(o);return new Blob([a]).size}catch(a){throw new Error("Error calculating object size: "+a.message)}}var p,f=({onHeightChange:o,autoResizingDisabled:a})=>{if(typeof window=="undefined")return;let i=window,t=()=>{let l=Math.ceil(i.document.documentElement.getBoundingClientRect().height);l!==p&&(p=l,o==null||o(l))},e=a?void 0:new MutationObserver(t),n={instance:i,observer:e,height:0,enableAutoResizing:()=>{e==null||e.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),i.addEventListener("resize",t)},disableAutoResizing:()=>{e==null||e.disconnect(),i.removeEventListener("resize",t)}};return a||n.enableAutoResizing(),n};var R={};async function z({autoResizingDisabled:o}={}){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:R}),{initData:i,parent:t}=a,e={getCurrentLocation:()=>({getValue:()=>i.locationValue,setValue:async n=>{await t.setValue(n),i.locationValue=n},getMetadata:()=>i.locationMetadata}),currentWindow:f({onHeightChange:n=>{t.resize(n)},autoResizingDisabled:o}),version:i.uniformApiVersion,openLocationDialog:async({locationKey:n,options:l})=>{let r=await t.openDialog({dialogType:"location",data:{locationKey:n},options:l});if(!!r)return{dialogId:r.dialogId,value:r.value,closeDialog:async()=>{await t.closeDialog({dialogId:r.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:n})=>{await t.closeDialog({dialogId:n,dialogType:"location"})},openConfirmationDialog:async({titleText:n,bodyText:l})=>{let r=await t.openDialog({dialogType:"confirm",data:{titleText:n,bodyText:l}});if(!!r)return{dialogId:r.dialogId,value:r.value,closeDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:n})=>{let l=await t.openDialog({dialogType:"location",data:{},options:n});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await t.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:i.dialogContext};return window.UniformMeshSDK=e,e}}module.exports=x(S);0&&(module.exports={initializeUniformMeshSDK});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var m=()=>import("@datadog/framepost");async function c({dialogResponseHandlers:t}){let r=await m(),a=new r.ChildClient({debug:!0,handshakeTimeout:1e4,requestTimeout:3e4}),n=await a.request("initialize");return a.onRequest("dialog-value",async({data:e})=>{let o=t[e.dialogId];!o||(e.value?o.resolve({value:e.value,dialogId:e.dialogId}):e.error&&o.reject(e.error),delete t[e.dialogId])}),{initData:n,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:o,options:i})=>{var g;if(y(i==null?void 0:i.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let l=await a.request("openDialog",{dialogType:e,dialogData:o,options:i}),u=(g=l==null?void 0:l.data)==null?void 0:g.dialogId;if(!!u)return new Promise((f,w)=>{t[u]={resolve:f,reject:w}})},closeDialog:async({dialogId:e,dialogType:o,dialogData:i})=>{await a.request("closeDialog",{dialogId:e,dialogType:o,dialogData:i})}}}}function y(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,n=()=>{let i=Math.ceil(a.document.documentElement.getBoundingClientRect().height);i!==D&&(D=i,t==null||t(i))},e=r?void 0:new MutationObserver(n),o={instance:a,observer:e,height:0,enableAutoResizing:()=>{e==null||e.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),a.addEventListener("resize",n)},disableAutoResizing:()=>{e==null||e.disconnect(),a.removeEventListener("resize",n)}};return r||o.enableAutoResizing(),o};var T={};async function k({autoResizingDisabled:t}={}){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 r=await c({dialogResponseHandlers:T}),{initData:a,parent:n}=r,e={getCurrentLocation:()=>({getValue:()=>a.locationValue,setValue:async o=>{await n.setValue(o),a.locationValue=o},getMetadata:()=>a.locationMetadata}),currentWindow:p({onHeightChange:o=>{n.resize(o)},autoResizingDisabled:t}),version:a.uniformApiVersion,openLocationDialog:async({locationKey:o,options:i})=>{let l=await n.openDialog({dialogType:"location",data:{locationKey:o},options:i});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:o})=>{await n.closeDialog({dialogId:o,dialogType:"location"})},openConfirmationDialog:async({titleText:o,bodyText:i})=>{let l=await n.openDialog({dialogType:"confirm",data:{titleText:o,bodyText:i}});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:o})=>{let i=await n.openDialog({dialogType:"location",data:{},options:o});if(!!i)return{dialogId:i.dialogId,value:i.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:a.dialogContext};return window.UniformMeshSDK=e,e}}export{k as initializeUniformMeshSDK};
1
+ var w=()=>import("@datadog/framepost");async function u({dialogResponseHandlers:t}){let r=await w(),i=new r.ChildClient,n=await i.request("initialize");return i.onRequest("dialog-value",async e=>{let o=t[e.dialogId];!o||(e.value?o.resolve({value:e.value,dialogId:e.dialogId}):e.error&&o.reject(e.error),delete t[e.dialogId])}),{initData:n,parent:{resize:async e=>{i.request("resize",{height:e})},getValue:async()=>{let e=await i.request("getValue");return e==null?void 0:e.data},setValue:async e=>{await i.request("setValue",e)},getMetadata:async()=>{let e=await i.request("getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:o,options:a})=>{if(m(a==null?void 0:a.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let l=await i.request("openDialog",{dialogType:e,dialogData:o,options:a}),g=l==null?void 0:l.dialogId;if(!!g)return new Promise((p,f)=>{t[g]={resolve:p,reject:f}})},closeDialog:async({dialogId:e,dialogType:o,dialogData:a})=>{await i.request("closeDialog",{dialogId:e,dialogType:o,dialogData:a})}}}}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 c,D=({onHeightChange:t,autoResizingDisabled:r})=>{if(typeof window=="undefined")return;let i=window,n=()=>{let a=Math.ceil(i.document.documentElement.getBoundingClientRect().height);a!==c&&(c=a,t==null||t(a))},e=r?void 0:new MutationObserver(n),o={instance:i,observer:e,height:0,enableAutoResizing:()=>{e==null||e.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),i.addEventListener("resize",n)},disableAutoResizing:()=>{e==null||e.disconnect(),i.removeEventListener("resize",n)}};return r||o.enableAutoResizing(),o};var y={};async function b({autoResizingDisabled:t}={}){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 r=await u({dialogResponseHandlers:y}),{initData:i,parent:n}=r,e={getCurrentLocation:()=>({getValue:()=>i.locationValue,setValue:async o=>{await n.setValue(o),i.locationValue=o},getMetadata:()=>i.locationMetadata}),currentWindow:D({onHeightChange:o=>{n.resize(o)},autoResizingDisabled:t}),version:i.uniformApiVersion,openLocationDialog:async({locationKey:o,options:a})=>{let l=await n.openDialog({dialogType:"location",data:{locationKey:o},options:a});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:o})=>{await n.closeDialog({dialogId:o,dialogType:"location"})},openConfirmationDialog:async({titleText:o,bodyText:a})=>{let l=await n.openDialog({dialogType:"confirm",data:{titleText:o,bodyText:a}});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:o})=>{let a=await n.openDialog({dialogType:"location",data:{},options:o});if(!!a)return{dialogId:a.dialogId,value:a.value,closeDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await n.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:i.dialogContext};return window.UniformMeshSDK=e,e}}export{b as initializeUniformMeshSDK};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk",
3
- "version": "14.1.1-alpha.0",
3
+ "version": "14.1.1-alpha.1",
4
4
  "description": "Uniform Mesh Framework SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -25,14 +25,12 @@
25
25
  "ci:build": "tsup --minify --clean"
26
26
  },
27
27
  "dependencies": {
28
- "@datadog/framepost": "0.3.1",
29
- "post-robot": "10.0.46"
28
+ "@datadog/framepost": "0.3.1"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@types/jest": "27.4.0",
33
32
  "@types/node": "16.11.24",
34
- "@types/post-robot": "10.0.3",
35
- "eslint": "8.8.0",
33
+ "eslint": "8.9.0",
36
34
  "jest": "27.5.1",
37
35
  "npm-run-all": "4.1.5",
38
36
  "rimraf": "3.0.2",