@jolibox/sdk 1.0.7-beta.0 → 1.0.7-beta.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.cjs +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var L=(i,o)=>{for(var e in o)f(i,e,{get:o[e],enumerable:!0})},k=(i,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of j(o))!J.call(i,t)&&t!==e&&f(i,t,{get:()=>o[t],enumerable:!(a=S(o,t))||a.enumerable});return i};var _=i=>k(f({},"__esModule",{value:!0}),i);var p=(i,o,e)=>new Promise((a,t)=>{var d=n=>{try{r(e.next(n))}catch(l){t(l)}},s=n=>{try{r(e.throw(n))}catch(l){t(l)}},r=n=>n.done?a(n.value):Promise.resolve(n.value).then(d,s);r((e=e.apply(i,o)).next())});var A={};L(A,{JoliboxSDK:()=>c,default:()=>v});module.exports=_(A);var b=i=>{var r,n,l;let o=i.split("-")[1];o&&(i=i.replace(`-${o}`,""));let e=i.split("+")[1];e&&(i=i.replace(`+${e}`,""));let a=i.split(".").slice(0,3),[t,d,s]=[(r=a[0])!=null?r:"0",(n=a[1])!=null?n:"0",(l=a[2])!=null?l:"0"];return{major:t,minor:d,patch:s,prerelease:o,build:e}},m=i=>parseInt(b(i).major,10),h=(i,o)=>{let{major:e,minor:a,patch:t}=b(i),{major:d,minor:s,patch:r}=b(o);return e!==d?e>d?1:-1:a!==s?a>s?1:-1:t!==r?t>r?1:-1:0};var y="jolibox-sdk-loader-metadata",x=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var t,d;let o=this.currentVersion,e=null;try{if(e=JSON.parse((t=localStorage.getItem(y))!=null?t:"null"),!e||!e.version)throw new Error("Invalid loader metadata")}catch(s){e=this.defaultMetadata}let a=(d=e==null?void 0:e.version)!=null?d:o;return m(a)!==m(o)?e=this.defaultMetadata:h(a,o)<0&&(e=this.defaultMetadata),e};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let e=document.createElement("script");e.type="text/javascript",e.innerHTML=o.responseText,document.head.appendChild(e)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...d)=>p(this,[...d],function*(o=this.currentVersion,e=this.loaderMetadata.version,a=(t=>(t=window.JOLIBOX_ENV)!=null?t:"WEB")()){var r,n,l;let s=`${(n=(r=window.joliboxenv)==null?void 0:r.apiBaseURL)!=null?n:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let w=yield(yield fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:e,env:a})})).json();if(w.code!=="SUCCESS")throw new Error(w.message);this.loaderMetadata=(l=w.data)!=null?l:this.defaultMetadata,localStorage.setItem(y,JSON.stringify(this.loaderMetadata))}catch(g){console.warn("Failed to fetch loader metadata: ",g)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,e=m(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${e}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${e}/dist/index.iife.js`}}};window.JoliboxSDKLoader=x;var u=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>p(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=u;var I=class{constructor(){this.trackEvent=(o,e)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(e!==null&&typeof e!="object"&&e!==void 0)throw new Error("extra must be an object or null or undefined");if(e){for(let a in e)if(typeof e[a]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,e]})}}};window.JoliboxAnalytics=I;var N=require("@jolibox/web-sync-sdk");window.__JOLIBOX_LOCAL_SDK_VERSION__="1.0.7-beta.
|
|
1
|
+
"use strict";var f=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var L=(i,o)=>{for(var e in o)f(i,e,{get:o[e],enumerable:!0})},k=(i,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of j(o))!J.call(i,t)&&t!==e&&f(i,t,{get:()=>o[t],enumerable:!(a=S(o,t))||a.enumerable});return i};var _=i=>k(f({},"__esModule",{value:!0}),i);var p=(i,o,e)=>new Promise((a,t)=>{var d=n=>{try{r(e.next(n))}catch(l){t(l)}},s=n=>{try{r(e.throw(n))}catch(l){t(l)}},r=n=>n.done?a(n.value):Promise.resolve(n.value).then(d,s);r((e=e.apply(i,o)).next())});var A={};L(A,{JoliboxSDK:()=>c,default:()=>v});module.exports=_(A);var b=i=>{var r,n,l;let o=i.split("-")[1];o&&(i=i.replace(`-${o}`,""));let e=i.split("+")[1];e&&(i=i.replace(`+${e}`,""));let a=i.split(".").slice(0,3),[t,d,s]=[(r=a[0])!=null?r:"0",(n=a[1])!=null?n:"0",(l=a[2])!=null?l:"0"];return{major:t,minor:d,patch:s,prerelease:o,build:e}},m=i=>parseInt(b(i).major,10),h=(i,o)=>{let{major:e,minor:a,patch:t}=b(i),{major:d,minor:s,patch:r}=b(o);return e!==d?e>d?1:-1:a!==s?a>s?1:-1:t!==r?t>r?1:-1:0};var y="jolibox-sdk-loader-metadata",x=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var t,d;let o=this.currentVersion,e=null;try{if(e=JSON.parse((t=localStorage.getItem(y))!=null?t:"null"),!e||!e.version)throw new Error("Invalid loader metadata")}catch(s){e=this.defaultMetadata}let a=(d=e==null?void 0:e.version)!=null?d:o;return m(a)!==m(o)?e=this.defaultMetadata:h(a,o)<0&&(e=this.defaultMetadata),e};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let e=document.createElement("script");e.type="text/javascript",e.innerHTML=o.responseText,document.head.appendChild(e)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...d)=>p(this,[...d],function*(o=this.currentVersion,e=this.loaderMetadata.version,a=(t=>(t=window.JOLIBOX_ENV)!=null?t:"WEB")()){var r,n,l;let s=`${(n=(r=window.joliboxenv)==null?void 0:r.apiBaseURL)!=null?n:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let w=yield(yield fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:e,env:a})})).json();if(w.code!=="SUCCESS")throw new Error(w.message);this.loaderMetadata=(l=w.data)!=null?l:this.defaultMetadata,localStorage.setItem(y,JSON.stringify(this.loaderMetadata))}catch(g){console.warn("Failed to fetch loader metadata: ",g)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,e=m(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${e}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${e}/dist/index.iife.js`}}};window.JoliboxSDKLoader=x;var u=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>p(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=u;var I=class{constructor(){this.trackEvent=(o,e)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(e!==null&&typeof e!="object"&&e!==void 0)throw new Error("extra must be an object or null or undefined");if(e){for(let a in e)if(typeof e[a]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,e]})}}};window.JoliboxAnalytics=I;var N=require("@jolibox/web-sync-sdk");window.__JOLIBOX_LOCAL_SDK_VERSION__="1.0.7-beta.1";var c=class{constructor({useRuntimeSDK:o=!0,loaderConfig:e,testMode:a,apiBaseURL:t}={}){this.setJoliboxEnv=(o,e)=>{let t=typeof window<"u"?new URLSearchParams(window.location.search):null,d=(t==null?void 0:t.get("testMode"))==="true",s=o!=null?o:d,r=t==null?void 0:t.get("apiBaseURL"),n;e?n=e:r?n=r:n=s?"https://test-api.jolibox.com":"https://api.jolibox.com",window.joliboxenv={testMode:s,apiBaseURL:n}};var d,s,r,n;this.setJoliboxEnv(a,t),o&&window.joliboxsdk?(this.loader=(d=window.joliboxsdk.loader)!=null?d:new window.JoliboxSDKLoader(e),this.ads=(s=window.joliboxsdk.ads)!=null?s:new window.JoliboxAds,this.anaytics=(r=window.joliboxsdk.anaytics)!=null?r:new window.JoliboxAnalytics,this.runtime=(n=window.joliboxsdk.runtime)!=null?n:new window.JoliboxRuntime):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(e),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=c);var v=c;0&&(module.exports={JoliboxSDK});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{var c=(t,o,e)=>new Promise((n,i)=>{var d=a=>{try{r(e.next(a))}catch(l){i(l)}},s=a=>{try{r(e.throw(a))}catch(l){i(l)}},r=a=>a.done?n(a.value):Promise.resolve(a.value).then(d,s);r((e=e.apply(t,o)).next())});var b=t=>{var r,a,l;let o=t.split("-")[1];o&&(t=t.replace(`-${o}`,""));let e=t.split("+")[1];e&&(t=t.replace(`+${e}`,""));let n=t.split(".").slice(0,3),[i,d,s]=[(r=n[0])!=null?r:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:i,minor:d,patch:s,prerelease:o,build:e}},p=t=>parseInt(b(t).major,10),h=(t,o)=>{let{major:e,minor:n,patch:i}=b(t),{major:d,minor:s,patch:r}=b(o);return e!==d?e>d?1:-1:n!==s?n>s?1:-1:i!==r?i>r?1:-1:0};var g="jolibox-sdk-loader-metadata",f=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var i,d;let o=this.currentVersion,e=null;try{if(e=JSON.parse((i=localStorage.getItem(g))!=null?i:"null"),!e||!e.version)throw new Error("Invalid loader metadata")}catch(s){e=this.defaultMetadata}let n=(d=e==null?void 0:e.version)!=null?d:o;return p(n)!==p(o)?e=this.defaultMetadata:h(n,o)<0&&(e=this.defaultMetadata),e};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let e=document.createElement("script");e.type="text/javascript",e.innerHTML=o.responseText,document.head.appendChild(e)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...d)=>c(this,[...d],function*(o=this.currentVersion,e=this.loaderMetadata.version,n=(i=>(i=window.JOLIBOX_ENV)!=null?i:"WEB")()){var r,a,l;let s=`${(a=(r=window.joliboxenv)==null?void 0:r.apiBaseURL)!=null?a:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let w=yield(yield fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:e,env:n})})).json();if(w.code!=="SUCCESS")throw new Error(w.message);this.loaderMetadata=(l=w.data)!=null?l:this.defaultMetadata,localStorage.setItem(g,JSON.stringify(this.loaderMetadata))}catch(u){console.warn("Failed to fetch loader metadata: ",u)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,e=p(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${e}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${e}/dist/index.iife.js`}}};window.JoliboxSDKLoader=f;var x=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>c(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=x;var I=class{constructor(){this.trackEvent=(o,e)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(e!==null&&typeof e!="object"&&e!==void 0)throw new Error("extra must be an object or null or undefined");if(e){for(let n in e)if(typeof e[n]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,e]})}}};window.JoliboxAnalytics=I;var S=(t=>(t.LOAD_START="JOLIBOX_RUNTIME_LOAD_START",t.LOAD_FINISHED="JOLIBOX_RUNTIME_LOAD_FINISHED",t.LOAD_PROGRESS="JOLIBOX_RUNTIME_LOAD_PROGRESS",t))(S||{});window.dispatchEvent(new Event("JOLIBOX_RUNTIME_LOAD_START"));var y=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t),window.joliboxsdk._commandPipe.push({cmd:"analytics.trackSystemEvent",params:["CallRuntimeLoadFinished"]})},this.notifyLoadProgress=t=>{let o=Math.ceil(t),e=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:o});window.dispatchEvent(e)}}};window.JoliboxRuntime=y;window.__JOLIBOX_LOCAL_SDK_VERSION__="1.0.7-beta.
|
|
1
|
+
"use strict";(()=>{var c=(t,o,e)=>new Promise((n,i)=>{var d=a=>{try{r(e.next(a))}catch(l){i(l)}},s=a=>{try{r(e.throw(a))}catch(l){i(l)}},r=a=>a.done?n(a.value):Promise.resolve(a.value).then(d,s);r((e=e.apply(t,o)).next())});var b=t=>{var r,a,l;let o=t.split("-")[1];o&&(t=t.replace(`-${o}`,""));let e=t.split("+")[1];e&&(t=t.replace(`+${e}`,""));let n=t.split(".").slice(0,3),[i,d,s]=[(r=n[0])!=null?r:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:i,minor:d,patch:s,prerelease:o,build:e}},p=t=>parseInt(b(t).major,10),h=(t,o)=>{let{major:e,minor:n,patch:i}=b(t),{major:d,minor:s,patch:r}=b(o);return e!==d?e>d?1:-1:n!==s?n>s?1:-1:i!==r?i>r?1:-1:0};var g="jolibox-sdk-loader-metadata",f=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var i,d;let o=this.currentVersion,e=null;try{if(e=JSON.parse((i=localStorage.getItem(g))!=null?i:"null"),!e||!e.version)throw new Error("Invalid loader metadata")}catch(s){e=this.defaultMetadata}let n=(d=e==null?void 0:e.version)!=null?d:o;return p(n)!==p(o)?e=this.defaultMetadata:h(n,o)<0&&(e=this.defaultMetadata),e};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let e=document.createElement("script");e.type="text/javascript",e.innerHTML=o.responseText,document.head.appendChild(e)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...d)=>c(this,[...d],function*(o=this.currentVersion,e=this.loaderMetadata.version,n=(i=>(i=window.JOLIBOX_ENV)!=null?i:"WEB")()){var r,a,l;let s=`${(a=(r=window.joliboxenv)==null?void 0:r.apiBaseURL)!=null?a:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let w=yield(yield fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:e,env:n})})).json();if(w.code!=="SUCCESS")throw new Error(w.message);this.loaderMetadata=(l=w.data)!=null?l:this.defaultMetadata,localStorage.setItem(g,JSON.stringify(this.loaderMetadata))}catch(u){console.warn("Failed to fetch loader metadata: ",u)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,e=p(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${e}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${e}/dist/index.iife.js`}}};window.JoliboxSDKLoader=f;var x=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>c(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=x;var I=class{constructor(){this.trackEvent=(o,e)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(e!==null&&typeof e!="object"&&e!==void 0)throw new Error("extra must be an object or null or undefined");if(e){for(let n in e)if(typeof e[n]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,e]})}}};window.JoliboxAnalytics=I;var S=(t=>(t.LOAD_START="JOLIBOX_RUNTIME_LOAD_START",t.LOAD_FINISHED="JOLIBOX_RUNTIME_LOAD_FINISHED",t.LOAD_PROGRESS="JOLIBOX_RUNTIME_LOAD_PROGRESS",t))(S||{});window.dispatchEvent(new Event("JOLIBOX_RUNTIME_LOAD_START"));var y=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t),window.joliboxsdk._commandPipe.push({cmd:"analytics.trackSystemEvent",params:["CallRuntimeLoadFinished"]})},this.notifyLoadProgress=t=>{let o=Math.ceil(t),e=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:o});window.dispatchEvent(e)}}};window.JoliboxRuntime=y;window.__JOLIBOX_LOCAL_SDK_VERSION__="1.0.7-beta.1";var m=class{constructor({useRuntimeSDK:o=!0,loaderConfig:e,testMode:n,apiBaseURL:i}={}){this.setJoliboxEnv=(o,e)=>{let i=typeof window<"u"?new URLSearchParams(window.location.search):null,d=(i==null?void 0:i.get("testMode"))==="true",s=o!=null?o:d,r=i==null?void 0:i.get("apiBaseURL"),a;e?a=e:r?a=r:a=s?"https://test-api.jolibox.com":"https://api.jolibox.com",window.joliboxenv={testMode:s,apiBaseURL:a}};var d,s,r,a;this.setJoliboxEnv(n,i),o&&window.joliboxsdk?(this.loader=(d=window.joliboxsdk.loader)!=null?d:new window.JoliboxSDKLoader(e),this.ads=(s=window.joliboxsdk.ads)!=null?s:new window.JoliboxAds,this.anaytics=(r=window.joliboxsdk.anaytics)!=null?r:new window.JoliboxAnalytics,this.runtime=(a=window.joliboxsdk.runtime)!=null?a:new window.JoliboxRuntime):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(e),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=m);var B=m;})();
|
|
2
2
|
//# sourceMappingURL=index.iife.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var c=(r,o,e)=>new Promise((a,t)=>{var d=i=>{try{n(e.next(i))}catch(l){t(l)}},s=i=>{try{n(e.throw(i))}catch(l){t(l)}},n=i=>i.done?a(i.value):Promise.resolve(i.value).then(d,s);n((e=e.apply(r,o)).next())});var f=r=>{var n,i,l;let o=r.split("-")[1];o&&(r=r.replace(`-${o}`,""));let e=r.split("+")[1];e&&(r=r.replace(`+${e}`,""));let a=r.split(".").slice(0,3),[t,d,s]=[(n=a[0])!=null?n:"0",(i=a[1])!=null?i:"0",(l=a[2])!=null?l:"0"];return{major:t,minor:d,patch:s,prerelease:o,build:e}},p=r=>parseInt(f(r).major,10),g=(r,o)=>{let{major:e,minor:a,patch:t}=f(r),{major:d,minor:s,patch:n}=f(o);return e!==d?e>d?1:-1:a!==s?a>s?1:-1:t!==n?t>n?1:-1:0};var h="jolibox-sdk-loader-metadata",b=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var t,d;let o=this.currentVersion,e=null;try{if(e=JSON.parse((t=localStorage.getItem(h))!=null?t:"null"),!e||!e.version)throw new Error("Invalid loader metadata")}catch(s){e=this.defaultMetadata}let a=(d=e==null?void 0:e.version)!=null?d:o;return p(a)!==p(o)?e=this.defaultMetadata:g(a,o)<0&&(e=this.defaultMetadata),e};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let e=document.createElement("script");e.type="text/javascript",e.innerHTML=o.responseText,document.head.appendChild(e)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...d)=>c(this,[...d],function*(o=this.currentVersion,e=this.loaderMetadata.version,a=(t=>(t=window.JOLIBOX_ENV)!=null?t:"WEB")()){var n,i,l;let s=`${(i=(n=window.joliboxenv)==null?void 0:n.apiBaseURL)!=null?i:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let w=yield(yield fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:e,env:a})})).json();if(w.code!=="SUCCESS")throw new Error(w.message);this.loaderMetadata=(l=w.data)!=null?l:this.defaultMetadata,localStorage.setItem(h,JSON.stringify(this.loaderMetadata))}catch(I){console.warn("Failed to fetch loader metadata: ",I)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,e=p(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${e}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${e}/dist/index.iife.js`}}};window.JoliboxSDKLoader=b;var x=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>c(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=x;var u=class{constructor(){this.trackEvent=(o,e)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(e!==null&&typeof e!="object"&&e!==void 0)throw new Error("extra must be an object or null or undefined");if(e){for(let a in e)if(typeof e[a]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,e]})}}};window.JoliboxAnalytics=u;import"@jolibox/web-sync-sdk";window.__JOLIBOX_LOCAL_SDK_VERSION__="1.0.7-beta.
|
|
1
|
+
var c=(r,o,e)=>new Promise((a,t)=>{var d=i=>{try{n(e.next(i))}catch(l){t(l)}},s=i=>{try{n(e.throw(i))}catch(l){t(l)}},n=i=>i.done?a(i.value):Promise.resolve(i.value).then(d,s);n((e=e.apply(r,o)).next())});var f=r=>{var n,i,l;let o=r.split("-")[1];o&&(r=r.replace(`-${o}`,""));let e=r.split("+")[1];e&&(r=r.replace(`+${e}`,""));let a=r.split(".").slice(0,3),[t,d,s]=[(n=a[0])!=null?n:"0",(i=a[1])!=null?i:"0",(l=a[2])!=null?l:"0"];return{major:t,minor:d,patch:s,prerelease:o,build:e}},p=r=>parseInt(f(r).major,10),g=(r,o)=>{let{major:e,minor:a,patch:t}=f(r),{major:d,minor:s,patch:n}=f(o);return e!==d?e>d?1:-1:a!==s?a>s?1:-1:t!==n?t>n?1:-1:0};var h="jolibox-sdk-loader-metadata",b=class{constructor({loaderMetadata:o}={}){this.computeLoaderMetaData=()=>{var t,d;let o=this.currentVersion,e=null;try{if(e=JSON.parse((t=localStorage.getItem(h))!=null?t:"null"),!e||!e.version)throw new Error("Invalid loader metadata")}catch(s){e=this.defaultMetadata}let a=(d=e==null?void 0:e.version)!=null?d:o;return p(a)!==p(o)?e=this.defaultMetadata:g(a,o)<0&&(e=this.defaultMetadata),e};this.loadScript=()=>{if(this.loaderMetadata.syncScriptUrl){let o=new XMLHttpRequest;o.open("GET",this.loaderMetadata.syncScriptUrl,!1),o.send();let e=document.createElement("script");e.type="text/javascript",e.innerHTML=o.responseText,document.head.appendChild(e)}if(this.loaderMetadata.asyncScriptUrl){let o=document.createElement("script");o.type="text/javascript",o.src=this.loaderMetadata.asyncScriptUrl,o.async=!0,document.head.appendChild(o)}};this.fetchUpdateLoaderMetadata=(...d)=>c(this,[...d],function*(o=this.currentVersion,e=this.loaderMetadata.version,a=(t=>(t=window.JOLIBOX_ENV)!=null?t:"WEB")()){var n,i,l;let s=`${(i=(n=window.joliboxenv)==null?void 0:n.apiBaseURL)!=null?i:"https://api.jolibox.com"}/frontend/js-sdk/loader-metadata`;try{let w=yield(yield fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({installedSDKVersion:o,localSDKVersion:e,env:a})})).json();if(w.code!=="SUCCESS")throw new Error(w.message);this.loaderMetadata=(l=w.data)!=null?l:this.defaultMetadata,localStorage.setItem(h,JSON.stringify(this.loaderMetadata))}catch(I){console.warn("Failed to fetch loader metadata: ",I)}});console.log("Loading Jolibox SDK..."),this.loaderMetadata=o!=null?o:this.computeLoaderMetaData(),this.loadScript(),this.fetchUpdateLoaderMetadata(),console.log("Jolibox SDK loaded.")}get currentVersion(){return window.__JOLIBOX_LOCAL_SDK_VERSION__}get defaultMetadata(){let o=this.currentVersion,e=p(o);return{version:o,syncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-sync-sdk@${e}/dist/index.iife.js`,asyncScriptUrl:`https://cdn.jsdelivr.net/npm/@jolibox/web-async-sdk@${e}/dist/index.iife.js`}}};window.JoliboxSDKLoader=b;var x=class{constructor(){this.init=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.init",params:o})};this.adConfig=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adConfig",params:o})};this.adBreak=o=>{window.joliboxsdk._commandPipe.push({cmd:"ads.adBreak",params:o})};this.adUnit=o=>c(this,null,function*(){window.joliboxsdk._commandPipe.push({cmd:"ads.adUnit",params:o})})}};window.JoliboxAds=x;var u=class{constructor(){this.trackEvent=(o,e)=>{if(typeof o!="string")throw new Error("eventName must be a string");if(e!==null&&typeof e!="object"&&e!==void 0)throw new Error("extra must be an object or null or undefined");if(e){for(let a in e)if(typeof e[a]=="object")throw new Error("extra must not have nested objects")}window.joliboxsdk._commandPipe.push({cmd:"analytics.trackEvent",params:[o,e]})}}};window.JoliboxAnalytics=u;import"@jolibox/web-sync-sdk";window.__JOLIBOX_LOCAL_SDK_VERSION__="1.0.7-beta.1";var m=class{constructor({useRuntimeSDK:o=!0,loaderConfig:e,testMode:a,apiBaseURL:t}={}){this.setJoliboxEnv=(o,e)=>{let t=typeof window<"u"?new URLSearchParams(window.location.search):null,d=(t==null?void 0:t.get("testMode"))==="true",s=o!=null?o:d,n=t==null?void 0:t.get("apiBaseURL"),i;e?i=e:n?i=n:i=s?"https://test-api.jolibox.com":"https://api.jolibox.com",window.joliboxenv={testMode:s,apiBaseURL:i}};var d,s,n,i;this.setJoliboxEnv(a,t),o&&window.joliboxsdk?(this.loader=(d=window.joliboxsdk.loader)!=null?d:new window.JoliboxSDKLoader(e),this.ads=(s=window.joliboxsdk.ads)!=null?s:new window.JoliboxAds,this.anaytics=(n=window.joliboxsdk.anaytics)!=null?n:new window.JoliboxAnalytics,this.runtime=(i=window.joliboxsdk.runtime)!=null?i:new window.JoliboxRuntime):(window.joliboxsdk||(window.joliboxsdk={_commandPipe:[]}),this.loader=new window.JoliboxSDKLoader(e),this.ads=new window.JoliboxAds,this.anaytics=new window.JoliboxAnalytics,this.runtime=new window.JoliboxRuntime,window.joliboxsdk=Object.assign(this,window.joliboxsdk)),window.joliboxsdk._commandPipe||(window.joliboxsdk._commandPipe=[])}};window.JoliboxSDK||(window.JoliboxSDK=m);var M=m;export{m as JoliboxSDK,M as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/sdk",
|
|
3
|
-
"version": "1.0.7-beta.
|
|
3
|
+
"version": "1.0.7-beta.1",
|
|
4
4
|
"description": "Jolibox JavaScript SDK for Ads",
|
|
5
5
|
"homepage": "https://sdk-docs.jolibox.com",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@jolibox/web-sync-sdk": "1.0.7-beta.
|
|
31
|
+
"@jolibox/web-sync-sdk": "1.0.7-beta.1"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsup",
|