@uniformdev/mesh-sdk 14.1.1-alpha.1 → 14.1.2-alpha.94

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
@@ -1,20 +1,13 @@
1
- interface SdkWindow {
2
- instance: Window;
3
- height?: number;
4
- observer?: MutationObserver;
5
- enableAutoResizing: () => void;
6
- disableAutoResizing: () => void;
7
- }
8
-
9
1
  interface ContextData {
10
2
  locationKey: string;
11
3
  locationValue: any;
12
4
  locationMetadata: any;
13
5
  uniformApiVersion: string;
14
- dialogContext?: {
15
- dialogId: string;
16
- };
17
- parentDomain: string;
6
+ dialogContext?: DialogContext;
7
+ }
8
+ interface DialogContext {
9
+ dialogId: string;
10
+ contentHeight?: CSSHeight;
18
11
  }
19
12
  interface DialogResponseHandlers {
20
13
  [dialogId: string]: DialogResponseHandler;
@@ -38,6 +31,9 @@ interface DialogOptions {
38
31
  * that is returned from the `openLocationDialog` method.
39
32
  */
40
33
  disableCloseDialogOnSetValue?: boolean;
34
+ /**
35
+ * Options for setting the max width of the dialog.
36
+ */
41
37
  maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'full';
42
38
  /**
43
39
  * Parameters to pass to the dialog, which will be available in the dialog via
@@ -46,6 +42,17 @@ interface DialogOptions {
46
42
  * elements or similar non-serializable objects.
47
43
  */
48
44
  params?: DialogParams;
45
+ /**
46
+ * Allows you to specify the height of the dialog content upon open. Note: the
47
+ * dialog itself will always be full height to match the Uniform dashboard UI.
48
+ * However, the content container within the dialog is, by default, auto-sized to
49
+ * the calculated height of the rendered content of the dialog.
50
+ * Setting the `contentHeight` option disables auto-sizing and allows you to specify
51
+ * your own height for the dialog content.
52
+ * `contentHeight` option can be specific lengths, e.g. 100vh, 500px, etc... as
53
+ * well as other standard CSS height options.
54
+ */
55
+ contentHeight?: CSSHeight;
49
56
  }
50
57
  declare type DialogParamValue = string | number | boolean | null | DialogParamValue[] | {
51
58
  [key: string]: DialogParamValue;
@@ -53,6 +60,24 @@ declare type DialogParamValue = string | number | boolean | null | DialogParamVa
53
60
  declare type DialogParams = {
54
61
  [paramName: string]: DialogParamValue;
55
62
  };
63
+ declare type CSSHeight = '-moz-initial' | 'inherit' | 'initial' | 'revert' | 'unset' | '-moz-max-content' | '-moz-min-content' | '-webkit-fit-content' | 'auto' | 'fit-content' | 'max-content' | 'min-content' | `${number}${'px' | 'em' | 'rem' | 'vh'}`;
64
+
65
+ interface SdkWindow {
66
+ /** The current window object. */
67
+ instance: Window;
68
+ /** The numerical height of the current window. */
69
+ height: number;
70
+ /** The MutationObserver object used to detect content height changes.
71
+ * Note: this property is only defined if `enableAutoResizing` is true. */
72
+ observer?: MutationObserver;
73
+ /** Enables auto-resizing of the window (iframe) based on the size of the content. */
74
+ enableAutoResizing: () => void;
75
+ /** Disables auto-resizing of the window (iframe) based on the size of the content. */
76
+ disableAutoResizing: () => void;
77
+ /** `height` argument can be specific lengths, e.g. 100vh, 300px, etc...
78
+ * as well as other standard CSS height options */
79
+ updateHeight: (height: CSSHeight) => void;
80
+ }
56
81
 
57
82
  interface UniformMeshSDK {
58
83
  getCurrentLocation: <TValue = unknown, TMetadata = unknown>() => MeshLocation<TValue, TMetadata>;
@@ -79,9 +104,7 @@ interface UniformMeshSDK {
79
104
  options?: DialogOptions;
80
105
  }): Promise<LocationDialogResponse<TDialogValue> | undefined>;
81
106
  closeCurrentLocationDialog(): Promise<void>;
82
- dialogContext?: {
83
- dialogId: string;
84
- };
107
+ dialogContext?: DialogContext;
85
108
  }
86
109
  interface LocationDialogResponse<TDialogValue> {
87
110
  /** Generated id for the dialog. */
@@ -111,4 +134,4 @@ declare function initializeUniformMeshSDK({ autoResizingDisabled, }?: {
111
134
  autoResizingDisabled?: boolean;
112
135
  }): Promise<UniformMeshSDK | undefined>;
113
136
 
114
- export { ContextData, DialogOptions, DialogParamValue, DialogParams, DialogResponseData, DialogResponseHandler, DialogResponseHandlers, DialogType, LocationDialogResponse, MeshLocation, SdkWindow, UniformMeshSDK, initializeUniformMeshSDK };
137
+ export { CSSHeight, ContextData, DialogContext, DialogOptions, DialogParamValue, DialogParams, DialogResponseData, DialogResponseHandler, DialogResponseHandlers, DialogType, LocationDialogResponse, MeshLocation, SdkWindow, UniformMeshSDK, initializeUniformMeshSDK };
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
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};
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};
package/dist/index.js CHANGED
@@ -1 +1 @@
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});
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});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
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};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk",
3
- "version": "14.1.1-alpha.1",
3
+ "version": "14.1.2-alpha.94+ae67f1b3",
4
4
  "description": "Uniform Mesh Framework SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "@datadog/framepost": "0.3.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/jest": "27.4.0",
32
- "@types/node": "16.11.24",
31
+ "@types/jest": "27.4.1",
32
+ "@types/node": "16.11.25",
33
33
  "eslint": "8.9.0",
34
34
  "jest": "27.5.1",
35
35
  "npm-run-all": "4.1.5",
@@ -42,5 +42,6 @@
42
42
  ],
43
43
  "publishConfig": {
44
44
  "access": "public"
45
- }
45
+ },
46
+ "gitHead": "ae67f1b3366c3615afb6b9cd70f2d977c32c9e18"
46
47
  }
package/CHANGELOG.md DELETED
@@ -1,20 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ### [14.1.1](https://github.com/uniformdev/optimize-sdk-internal/compare/v14.1.0...v14.1.1) (2022-02-02)
7
-
8
- **Note:** Version bump only for package @uniformdev/mesh-sdk
9
-
10
- ## [14.1.0](https://github.com/uniformdev/optimize-sdk-internal/compare/v14.0.0...v14.1.0) (2022-02-02)
11
-
12
- ### Features
13
-
14
- - mesh sdk dialogs api ([#897](https://github.com/uniformdev/optimize-sdk-internal/issues/897)) ([79f3920](https://github.com/uniformdev/optimize-sdk-internal/commit/79f39208259f2edba89305ea807fcdc6ddb6e6bc))
15
-
16
- ## [14.0.0](https://github.com/uniformdev/optimize-sdk-internal/compare/v13.0.0...v14.0.0) (2021-12-21)
17
-
18
- ### Features
19
-
20
- - **mesh:** external integrations sdk (vanilla and react) and sample app/integration ([#782](https://github.com/uniformdev/optimize-sdk-internal/issues/782)) ([3491592](https://github.com/uniformdev/optimize-sdk-internal/commit/349159291dd64cdac264c16ee27e499099c2a5e3))