@uniformdev/mesh-sdk 14.0.1-alpha.101 → 14.1.1-alpha.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
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))
package/dist/index.d.ts CHANGED
@@ -6,6 +6,56 @@ interface SdkWindow {
6
6
  disableAutoResizing: () => void;
7
7
  }
8
8
 
9
+ interface ContextData {
10
+ locationKey: string;
11
+ locationValue: any;
12
+ locationMetadata: any;
13
+ uniformApiVersion: string;
14
+ dialogContext?: {
15
+ dialogId: string;
16
+ };
17
+ parentDomain: string;
18
+ }
19
+ interface DialogResponseHandlers {
20
+ [dialogId: string]: DialogResponseHandler;
21
+ }
22
+ interface DialogResponseHandler {
23
+ resolve: (value: Pick<DialogResponseData['data'], 'value' | 'dialogId'>) => void;
24
+ reject: (reason?: unknown) => void;
25
+ }
26
+ interface DialogResponseData {
27
+ data: {
28
+ value?: unknown;
29
+ dialogId: string;
30
+ error?: string;
31
+ };
32
+ }
33
+ declare type DialogType = 'location' | 'confirm';
34
+ interface DialogOptions {
35
+ /**
36
+ * By default, dialogs will be closed when they set a value.
37
+ * You can disable this behavior by setting the `disableCloseDialogOnSetValue`
38
+ * property to true.
39
+ * You'll still be able to close a dialog via the `closeDialog` method
40
+ * that is returned from the `openLocationDialog` method.
41
+ */
42
+ disableCloseDialogOnSetValue?: boolean;
43
+ maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'full';
44
+ /**
45
+ * Parameters to pass to the dialog, which will be available in the dialog via
46
+ * the `metadata` object for the dialog location, e.g. `metadata.dialogParams`.
47
+ * Parameters should be simple (serializable) types, not functions or DOM
48
+ * elements or similar non-serializable objects.
49
+ */
50
+ params?: DialogParams;
51
+ }
52
+ declare type DialogParamValue = string | number | boolean | null | DialogParamValue[] | {
53
+ [key: string]: DialogParamValue;
54
+ };
55
+ declare type DialogParams = {
56
+ [paramName: string]: DialogParamValue;
57
+ };
58
+
9
59
  interface UniformMeshSDK {
10
60
  getCurrentLocation: <TValue = unknown, TMetadata = unknown>() => MeshLocation<TValue, TMetadata>;
11
61
  currentWindow: SdkWindow | undefined;
@@ -40,30 +90,10 @@ interface LocationDialogResponse<TDialogValue> {
40
90
  dialogId: string;
41
91
  /** The value set by the dialog. */
42
92
  value: TDialogValue;
43
- /** Allows for closing the dialog manually. Typically used when `closeDialogOnSetValue` is false. */
93
+ /** Allows for closing the dialog manually.
94
+ * Typically used when `closeDialogOnSetValue` is false. */
44
95
  closeDialog: () => Promise<void>;
45
96
  }
46
- declare type DialogType = 'location' | 'confirm';
47
- interface DialogOptions {
48
- /**
49
- * By default, dialogs will be closed when they set a value.
50
- * You can disable this behavior by setting the `disableCloseDialogOnSetValue` property to true.
51
- * You'll still be able to close a dialog via the `closeDialog` method that is returned from the `openLocationDialog` method.
52
- */
53
- disableCloseDialogOnSetValue?: boolean;
54
- maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'full';
55
- /**
56
- * Parameters to pass to the dialog, which will be available in the dialog via the `metadata` object for the dialog location, e.g. `metadata.dialogParams`.
57
- * Parameters should be simple (serializable) types, not functions or DOM elements or similar non-serializable objects.
58
- */
59
- params?: DialogParams;
60
- }
61
- declare type DialogParamValue = string | number | boolean | null | DialogParamValue[] | {
62
- [key: string]: DialogParamValue;
63
- };
64
- declare type DialogParams = {
65
- [paramName: string]: DialogParamValue;
66
- };
67
97
  declare global {
68
98
  interface Window {
69
99
  UniformMeshSDK: UniformMeshSDK;
@@ -83,4 +113,4 @@ declare function initializeUniformMeshSDK({ autoResizingDisabled, }?: {
83
113
  autoResizingDisabled?: boolean;
84
114
  }): Promise<UniformMeshSDK | undefined>;
85
115
 
86
- export { DialogOptions, DialogParamValue, DialogParams, DialogType, LocationDialogResponse, MeshLocation, UniformMeshSDK, initializeUniformMeshSDK };
116
+ export { ContextData, DialogOptions, DialogParamValue, DialogParams, DialogResponseData, DialogResponseHandler, DialogResponseHandlers, DialogType, LocationDialogResponse, MeshLocation, SdkWindow, UniformMeshSDK, initializeUniformMeshSDK };
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var g,u=({onHeightChange:l,autoResizingDisabled:o})=>{if(typeof window=="undefined")return;let e=window,i=()=>{let t=Math.ceil(e.document.documentElement.getBoundingClientRect().height);t!==g&&(g=t,l==null||l(t))},a=o?void 0:new MutationObserver(i),n={instance:e,observer:a,height:0,enableAutoResizing:()=>{a==null||a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),e.addEventListener("resize",i)},disableAutoResizing:()=>{a==null||a.disconnect(),e.removeEventListener("resize",i)}};return o||n.enableAutoResizing(),n};var D=()=>import("post-robot"),w={};async function v({autoResizingDisabled:l}={}){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 f({dialogResponseHandlers:w}),e=await o.initialize(),i={getCurrentLocation:()=>({getValue:()=>e.locationValue,setValue:async a=>{await o.setValue(a),e.locationValue=a},getMetadata:()=>e.locationMetadata}),currentWindow:u({onHeightChange:a=>{o.resize(a)},autoResizingDisabled:l}),version:e.uniformApiVersion,openLocationDialog:async({locationKey:a,options:n})=>{let t=await o.openDialog({dialogType:"location",data:{locationKey:a},options:n});if(!!t)return{dialogId:t.dialogId,value:t.value,closeDialog:async()=>{await o.closeDialog({dialogId:t.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:a})=>{await o.closeDialog({dialogId:a,dialogType:"location"})},openConfirmationDialog:async({titleText:a,bodyText:n})=>{let t=await o.openDialog({dialogType:"confirm",data:{titleText:a,bodyText:n}});if(!!t)return{value:t.value,closeDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:a})=>{let n=await o.openDialog({dialogType:"location",data:{},options:a});if(!!n)return{dialogId:n.dialogId,value:n.value,closeDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:e.dialogContext};return window.UniformMeshSDK=i,i}}async function f({dialogResponseHandlers:l}){let o=await D();return o.on("dialog-value",{},async({data:e})=>{let i=l[e.dialogId];!i||(e.value?i.resolve({value:e.value,dialogId:e.dialogId}):e.error&&i.reject(e.error),delete l[e.dialogId])}),{initialize:async()=>(await o.send(window.parent,"initialize")).data,resize:async e=>{o.send(window.parent,"resize",{height:e})},getValue:async()=>{let e=await o.send(window.parent,"getValue");return e==null?void 0:e.data},setValue:async e=>{await o.send(window.parent,"setValue",e)},getMetadata:async()=>{let e=await o.send(window.parent,"getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:i,options:a})=>{var r;if(m(a==null?void 0:a.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let n=await o.send(window.parent,"openDialog",{dialogType:e,dialogData:i,options:a}),t=(r=n==null?void 0:n.data)==null?void 0:r.dialogId;if(!!t)return new Promise((c,p)=>{l[t]={resolve:c,reject:p}})},closeDialog:async({dialogId:e,dialogType:i,dialogData:a})=>{await o.send(window.parent,"closeDialog",{dialogId:e,dialogType:i,dialogData:a})}}}function m(l){if(!l||typeof Blob=="undefined")return 0;try{let o=JSON.stringify(l);return new Blob([o]).size}catch(o){throw new Error("Error calculating object size: "+o.message)}}export{v as initializeUniformMeshSDK};
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};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var f=Object.create;var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var d=a=>r(a,"__esModule",{value:!0});var v=(a,o)=>{for(var e in o)r(a,e,{get:o[e],enumerable:!0})},g=(a,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of y(o))!V.call(a,i)&&(e||i!=="default")&&r(a,i,{get:()=>o[i],enumerable:!(n=m(o,i))||n.enumerable});return a},x=(a,o)=>g(d(r(a!=null?f(T(a)):{},"default",!o&&a&&a.__esModule?{get:()=>a.default,enumerable:!0}:{value:a,enumerable:!0})),a),b=(a=>(o,e)=>a&&a.get(o)||(e=g(d({}),o,1),a&&a.set(o,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var z={};v(z,{initializeUniformMeshSDK:()=>k});var c,p=({onHeightChange:a,autoResizingDisabled:o})=>{if(typeof window=="undefined")return;let e=window,n=()=>{let l=Math.ceil(e.document.documentElement.getBoundingClientRect().height);l!==c&&(c=l,a==null||a(l))},i=o?void 0:new MutationObserver(n),t={instance:e,observer:i,height:0,enableAutoResizing:()=>{i==null||i.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),e.addEventListener("resize",n)},disableAutoResizing:()=>{i==null||i.disconnect(),e.removeEventListener("resize",n)}};return o||t.enableAutoResizing(),t};var I=()=>import("post-robot"),h={};async function k({autoResizingDisabled:a}={}){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:h}),e=await o.initialize(),n={getCurrentLocation:()=>({getValue:()=>e.locationValue,setValue:async i=>{await o.setValue(i),e.locationValue=i},getMetadata:()=>e.locationMetadata}),currentWindow:p({onHeightChange:i=>{o.resize(i)},autoResizingDisabled:a}),version:e.uniformApiVersion,openLocationDialog:async({locationKey:i,options:t})=>{let l=await o.openDialog({dialogType:"location",data:{locationKey:i},options:t});if(!!l)return{dialogId:l.dialogId,value:l.value,closeDialog:async()=>{await o.closeDialog({dialogId:l.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:i})=>{await o.closeDialog({dialogId:i,dialogType:"location"})},openConfirmationDialog:async({titleText:i,bodyText:t})=>{let l=await o.openDialog({dialogType:"confirm",data:{titleText:i,bodyText:t}});if(!!l)return{value:l.value,closeDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:i})=>{let t=await o.openDialog({dialogType:"location",data:{},options:i});if(!!t)return{dialogId:t.dialogId,value:t.value,closeDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:e.dialogContext};return window.UniformMeshSDK=n,n}}async function M({dialogResponseHandlers:a}){let o=await I();return o.on("dialog-value",{},async({data:e})=>{let n=a[e.dialogId];!n||(e.value?n.resolve({value:e.value,dialogId:e.dialogId}):e.error&&n.reject(e.error),delete a[e.dialogId])}),{initialize:async()=>(await o.send(window.parent,"initialize")).data,resize:async e=>{o.send(window.parent,"resize",{height:e})},getValue:async()=>{let e=await o.send(window.parent,"getValue");return e==null?void 0:e.data},setValue:async e=>{await o.send(window.parent,"setValue",e)},getMetadata:async()=>{let e=await o.send(window.parent,"getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:n,options:i})=>{var s;if(R(i==null?void 0:i.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let t=await o.send(window.parent,"openDialog",{dialogType:e,dialogData:n,options:i}),l=(s=t==null?void 0:t.data)==null?void 0:s.dialogId;if(!!l)return new Promise((D,w)=>{a[l]={resolve:D,reject:w}})},closeDialog:async({dialogId:e,dialogType:n,dialogData:i})=>{await o.send(window.parent,"closeDialog",{dialogId:e,dialogType:n,dialogData:i})}}}function R(a){if(!a||typeof Blob=="undefined")return 0;try{let o=JSON.stringify(a);return new Blob([o]).size}catch(o){throw new Error("Error calculating object size: "+o.message)}}module.exports=b(z);0&&(module.exports={initializeUniformMeshSDK});
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});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var g,u=({onHeightChange:l,autoResizingDisabled:o})=>{if(typeof window=="undefined")return;let e=window,i=()=>{let t=Math.ceil(e.document.documentElement.getBoundingClientRect().height);t!==g&&(g=t,l==null||l(t))},a=o?void 0:new MutationObserver(i),n={instance:e,observer:a,height:0,enableAutoResizing:()=>{a==null||a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),e.addEventListener("resize",i)},disableAutoResizing:()=>{a==null||a.disconnect(),e.removeEventListener("resize",i)}};return o||n.enableAutoResizing(),n};var D=()=>import("post-robot"),w={};async function v({autoResizingDisabled:l}={}){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 f({dialogResponseHandlers:w}),e=await o.initialize(),i={getCurrentLocation:()=>({getValue:()=>e.locationValue,setValue:async a=>{await o.setValue(a),e.locationValue=a},getMetadata:()=>e.locationMetadata}),currentWindow:u({onHeightChange:a=>{o.resize(a)},autoResizingDisabled:l}),version:e.uniformApiVersion,openLocationDialog:async({locationKey:a,options:n})=>{let t=await o.openDialog({dialogType:"location",data:{locationKey:a},options:n});if(!!t)return{dialogId:t.dialogId,value:t.value,closeDialog:async()=>{await o.closeDialog({dialogId:t.dialogId,dialogType:"location"})}}},closeLocationDialog:async({dialogId:a})=>{await o.closeDialog({dialogId:a,dialogType:"location"})},openConfirmationDialog:async({titleText:a,bodyText:n})=>{let t=await o.openDialog({dialogType:"confirm",data:{titleText:a,bodyText:n}});if(!!t)return{value:t.value,closeDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"confirm"})}}},closeConfirmationDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"confirm"})},openCurrentLocationDialog:async({options:a})=>{let n=await o.openDialog({dialogType:"location",data:{},options:a});if(!!n)return{dialogId:n.dialogId,value:n.value,closeDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"location"})}}},closeCurrentLocationDialog:async()=>{await o.closeDialog({dialogId:void 0,dialogType:"location"})},dialogContext:e.dialogContext};return window.UniformMeshSDK=i,i}}async function f({dialogResponseHandlers:l}){let o=await D();return o.on("dialog-value",{},async({data:e})=>{let i=l[e.dialogId];!i||(e.value?i.resolve({value:e.value,dialogId:e.dialogId}):e.error&&i.reject(e.error),delete l[e.dialogId])}),{initialize:async()=>(await o.send(window.parent,"initialize")).data,resize:async e=>{o.send(window.parent,"resize",{height:e})},getValue:async()=>{let e=await o.send(window.parent,"getValue");return e==null?void 0:e.data},setValue:async e=>{await o.send(window.parent,"setValue",e)},getMetadata:async()=>{let e=await o.send(window.parent,"getMetadata");return e==null?void 0:e.data},openDialog:async({dialogType:e,data:i,options:a})=>{var r;if(m(a==null?void 0:a.params)>1e5)throw new Error("Dialog parameters object is too large, maximum size is 100KB");let n=await o.send(window.parent,"openDialog",{dialogType:e,dialogData:i,options:a}),t=(r=n==null?void 0:n.data)==null?void 0:r.dialogId;if(!!t)return new Promise((c,p)=>{l[t]={resolve:c,reject:p}})},closeDialog:async({dialogId:e,dialogType:i,dialogData:a})=>{await o.send(window.parent,"closeDialog",{dialogId:e,dialogType:i,dialogData:a})}}}function m(l){if(!l||typeof Blob=="undefined")return 0;try{let o=JSON.stringify(l);return new Blob([o]).size}catch(o){throw new Error("Error calculating object size: "+o.message)}}export{v as initializeUniformMeshSDK};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk",
3
- "version": "14.0.1-alpha.101+61fc2a31",
3
+ "version": "14.1.1-alpha.0",
4
4
  "description": "Uniform Mesh Framework SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -25,21 +25,24 @@
25
25
  "ci:build": "tsup --minify --clean"
26
26
  },
27
27
  "dependencies": {
28
- "post-robot": "10.0.44"
28
+ "@datadog/framepost": "0.3.1",
29
+ "post-robot": "10.0.46"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/jest": "27.4.0",
32
- "@types/node": "16.11.21",
33
+ "@types/node": "16.11.24",
33
34
  "@types/post-robot": "10.0.3",
34
- "eslint": "8.7.0",
35
- "jest": "27.4.7",
35
+ "eslint": "8.8.0",
36
+ "jest": "27.5.1",
36
37
  "npm-run-all": "4.1.5",
37
38
  "rimraf": "3.0.2",
38
39
  "ts-jest": "27.1.3",
39
- "tsup": "5.11.11"
40
+ "tsup": "5.11.13"
40
41
  },
41
42
  "files": [
42
43
  "/dist"
43
44
  ],
44
- "gitHead": "61fc2a311b553e21d03b1b70ec6db0ada73974b7"
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
45
48
  }