@rechat/sdk 1.1.2 → 1.2.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/dist/rechat.min.css +1 -1
- package/dist/rechat.min.js +1 -1
- package/esm/index.esm.js +1 -1
- package/esm/sdk/LeadBase.d.ts +6 -0
- package/esm/sdk/LeadCapture.d.ts +2 -2
- package/esm/sdk/types/index.d.ts +13 -0
- package/package.json +1 -1
package/esm/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var a,c={};var u=i(function(){if(a)return c;a=1,Object.defineProperty(c,"__esModule",{value:!0}),c.parse=function(t,e){const n=new i,r=t.length;if(r<2)return n;const o=e?.decode||p;let a=0;do{const e=t.indexOf("=",a);if(-1===e)break;const i=t.indexOf(";",a),c=-1===i?r:i;if(e>c){a=t.lastIndexOf(";",e-1)+1;continue}const p=u(t,a,e),l=s(t,e,p),f=t.slice(p,l);if(void 0===n[f]){let r=u(t,e+1,c),i=s(t,c,r);const a=o(t.slice(r,i));n[f]=a}a=c+1}while(a<r);return n},c.serialize=function(i,a,c){const u=c?.encode||encodeURIComponent;if(!t.test(i))throw new TypeError(`argument name is invalid: ${i}`);const s=u(a);if(!e.test(s))throw new TypeError(`argument val is invalid: ${a}`);let p=i+"="+s;if(!c)return p;if(void 0!==c.maxAge){if(!Number.isInteger(c.maxAge))throw new TypeError(`option maxAge is invalid: ${c.maxAge}`);p+="; Max-Age="+c.maxAge}if(c.domain){if(!n.test(c.domain))throw new TypeError(`option domain is invalid: ${c.domain}`);p+="; Domain="+c.domain}if(c.path){if(!r.test(c.path))throw new TypeError(`option path is invalid: ${c.path}`);p+="; Path="+c.path}if(c.expires){if(!function(t){return"[object Date]"===o.call(t)}(c.expires)||!Number.isFinite(c.expires.valueOf()))throw new TypeError(`option expires is invalid: ${c.expires}`);p+="; Expires="+c.expires.toUTCString()}c.httpOnly&&(p+="; HttpOnly");c.secure&&(p+="; Secure");c.partitioned&&(p+="; Partitioned");if(c.priority){switch("string"==typeof c.priority?c.priority.toLowerCase():void 0){case"low":p+="; Priority=Low";break;case"medium":p+="; Priority=Medium";break;case"high":p+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${c.priority}`)}}if(c.sameSite){switch("string"==typeof c.sameSite?c.sameSite.toLowerCase():c.sameSite){case!0:case"strict":p+="; SameSite=Strict";break;case"lax":p+="; SameSite=Lax";break;case"none":p+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${c.sameSite}`)}}return p};const t=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,e=/^[\u0021-\u003A\u003C-\u007E]*$/,n=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,r=/^[\u0020-\u003A\u003D-\u007E]*$/,o=Object.prototype.toString,i=(()=>{const t=function(){};return t.prototype=Object.create(null),t})();function u(t,e,n){do{const n=t.charCodeAt(e);if(32!==n&&9!==n)return e}while(++e<n);return n}function s(t,e,n){for(;e>n;){const n=t.charCodeAt(--e);if(32!==n&&9!==n)return e+1}return n}function p(t){if(-1===t.indexOf("%"))return t;try{return decodeURIComponent(t)}catch(e){return t}}return c}()),s=function(){function t(t){this.settings=t}return Object.defineProperty(t.prototype,"ApiUrl",{get:function(){var t;return null!==(t=this.settings.api_url)&&void 0!==t?t:"https://".concat(this.settings.sandbox?"boer.":"","api.rechat.com")},enumerable:!1,configurable:!0}),t}(),p=function(t){function n(e){return t.call(this,e)||this}return e(n,t),n.prototype.identify=function(t){var e,n;document.cookie=u.serialize(this.CookieName,t,null===(n=null===(e=this.TrackerSettings)||void 0===e?void 0:e.cookie)||void 0===n?void 0:n.options)},n.prototype.viewedListing=function(t,e){return this.capture({action:"ContactViewedListing",listing:t,notes:e})},n.prototype.sharedListing=function(t,e){return this.capture({action:"ContactSharedListing",listing:t,notes:e})},n.prototype.favoritedListing=function(t,e){return this.capture({action:"ContactFavoritedListing",listing:t,notes:e})},n.prototype.removedFavoriteListing=function(t,e){return this.capture({action:"ContactRemovedFavoriteListing",listing:t,notes:e})},n.prototype.valuedListing=function(t,e){return this.capture({action:"ContactValuedListing",listing:t,notes:e})},n.prototype.signedUp=function(t){return this.capture({action:"ContactSignedUp",notes:t})},n.prototype.loggedIn=function(t){return this.capture({action:"ContactLoggedIn",notes:t})},n.prototype.searchedListings=function(t,e){return this.capture({action:"ContactSearchedListings",search:t,notes:e})},n.prototype.createdSearch=function(t,e){return this.capture({action:"ContactCreatedSearch",search:t,notes:e})},n.prototype.removedSearch=function(t,e){return this.capture({action:"ContactRemovedSearch",search:t,notes:e})},n.prototype.capture=function(t){var e=this;return new Promise((function(n,r){var o=e.leadTrackingId;o?fetch("".concat(e.ApiUrl,"/leads/").concat(o,"/timeline"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}).then((function(t){return t.ok?n():r(t)})).catch(r):r("No tracking id is found")}))},n.prototype.stop=function(){document.cookie="".concat(this.CookieName,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;")},Object.defineProperty(n.prototype,"CookieName",{get:function(){var t,e,n;return null!==(n=null===(e=null===(t=this.TrackerSettings)||void 0===t?void 0:t.cookie)||void 0===e?void 0:e.name)&&void 0!==n?n:"rechat-sdk-tracker"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"TrackerSettings",{get:function(){return this.settings.tracker},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"leadTrackingId",{get:function(){var t;return null!==(t=u.parse(document.cookie)[this.CookieName])&&void 0!==t?t:null},enumerable:!1,configurable:!0}),n}(s),l=function(t){function i(e){var n=t.call(this,e)||this;return n._tracker=new p(e),n}return e(i,t),Object.defineProperty(i.prototype,"Tracker",{get:function(){return this._tracker},enumerable:!1,configurable:!0}),i.prototype.getLeadMetaDataFromUrl=function(){var t=new URLSearchParams(window.location.search);return["user_id","brand_id","ad_campaign_id","email_campaign_id","email_campaign_email_id"].reduce((function(e,r){var o,i;return n(n({},e),((o={})[r]=null!==(i=t.get("rechat_".concat(r)))&&void 0!==i?i:"",o))}),{})},i.prototype.capture=function(t,e){return r(this,void 0,void 0,(function(){var r=this;return o(this,(function(o){return[2,new Promise((function(o,i){fetch("".concat(r.ApiUrl,"/leads"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({lead:e,metadata:n(n({},r.getLeadMetaDataFromUrl()),t)})}).then((function(t){t.ok?t.json().then((function(t){var e=t.data;!1!==r.settings.tracker&&r._tracker.identify(e.id),o(e)})):i(t)})).catch(i)}))]}))}))},i.prototype.form=function(t,e,r){var o=this;t.addEventListener("submit",(function(i){var a;i.preventDefault();var c=Object.values(t).reduce((function(t,e){var r;return e.name?n(n({},t),((r={})[e.name]=e.value,r)):t}),{});!1!==(null===(a=r.validate)||void 0===a?void 0:a.call(r,c))&&o.capture(e,c).then(r.onSuccess).catch(r.onError)}))},i}(s),f=function(){function t(t){void 0===t&&(t={}),this._settings=t,this._leads=new l(t)}return Object.defineProperty(t.prototype,"Leads",{get:function(){return this._leads},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Settings",{get:function(){return this._settings},enumerable:!1,configurable:!0}),t}();export{l as LeadCapture,p as LeadTracker,f as Sdk};
|
|
1
|
+
var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var i="rechat-sdk-offline-queue",a=function(){function t(t){var e=this;this.settings=t,this.resync(),this.storage&&window.addEventListener("online",(function(){return e.resync()}))}return Object.defineProperty(t.prototype,"ApiUrl",{get:function(){var t;return null!==(t=this.settings.api_url)&&void 0!==t?t:"https://".concat(this.settings.sandbox?"boer.":"","api.rechat.com")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"storage",{get:function(){var t;return null===(t=this.settings.offline_sync)||void 0===t?void 0:t.storage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxQueueSize",{get:function(){var t,e;return null!==(e=null===(t=this.settings.offline_sync)||void 0===t?void 0:t.max_queue_size)&&void 0!==e?e:500},enumerable:!1,configurable:!0}),t.prototype.fetch=function(t,e){return r(this,void 0,void 0,(function(){var n=this;return o(this,(function(r){return!navigator.onLine&&this.storage?(this.enqueue({path:t,body:e}),[2,Promise.reject(new Error("offline"))]):[2,fetch("".concat(this.ApiUrl).concat(t),{method:"POST",headers:{"content-type":"application/json"},body:e}).catch((function(r){throw n.storage&&n.enqueue({path:t,body:e}),r}))]}))}))},t.prototype.enqueue=function(t){var e=this.getPendingRequests();e.length>=this.maxQueueSize||(e.push(t),this.storage.setItem(i,JSON.stringify(e)))},t.prototype.getPendingRequests=function(){var t,e=null===(t=this.storage)||void 0===t?void 0:t.getItem(i);return e?JSON.parse(e):[]},t.prototype.resync=function(){return r(this,void 0,void 0,(function(){var t,e,n,r=this;return o(this,(function(o){switch(o.label){case 0:return 0===(t=this.getPendingRequests()).length?[2]:(this.storage.removeItem(i),[4,Promise.all(t.map((function(t){return fetch("".concat(r.ApiUrl).concat(t.path),{method:"POST",headers:{"content-type":"application/json"},body:t.body}).catch((function(){r.enqueue(t)}))})))]);case 1:return o.sent(),null===(n=null===(e=this.settings.offline_sync)||void 0===e?void 0:e.on_sync_complete)||void 0===n||n.call(e),[2]}}))}))},t}();function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var u,s={};var p=c(function(){if(u)return s;u=1,Object.defineProperty(s,"__esModule",{value:!0}),s.parse=function(t,e){const n=new i,r=t.length;if(r<2)return n;const o=e?.decode||p;let u=0;do{const e=t.indexOf("=",u);if(-1===e)break;const i=t.indexOf(";",u),s=-1===i?r:i;if(e>s){u=t.lastIndexOf(";",e-1)+1;continue}const p=a(t,u,e),l=c(t,e,p),f=t.slice(p,l);if(void 0===n[f]){let r=a(t,e+1,s),i=c(t,s,r);const u=o(t.slice(r,i));n[f]=u}u=s+1}while(u<r);return n},s.serialize=function(i,a,c){const u=c?.encode||encodeURIComponent;if(!t.test(i))throw new TypeError(`argument name is invalid: ${i}`);const s=u(a);if(!e.test(s))throw new TypeError(`argument val is invalid: ${a}`);let p=i+"="+s;if(!c)return p;if(void 0!==c.maxAge){if(!Number.isInteger(c.maxAge))throw new TypeError(`option maxAge is invalid: ${c.maxAge}`);p+="; Max-Age="+c.maxAge}if(c.domain){if(!n.test(c.domain))throw new TypeError(`option domain is invalid: ${c.domain}`);p+="; Domain="+c.domain}if(c.path){if(!r.test(c.path))throw new TypeError(`option path is invalid: ${c.path}`);p+="; Path="+c.path}if(c.expires){if(!function(t){return"[object Date]"===o.call(t)}(c.expires)||!Number.isFinite(c.expires.valueOf()))throw new TypeError(`option expires is invalid: ${c.expires}`);p+="; Expires="+c.expires.toUTCString()}c.httpOnly&&(p+="; HttpOnly");c.secure&&(p+="; Secure");c.partitioned&&(p+="; Partitioned");if(c.priority){switch("string"==typeof c.priority?c.priority.toLowerCase():void 0){case"low":p+="; Priority=Low";break;case"medium":p+="; Priority=Medium";break;case"high":p+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${c.priority}`)}}if(c.sameSite){switch("string"==typeof c.sameSite?c.sameSite.toLowerCase():c.sameSite){case!0:case"strict":p+="; SameSite=Strict";break;case"lax":p+="; SameSite=Lax";break;case"none":p+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${c.sameSite}`)}}return p};const t=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,e=/^[\u0021-\u003A\u003C-\u007E]*$/,n=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,r=/^[\u0020-\u003A\u003D-\u007E]*$/,o=Object.prototype.toString,i=(()=>{const t=function(){};return t.prototype=Object.create(null),t})();function a(t,e,n){do{const n=t.charCodeAt(e);if(32!==n&&9!==n)return e}while(++e<n);return n}function c(t,e,n){for(;e>n;){const n=t.charCodeAt(--e);if(32!==n&&9!==n)return e+1}return n}function p(t){if(-1===t.indexOf("%"))return t;try{return decodeURIComponent(t)}catch(e){return t}}return s}()),l=function(t){function n(e){return t.call(this,e)||this}return e(n,t),n.prototype.identify=function(t){var e,n;document.cookie=p.serialize(this.CookieName,t,null===(n=null===(e=this.TrackerSettings)||void 0===e?void 0:e.cookie)||void 0===n?void 0:n.options)},n.prototype.viewedListing=function(t,e){return this.capture({action:"ContactViewedListing",listing:t,notes:e})},n.prototype.sharedListing=function(t,e){return this.capture({action:"ContactSharedListing",listing:t,notes:e})},n.prototype.favoritedListing=function(t,e){return this.capture({action:"ContactFavoritedListing",listing:t,notes:e})},n.prototype.removedFavoriteListing=function(t,e){return this.capture({action:"ContactRemovedFavoriteListing",listing:t,notes:e})},n.prototype.valuedListing=function(t,e){return this.capture({action:"ContactValuedListing",listing:t,notes:e})},n.prototype.signedUp=function(t){return this.capture({action:"ContactSignedUp",notes:t})},n.prototype.loggedIn=function(t){return this.capture({action:"ContactLoggedIn",notes:t})},n.prototype.searchedListings=function(t,e){return this.capture({action:"ContactSearchedListings",search:t,notes:e})},n.prototype.createdSearch=function(t,e){return this.capture({action:"ContactCreatedSearch",search:t,notes:e})},n.prototype.removedSearch=function(t,e){return this.capture({action:"ContactRemovedSearch",search:t,notes:e})},n.prototype.capture=function(t){var e=this;return new Promise((function(n,r){var o=e.leadTrackingId;o?e.fetch("/leads/".concat(o,"/timeline"),JSON.stringify(t)).then((function(t){return t.ok?n():r(t)})).catch(r):r("No tracking id is found")}))},n.prototype.stop=function(){document.cookie="".concat(this.CookieName,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;")},Object.defineProperty(n.prototype,"CookieName",{get:function(){var t,e,n;return null!==(n=null===(e=null===(t=this.TrackerSettings)||void 0===t?void 0:t.cookie)||void 0===e?void 0:e.name)&&void 0!==n?n:"rechat-sdk-tracker"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"TrackerSettings",{get:function(){return this.settings.tracker},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"leadTrackingId",{get:function(){var t;return null!==(t=p.parse(document.cookie)[this.CookieName])&&void 0!==t?t:null},enumerable:!1,configurable:!0}),n}(a),f=function(t){function i(e){var n=t.call(this,e)||this;return n._tracker=new l(e),n}return e(i,t),Object.defineProperty(i.prototype,"Tracker",{get:function(){return this._tracker},enumerable:!1,configurable:!0}),i.prototype.getLeadMetaDataFromUrl=function(){var t=new URLSearchParams(window.location.search);return["user_id","brand_id","ad_campaign_id","email_campaign_id","email_campaign_email_id"].reduce((function(e,r){var o,i;return n(n({},e),((o={})[r]=null!==(i=t.get("rechat_".concat(r)))&&void 0!==i?i:"",o))}),{})},i.prototype.capture=function(t,e){return r(this,void 0,void 0,(function(){var r=this;return o(this,(function(o){return[2,new Promise((function(o,i){r.fetch("/leads",JSON.stringify({lead:e,metadata:n(n({},r.getLeadMetaDataFromUrl()),t)})).then((function(t){t.ok?t.json().then((function(t){var e=t.data;!1!==r.settings.tracker&&r._tracker.identify(e.id),o(e)})):i(t)})).catch(i)}))]}))}))},i.prototype.form=function(t,e,r){var o=this;t.addEventListener("submit",(function(i){var a;i.preventDefault();var c=Object.values(t).reduce((function(t,e){var r;return e.name?n(n({},t),((r={})[e.name]=e.value,r)):t}),{});!1!==(null===(a=r.validate)||void 0===a?void 0:a.call(r,c))&&o.capture(e,c).then(r.onSuccess).catch(r.onError)}))},i}(a),d=function(){function t(t){void 0===t&&(t={}),this._settings=t,this._leads=new f(t)}return Object.defineProperty(t.prototype,"Leads",{get:function(){return this._leads},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Settings",{get:function(){return this._settings},enumerable:!1,configurable:!0}),t}();export{f as LeadCapture,l as LeadTracker,d as Sdk};
|
package/esm/sdk/LeadBase.d.ts
CHANGED
|
@@ -3,4 +3,10 @@ export declare abstract class LeadBase {
|
|
|
3
3
|
protected settings: ISdkSettings;
|
|
4
4
|
constructor(settings: ISdkSettings);
|
|
5
5
|
protected get ApiUrl(): string;
|
|
6
|
+
private get storage();
|
|
7
|
+
private get maxQueueSize();
|
|
8
|
+
protected fetch(path: string, body: string): Promise<Response>;
|
|
9
|
+
private enqueue;
|
|
10
|
+
private getPendingRequests;
|
|
11
|
+
private resync;
|
|
6
12
|
}
|
package/esm/sdk/LeadCapture.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LeadTracker } from './LeadTracker';
|
|
2
1
|
import { LeadBase } from './LeadBase';
|
|
3
|
-
import
|
|
2
|
+
import { LeadTracker } from './LeadTracker';
|
|
3
|
+
import type { IFormEvents, ILeadCaptureResponse, ILeadInput, ILeadMetaData, ISdkSettings } from './types';
|
|
4
4
|
export declare class LeadCapture extends LeadBase {
|
|
5
5
|
private _tracker;
|
|
6
6
|
constructor(settings: ISdkSettings);
|
package/esm/sdk/types/index.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { ILeadTrackerOptions } from './lead-tracker';
|
|
2
2
|
export * from './lead-capture';
|
|
3
3
|
export * from './lead-form';
|
|
4
|
+
export interface OfflineSyncStorage {
|
|
5
|
+
readonly length: number;
|
|
6
|
+
clear(): void;
|
|
7
|
+
getItem(key: string): string | null;
|
|
8
|
+
key(index: number): string | null;
|
|
9
|
+
removeItem(key: string): void;
|
|
10
|
+
setItem(key: string, value: string): void;
|
|
11
|
+
}
|
|
4
12
|
export interface ISdkSettings {
|
|
5
13
|
sandbox?: boolean;
|
|
6
14
|
api_url?: string;
|
|
7
15
|
tracker?: ILeadTrackerOptions | false;
|
|
16
|
+
offline_sync?: {
|
|
17
|
+
storage: OfflineSyncStorage;
|
|
18
|
+
max_queue_size?: number;
|
|
19
|
+
on_sync_complete?: () => void;
|
|
20
|
+
};
|
|
8
21
|
}
|