@uniformdev/mesh-sdk 12.2.1-alpha.107

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.
@@ -0,0 +1,33 @@
1
+ interface SdkWindow {
2
+ instance: Window;
3
+ height?: number;
4
+ observer?: MutationObserver;
5
+ enableAutoResizing: () => void;
6
+ disableAutoResizing: () => void;
7
+ }
8
+
9
+ interface UniformMeshSDK {
10
+ getCurrentLocation: <TValue = unknown, TMetadata = unknown>() => MeshLocation<TValue, TMetadata>;
11
+ currentWindow: SdkWindow | undefined;
12
+ version: string;
13
+ }
14
+ declare global {
15
+ interface Window {
16
+ UniformMeshSDK: UniformMeshSDK;
17
+ }
18
+ }
19
+ /** Defines methods used for interacting with a Mesh location */
20
+ interface MeshLocation<TValue = unknown, TMetadata = unknown> {
21
+ getValue: () => TValue;
22
+ setValue: (value: TValue) => Promise<void>;
23
+ getMetadata: () => TMetadata;
24
+ }
25
+ /**
26
+ * Initializes the Uniform Mesh SDK. Intended to be called (and awaited) prior to any
27
+ * attempted interaction with the Uniform Mesh SDK.
28
+ */
29
+ declare function initializeUniformMeshSDK({ autoResizingDisabled, }?: {
30
+ autoResizingDisabled?: boolean;
31
+ }): Promise<UniformMeshSDK | undefined>;
32
+
33
+ export { MeshLocation, UniformMeshSDK, initializeUniformMeshSDK };
@@ -0,0 +1 @@
1
+ var u,c=({onHeightChange:t,autoResizingDisabled:e})=>{if(typeof window=="undefined")return;let a=window,i=()=>{let o=Math.ceil(a.document.documentElement.getBoundingClientRect().height);o!==u&&(u=o,t==null||t(o))},n=e?void 0:new MutationObserver(i),r={instance:a,observer:n,height:0,enableAutoResizing:()=>{n==null||n.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),a.addEventListener("resize",i)},disableAutoResizing:()=>{n==null||n.disconnect(),a.removeEventListener("resize",i)}};return e||r.enableAutoResizing(),r};var w=()=>import("post-robot");async function p({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 e=await l(),a=await e.initialize(),i={getCurrentLocation:()=>({getValue:()=>a.locationValue,setValue:async n=>{await e.setValue(n),a.locationValue=n},getMetadata:()=>a.locationMetadata}),currentWindow:c({onHeightChange:n=>{e.resize(n)},autoResizingDisabled:t}),version:a.uniformApiVersion};return window.UniformMeshSDK=i,i}}async function l(){let t=await w();return{initialize:async()=>(await t.send(window.parent,"initialize")).data,resize:async e=>{t.send(window.parent,"resize",{height:e})},getValue:async()=>{let e=await t.send(window.parent,"getValue");return e==null?void 0:e.data},setValue:async e=>{await t.send(window.parent,"setValue",e)},getMetadata:async()=>{let e=await t.send(window.parent,"getMetadata");return e==null?void 0:e.data}}}export{p as initializeUniformMeshSDK};
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var l=Object.create;var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var s=e=>o(e,"__esModule",{value:!0});var h=(e,n)=>{s(e);for(var t in n)o(e,t,{get:n[t],enumerable:!0})},M=(e,n,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of m(n))!p.call(e,a)&&a!=="default"&&o(e,a,{get:()=>n[a],enumerable:!(t=f(n,a))||t.enumerable});return e},y=e=>M(s(o(e!=null?l(g(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);h(exports,{initializeUniformMeshSDK:()=>b});var c,w=({onHeightChange:e,autoResizingDisabled:n})=>{if(typeof window=="undefined")return;let t=window,a=()=>{let r=Math.ceil(t.document.documentElement.getBoundingClientRect().height);r!==c&&(c=r,e==null||e(r))},i=n?void 0:new MutationObserver(a),d={instance:t,observer:i,height:0,enableAutoResizing:()=>{i==null||i.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),t.addEventListener("resize",a)},disableAutoResizing:()=>{i==null||i.disconnect(),t.removeEventListener("resize",a)}};return n||d.enableAutoResizing(),d};var V=()=>import("post-robot");async function b({autoResizingDisabled: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 n=await k(),t=await n.initialize(),a={getCurrentLocation:()=>({getValue:()=>t.locationValue,setValue:async i=>{await n.setValue(i),t.locationValue=i},getMetadata:()=>t.locationMetadata}),currentWindow:w({onHeightChange:i=>{n.resize(i)},autoResizingDisabled:e}),version:t.uniformApiVersion};return window.UniformMeshSDK=a,a}}async function k(){let e=await V();return{initialize:async()=>(await e.send(window.parent,"initialize")).data,resize:async n=>{e.send(window.parent,"resize",{height:n})},getValue:async()=>{let n=await e.send(window.parent,"getValue");return n==null?void 0:n.data},setValue:async n=>{await e.send(window.parent,"setValue",n)},getMetadata:async()=>{let n=await e.send(window.parent,"getMetadata");return n==null?void 0:n.data}}}0&&(module.exports={initializeUniformMeshSDK});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var u,c=({onHeightChange:t,autoResizingDisabled:e})=>{if(typeof window=="undefined")return;let a=window,i=()=>{let o=Math.ceil(a.document.documentElement.getBoundingClientRect().height);o!==u&&(u=o,t==null||t(o))},n=e?void 0:new MutationObserver(i),r={instance:a,observer:n,height:0,enableAutoResizing:()=>{n==null||n.observe(document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),a.addEventListener("resize",i)},disableAutoResizing:()=>{n==null||n.disconnect(),a.removeEventListener("resize",i)}};return e||r.enableAutoResizing(),r};var w=()=>import("post-robot");async function p({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 e=await l(),a=await e.initialize(),i={getCurrentLocation:()=>({getValue:()=>a.locationValue,setValue:async n=>{await e.setValue(n),a.locationValue=n},getMetadata:()=>a.locationMetadata}),currentWindow:c({onHeightChange:n=>{e.resize(n)},autoResizingDisabled:t}),version:a.uniformApiVersion};return window.UniformMeshSDK=i,i}}async function l(){let t=await w();return{initialize:async()=>(await t.send(window.parent,"initialize")).data,resize:async e=>{t.send(window.parent,"resize",{height:e})},getValue:async()=>{let e=await t.send(window.parent,"getValue");return e==null?void 0:e.data},setValue:async e=>{await t.send(window.parent,"setValue",e)},getMetadata:async()=>{let e=await t.send(window.parent,"getMetadata");return e==null?void 0:e.data}}}export{p as initializeUniformMeshSDK};
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@uniformdev/mesh-sdk",
3
+ "version": "12.2.1-alpha.107+b30768d5",
4
+ "description": "Uniform Mesh Framework SDK",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.esm.js",
8
+ "exports": {
9
+ "import": {
10
+ "node": "./dist/index.mjs",
11
+ "default": "./dist/index.esm.js"
12
+ },
13
+ "require": "./dist/index.js"
14
+ },
15
+ "types": "./dist/index.d.ts",
16
+ "sideEffects": false,
17
+ "scripts": {
18
+ "build": "tsup",
19
+ "dev": "tsup --watch",
20
+ "clean": "rimraf dist",
21
+ "test": "jest --maxWorkers=1 --passWithNoTests",
22
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
23
+ "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
24
+ "ci:verify": "run-p lint test",
25
+ "ci:build": "tsup --minify --clean"
26
+ },
27
+ "dependencies": {
28
+ "post-robot": "10.0.44"
29
+ },
30
+ "devDependencies": {
31
+ "@types/jest": "27.0.3",
32
+ "@types/node": "16.11.18",
33
+ "@types/post-robot": "10.0.3",
34
+ "eslint": "8.4.1",
35
+ "jest": "27.4.5",
36
+ "npm-run-all": "4.1.5",
37
+ "rimraf": "3.0.2",
38
+ "ts-jest": "27.1.1",
39
+ "tsup": "5.11.10"
40
+ },
41
+ "files": [
42
+ "/dist"
43
+ ],
44
+ "gitHead": "b30768d5d58d4c75b390274042724d50c1ee1041"
45
+ }