diff --git a/dist/zaf_sdk.js b/dist/zaf_sdk.js new file mode 100644 index 00000000..aaadd835 --- /dev/null +++ b/dist/zaf_sdk.js @@ -0,0 +1,3 @@ +/*! For license information please see zaf_sdk.js.LICENSE.txt */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ZAFClient=t():e.ZAFClient=t()}(self,(function(){return(()=>{var e={905:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isTest=t.isDevelopment=t.isProduction=void 0;t.isProduction=!0,t.isDevelopment=!1,t.isTest=!1},94:(e,t,n)=>{"use strict";t.bc=t.EB=void 0;var i=n(74),r=n(905);t.EB="active",t.bc="idle";var s=["mousemove","keydown","wheel","mousedown","touchstart","touchmove"],o=Symbol("state"),a=(e,t)=>{e[o]!==t&&(e[o]=t,e.observers&&e.observers.call(t))};t.ZP=class{constructor(e){this.timeout=e,this[o]=t.EB,this.hasActiveEvent=!0,this.timer=null,this.hasFocus=!0,this.userEventListenerAdded=!1,this.observers=new i.default,this.refcount=1,this.handleVisibilityChange=this.handleVisibilityChange.bind(this),this.handleFocusChange=this.handleFocusChange.bind(this),this.handleUserEvent=this.handleUserEvent.bind(this),this.handleTimer=this.handleTimer.bind(this),document.addEventListener("visibilitychange",this.handleVisibilityChange,!0),window.addEventListener("focus",this.handleFocusChange,!0),window.addEventListener("blur",this.handleFocusChange,!0),this.handleVisibilityChange(),this.resetTimer(),r.isTest&&(this.setState=e=>{a(this,e)})}delete(){void 0!==this.refcount&&0==--this.refcount&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange,!0),window.removeEventListener("focus",this.handleFocusChange,!0),window.removeEventListener("blur",this.handleFocusChange,!0),this.userEventListenerAdded&&s.forEach((e=>document.removeEventListener(e,this.handleUserEvent,!0))),this.clearTimer(),delete this.observers)}get state(){return this[o]}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=void 0)}resetTimer(){this.clearTimer(),this.timer=window.setTimeout(this.handleTimer,this.timeout)}handleTimer(){this.resetTimer(),this.hasActiveEvent?this.hasActiveEvent=!1:a(this,t.bc)}markActive(){this.hasActiveEvent=!0,a(this,t.EB)}handleUserEvent(e){!this.hasFocus&&"mousemove".includes(e.type)||this.markActive()}handleFocusChange(e){e.target===window&&(this.hasFocus="focus"===e.type,this.hasFocus&&this.markActive())}handleVisibilityChange(){document.hidden?this.userEventListenerAdded&&(s.forEach((e=>document.removeEventListener(e,this.handleUserEvent,!0))),this.userEventListenerAdded=!1):this.userEventListenerAdded||(s.forEach((e=>document.addEventListener(e,this.handleUserEvent,!0))),this.userEventListenerAdded=!0)}addObserver(e){return this.observers&&this.observers.add(e)}}},74:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this.listeners=[]}add(e){var t=e=>this.listeners.findIndex((t=>t.fn===e)),n=t(e);if(-1===n)this.listeners.push({fn:e,count:1});else{var i=this.listeners[n];i&&i.count++}return()=>{var n=t(e);if(-1!==n){var i=this.listeners[n];i&&i.count--,i&&0===i.count&&this.listeners.splice(n,1)}}}call(){for(var e=arguments.length,t=new Array(e),n=0;ne.fn(...t)))}}},255:(e,t,n)=>{"use strict";n.d(t,{default:()=>P});const i="2.0.33";var r=n(459),s=n.n(r),o=window.Promise||s();function a(e){return decodeURIComponent((e||"").replace(/\+/g," "))}function c(e){var t,n,i,r,s={};if(0===(e=e||"").search(/\?|#/)&&(e=e.slice(1)),0===e.length)return s;t=e.split("&");for(var o=0;o{t=e,n=i})),r=0,s=[],a=Array.isArray(e)?e.slice():[e];return(r=a.length)<=0?(t(),i):(a.forEach(((e,i)=>{var a;if(h(e))a=e;else if("function"==typeof e){var c;try{a=h(c=e())?c:u(c)?o.reject(c):o.resolve(c)}catch(e){a=o.reject(e)}}else a=new o(((t,n)=>{u(e)?n(e):t(e)}));a.then((e=>{!function(e,n){s[n]=e,--r<=0&&t(s)}(e,i)})).catch(n.bind(n))})),i)}var f=n(94);class p{constructor(e){this.startTime=Date.now(),this.client=e,this.MIN_HOVER_TIME=200}handleMouseEnter(){this.startTime=Date.now()}handleMouseLeave(){var e=Date.now()-this.startTime;e>=this.MIN_HOVER_TIME&&this.client.invoke("track",{type:"hover",value:e})}handleClick(){this.client.invoke("track",{type:"click"})}setup(){var e=document.querySelector("html");e.addEventListener("click",this.handleClick.bind(this)),e.addEventListener("mouseleave",this.handleMouseLeave.bind(this)),e.addEventListener("mouseenter",this.handleMouseEnter.bind(this))}}var v=window.Promise||s(),m=3e5,g=["instances.create"],_=/^zaf\./,y={},w={};function b(e,t,n){return setTimeout((()=>{T(e,t,m),n(new Error("Invocation request timeout"))}),m)}function E(e,t){return t.map((t=>"".concat(e,"-").concat(t)))}function T(e,t,n){var i=t.map((e=>"action:".concat(function(e){return e.replace(/:\w+(,?\w+)*((\.(show|hide|enable|disable))|(\\?\.\w*))?/g,":arg$3")}(e)))),r="request_response_time:".concat(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m;if(e>=t)return"".concat(t/1e3,"-");var n=e-e%1e4;return"".concat(n/1e3,"-").concat((n+1e4)/1e3)}(n));e.postMessage("__track__",{event_name:"sdk_request_timeout",event_type:"increment",data:1,tags:i.concat(r)})}function k(e){return isNaN(w[e])&&(w[e]=0),++w[e]}function j(e,t,n){e.ready||n?e._source.postMessage(t,e._origin):e.on("app.registered",j.bind(null,e,t))}function x(e,t){var n,i,r=k("promise"),s=Array.isArray(t)?t:Object.keys(t),o=E(e,s),a=this,c=new v(((o,c)=>{i=window.performance.now(),n=function(e,t,n,i){var r=E(n,i);if("invoke"===n){var s=i.filter((e=>-1!==g.indexOf(e)));if(s.length===i.length)return NaN;if(0!==s.length)throw new Error("Illegal bulk call - `instances.create` must be called separately.");return b(e,r,t)}return b(e,r,t)}(a,c,e,s),y[r]={resolve:o,reject:c};var h=JSON.stringify({id:r,request:e,params:t,appGuid:a._appGuid,instanceGuid:a._instanceGuid});j(a,h)}));return c.then(C.bind(null,{id:r,timeoutId:n,trackTimeoutWithResolutionTime:()=>{var e=window.performance.now()-i;e>1e4&&T(a,o,e)}}),C.bind(null,{id:r,timeoutId:n}))}function A(e){e.path&&(e.message='"'+e.path+'" '+e.message);var t=new Error(e.message);return t.name=e.name,t.stack=e.stack,t}function C(e,t){if(clearTimeout(e.timeoutId),delete y[e.id],e.trackTimeoutWithResolutionTime&&e.trackTimeoutWithResolutionTime(),t instanceof Error)throw t;return t}function G(e,t){if(function(e,t){return e&&e._origin===t.origin&&e._source===t.source}(e,t)){var n=t.data;if(n){if("string"==typeof n)try{n=JSON.parse(t.data)}catch(e){return e}var i,r=function(e,t){var n=e;if(t&&t!==e._instanceGuid&&!(n=e._instanceClients[t]))throw Error("[ZAF SDK] Could not find client for instance "+t);return n}(e,n.instanceGuid);if(n.id&&(i=y[n.id]))!function(e,t){if(t.error){var n=t.error.name?A(t.error):t.error;e.reject(n)}else e.resolve(t.result)}(i,n);else if(_.test(n.key)){var s=n.key.replace(_,""),o={appGuid:e._appGuid};if(n.needsReply)return function(e,t,n){if(!e._repliesPending[t])return n.key="iframe.reply:"+t,e._repliesPending[t]=!0,l(e._messageHandlers[t]).then(j.bind(null,e,n)).catch((t=>{var i=t instanceof Error?t.message:t;n.error={msg:i},j(e,n)})).then((()=>{delete e._repliesPending[t]}))}(r,s,o);!function(e,t,n){if(!e._messageHandlers[t])return!1;e._messageHandlers[t].forEach((e=>{e(n)}))}(r,s,n.message)}}}}function O(e,t){if(!("string"==typeof e))return t;var n=t.errors&&t.errors[e];if(n)throw A(n);return t}window.Promise=v;class N{constructor(e){if(this._parent=e.parent,this._origin=e.origin||this._parent&&this._parent._origin,this._source=e.source||this._parent&&this._parent._source||window.parent,this._appGuid=e.appGuid||this._parent&&this._parent._appGuid,this._instanceGuid=e.instanceGuid||this._appGuid,this._messageHandlers={},this._repliesPending={},this._instanceClients={},this._metadata=null,this._context=e.context||null,this._iframe_session_timeout=e.iframe_session_timeout||3e5,this._idleState=null,this.ready=!1,!function(e){if(e)for(var t=[/^https?:\/\/127.0.0.1(:\d+)?$/,/^https?:\/\/localhost(:\d+)?$/,/^https:\/\/.+\.zendesk\.com$/,/^https:\/\/.+\.zd-staging\.com$/,/^https:\/\/.+\.zd-dev\.com$/,/^https:\/\/.+\.zd-master\.com$/,/^https:\/\/.+\.zendesk-staging\.com$/,/^https?:\/\/.+\.zopim\.com(:\d+)?$/,/^https:\/\/dashboard\.zopim\.org$/,/^https:\/\/.+\.futuresimple\.com$/,/^https:\/\/.+\.cloudhatchery\.com$/,/^https:\/\/.+\.idealwith\.com$/,/^https:\/\/.+\.ourtesco\.com$/],n=0;n{this.ready=!0,this._metadata=e.metadata,this._context=e.context,this._iframe_session_timeout=e.iframe_session_timeout,this._idleState=new f.ZP(e.iframe_session_timeout),this._idleState.addObserver((e=>{"active"===e?this.postMessage("session.live"):"idle"===e&&this.postMessage("session.idle")}))}),this),this.on("context.updated",(e=>{this._context=e}),this),this._parent)return this.ready=this._parent.ready,this;new p(this).setup(),window.addEventListener("message",G.bind(null,this)),this.postMessage("iframe.handshake",{version:i})}postMessage(e,t){j(this,JSON.stringify({key:e,message:t,appGuid:this._appGuid,instanceGuid:this._instanceGuid}),"iframe.handshake"===e)}on(e,t,n){"function"==typeof t&&(t=n?t.bind(n):t,this._messageHandlers[e]=this._messageHandlers[e]||[],this._messageHandlers[e].push(t),"app.registered"!==e&&this.postMessage("iframe.on:"+e,{subscriberCount:this._messageHandlers[e].length}))}off(e,t){if(!this._messageHandlers[e])return!1;var n=this._messageHandlers[e].indexOf(t);return this.has(e,t)&&this._messageHandlers[e].splice(n,1),this.postMessage("iframe.off:"+e,{subscriberCount:this._messageHandlers[e].length}),t}has(e,t){return!!this._messageHandlers[e]&&-1!==this._messageHandlers[e].indexOf(t)}trigger(e,t){this.postMessage("iframe.trigger:"+e,t)}request(e){if(this._parent)return this._parent.request(e);var t="request:"+k("request");return new v(((n,i)=>{"string"==typeof e&&(e={url:e}),this.on(t+".done",(e=>{n.apply(this,e.responseArgs)})),this.on(t+".fail",(e=>{i.apply(this,e.responseArgs)})),this.postMessage(t,e)}))}instance(e){if(!e||"string"!=typeof e)throw new Error("The instance method expects an `instanceGuid` string.");if(e===this._instanceGuid)return this;if(this._parent)return this._parent.instance(e);var t=this._instanceClients[e];return t||(t=new N({parent:this,instanceGuid:e}),this._instanceClients[e]=t),t}metadata(){return this._parent?this._parent.metadata():new v((e=>{this._metadata?e(this._metadata):this.on("app.registered",(()=>{e(this._metadata)}))}))}context(){if(this._context)return v.resolve(this._context);if(this._instanceGuid&&this._instanceGuid!==this._appGuid){var e="instances."+this._instanceGuid;return this.get(e).then((t=>(this._context=t[e],this._context)))}return new v((e=>{this.on("app.registered",(t=>{e(t.context)}))}))}get(e){var t=Array.isArray(e)?e:[e];if(arguments.length>1||t.some((e=>!d(e))))throw new Error("The get method accepts a string or array of strings.");return x.call(this,"get",t).then(O.bind(null,e))}set(e,t){var n=e;if("string"==typeof e){if(1===arguments.length)throw new Error("The setter requires a value");(n={})[e]=t}if(!function(e){return null!==e&&"object"==typeof e}(n)||Array.isArray(n))throw new Error("The set method accepts a key and value pair, or an object of key and value pairs.");return x.call(this,"set",n).then(O.bind(null,e))}invoke(e){var t={};if("string"==typeof e)t[e]=Array.prototype.slice.call(arguments,1);else{if("object"!=typeof e)throw new Error("Invoke supports string arguments or an object with array of strings.");Object.keys(e).forEach((t=>{var n=e[t];if(!Array.isArray(n)||n.some((e=>!d(e))))throw new Error("Invoke supports string arguments or an object with array of strings.")})),t=e}return x.call(this,"invoke",t).then(O.bind(null,e))}}const P={init:function(e,t){var n=c((t=t||window.location).search),i=c(t.hash),r=n.origin||i.origin,s=n.app_guid||i.app_guid;if(!r||!s)return!1;var o=new N({origin:r,appGuid:s});return"function"==typeof e&&o.on("app.registered",e.bind(o)),o}}},459:function(e,t,n){var i,r,s,o;r="Promise",s=void 0!==n.g?n.g:this,o=function(){"use strict";var e,t,n,i=Object.prototype.toString,r="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,t,n,i){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:!1!==i})}}catch(t){e=function(e,t,n){return e[t]=n,e}}function s(e,i){n.add(e,i),t||(t=r(n.drain))}function o(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function a(){for(var e=0;e0&&s(a,n))}catch(e){u.call(new l(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&s(a,t))}function d(e,t,n,i){for(var r=0;r{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(459);var i=n(255);return i=i.default})()})); +//# sourceMappingURL=zaf_sdk.js.map \ No newline at end of file diff --git a/dist/zaf_sdk.js.LICENSE.txt b/dist/zaf_sdk.js.LICENSE.txt new file mode 100644 index 00000000..4151354d --- /dev/null +++ b/dist/zaf_sdk.js.LICENSE.txt @@ -0,0 +1,4 @@ +/*! Native Promise Only + v0.8.1 (c) Kyle Simpson + MIT License: http://getify.mit-license.org +*/ diff --git a/dist/zaf_sdk.js.map b/dist/zaf_sdk.js.map new file mode 100644 index 00000000..92505a40 --- /dev/null +++ b/dist/zaf_sdk.js.map @@ -0,0 +1 @@ +{"version":3,"file":"zaf_sdk.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAmB,UAAID,IAEvBD,EAAgB,UAAIC,IARtB,CAS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K,OAAOgG,UAAUuE,eAAerT,KAAKgE,EAAKoP,GCGlFZ,EAAoB,KACpB,IAAIc,EAAsBd,EAAoB","sources":["webpack://ZAFClient/webpack/universalModuleDefinition","webpack://ZAFClient/./lib/utils/environment.ts","webpack://ZAFClient/./lib/utils/idleState.ts","webpack://ZAFClient/./lib/utils/listeners.ts","webpack://ZAFClient/./lib/utils.js","webpack://ZAFClient/./lib/tracker.js","webpack://ZAFClient/./lib/client.js","webpack://ZAFClient/./lib/index.js","webpack://ZAFClient/./node_modules/native-promise-only/lib/npo.src.js","webpack://ZAFClient/webpack/bootstrap","webpack://ZAFClient/webpack/runtime/compat get default export","webpack://ZAFClient/webpack/runtime/define property getters","webpack://ZAFClient/webpack/runtime/global","webpack://ZAFClient/webpack/runtime/hasOwnProperty shorthand","webpack://ZAFClient/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ZAFClient\"] = factory();\n\telse\n\t\troot[\"ZAFClient\"] = factory();\n})(self, function() {\nreturn ","const NODE_ENV = process.env['NODE_ENV'];\n\nexport const isProduction = NODE_ENV === 'production';\n\nexport const isDevelopment = NODE_ENV === 'development';\n\nexport const isTest = NODE_ENV === 'test';\n","import Observers, { ListenerFunction } from './listeners';\n\n/*\n IdleState let you know if the application is active or idle. The application is considered idle if not user\n interactions have been detected for a specific amount of time (timeout). To use IdleState, you first create an\n IdleState instance, then you can either get the current state from the instance or add an observer to be called each\n time the state changes.\n\n When creating an instance, you can provide a timeout, by default timeout of 3 minutes is used. When done with the\n IdleState instance, you must call the delete method to release it.\n\n If several consumers create an idleState with the same timeout, only one instance is created. The instance is shared\n between the consumers.\n\n Syntax:\n new IdleState();\n new IdleState(timeout);\n\n timeout: timeout in milliseconds, default is 3 minutes.\n\n Properties:\n IdleState.state:\n current state as string, either 'active' or 'idle', read only.\n\n Methods:\n IdleState.addObserver(observer):\n Add an observer to be called when the idle state changes. The observer receives the new state as parameter. You\n can several observers.\n Returns a function to be called to remove the observer.\n\n IdleState.delete():\n Release the IdleState instance. As the same instance can be shared with multiple consumers, it's important to call\n delete() when done with it. But first, you should remove any observer you have added, else they will still be\n called until all consumers have released the instance.\n\n Usage:\n import IdleState from 'utils/IdleState';\n\n // Create an instance with a timeout of 2 minutes\n const idleState = new IdleState(2 * 60 * 1000);\n\n // Add an observer\n const removeObserver = idleState.addObserver(state => {\n if (state === 'active') {\n // ... application is now active\n } else if (state === 'idle') {\n // ... application is now idle\n }\n });\n\n // Read the current state\n const currentState = idleState.state;\n\n // When done, release the instance, but first remove the observer\n removeObserver();\n idleState.delete();\n*/\n\nimport { isTest } from './environment';\nexport const STATE_ACTIVE = 'active';\nexport const STATE_IDLE = 'idle';\n\nconst USER_EVENTS = ['mousemove', 'keydown', 'wheel', 'mousedown', 'touchstart', 'touchmove'];\n// list of user events to ignore when window hasn't focus as string, i.e. 'mousemove touchmove'\nconst IGNORED_USER_EVENTS = 'mousemove';\n\nconst stateProperty = Symbol('state');\n\nconst setState = (idleState: IdleState, state: 'active' | 'idle') => {\n if (idleState[stateProperty] !== state) {\n idleState[stateProperty] = state;\n idleState.observers && idleState.observers.call(state);\n }\n};\nclass IdleState {\n refcount?: number;\n timeout?: number;\n [stateProperty]: 'active' | 'idle';\n hasActiveEvent?: boolean;\n timer?: number | null;\n hasFocus?: boolean;\n userEventListenerAdded?: boolean;\n observers?: Observers;\n setState?: (state: 'active' | 'idle') => void;\n\n constructor(timeout) {\n this.timeout = timeout;\n this[stateProperty] = STATE_ACTIVE;\n this.hasActiveEvent = true;\n this.timer = null;\n this.hasFocus = true;\n this.userEventListenerAdded = false;\n this.observers = new Observers();\n\n this.refcount = 1;\n\n // Bind callbacks\n this.handleVisibilityChange = this.handleVisibilityChange.bind(this);\n this.handleFocusChange = this.handleFocusChange.bind(this);\n this.handleUserEvent = this.handleUserEvent.bind(this);\n this.handleTimer = this.handleTimer.bind(this);\n\n // Install listeners and timer\n document.addEventListener('visibilitychange', this.handleVisibilityChange, true);\n\n // Because Safari dispatches focus events before visibilitychange, we need to register focus/blurr listener here\n // and not inside handleVisibilityChange with the other event listeners\n window.addEventListener('focus', this.handleFocusChange, true);\n window.addEventListener('blur', this.handleFocusChange, true);\n\n this.handleVisibilityChange();\n this.resetTimer();\n\n // Add access to setState for testing\n if (isTest) {\n this.setState = (state) => {\n setState(this, state);\n };\n }\n }\n\n delete(): void {\n if (this.refcount !== undefined && --this.refcount === 0) {\n document.removeEventListener('visibilitychange', this.handleVisibilityChange, true);\n window.removeEventListener('focus', this.handleFocusChange, true);\n window.removeEventListener('blur', this.handleFocusChange, true);\n\n if (this.userEventListenerAdded) {\n USER_EVENTS.forEach((type) =>\n document.removeEventListener(type, this.handleUserEvent, true)\n );\n }\n\n this.clearTimer();\n delete this.observers;\n }\n }\n\n get state(): 'active' | 'idle' {\n return this[stateProperty];\n }\n\n clearTimer(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = undefined;\n }\n }\n\n resetTimer(): void {\n this.clearTimer();\n this.timer = window.setTimeout(this.handleTimer, this.timeout);\n }\n\n handleTimer(): void {\n this.resetTimer();\n\n if (this.hasActiveEvent) {\n // we had user events during last timeout cycle,\n // do not set state to idle yet\n this.hasActiveEvent = false;\n } else {\n // we did not have user event during last timeout cycle,\n // set state to idle now\n setState(this, STATE_IDLE);\n }\n }\n\n markActive(): void {\n this.hasActiveEvent = true;\n setState(this, STATE_ACTIVE);\n }\n\n handleUserEvent(event: Event): void {\n if (!this.hasFocus && IGNORED_USER_EVENTS.includes(event.type)) return;\n\n this.markActive();\n }\n\n handleFocusChange(event: Event): void {\n // we only care about focus/blur event related to the window itself\n if (event.target !== window) return;\n\n this.hasFocus = event.type === 'focus';\n if (this.hasFocus) {\n this.markActive();\n }\n }\n\n handleVisibilityChange(): void {\n if (document.hidden) {\n if (this.userEventListenerAdded) {\n USER_EVENTS.forEach((type) =>\n document.removeEventListener(type, this.handleUserEvent, true)\n );\n this.userEventListenerAdded = false;\n }\n } else if (!this.userEventListenerAdded) {\n USER_EVENTS.forEach((type) => document.addEventListener(type, this.handleUserEvent, true));\n this.userEventListenerAdded = true;\n }\n }\n\n addObserver(observer: ListenerFunction): (() => void) | undefined {\n return this.observers && this.observers.add(observer);\n }\n}\n\nexport default IdleState;\n","export type ListenerFunction = (...args: unknown[]) => void;\n\ninterface Listener {\n fn: ListenerFunction;\n count: number;\n}\n\nclass Listeners {\n private listeners: Listener[];\n\n constructor() {\n this.listeners = [];\n }\n\n add(listener: ListenerFunction): () => void {\n const find = (listener: ListenerFunction) =>\n this.listeners.findIndex((item) => item.fn === listener);\n\n const index = find(listener);\n if (index === -1) {\n this.listeners.push({ fn: listener, count: 1 });\n } else {\n const listener = this.listeners[index];\n listener && listener.count++;\n }\n\n return () => {\n const index = find(listener);\n\n if (index !== -1) {\n const listener = this.listeners[index];\n listener && listener.count--;\n if (listener && listener.count === 0) {\n this.listeners.splice(index, 1);\n }\n }\n };\n }\n\n call(...args: unknown[]): void {\n this.listeners.forEach((listener) => listener.fn(...args));\n }\n}\n\nexport default Listeners;\n","import NativePromise from 'native-promise-only'\nconst Promise = window.Promise || NativePromise\n\nexport function isObject (obj) {\n return (obj !== null && typeof obj === 'object')\n}\n\nfunction decode (s) {\n return decodeURIComponent((s || '').replace(/\\+/g, ' '))\n}\n\nexport function queryParameters (queryString) {\n queryString = queryString || ''\n\n const result = {}\n let keyValuePairs, keyAndValue, key, value\n\n if (queryString.search(/\\?|#/) === 0) {\n queryString = queryString.slice(1)\n }\n\n if (queryString.length === 0) { return result }\n\n keyValuePairs = queryString.split('&')\n\n for (let i = 0; i < keyValuePairs.length; i++) {\n keyAndValue = keyValuePairs[i].split('=')\n key = decode(keyAndValue[0])\n value = decode(keyAndValue[1]) || ''\n result[key] = value\n }\n\n return result\n}\n\nfunction isPromise (obj) {\n if (obj instanceof Promise) return true\n return !!obj && obj.then && typeof obj.then === 'function'\n}\n\nfunction shouldReject (val) {\n return val === false ||\n val instanceof Error ||\n typeof val === 'string'\n}\n\nexport function isString (key) {\n return typeof key === 'string'\n}\n\n// When receives a list of things to wrap as Promises.\n// it will then wait for:\n// a) all to settle\n// b) first to reject\n// c) first to settle with a falsy value\n// c) is sub-optimal, since it has a specific narrow use-case\n// for save hooks\nexport function when (items) {\n items = items || []\n let resolveAll, rejectAll\n const allResolvedPromise = new Promise((resolve, reject) => {\n resolveAll = resolve\n rejectAll = reject\n })\n\n let remaining = 0\n const settledWith = []\n const itemsCopy = Array.isArray(items) ? items.slice() : [items]\n\n function resolveWith (data, index) {\n settledWith[index] = data\n\n if (--remaining <= 0) {\n resolveAll(settledWith)\n }\n }\n\n remaining = itemsCopy.length\n\n if (remaining <= 0) {\n resolveAll()\n return allResolvedPromise\n }\n\n itemsCopy.forEach((item, index) => {\n let promise\n if (isPromise(item)) {\n promise = item\n } else if (typeof item === 'function') {\n let res\n try {\n res = item()\n if (isPromise(res)) {\n promise = res\n } else if (shouldReject(res)) {\n promise = Promise.reject(res)\n } else {\n promise = Promise.resolve(res)\n }\n } catch (err) {\n promise = Promise.reject(err)\n }\n } else {\n promise = new Promise((resolve, reject) => {\n shouldReject(item)\n ? reject(item)\n : resolve(item)\n })\n }\n promise.then((data) => {\n resolveWith(data, index)\n }).catch(rejectAll.bind(rejectAll))\n })\n\n return allResolvedPromise\n}\n","export default class Tracker {\n constructor (client) {\n this.startTime = Date.now()\n this.client = client\n this.MIN_HOVER_TIME = 200 // milliseconds\n }\n\n handleMouseEnter () {\n this.startTime = Date.now()\n }\n\n handleMouseLeave () {\n const overFor = Date.now() - this.startTime\n if (overFor >= this.MIN_HOVER_TIME) {\n this.client.invoke('track', { type: 'hover', value: overFor })\n }\n }\n\n handleClick () {\n this.client.invoke('track', { type: 'click' })\n }\n\n setup () {\n const $html = document.querySelector('html')\n $html.addEventListener('click', this.handleClick.bind(this))\n $html.addEventListener('mouseleave', this.handleMouseLeave.bind(this))\n $html.addEventListener('mouseenter', this.handleMouseEnter.bind(this))\n }\n}\n","/* global URL */\nimport pkgJson from '../package.json'\nimport { when, isObject, isString } from './utils'\nimport IdleState from './utils/idleState'\nimport Tracker from './tracker'\nimport NativePromise from 'native-promise-only'\n\nconst Promise = window.Promise || NativePromise\n\nexport const IFRAME_SESSION_TIMEOUT = 5 * 60 * 1000 // Set timeout for iframe sessions to 5 minutes.\nexport const PROMISE_TIMEOUT = 10000\n// 10 seconds, see ZD#4058685\nexport const PROMISE_TIMEOUT_LONG = 5 * 60 * 1000\n// Set a high timeout threshold to allow us to better gauge the time taken for successful requests\nconst NO_TIMEOUT_ACTIONS = ['instances.create']\nconst ZAF_EVENT = /^zaf\\./\nconst pendingPromises = {}\nconst ids = {}\n\n// // export Promise!\nwindow.Promise = Promise\n\n// @internal\n// #timeoutReject(rejectionFn, name, client, params)\n//\n// Reject a request if required, given the rejection function, name (get, set or invoke)\n// and arguments to that request. Falls back to 10000 second timeout with few exceptions.\n//\nfunction timeoutReject (client, reject, name, paramsArray) {\n const actions = collateActions(name, paramsArray)\n switch (name) {\n case 'invoke': {\n const matches = paramsArray.filter((action) => {\n return NO_TIMEOUT_ACTIONS.indexOf(action) !== -1\n })\n const allWhitelisted = matches.length === paramsArray.length\n if (allWhitelisted) {\n return NaN // timer IDs are numbers; embrace the JavaScript 😬\n } else {\n const notAllWhitelisted = matches.length !== 0\n if (notAllWhitelisted) {\n throw new Error('Illegal bulk call - `instances.create` must be called separately.')\n }\n return defaultTimer(client, actions, reject)\n }\n }\n default: {\n return defaultTimer(client, actions, reject)\n }\n }\n}\n\nfunction defaultTimer (client, actions, callback) {\n return setTimeout(() => {\n trackSDKRequestTimeout(client, actions, PROMISE_TIMEOUT_LONG)\n callback(new Error('Invocation request timeout'))\n }, PROMISE_TIMEOUT_LONG)\n}\n\nexport function collateActions (name, params) { return params.map(action => `${name}-${action}`) }\n\nexport function stripActionArgs (action) {\n // Capture:\n // 1. single or multiple comma-delimited arguments following an initial colon, and\n // 2. non-whitelisted, unescaped words following a period (i.e. file extensions in the case of assetURL calls)\n const ACTION_ARGS = /:\\w+(,?\\w+)*((\\.(show|hide|enable|disable))|(\\\\?\\.\\w*))?/g\n // Return :arg.field_modifier, where field modifier is (optionally) one of 'show', 'hide', 'enable' or 'disable'\n return action.replace(ACTION_ARGS, ':arg$3')\n}\n\nexport function timeMsToSecondsRange (value, upperLimit = PROMISE_TIMEOUT_LONG) {\n if (value >= upperLimit) return `${upperLimit / 1000}-`\n const lowerRangeBound = value - (value % 10000)\n return `${lowerRangeBound / 1000}-${(lowerRangeBound + 10000) / 1000}`\n}\n\nexport function trackSDKRequestTimeout (client, actions, requestResponseTime) {\n const actionsTags = actions.map(action => `action:${stripActionArgs(action)}`)\n const responseTimeTag = `request_response_time:${timeMsToSecondsRange(requestResponseTime)}`\n client.postMessage('__track__', {\n event_name: 'sdk_request_timeout',\n event_type: 'increment',\n data: 1,\n tags: actionsTags.concat(responseTimeTag)\n })\n}\n\nfunction nextIdFor (name) {\n if (isNaN(ids[name])) {\n ids[name] = 0\n }\n return ++ids[name]\n}\n\n// @internal\n// #### rawPostMessage(client, msg, forceReady)\n//\n// Post a message to the hosting frame.\n// If the client is not ready and forceReady is not specified, it will wait for client registration.\n//\nfunction rawPostMessage (client, msg, forceReady) {\n if (client.ready || forceReady) {\n client._source.postMessage(msg, client._origin)\n } else {\n client.on('app.registered', rawPostMessage.bind(null, client, msg))\n }\n}\n\n// @internal\n// #### wrappedPostMessage(name, params)\n//\n// Wraps post message with a request/response mechanism using Promises.\n// Must be invoked in the context of a Client.\n//\n// ##### Arguments\n//\n// * `name` the name of the request to make (get/set/invoke)\n// * `params` parameters of the request (an array for get, and an object for set/invoke)\n//\nfunction wrappedPostMessage (name, params) {\n const id = nextIdFor('promise')\n let timeoutId, promiseStartTime\n const paramsArray = Array.isArray(params) ? params : Object.keys(params)\n const actions = collateActions(name, paramsArray)\n const client = this\n\n const promise = new Promise((resolve, reject) => {\n promiseStartTime = window.performance.now()\n\n // Time out the promise to ensure it will be garbage collected if nobody responds\n timeoutId = timeoutReject(client, reject, name, paramsArray)\n pendingPromises[id] = { resolve, reject }\n\n const msg = JSON.stringify({\n id: id,\n request: name,\n params: params,\n appGuid: client._appGuid,\n instanceGuid: client._instanceGuid\n })\n rawPostMessage(client, msg)\n })\n\n const trackTimeoutWithResolutionTime = () => {\n const promiseResolutionTime = window.performance.now() - promiseStartTime\n if (promiseResolutionTime > PROMISE_TIMEOUT) {\n trackSDKRequestTimeout(client, actions, promiseResolutionTime)\n }\n }\n\n // ensure promise is cleaned up when resolved/rejected, track request performance for resolved promises\n return promise.then(\n removePromise.bind(null, { id, timeoutId, trackTimeoutWithResolutionTime }),\n removePromise.bind(null, { id, timeoutId })\n )\n}\n\nfunction createError (error) {\n if (error.path) { error.message = '\"' + error.path + '\" ' + error.message }\n const err = new Error(error.message)\n err.name = error.name\n err.stack = error.stack\n return err\n}\n\nfunction removePromise (options, args) {\n clearTimeout(options.timeoutId)\n delete pendingPromises[options.id]\n options.trackTimeoutWithResolutionTime && options.trackTimeoutWithResolutionTime()\n if (args instanceof Error) throw args\n return args\n}\n\nfunction isValidEvent (client, event) {\n return client && client._origin === event.origin && client._source === event.source\n}\n\nfunction triggerEvent (client, eventName, data) {\n if (!client._messageHandlers[eventName]) { return false }\n client._messageHandlers[eventName].forEach((handler) => {\n handler(data)\n })\n}\n\nfunction finalizePendingPromise (pendingPromise, data) {\n if (data.error) {\n const error = data.error.name ? createError(data.error) : data.error\n pendingPromise.reject(error)\n } else {\n pendingPromise.resolve(data.result)\n }\n}\n\nfunction postReplyWith (client, key, msg) {\n if (client._repliesPending[key]) { return }\n msg.key = 'iframe.reply:' + key\n client._repliesPending[key] = true\n return when(client._messageHandlers[key]).then(\n rawPostMessage.bind(null, client, msg)\n ).catch((reason) => {\n // if the handler throws an error we want to send back its message, but\n // Error objects don't pass through the postMessage boundary.\n const rejectMessage = reason instanceof Error ? reason.message : reason\n msg.error = {\n msg: rejectMessage\n }\n rawPostMessage(client, msg)\n }).then(() => {\n delete client._repliesPending[key]\n })\n}\n\nfunction getMessageRecipient (client, recipientGuid) {\n let messageRecipient = client\n\n if (recipientGuid && recipientGuid !== client._instanceGuid) {\n messageRecipient = client._instanceClients[recipientGuid]\n\n if (!messageRecipient) {\n throw Error('[ZAF SDK] Could not find client for instance ' + recipientGuid)\n }\n }\n\n return messageRecipient\n}\n\nfunction messageHandler (client, event) {\n if (!isValidEvent(client, event)) { return }\n\n let data = event.data\n\n if (!data) { return }\n\n if (typeof data === 'string') {\n try {\n data = JSON.parse(event.data)\n } catch (e) {\n return e\n }\n }\n\n const clientRecipient = getMessageRecipient(client, data.instanceGuid)\n let pendingPromise\n\n if (data.id && (pendingPromise = pendingPromises[data.id])) {\n finalizePendingPromise(pendingPromise, data)\n } else if (ZAF_EVENT.test(data.key)) {\n const key = data.key.replace(ZAF_EVENT, '')\n const msg = { appGuid: client._appGuid }\n\n if (data.needsReply) {\n return postReplyWith(clientRecipient, key, msg)\n } else {\n triggerEvent(clientRecipient, key, data.message)\n }\n }\n}\n\n// When doing singular operations and we retrieve an error this function will throw that error\nfunction processResponse (path, result) {\n const isSingularOperation = typeof path === 'string'\n\n if (!isSingularOperation) {\n return result\n }\n\n // CRUFT: When framework starts always appending errors we can remove the extra results.errors check\n const err = result.errors && result.errors[path]\n if (err) {\n throw createError(err)\n }\n\n return result\n}\n\nfunction isOriginValid (origin) {\n if (origin) {\n const WHITELISTED_ORIGINS = [\n /^https?:\\/\\/127.0.0.1(:\\d+)?$/,\n /^https?:\\/\\/localhost(:\\d+)?$/,\n /^https:\\/\\/.+\\.zendesk\\.com$/,\n /^https:\\/\\/.+\\.zd-staging\\.com$/,\n /^https:\\/\\/.+\\.zd-dev\\.com$/,\n /^https:\\/\\/.+\\.zd-master\\.com$/,\n /^https:\\/\\/.+\\.zendesk-staging\\.com$/,\n // Zendesk Chat domains:\n /^https?:\\/\\/.+\\.zopim\\.com(:\\d+)?$/,\n /^https:\\/\\/dashboard\\.zopim\\.org$/,\n // Zendesk Sell domains:\n /^https:\\/\\/.+\\.futuresimple\\.com$/,\n /^https:\\/\\/.+\\.cloudhatchery\\.com$/,\n /^https:\\/\\/.+\\.idealwith\\.com$/,\n // Tesco domains:\n /^https:\\/\\/.+\\.ourtesco\\.com$/\n ]\n\n for (let i = 0; i < WHITELISTED_ORIGINS.length; i++) {\n if (WHITELISTED_ORIGINS[i].test(origin)) {\n return true\n }\n }\n }\n\n return false\n}\n\nfunction clearDocument () {\n document.body = document.createElement('body')\n\n const iframeHead = document.head\n iframeHead && iframeHead.remove()\n}\n\nfunction appendErrorToBody (errorMsg) {\n var errorElement = document.createElement('h3')\n var errorTextNode = document.createTextNode(errorMsg)\n\n errorElement.appendChild(errorTextNode)\n document.body.appendChild(errorElement)\n}\n\nexport default class Client {\n constructor (options) {\n this._parent = options.parent\n this._origin = options.origin || (this._parent && this._parent._origin)\n this._source = options.source || (this._parent && this._parent._source) || window.parent\n this._appGuid = options.appGuid || (this._parent && this._parent._appGuid)\n this._instanceGuid = options.instanceGuid || this._appGuid\n this._messageHandlers = {}\n this._repliesPending = {}\n this._instanceClients = {}\n this._metadata = null\n this._context = options.context || null\n this._iframe_session_timeout = options.iframe_session_timeout || IFRAME_SESSION_TIMEOUT\n this._idleState = null\n this.ready = false\n\n if (!isOriginValid(this._origin)) {\n const originHostname = new URL(this._origin).hostname\n this.postMessage('__track__', {\n event_name: 'invalid_sdk_origin',\n event_type: 'increment',\n data: 1,\n tags: ['origin:' + originHostname]\n })\n\n clearDocument()\n appendErrorToBody(`Invalid domain ${this._origin}`)\n }\n\n this.on('app.registered', (data) => {\n this.ready = true\n this._metadata = data.metadata\n this._context = data.context\n this._iframe_session_timeout = data.iframe_session_timeout\n this._idleState = new IdleState(data.iframe_session_timeout)\n // Add an observer. This will be called when the idleState changes\n this._idleState.addObserver(state => {\n if (state === 'active') {\n // ... application is now active, timeout clock is reset to zero\n // Send a postMessage indicating liveness + possibly a payload too\n this.postMessage('session.live')\n } else if (state === 'idle') {\n // ... application is now idle, timeout clock is ticking\n // Send a postMessage indicating sessionTimeout + possibly a payload too\n this.postMessage('session.idle')\n }\n })\n }, this)\n\n this.on('context.updated', (context) => {\n this._context = context\n }, this)\n\n if (this._parent) {\n this.ready = this._parent.ready\n return this // shortcut handshake\n }\n\n const tracker = new Tracker(this)\n tracker.setup()\n window.addEventListener('message', messageHandler.bind(null, this))\n this.postMessage('iframe.handshake', { version: pkgJson.version })\n }\n\n /**\n * ### Client Object\n *\n * #### client.postMessage(name, [data])\n *\n * Allows you to send message events to the Zendesk app.\n *\n * ##### Arguments\n *\n * * `name` the name of the message event. This determines the name of the iframe\n * event your app will receive. For example, if you set this to 'hello', your app will receive\n * the event 'iframe.hello'\n * * `data` (optional) a JSON object with any data that you want to pass along with the\n * event\n *\n * ```javascript\n * const client = ZAFClient.init();\n * client.postMessage('hello', { awesome: true });\n * ``\n */\n postMessage (name, data) {\n const msg = JSON.stringify({ key: name, message: data, appGuid: this._appGuid, instanceGuid: this._instanceGuid })\n rawPostMessage(this, msg, name === 'iframe.handshake')\n }\n\n /**\n * #### client.on(name, handler, [context])\n *\n * Allows you to add handlers to a framework event. You can add as many handler as you wish.\n * They will be executed in the order they were added.\n *\n * ##### Arguments\n *\n * * `name` the name of the framework event you want to listen to. This can be\n * [framework](./events.html#framework-events), [request](./events.html#request-events), or\n * [custom](./events.html#custom-events) events. Your iframe can listen to any events your app\n * receives, apart from DOM events. You don't need to register these events in the app first\n * * `handler` a function to be called when this event fires. You can expect to receive the same\n * event object your app would receive, parsed as JSON\n * * `context` (optional) the value of `this` within your handler\n *\n * ```javascript\n * const client = ZAFClient.init();\n * client.on('app.registered', (e) => {\n * // go nuts\n * });\n * ```\n *\n * Note: As soon as communication with the Zendesk app is established, the SDK triggers an\n * `app.registered` event. You can add as many handlers to `app.registered` as you like. They're\n * called immediately after the `init` callback\n */\n on (name, handler, context) {\n if (typeof handler === 'function') {\n handler = context\n ? handler.bind(context)\n : handler\n\n this._messageHandlers[name] = this._messageHandlers[name] || []\n this._messageHandlers[name].push(handler)\n\n if (name !== 'app.registered') {\n // Subscriber count is needed as the framework will only bind events on the first attached handler\n this.postMessage('iframe.on:' + name, { subscriberCount: this._messageHandlers[name].length })\n }\n }\n }\n\n /**\n * #### client.off(name, handler)\n *\n * Allows you to remove a handler for a framework event.\n *\n * ##### Arguments\n *\n * * `name` the name of the event\n * * `handler` the function you attached earlier with `on`\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.on('app.registered', function appRegistered(e) {\n * // do stuff then remove the handler\n * client.off('app.registered', appRegistered);\n * });\n * ``\n */\n off (name, handler) {\n if (!this._messageHandlers[name]) { return false }\n const index = this._messageHandlers[name].indexOf(handler)\n if (this.has(name, handler)) {\n this._messageHandlers[name].splice(index, 1)\n }\n\n // Subscriber count is needed as the framework will only unbind events on the last detached handler (count of 0)\n this.postMessage('iframe.off:' + name, { subscriberCount: this._messageHandlers[name].length })\n return handler\n }\n\n /**\n * #### client.has(name, handler)\n *\n * Returns whether or not an event has the specified handler attached to it.\n *\n * ##### Arguments\n *\n * * `name` the name of the event\n * * `handler` the handler you want to test\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.on('app.registered', function appRegistered(e) {\n * // do stuff\n * });\n *\n * client.has('app.registered', appRegistered); // true\n * client.has('app.activated', appRegistered); // false\n * ``\n */\n has (name, handler) {\n if (!this._messageHandlers[name]) { return false }\n return this._messageHandlers[name].indexOf(handler) !== -1\n }\n\n /**\n * #### client.trigger(name, [data])\n *\n * Triggers the specified event on the client.\n *\n * ##### Arguments\n *\n * * `name` the name of the event you want to trigger\n * * `data` (optional) data you want to pass to the handler\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.on('activation', () => {\n * console.log('activating!')\n * });\n *\n * client.trigger('activation') // activating!\n * ``\n */\n trigger (name, data) {\n this.postMessage('iframe.trigger:' + name, data)\n }\n\n /**\n * #### client.request(options)\n *\n * Dispatch [requests](./requests) via the Zendesk app.\n *\n * ##### Arguments\n *\n * * `options` the url of the request or an options object containing a url key/value\n *\n * ##### Returns\n *\n * A [Promises/A+](https://promisesaplus.com) conformant `promise` object.\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.request('/api/v2/tickets.json').then(\n * (tickets) => {\n * console.log(tickets);\n * },\n * (response) => {\n * console.error(response.responseText);\n * }\n * );\n * ``\n */\n request (options) {\n if (this._parent) { return this._parent.request(options) }\n const requestKey = 'request:' + nextIdFor('request')\n\n return new Promise((resolve, reject) => {\n if (typeof options === 'string') {\n options = { url: options }\n }\n\n this.on(requestKey + '.done', (evt) => {\n resolve.apply(this, evt.responseArgs)\n })\n\n this.on(requestKey + '.fail', (evt) => {\n reject.apply(this, evt.responseArgs)\n })\n\n this.postMessage(requestKey, options)\n })\n }\n\n instance (instanceGuid) {\n if (!instanceGuid || typeof instanceGuid !== 'string') {\n throw new Error('The instance method expects an `instanceGuid` string.')\n }\n if (instanceGuid === this._instanceGuid) { return this }\n if (this._parent) { return this._parent.instance(instanceGuid) }\n let instanceClient = this._instanceClients[instanceGuid]\n if (!instanceClient) {\n instanceClient = new Client({\n parent: this,\n instanceGuid: instanceGuid\n })\n this._instanceClients[instanceGuid] = instanceClient\n }\n return instanceClient\n }\n\n metadata () {\n if (this._parent) { return this._parent.metadata() }\n return new Promise((resolve) => {\n if (this._metadata) {\n resolve(this._metadata)\n } else {\n this.on('app.registered', () => {\n resolve(this._metadata)\n })\n }\n })\n }\n\n context () {\n if (this._context) {\n return Promise.resolve(this._context)\n } else {\n if (this._instanceGuid && this._instanceGuid !== this._appGuid) {\n const key = 'instances.' + this._instanceGuid\n return this.get(key).then((data) => {\n this._context = data[key]\n return this._context\n })\n } else {\n return new Promise((resolve) => {\n this.on('app.registered', (data) => {\n resolve(data.context)\n })\n })\n }\n }\n }\n\n // Accepts string or array of strings.\n get (path) {\n const paths = Array.isArray(path) ? path : [path]\n\n if (arguments.length > 1 || paths.some((path) => { return !isString(path) })) {\n throw new Error('The get method accepts a string or array of strings.')\n }\n\n return wrappedPostMessage.call(this, 'get', paths).then(processResponse.bind(null, path))\n }\n\n set (key, val) {\n let obj = key\n\n if (typeof key === 'string') {\n if (arguments.length === 1) {\n throw new Error('The setter requires a value')\n }\n obj = {}\n obj[key] = val\n }\n\n if (!isObject(obj) || Array.isArray(obj)) {\n throw new Error('The set method accepts a key and value pair, or an object of key and value pairs.')\n }\n\n return wrappedPostMessage.call(this, 'set', obj).then(processResponse.bind(null, key))\n }\n\n invoke (keyOrObject) {\n let obj = {}\n\n if (typeof keyOrObject === 'string') {\n obj[keyOrObject] = Array.prototype.slice.call(arguments, 1)\n } else if (typeof keyOrObject === 'object') {\n // Validate object\n Object.keys(keyOrObject).forEach((key) => {\n const methodArgs = keyOrObject[key]\n\n if (!Array.isArray(methodArgs) || methodArgs.some((arg) => { return !isString(arg) })) {\n throw new Error('Invoke supports string arguments or an object with array of strings.')\n }\n })\n\n obj = keyOrObject\n } else {\n throw new Error('Invoke supports string arguments or an object with array of strings.')\n }\n\n return wrappedPostMessage.call(this, 'invoke', obj).then(processResponse.bind(null, keyOrObject))\n }\n}\n","import Client from './client'\nimport { queryParameters } from './utils'\n\n/**\n * ### ZAFClient API\n *\n * When you include the ZAF SDK on your website, you get access to the `ZAFClient` object.\n *\n * #### ZAFClient.init([callback(context)])\n *\n * Returns a [`client`](#client-object) object.\n *\n * ##### Arguments\n *\n * * `callback(context)` (optional) a function called as soon as communication with\n * the Zendesk app is established. The callback receives a context object with\n * data related to the Zendesk app, including `currentAccount`, `currentUser`, and `location`\n *\n * Example:\n *\n * ```javascript\n * const client = ZAFClient.init((context) => {\n * const currentUser = context.currentUser;\n * console.log('Hi ' + currentUser.name);\n * });\n * ```\n */\n\nconst ZAFClient = {\n init: function (callback, loc) {\n loc = loc || window.location\n const queryParams = queryParameters(loc.search)\n const hashParams = queryParameters(loc.hash)\n const origin = queryParams.origin || hashParams.origin\n const appGuid = queryParams.app_guid || hashParams.app_guid\n if (!origin || !appGuid) { return false }\n\n const client = new Client({ origin, appGuid })\n\n if (typeof callback === 'function') {\n client.on('app.registered', callback.bind(client))\n }\n\n return client\n }\n}\n\nexport default ZAFClient\n","/*! Native Promise Only\n v0.8.1 (c) Kyle Simpson\n MIT License: http://getify.mit-license.org\n*/\n\n(function UMD(name,context,definition){\n\t// special form of UMD for polyfilling across evironments\n\tcontext[name] = context[name] || definition();\n\tif (typeof module != \"undefined\" && module.exports) { module.exports = context[name]; }\n\telse if (typeof define == \"function\" && define.amd) { define(function $AMD$(){ return context[name]; }); }\n})(\"Promise\",typeof global != \"undefined\" ? global : this,function DEF(){\n\t/*jshint validthis:true */\n\t\"use strict\";\n\n\tvar builtInProp, cycle, scheduling_queue,\n\t\tToString = Object.prototype.toString,\n\t\ttimer = (typeof setImmediate != \"undefined\") ?\n\t\t\tfunction timer(fn) { return setImmediate(fn); } :\n\t\t\tsetTimeout\n\t;\n\n\t// dammit, IE8.\n\ttry {\n\t\tObject.defineProperty({},\"x\",{});\n\t\tbuiltInProp = function builtInProp(obj,name,val,config) {\n\t\t\treturn Object.defineProperty(obj,name,{\n\t\t\t\tvalue: val,\n\t\t\t\twritable: true,\n\t\t\t\tconfigurable: config !== false\n\t\t\t});\n\t\t};\n\t}\n\tcatch (err) {\n\t\tbuiltInProp = function builtInProp(obj,name,val) {\n\t\t\tobj[name] = val;\n\t\t\treturn obj;\n\t\t};\n\t}\n\n\t// Note: using a queue instead of array for efficiency\n\tscheduling_queue = (function Queue() {\n\t\tvar first, last, item;\n\n\t\tfunction Item(fn,self) {\n\t\t\tthis.fn = fn;\n\t\t\tthis.self = self;\n\t\t\tthis.next = void 0;\n\t\t}\n\n\t\treturn {\n\t\t\tadd: function add(fn,self) {\n\t\t\t\titem = new Item(fn,self);\n\t\t\t\tif (last) {\n\t\t\t\t\tlast.next = item;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfirst = item;\n\t\t\t\t}\n\t\t\t\tlast = item;\n\t\t\t\titem = void 0;\n\t\t\t},\n\t\t\tdrain: function drain() {\n\t\t\t\tvar f = first;\n\t\t\t\tfirst = last = cycle = void 0;\n\n\t\t\t\twhile (f) {\n\t\t\t\t\tf.fn.call(f.self);\n\t\t\t\t\tf = f.next;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t})();\n\n\tfunction schedule(fn,self) {\n\t\tscheduling_queue.add(fn,self);\n\t\tif (!cycle) {\n\t\t\tcycle = timer(scheduling_queue.drain);\n\t\t}\n\t}\n\n\t// promise duck typing\n\tfunction isThenable(o) {\n\t\tvar _then, o_type = typeof o;\n\n\t\tif (o != null &&\n\t\t\t(\n\t\t\t\to_type == \"object\" || o_type == \"function\"\n\t\t\t)\n\t\t) {\n\t\t\t_then = o.then;\n\t\t}\n\t\treturn typeof _then == \"function\" ? _then : false;\n\t}\n\n\tfunction notify() {\n\t\tfor (var i=0; i 0) {\n\t\t\t\t\tschedule(notify,self);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (err) {\n\t\t\treject.call(new MakeDefWrapper(self),err);\n\t\t}\n\t}\n\n\tfunction reject(msg) {\n\t\tvar self = this;\n\n\t\t// already triggered?\n\t\tif (self.triggered) { return; }\n\n\t\tself.triggered = true;\n\n\t\t// unwrap\n\t\tif (self.def) {\n\t\t\tself = self.def;\n\t\t}\n\n\t\tself.msg = msg;\n\t\tself.state = 2;\n\t\tif (self.chain.length > 0) {\n\t\t\tschedule(notify,self);\n\t\t}\n\t}\n\n\tfunction iteratePromises(Constructor,arr,resolver,rejecter) {\n\t\tfor (var idx=0; idx {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\n__webpack_require__(459);\nvar __webpack_exports__ = __webpack_require__(255);\n"],"names":["root","factory","exports","module","define","amd","self","isProduction","NODE_ENV","isDevelopment","isTest","USER_EVENTS","stateProperty","Symbol","setState","idleState","state","observers","call","constructor","timeout","this","hasActiveEvent","timer","hasFocus","userEventListenerAdded","refcount","handleVisibilityChange","bind","handleFocusChange","handleUserEvent","handleTimer","document","addEventListener","window","resetTimer","delete","undefined","removeEventListener","forEach","type","clearTimer","clearTimeout","setTimeout","markActive","event","includes","target","hidden","addObserver","observer","add","listeners","listener","find","findIndex","item","fn","index","push","count","splice","args","Promise","NativePromise","decode","s","decodeURIComponent","replace","queryParameters","queryString","keyValuePairs","keyAndValue","key","value","result","search","slice","length","split","i","isPromise","obj","then","shouldReject","val","Error","isString","when","items","resolveAll","rejectAll","allResolvedPromise","resolve","reject","remaining","settledWith","itemsCopy","Array","isArray","promise","res","err","data","resolveWith","catch","Tracker","client","startTime","Date","now","MIN_HOVER_TIME","handleMouseEnter","handleMouseLeave","overFor","invoke","handleClick","setup","$html","querySelector","PROMISE_TIMEOUT_LONG","NO_TIMEOUT_ACTIONS","ZAF_EVENT","pendingPromises","ids","defaultTimer","actions","callback","trackSDKRequestTimeout","collateActions","name","params","map","action","requestResponseTime","actionsTags","stripActionArgs","responseTimeTag","upperLimit","lowerRangeBound","timeMsToSecondsRange","postMessage","event_name","event_type","tags","concat","nextIdFor","isNaN","rawPostMessage","msg","forceReady","ready","_source","_origin","on","wrappedPostMessage","timeoutId","promiseStartTime","id","paramsArray","Object","keys","performance","matches","filter","indexOf","NaN","timeoutReject","JSON","stringify","request","appGuid","_appGuid","instanceGuid","_instanceGuid","removePromise","trackTimeoutWithResolutionTime","promiseResolutionTime","createError","error","path","message","stack","options","messageHandler","origin","source","isValidEvent","parse","e","pendingPromise","clientRecipient","recipientGuid","messageRecipient","_instanceClients","getMessageRecipient","finalizePendingPromise","test","needsReply","_repliesPending","_messageHandlers","reason","rejectMessage","postReplyWith","eventName","handler","triggerEvent","processResponse","errors","Client","_parent","parent","_metadata","_context","context","_iframe_session_timeout","iframe_session_timeout","_idleState","WHITELISTED_ORIGINS","isOriginValid","originHostname","URL","hostname","body","createElement","iframeHead","head","remove","clearDocument","errorMsg","errorElement","errorTextNode","createTextNode","appendChild","metadata","IdleState","version","pkgJson","subscriberCount","off","has","trigger","requestKey","url","evt","apply","responseArgs","instance","instanceClient","get","paths","arguments","some","set","isObject","keyOrObject","prototype","methodArgs","arg","init","loc","queryParams","location","hashParams","hash","app_guid","definition","g","builtInProp","cycle","scheduling_queue","ToString","toString","setImmediate","defineProperty","config","writable","configurable","schedule","drain","isThenable","o","_then","o_type","notify","chain","notifyIsolated","success","failure","cb","ret","TypeError","triggered","def","def_wrapper","MakeDefWrapper","iteratePromises","Constructor","arr","resolver","rejecter","idx","MakeDef","executor","__NPO__","first","last","Item","next","f","PromisePrototype","len","msgs","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","n","getter","__esModule","d","a","enumerable","globalThis","Function","prop","hasOwnProperty","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/zaf_sdk.min.js b/dist/zaf_sdk.min.js new file mode 100644 index 00000000..bfaca273 --- /dev/null +++ b/dist/zaf_sdk.min.js @@ -0,0 +1,3 @@ +/*! For license information please see zaf_sdk.min.js.LICENSE.txt */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ZAFClient=t():e.ZAFClient=t()}(self,(function(){return(()=>{var e={905:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isTest=t.isDevelopment=t.isProduction=void 0;t.isProduction=!0,t.isDevelopment=!1,t.isTest=!1},94:(e,t,n)=>{"use strict";t.bc=t.EB=void 0;var i=n(74),r=n(905);t.EB="active",t.bc="idle";var s=["mousemove","keydown","wheel","mousedown","touchstart","touchmove"],o=Symbol("state"),a=(e,t)=>{e[o]!==t&&(e[o]=t,e.observers&&e.observers.call(t))};t.ZP=class{constructor(e){this.timeout=e,this[o]=t.EB,this.hasActiveEvent=!0,this.timer=null,this.hasFocus=!0,this.userEventListenerAdded=!1,this.observers=new i.default,this.refcount=1,this.handleVisibilityChange=this.handleVisibilityChange.bind(this),this.handleFocusChange=this.handleFocusChange.bind(this),this.handleUserEvent=this.handleUserEvent.bind(this),this.handleTimer=this.handleTimer.bind(this),document.addEventListener("visibilitychange",this.handleVisibilityChange,!0),window.addEventListener("focus",this.handleFocusChange,!0),window.addEventListener("blur",this.handleFocusChange,!0),this.handleVisibilityChange(),this.resetTimer(),r.isTest&&(this.setState=e=>{a(this,e)})}delete(){void 0!==this.refcount&&0==--this.refcount&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange,!0),window.removeEventListener("focus",this.handleFocusChange,!0),window.removeEventListener("blur",this.handleFocusChange,!0),this.userEventListenerAdded&&s.forEach((e=>document.removeEventListener(e,this.handleUserEvent,!0))),this.clearTimer(),delete this.observers)}get state(){return this[o]}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=void 0)}resetTimer(){this.clearTimer(),this.timer=window.setTimeout(this.handleTimer,this.timeout)}handleTimer(){this.resetTimer(),this.hasActiveEvent?this.hasActiveEvent=!1:a(this,t.bc)}markActive(){this.hasActiveEvent=!0,a(this,t.EB)}handleUserEvent(e){!this.hasFocus&&"mousemove".includes(e.type)||this.markActive()}handleFocusChange(e){e.target===window&&(this.hasFocus="focus"===e.type,this.hasFocus&&this.markActive())}handleVisibilityChange(){document.hidden?this.userEventListenerAdded&&(s.forEach((e=>document.removeEventListener(e,this.handleUserEvent,!0))),this.userEventListenerAdded=!1):this.userEventListenerAdded||(s.forEach((e=>document.addEventListener(e,this.handleUserEvent,!0))),this.userEventListenerAdded=!0)}addObserver(e){return this.observers&&this.observers.add(e)}}},74:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this.listeners=[]}add(e){var t=e=>this.listeners.findIndex((t=>t.fn===e)),n=t(e);if(-1===n)this.listeners.push({fn:e,count:1});else{var i=this.listeners[n];i&&i.count++}return()=>{var n=t(e);if(-1!==n){var i=this.listeners[n];i&&i.count--,i&&0===i.count&&this.listeners.splice(n,1)}}}call(){for(var e=arguments.length,t=new Array(e),n=0;ne.fn(...t)))}}},255:(e,t,n)=>{"use strict";n.d(t,{default:()=>P});const i="2.0.33";var r=n(459),s=n.n(r),o=window.Promise||s();function a(e){return decodeURIComponent((e||"").replace(/\+/g," "))}function c(e){var t,n,i,r,s={};if(0===(e=e||"").search(/\?|#/)&&(e=e.slice(1)),0===e.length)return s;t=e.split("&");for(var o=0;o{t=e,n=i})),r=0,s=[],a=Array.isArray(e)?e.slice():[e];return(r=a.length)<=0?(t(),i):(a.forEach(((e,i)=>{var a;if(h(e))a=e;else if("function"==typeof e){var c;try{a=h(c=e())?c:u(c)?o.reject(c):o.resolve(c)}catch(e){a=o.reject(e)}}else a=new o(((t,n)=>{u(e)?n(e):t(e)}));a.then((e=>{!function(e,n){s[n]=e,--r<=0&&t(s)}(e,i)})).catch(n.bind(n))})),i)}var f=n(94);class p{constructor(e){this.startTime=Date.now(),this.client=e,this.MIN_HOVER_TIME=200}handleMouseEnter(){this.startTime=Date.now()}handleMouseLeave(){var e=Date.now()-this.startTime;e>=this.MIN_HOVER_TIME&&this.client.invoke("track",{type:"hover",value:e})}handleClick(){this.client.invoke("track",{type:"click"})}setup(){var e=document.querySelector("html");e.addEventListener("click",this.handleClick.bind(this)),e.addEventListener("mouseleave",this.handleMouseLeave.bind(this)),e.addEventListener("mouseenter",this.handleMouseEnter.bind(this))}}var v=window.Promise||s(),m=3e5,g=["instances.create"],_=/^zaf\./,y={},w={};function b(e,t,n){return setTimeout((()=>{T(e,t,m),n(new Error("Invocation request timeout"))}),m)}function E(e,t){return t.map((t=>"".concat(e,"-").concat(t)))}function T(e,t,n){var i=t.map((e=>"action:".concat(function(e){return e.replace(/:\w+(,?\w+)*((\.(show|hide|enable|disable))|(\\?\.\w*))?/g,":arg$3")}(e)))),r="request_response_time:".concat(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m;if(e>=t)return"".concat(t/1e3,"-");var n=e-e%1e4;return"".concat(n/1e3,"-").concat((n+1e4)/1e3)}(n));e.postMessage("__track__",{event_name:"sdk_request_timeout",event_type:"increment",data:1,tags:i.concat(r)})}function k(e){return isNaN(w[e])&&(w[e]=0),++w[e]}function j(e,t,n){e.ready||n?e._source.postMessage(t,e._origin):e.on("app.registered",j.bind(null,e,t))}function x(e,t){var n,i,r=k("promise"),s=Array.isArray(t)?t:Object.keys(t),o=E(e,s),a=this,c=new v(((o,c)=>{i=window.performance.now(),n=function(e,t,n,i){var r=E(n,i);if("invoke"===n){var s=i.filter((e=>-1!==g.indexOf(e)));if(s.length===i.length)return NaN;if(0!==s.length)throw new Error("Illegal bulk call - `instances.create` must be called separately.");return b(e,r,t)}return b(e,r,t)}(a,c,e,s),y[r]={resolve:o,reject:c};var h=JSON.stringify({id:r,request:e,params:t,appGuid:a._appGuid,instanceGuid:a._instanceGuid});j(a,h)}));return c.then(C.bind(null,{id:r,timeoutId:n,trackTimeoutWithResolutionTime:()=>{var e=window.performance.now()-i;e>1e4&&T(a,o,e)}}),C.bind(null,{id:r,timeoutId:n}))}function A(e){e.path&&(e.message='"'+e.path+'" '+e.message);var t=new Error(e.message);return t.name=e.name,t.stack=e.stack,t}function C(e,t){if(clearTimeout(e.timeoutId),delete y[e.id],e.trackTimeoutWithResolutionTime&&e.trackTimeoutWithResolutionTime(),t instanceof Error)throw t;return t}function G(e,t){if(function(e,t){return e&&e._origin===t.origin&&e._source===t.source}(e,t)){var n=t.data;if(n){if("string"==typeof n)try{n=JSON.parse(t.data)}catch(e){return e}var i,r=function(e,t){var n=e;if(t&&t!==e._instanceGuid&&!(n=e._instanceClients[t]))throw Error("[ZAF SDK] Could not find client for instance "+t);return n}(e,n.instanceGuid);if(n.id&&(i=y[n.id]))!function(e,t){if(t.error){var n=t.error.name?A(t.error):t.error;e.reject(n)}else e.resolve(t.result)}(i,n);else if(_.test(n.key)){var s=n.key.replace(_,""),o={appGuid:e._appGuid};if(n.needsReply)return function(e,t,n){if(!e._repliesPending[t])return n.key="iframe.reply:"+t,e._repliesPending[t]=!0,l(e._messageHandlers[t]).then(j.bind(null,e,n)).catch((t=>{var i=t instanceof Error?t.message:t;n.error={msg:i},j(e,n)})).then((()=>{delete e._repliesPending[t]}))}(r,s,o);!function(e,t,n){if(!e._messageHandlers[t])return!1;e._messageHandlers[t].forEach((e=>{e(n)}))}(r,s,n.message)}}}}function O(e,t){if(!("string"==typeof e))return t;var n=t.errors&&t.errors[e];if(n)throw A(n);return t}window.Promise=v;class N{constructor(e){if(this._parent=e.parent,this._origin=e.origin||this._parent&&this._parent._origin,this._source=e.source||this._parent&&this._parent._source||window.parent,this._appGuid=e.appGuid||this._parent&&this._parent._appGuid,this._instanceGuid=e.instanceGuid||this._appGuid,this._messageHandlers={},this._repliesPending={},this._instanceClients={},this._metadata=null,this._context=e.context||null,this._iframe_session_timeout=e.iframe_session_timeout||3e5,this._idleState=null,this.ready=!1,!function(e){if(e)for(var t=[/^https?:\/\/127.0.0.1(:\d+)?$/,/^https?:\/\/localhost(:\d+)?$/,/^https:\/\/.+\.zendesk\.com$/,/^https:\/\/.+\.zd-staging\.com$/,/^https:\/\/.+\.zd-dev\.com$/,/^https:\/\/.+\.zd-master\.com$/,/^https:\/\/.+\.zendesk-staging\.com$/,/^https?:\/\/.+\.zopim\.com(:\d+)?$/,/^https:\/\/dashboard\.zopim\.org$/,/^https:\/\/.+\.futuresimple\.com$/,/^https:\/\/.+\.cloudhatchery\.com$/,/^https:\/\/.+\.idealwith\.com$/,/^https:\/\/.+\.ourtesco\.com$/],n=0;n{this.ready=!0,this._metadata=e.metadata,this._context=e.context,this._iframe_session_timeout=e.iframe_session_timeout,this._idleState=new f.ZP(e.iframe_session_timeout),this._idleState.addObserver((e=>{"active"===e?this.postMessage("session.live"):"idle"===e&&this.postMessage("session.idle")}))}),this),this.on("context.updated",(e=>{this._context=e}),this),this._parent)return this.ready=this._parent.ready,this;new p(this).setup(),window.addEventListener("message",G.bind(null,this)),this.postMessage("iframe.handshake",{version:i})}postMessage(e,t){j(this,JSON.stringify({key:e,message:t,appGuid:this._appGuid,instanceGuid:this._instanceGuid}),"iframe.handshake"===e)}on(e,t,n){"function"==typeof t&&(t=n?t.bind(n):t,this._messageHandlers[e]=this._messageHandlers[e]||[],this._messageHandlers[e].push(t),"app.registered"!==e&&this.postMessage("iframe.on:"+e,{subscriberCount:this._messageHandlers[e].length}))}off(e,t){if(!this._messageHandlers[e])return!1;var n=this._messageHandlers[e].indexOf(t);return this.has(e,t)&&this._messageHandlers[e].splice(n,1),this.postMessage("iframe.off:"+e,{subscriberCount:this._messageHandlers[e].length}),t}has(e,t){return!!this._messageHandlers[e]&&-1!==this._messageHandlers[e].indexOf(t)}trigger(e,t){this.postMessage("iframe.trigger:"+e,t)}request(e){if(this._parent)return this._parent.request(e);var t="request:"+k("request");return new v(((n,i)=>{"string"==typeof e&&(e={url:e}),this.on(t+".done",(e=>{n.apply(this,e.responseArgs)})),this.on(t+".fail",(e=>{i.apply(this,e.responseArgs)})),this.postMessage(t,e)}))}instance(e){if(!e||"string"!=typeof e)throw new Error("The instance method expects an `instanceGuid` string.");if(e===this._instanceGuid)return this;if(this._parent)return this._parent.instance(e);var t=this._instanceClients[e];return t||(t=new N({parent:this,instanceGuid:e}),this._instanceClients[e]=t),t}metadata(){return this._parent?this._parent.metadata():new v((e=>{this._metadata?e(this._metadata):this.on("app.registered",(()=>{e(this._metadata)}))}))}context(){if(this._context)return v.resolve(this._context);if(this._instanceGuid&&this._instanceGuid!==this._appGuid){var e="instances."+this._instanceGuid;return this.get(e).then((t=>(this._context=t[e],this._context)))}return new v((e=>{this.on("app.registered",(t=>{e(t.context)}))}))}get(e){var t=Array.isArray(e)?e:[e];if(arguments.length>1||t.some((e=>!d(e))))throw new Error("The get method accepts a string or array of strings.");return x.call(this,"get",t).then(O.bind(null,e))}set(e,t){var n=e;if("string"==typeof e){if(1===arguments.length)throw new Error("The setter requires a value");(n={})[e]=t}if(!function(e){return null!==e&&"object"==typeof e}(n)||Array.isArray(n))throw new Error("The set method accepts a key and value pair, or an object of key and value pairs.");return x.call(this,"set",n).then(O.bind(null,e))}invoke(e){var t={};if("string"==typeof e)t[e]=Array.prototype.slice.call(arguments,1);else{if("object"!=typeof e)throw new Error("Invoke supports string arguments or an object with array of strings.");Object.keys(e).forEach((t=>{var n=e[t];if(!Array.isArray(n)||n.some((e=>!d(e))))throw new Error("Invoke supports string arguments or an object with array of strings.")})),t=e}return x.call(this,"invoke",t).then(O.bind(null,e))}}const P={init:function(e,t){var n=c((t=t||window.location).search),i=c(t.hash),r=n.origin||i.origin,s=n.app_guid||i.app_guid;if(!r||!s)return!1;var o=new N({origin:r,appGuid:s});return"function"==typeof e&&o.on("app.registered",e.bind(o)),o}}},459:function(e,t,n){var i,r,s,o;r="Promise",s=void 0!==n.g?n.g:this,o=function(){"use strict";var e,t,n,i=Object.prototype.toString,r="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,t,n,i){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:!1!==i})}}catch(t){e=function(e,t,n){return e[t]=n,e}}function s(e,i){n.add(e,i),t||(t=r(n.drain))}function o(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function a(){for(var e=0;e0&&s(a,n))}catch(e){u.call(new l(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&s(a,t))}function d(e,t,n,i){for(var r=0;r{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(459);var i=n(255);return i=i.default})()})); +//# sourceMappingURL=zaf_sdk.min.js.map \ No newline at end of file diff --git a/dist/zaf_sdk.min.js.LICENSE.txt b/dist/zaf_sdk.min.js.LICENSE.txt new file mode 100644 index 00000000..4151354d --- /dev/null +++ b/dist/zaf_sdk.min.js.LICENSE.txt @@ -0,0 +1,4 @@ +/*! Native Promise Only + v0.8.1 (c) Kyle Simpson + MIT License: http://getify.mit-license.org +*/ diff --git a/dist/zaf_sdk.min.js.map b/dist/zaf_sdk.min.js.map new file mode 100644 index 00000000..59f0b671 --- /dev/null +++ b/dist/zaf_sdk.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"zaf_sdk.min.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAmB,UAAID,IAEvBD,EAAgB,UAAIC,IARtB,CASGK,MAAM,WACT,4ICRa,EAAAC,cAAeC,EAEf,EAAAC,eAAgBD,EAEhB,EAAAE,QAASF,8CCNtB,YA0DA,SACa,KAAe,SACf,KAAa,OAE1B,IAAMG,EAAc,CAAC,YAAa,UAAW,QAAS,YAAa,aAAc,aAI3EC,EAAgBC,OAAO,SAEvBC,EAAW,CAACC,EAAsBC,KAClCD,EAAUH,K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KACPvD,SAIG/B,GA5WPuJ,EAAQpF,GAAQoF,EAAQpF,IAASwI,IACGvQ,EAAOD,QAAWC,EAAOD,QAAUoN,EAAQpF,QACuB,KAAhD,aAAyB,OAAOoF,EAAQpF,IAAQ,gCCRnGuL,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBtR,IAAjBuR,EACH,OAAOA,EAAa1T,QAGrB,IAAIC,EAASsT,EAAyBE,GAAY,CAGjDzT,QAAS,IAOV,OAHA2T,EAAoBF,GAAUzS,KAAKf,EAAOD,QAASC,EAAQA,EAAOD,QAASwT,GAGpEvT,EAAOD,QCpBfwT,EAAoBI,EAAK3T,IACxB,IAAI4T,EAAS5T,GAAUA,EAAO6T,WAC7B,IAAO7T,EAAiB,QACxB,IAAM,EAEP,OADAuT,EAAoBO,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRL,EAAoBO,EAAI,CAAC/T,EAASwQ,KACjC,IAAI,IAAIjM,KAAOiM,EACXgD,EAAoBjC,EAAEf,EAAYjM,KAASiP,EAAoBjC,EAAEvR,EAASuE,IAC5EuF,OAAOkH,eAAehR,EAASuE,EAAK,CAAE0P,YAAY,EAAM1E,IAAKiB,EAAWjM,MCJ3EiP,EAAoB/C,EAAI,WACvB,GAA0B,iBAAfyD,WAAyB,OAAOA,WAC3C,IACC,OAAO/S,MAAQ,IAAIgT,SAAS,cAAb,GACd,MAAOxI,GACR,GAAsB,iBAAX3J,OAAqB,OAAOA,QALjB,GCAxBwR,EAAoBjC,EAAI,CAACvM,EAAKoP,IAAUtK,OAAOgG,UAAUuE,eAAerT,KAAKgE,EAAKoP,GCGlFZ,EAAoB,KACpB,IAAIc,EAAsBd,EAAoB","sources":["webpack://ZAFClient/webpack/universalModuleDefinition","webpack://ZAFClient/./lib/utils/environment.ts","webpack://ZAFClient/./lib/utils/idleState.ts","webpack://ZAFClient/./lib/utils/listeners.ts","webpack://ZAFClient/./lib/utils.js","webpack://ZAFClient/./lib/tracker.js","webpack://ZAFClient/./lib/client.js","webpack://ZAFClient/./lib/index.js","webpack://ZAFClient/./node_modules/native-promise-only/lib/npo.src.js","webpack://ZAFClient/webpack/bootstrap","webpack://ZAFClient/webpack/runtime/compat get default export","webpack://ZAFClient/webpack/runtime/define property getters","webpack://ZAFClient/webpack/runtime/global","webpack://ZAFClient/webpack/runtime/hasOwnProperty shorthand","webpack://ZAFClient/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ZAFClient\"] = factory();\n\telse\n\t\troot[\"ZAFClient\"] = factory();\n})(self, function() {\nreturn ","const NODE_ENV = process.env['NODE_ENV'];\n\nexport const isProduction = NODE_ENV === 'production';\n\nexport const isDevelopment = NODE_ENV === 'development';\n\nexport const isTest = NODE_ENV === 'test';\n","import Observers, { ListenerFunction } from './listeners';\n\n/*\n IdleState let you know if the application is active or idle. The application is considered idle if not user\n interactions have been detected for a specific amount of time (timeout). To use IdleState, you first create an\n IdleState instance, then you can either get the current state from the instance or add an observer to be called each\n time the state changes.\n\n When creating an instance, you can provide a timeout, by default timeout of 3 minutes is used. When done with the\n IdleState instance, you must call the delete method to release it.\n\n If several consumers create an idleState with the same timeout, only one instance is created. The instance is shared\n between the consumers.\n\n Syntax:\n new IdleState();\n new IdleState(timeout);\n\n timeout: timeout in milliseconds, default is 3 minutes.\n\n Properties:\n IdleState.state:\n current state as string, either 'active' or 'idle', read only.\n\n Methods:\n IdleState.addObserver(observer):\n Add an observer to be called when the idle state changes. The observer receives the new state as parameter. You\n can several observers.\n Returns a function to be called to remove the observer.\n\n IdleState.delete():\n Release the IdleState instance. As the same instance can be shared with multiple consumers, it's important to call\n delete() when done with it. But first, you should remove any observer you have added, else they will still be\n called until all consumers have released the instance.\n\n Usage:\n import IdleState from 'utils/IdleState';\n\n // Create an instance with a timeout of 2 minutes\n const idleState = new IdleState(2 * 60 * 1000);\n\n // Add an observer\n const removeObserver = idleState.addObserver(state => {\n if (state === 'active') {\n // ... application is now active\n } else if (state === 'idle') {\n // ... application is now idle\n }\n });\n\n // Read the current state\n const currentState = idleState.state;\n\n // When done, release the instance, but first remove the observer\n removeObserver();\n idleState.delete();\n*/\n\nimport { isTest } from './environment';\nexport const STATE_ACTIVE = 'active';\nexport const STATE_IDLE = 'idle';\n\nconst USER_EVENTS = ['mousemove', 'keydown', 'wheel', 'mousedown', 'touchstart', 'touchmove'];\n// list of user events to ignore when window hasn't focus as string, i.e. 'mousemove touchmove'\nconst IGNORED_USER_EVENTS = 'mousemove';\n\nconst stateProperty = Symbol('state');\n\nconst setState = (idleState: IdleState, state: 'active' | 'idle') => {\n if (idleState[stateProperty] !== state) {\n idleState[stateProperty] = state;\n idleState.observers && idleState.observers.call(state);\n }\n};\nclass IdleState {\n refcount?: number;\n timeout?: number;\n [stateProperty]: 'active' | 'idle';\n hasActiveEvent?: boolean;\n timer?: number | null;\n hasFocus?: boolean;\n userEventListenerAdded?: boolean;\n observers?: Observers;\n setState?: (state: 'active' | 'idle') => void;\n\n constructor(timeout) {\n this.timeout = timeout;\n this[stateProperty] = STATE_ACTIVE;\n this.hasActiveEvent = true;\n this.timer = null;\n this.hasFocus = true;\n this.userEventListenerAdded = false;\n this.observers = new Observers();\n\n this.refcount = 1;\n\n // Bind callbacks\n this.handleVisibilityChange = this.handleVisibilityChange.bind(this);\n this.handleFocusChange = this.handleFocusChange.bind(this);\n this.handleUserEvent = this.handleUserEvent.bind(this);\n this.handleTimer = this.handleTimer.bind(this);\n\n // Install listeners and timer\n document.addEventListener('visibilitychange', this.handleVisibilityChange, true);\n\n // Because Safari dispatches focus events before visibilitychange, we need to register focus/blurr listener here\n // and not inside handleVisibilityChange with the other event listeners\n window.addEventListener('focus', this.handleFocusChange, true);\n window.addEventListener('blur', this.handleFocusChange, true);\n\n this.handleVisibilityChange();\n this.resetTimer();\n\n // Add access to setState for testing\n if (isTest) {\n this.setState = (state) => {\n setState(this, state);\n };\n }\n }\n\n delete(): void {\n if (this.refcount !== undefined && --this.refcount === 0) {\n document.removeEventListener('visibilitychange', this.handleVisibilityChange, true);\n window.removeEventListener('focus', this.handleFocusChange, true);\n window.removeEventListener('blur', this.handleFocusChange, true);\n\n if (this.userEventListenerAdded) {\n USER_EVENTS.forEach((type) =>\n document.removeEventListener(type, this.handleUserEvent, true)\n );\n }\n\n this.clearTimer();\n delete this.observers;\n }\n }\n\n get state(): 'active' | 'idle' {\n return this[stateProperty];\n }\n\n clearTimer(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = undefined;\n }\n }\n\n resetTimer(): void {\n this.clearTimer();\n this.timer = window.setTimeout(this.handleTimer, this.timeout);\n }\n\n handleTimer(): void {\n this.resetTimer();\n\n if (this.hasActiveEvent) {\n // we had user events during last timeout cycle,\n // do not set state to idle yet\n this.hasActiveEvent = false;\n } else {\n // we did not have user event during last timeout cycle,\n // set state to idle now\n setState(this, STATE_IDLE);\n }\n }\n\n markActive(): void {\n this.hasActiveEvent = true;\n setState(this, STATE_ACTIVE);\n }\n\n handleUserEvent(event: Event): void {\n if (!this.hasFocus && IGNORED_USER_EVENTS.includes(event.type)) return;\n\n this.markActive();\n }\n\n handleFocusChange(event: Event): void {\n // we only care about focus/blur event related to the window itself\n if (event.target !== window) return;\n\n this.hasFocus = event.type === 'focus';\n if (this.hasFocus) {\n this.markActive();\n }\n }\n\n handleVisibilityChange(): void {\n if (document.hidden) {\n if (this.userEventListenerAdded) {\n USER_EVENTS.forEach((type) =>\n document.removeEventListener(type, this.handleUserEvent, true)\n );\n this.userEventListenerAdded = false;\n }\n } else if (!this.userEventListenerAdded) {\n USER_EVENTS.forEach((type) => document.addEventListener(type, this.handleUserEvent, true));\n this.userEventListenerAdded = true;\n }\n }\n\n addObserver(observer: ListenerFunction): (() => void) | undefined {\n return this.observers && this.observers.add(observer);\n }\n}\n\nexport default IdleState;\n","export type ListenerFunction = (...args: unknown[]) => void;\n\ninterface Listener {\n fn: ListenerFunction;\n count: number;\n}\n\nclass Listeners {\n private listeners: Listener[];\n\n constructor() {\n this.listeners = [];\n }\n\n add(listener: ListenerFunction): () => void {\n const find = (listener: ListenerFunction) =>\n this.listeners.findIndex((item) => item.fn === listener);\n\n const index = find(listener);\n if (index === -1) {\n this.listeners.push({ fn: listener, count: 1 });\n } else {\n const listener = this.listeners[index];\n listener && listener.count++;\n }\n\n return () => {\n const index = find(listener);\n\n if (index !== -1) {\n const listener = this.listeners[index];\n listener && listener.count--;\n if (listener && listener.count === 0) {\n this.listeners.splice(index, 1);\n }\n }\n };\n }\n\n call(...args: unknown[]): void {\n this.listeners.forEach((listener) => listener.fn(...args));\n }\n}\n\nexport default Listeners;\n","import NativePromise from 'native-promise-only'\nconst Promise = window.Promise || NativePromise\n\nexport function isObject (obj) {\n return (obj !== null && typeof obj === 'object')\n}\n\nfunction decode (s) {\n return decodeURIComponent((s || '').replace(/\\+/g, ' '))\n}\n\nexport function queryParameters (queryString) {\n queryString = queryString || ''\n\n const result = {}\n let keyValuePairs, keyAndValue, key, value\n\n if (queryString.search(/\\?|#/) === 0) {\n queryString = queryString.slice(1)\n }\n\n if (queryString.length === 0) { return result }\n\n keyValuePairs = queryString.split('&')\n\n for (let i = 0; i < keyValuePairs.length; i++) {\n keyAndValue = keyValuePairs[i].split('=')\n key = decode(keyAndValue[0])\n value = decode(keyAndValue[1]) || ''\n result[key] = value\n }\n\n return result\n}\n\nfunction isPromise (obj) {\n if (obj instanceof Promise) return true\n return !!obj && obj.then && typeof obj.then === 'function'\n}\n\nfunction shouldReject (val) {\n return val === false ||\n val instanceof Error ||\n typeof val === 'string'\n}\n\nexport function isString (key) {\n return typeof key === 'string'\n}\n\n// When receives a list of things to wrap as Promises.\n// it will then wait for:\n// a) all to settle\n// b) first to reject\n// c) first to settle with a falsy value\n// c) is sub-optimal, since it has a specific narrow use-case\n// for save hooks\nexport function when (items) {\n items = items || []\n let resolveAll, rejectAll\n const allResolvedPromise = new Promise((resolve, reject) => {\n resolveAll = resolve\n rejectAll = reject\n })\n\n let remaining = 0\n const settledWith = []\n const itemsCopy = Array.isArray(items) ? items.slice() : [items]\n\n function resolveWith (data, index) {\n settledWith[index] = data\n\n if (--remaining <= 0) {\n resolveAll(settledWith)\n }\n }\n\n remaining = itemsCopy.length\n\n if (remaining <= 0) {\n resolveAll()\n return allResolvedPromise\n }\n\n itemsCopy.forEach((item, index) => {\n let promise\n if (isPromise(item)) {\n promise = item\n } else if (typeof item === 'function') {\n let res\n try {\n res = item()\n if (isPromise(res)) {\n promise = res\n } else if (shouldReject(res)) {\n promise = Promise.reject(res)\n } else {\n promise = Promise.resolve(res)\n }\n } catch (err) {\n promise = Promise.reject(err)\n }\n } else {\n promise = new Promise((resolve, reject) => {\n shouldReject(item)\n ? reject(item)\n : resolve(item)\n })\n }\n promise.then((data) => {\n resolveWith(data, index)\n }).catch(rejectAll.bind(rejectAll))\n })\n\n return allResolvedPromise\n}\n","export default class Tracker {\n constructor (client) {\n this.startTime = Date.now()\n this.client = client\n this.MIN_HOVER_TIME = 200 // milliseconds\n }\n\n handleMouseEnter () {\n this.startTime = Date.now()\n }\n\n handleMouseLeave () {\n const overFor = Date.now() - this.startTime\n if (overFor >= this.MIN_HOVER_TIME) {\n this.client.invoke('track', { type: 'hover', value: overFor })\n }\n }\n\n handleClick () {\n this.client.invoke('track', { type: 'click' })\n }\n\n setup () {\n const $html = document.querySelector('html')\n $html.addEventListener('click', this.handleClick.bind(this))\n $html.addEventListener('mouseleave', this.handleMouseLeave.bind(this))\n $html.addEventListener('mouseenter', this.handleMouseEnter.bind(this))\n }\n}\n","/* global URL */\nimport pkgJson from '../package.json'\nimport { when, isObject, isString } from './utils'\nimport IdleState from './utils/idleState'\nimport Tracker from './tracker'\nimport NativePromise from 'native-promise-only'\n\nconst Promise = window.Promise || NativePromise\n\nexport const IFRAME_SESSION_TIMEOUT = 5 * 60 * 1000 // Set timeout for iframe sessions to 5 minutes.\nexport const PROMISE_TIMEOUT = 10000\n// 10 seconds, see ZD#4058685\nexport const PROMISE_TIMEOUT_LONG = 5 * 60 * 1000\n// Set a high timeout threshold to allow us to better gauge the time taken for successful requests\nconst NO_TIMEOUT_ACTIONS = ['instances.create']\nconst ZAF_EVENT = /^zaf\\./\nconst pendingPromises = {}\nconst ids = {}\n\n// // export Promise!\nwindow.Promise = Promise\n\n// @internal\n// #timeoutReject(rejectionFn, name, client, params)\n//\n// Reject a request if required, given the rejection function, name (get, set or invoke)\n// and arguments to that request. Falls back to 10000 second timeout with few exceptions.\n//\nfunction timeoutReject (client, reject, name, paramsArray) {\n const actions = collateActions(name, paramsArray)\n switch (name) {\n case 'invoke': {\n const matches = paramsArray.filter((action) => {\n return NO_TIMEOUT_ACTIONS.indexOf(action) !== -1\n })\n const allWhitelisted = matches.length === paramsArray.length\n if (allWhitelisted) {\n return NaN // timer IDs are numbers; embrace the JavaScript 😬\n } else {\n const notAllWhitelisted = matches.length !== 0\n if (notAllWhitelisted) {\n throw new Error('Illegal bulk call - `instances.create` must be called separately.')\n }\n return defaultTimer(client, actions, reject)\n }\n }\n default: {\n return defaultTimer(client, actions, reject)\n }\n }\n}\n\nfunction defaultTimer (client, actions, callback) {\n return setTimeout(() => {\n trackSDKRequestTimeout(client, actions, PROMISE_TIMEOUT_LONG)\n callback(new Error('Invocation request timeout'))\n }, PROMISE_TIMEOUT_LONG)\n}\n\nexport function collateActions (name, params) { return params.map(action => `${name}-${action}`) }\n\nexport function stripActionArgs (action) {\n // Capture:\n // 1. single or multiple comma-delimited arguments following an initial colon, and\n // 2. non-whitelisted, unescaped words following a period (i.e. file extensions in the case of assetURL calls)\n const ACTION_ARGS = /:\\w+(,?\\w+)*((\\.(show|hide|enable|disable))|(\\\\?\\.\\w*))?/g\n // Return :arg.field_modifier, where field modifier is (optionally) one of 'show', 'hide', 'enable' or 'disable'\n return action.replace(ACTION_ARGS, ':arg$3')\n}\n\nexport function timeMsToSecondsRange (value, upperLimit = PROMISE_TIMEOUT_LONG) {\n if (value >= upperLimit) return `${upperLimit / 1000}-`\n const lowerRangeBound = value - (value % 10000)\n return `${lowerRangeBound / 1000}-${(lowerRangeBound + 10000) / 1000}`\n}\n\nexport function trackSDKRequestTimeout (client, actions, requestResponseTime) {\n const actionsTags = actions.map(action => `action:${stripActionArgs(action)}`)\n const responseTimeTag = `request_response_time:${timeMsToSecondsRange(requestResponseTime)}`\n client.postMessage('__track__', {\n event_name: 'sdk_request_timeout',\n event_type: 'increment',\n data: 1,\n tags: actionsTags.concat(responseTimeTag)\n })\n}\n\nfunction nextIdFor (name) {\n if (isNaN(ids[name])) {\n ids[name] = 0\n }\n return ++ids[name]\n}\n\n// @internal\n// #### rawPostMessage(client, msg, forceReady)\n//\n// Post a message to the hosting frame.\n// If the client is not ready and forceReady is not specified, it will wait for client registration.\n//\nfunction rawPostMessage (client, msg, forceReady) {\n if (client.ready || forceReady) {\n client._source.postMessage(msg, client._origin)\n } else {\n client.on('app.registered', rawPostMessage.bind(null, client, msg))\n }\n}\n\n// @internal\n// #### wrappedPostMessage(name, params)\n//\n// Wraps post message with a request/response mechanism using Promises.\n// Must be invoked in the context of a Client.\n//\n// ##### Arguments\n//\n// * `name` the name of the request to make (get/set/invoke)\n// * `params` parameters of the request (an array for get, and an object for set/invoke)\n//\nfunction wrappedPostMessage (name, params) {\n const id = nextIdFor('promise')\n let timeoutId, promiseStartTime\n const paramsArray = Array.isArray(params) ? params : Object.keys(params)\n const actions = collateActions(name, paramsArray)\n const client = this\n\n const promise = new Promise((resolve, reject) => {\n promiseStartTime = window.performance.now()\n\n // Time out the promise to ensure it will be garbage collected if nobody responds\n timeoutId = timeoutReject(client, reject, name, paramsArray)\n pendingPromises[id] = { resolve, reject }\n\n const msg = JSON.stringify({\n id: id,\n request: name,\n params: params,\n appGuid: client._appGuid,\n instanceGuid: client._instanceGuid\n })\n rawPostMessage(client, msg)\n })\n\n const trackTimeoutWithResolutionTime = () => {\n const promiseResolutionTime = window.performance.now() - promiseStartTime\n if (promiseResolutionTime > PROMISE_TIMEOUT) {\n trackSDKRequestTimeout(client, actions, promiseResolutionTime)\n }\n }\n\n // ensure promise is cleaned up when resolved/rejected, track request performance for resolved promises\n return promise.then(\n removePromise.bind(null, { id, timeoutId, trackTimeoutWithResolutionTime }),\n removePromise.bind(null, { id, timeoutId })\n )\n}\n\nfunction createError (error) {\n if (error.path) { error.message = '\"' + error.path + '\" ' + error.message }\n const err = new Error(error.message)\n err.name = error.name\n err.stack = error.stack\n return err\n}\n\nfunction removePromise (options, args) {\n clearTimeout(options.timeoutId)\n delete pendingPromises[options.id]\n options.trackTimeoutWithResolutionTime && options.trackTimeoutWithResolutionTime()\n if (args instanceof Error) throw args\n return args\n}\n\nfunction isValidEvent (client, event) {\n return client && client._origin === event.origin && client._source === event.source\n}\n\nfunction triggerEvent (client, eventName, data) {\n if (!client._messageHandlers[eventName]) { return false }\n client._messageHandlers[eventName].forEach((handler) => {\n handler(data)\n })\n}\n\nfunction finalizePendingPromise (pendingPromise, data) {\n if (data.error) {\n const error = data.error.name ? createError(data.error) : data.error\n pendingPromise.reject(error)\n } else {\n pendingPromise.resolve(data.result)\n }\n}\n\nfunction postReplyWith (client, key, msg) {\n if (client._repliesPending[key]) { return }\n msg.key = 'iframe.reply:' + key\n client._repliesPending[key] = true\n return when(client._messageHandlers[key]).then(\n rawPostMessage.bind(null, client, msg)\n ).catch((reason) => {\n // if the handler throws an error we want to send back its message, but\n // Error objects don't pass through the postMessage boundary.\n const rejectMessage = reason instanceof Error ? reason.message : reason\n msg.error = {\n msg: rejectMessage\n }\n rawPostMessage(client, msg)\n }).then(() => {\n delete client._repliesPending[key]\n })\n}\n\nfunction getMessageRecipient (client, recipientGuid) {\n let messageRecipient = client\n\n if (recipientGuid && recipientGuid !== client._instanceGuid) {\n messageRecipient = client._instanceClients[recipientGuid]\n\n if (!messageRecipient) {\n throw Error('[ZAF SDK] Could not find client for instance ' + recipientGuid)\n }\n }\n\n return messageRecipient\n}\n\nfunction messageHandler (client, event) {\n if (!isValidEvent(client, event)) { return }\n\n let data = event.data\n\n if (!data) { return }\n\n if (typeof data === 'string') {\n try {\n data = JSON.parse(event.data)\n } catch (e) {\n return e\n }\n }\n\n const clientRecipient = getMessageRecipient(client, data.instanceGuid)\n let pendingPromise\n\n if (data.id && (pendingPromise = pendingPromises[data.id])) {\n finalizePendingPromise(pendingPromise, data)\n } else if (ZAF_EVENT.test(data.key)) {\n const key = data.key.replace(ZAF_EVENT, '')\n const msg = { appGuid: client._appGuid }\n\n if (data.needsReply) {\n return postReplyWith(clientRecipient, key, msg)\n } else {\n triggerEvent(clientRecipient, key, data.message)\n }\n }\n}\n\n// When doing singular operations and we retrieve an error this function will throw that error\nfunction processResponse (path, result) {\n const isSingularOperation = typeof path === 'string'\n\n if (!isSingularOperation) {\n return result\n }\n\n // CRUFT: When framework starts always appending errors we can remove the extra results.errors check\n const err = result.errors && result.errors[path]\n if (err) {\n throw createError(err)\n }\n\n return result\n}\n\nfunction isOriginValid (origin) {\n if (origin) {\n const WHITELISTED_ORIGINS = [\n /^https?:\\/\\/127.0.0.1(:\\d+)?$/,\n /^https?:\\/\\/localhost(:\\d+)?$/,\n /^https:\\/\\/.+\\.zendesk\\.com$/,\n /^https:\\/\\/.+\\.zd-staging\\.com$/,\n /^https:\\/\\/.+\\.zd-dev\\.com$/,\n /^https:\\/\\/.+\\.zd-master\\.com$/,\n /^https:\\/\\/.+\\.zendesk-staging\\.com$/,\n // Zendesk Chat domains:\n /^https?:\\/\\/.+\\.zopim\\.com(:\\d+)?$/,\n /^https:\\/\\/dashboard\\.zopim\\.org$/,\n // Zendesk Sell domains:\n /^https:\\/\\/.+\\.futuresimple\\.com$/,\n /^https:\\/\\/.+\\.cloudhatchery\\.com$/,\n /^https:\\/\\/.+\\.idealwith\\.com$/,\n // Tesco domains:\n /^https:\\/\\/.+\\.ourtesco\\.com$/\n ]\n\n for (let i = 0; i < WHITELISTED_ORIGINS.length; i++) {\n if (WHITELISTED_ORIGINS[i].test(origin)) {\n return true\n }\n }\n }\n\n return false\n}\n\nfunction clearDocument () {\n document.body = document.createElement('body')\n\n const iframeHead = document.head\n iframeHead && iframeHead.remove()\n}\n\nfunction appendErrorToBody (errorMsg) {\n var errorElement = document.createElement('h3')\n var errorTextNode = document.createTextNode(errorMsg)\n\n errorElement.appendChild(errorTextNode)\n document.body.appendChild(errorElement)\n}\n\nexport default class Client {\n constructor (options) {\n this._parent = options.parent\n this._origin = options.origin || (this._parent && this._parent._origin)\n this._source = options.source || (this._parent && this._parent._source) || window.parent\n this._appGuid = options.appGuid || (this._parent && this._parent._appGuid)\n this._instanceGuid = options.instanceGuid || this._appGuid\n this._messageHandlers = {}\n this._repliesPending = {}\n this._instanceClients = {}\n this._metadata = null\n this._context = options.context || null\n this._iframe_session_timeout = options.iframe_session_timeout || IFRAME_SESSION_TIMEOUT\n this._idleState = null\n this.ready = false\n\n if (!isOriginValid(this._origin)) {\n const originHostname = new URL(this._origin).hostname\n this.postMessage('__track__', {\n event_name: 'invalid_sdk_origin',\n event_type: 'increment',\n data: 1,\n tags: ['origin:' + originHostname]\n })\n\n clearDocument()\n appendErrorToBody(`Invalid domain ${this._origin}`)\n }\n\n this.on('app.registered', (data) => {\n this.ready = true\n this._metadata = data.metadata\n this._context = data.context\n this._iframe_session_timeout = data.iframe_session_timeout\n this._idleState = new IdleState(data.iframe_session_timeout)\n // Add an observer. This will be called when the idleState changes\n this._idleState.addObserver(state => {\n if (state === 'active') {\n // ... application is now active, timeout clock is reset to zero\n // Send a postMessage indicating liveness + possibly a payload too\n this.postMessage('session.live')\n } else if (state === 'idle') {\n // ... application is now idle, timeout clock is ticking\n // Send a postMessage indicating sessionTimeout + possibly a payload too\n this.postMessage('session.idle')\n }\n })\n }, this)\n\n this.on('context.updated', (context) => {\n this._context = context\n }, this)\n\n if (this._parent) {\n this.ready = this._parent.ready\n return this // shortcut handshake\n }\n\n const tracker = new Tracker(this)\n tracker.setup()\n window.addEventListener('message', messageHandler.bind(null, this))\n this.postMessage('iframe.handshake', { version: pkgJson.version })\n }\n\n /**\n * ### Client Object\n *\n * #### client.postMessage(name, [data])\n *\n * Allows you to send message events to the Zendesk app.\n *\n * ##### Arguments\n *\n * * `name` the name of the message event. This determines the name of the iframe\n * event your app will receive. For example, if you set this to 'hello', your app will receive\n * the event 'iframe.hello'\n * * `data` (optional) a JSON object with any data that you want to pass along with the\n * event\n *\n * ```javascript\n * const client = ZAFClient.init();\n * client.postMessage('hello', { awesome: true });\n * ``\n */\n postMessage (name, data) {\n const msg = JSON.stringify({ key: name, message: data, appGuid: this._appGuid, instanceGuid: this._instanceGuid })\n rawPostMessage(this, msg, name === 'iframe.handshake')\n }\n\n /**\n * #### client.on(name, handler, [context])\n *\n * Allows you to add handlers to a framework event. You can add as many handler as you wish.\n * They will be executed in the order they were added.\n *\n * ##### Arguments\n *\n * * `name` the name of the framework event you want to listen to. This can be\n * [framework](./events.html#framework-events), [request](./events.html#request-events), or\n * [custom](./events.html#custom-events) events. Your iframe can listen to any events your app\n * receives, apart from DOM events. You don't need to register these events in the app first\n * * `handler` a function to be called when this event fires. You can expect to receive the same\n * event object your app would receive, parsed as JSON\n * * `context` (optional) the value of `this` within your handler\n *\n * ```javascript\n * const client = ZAFClient.init();\n * client.on('app.registered', (e) => {\n * // go nuts\n * });\n * ```\n *\n * Note: As soon as communication with the Zendesk app is established, the SDK triggers an\n * `app.registered` event. You can add as many handlers to `app.registered` as you like. They're\n * called immediately after the `init` callback\n */\n on (name, handler, context) {\n if (typeof handler === 'function') {\n handler = context\n ? handler.bind(context)\n : handler\n\n this._messageHandlers[name] = this._messageHandlers[name] || []\n this._messageHandlers[name].push(handler)\n\n if (name !== 'app.registered') {\n // Subscriber count is needed as the framework will only bind events on the first attached handler\n this.postMessage('iframe.on:' + name, { subscriberCount: this._messageHandlers[name].length })\n }\n }\n }\n\n /**\n * #### client.off(name, handler)\n *\n * Allows you to remove a handler for a framework event.\n *\n * ##### Arguments\n *\n * * `name` the name of the event\n * * `handler` the function you attached earlier with `on`\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.on('app.registered', function appRegistered(e) {\n * // do stuff then remove the handler\n * client.off('app.registered', appRegistered);\n * });\n * ``\n */\n off (name, handler) {\n if (!this._messageHandlers[name]) { return false }\n const index = this._messageHandlers[name].indexOf(handler)\n if (this.has(name, handler)) {\n this._messageHandlers[name].splice(index, 1)\n }\n\n // Subscriber count is needed as the framework will only unbind events on the last detached handler (count of 0)\n this.postMessage('iframe.off:' + name, { subscriberCount: this._messageHandlers[name].length })\n return handler\n }\n\n /**\n * #### client.has(name, handler)\n *\n * Returns whether or not an event has the specified handler attached to it.\n *\n * ##### Arguments\n *\n * * `name` the name of the event\n * * `handler` the handler you want to test\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.on('app.registered', function appRegistered(e) {\n * // do stuff\n * });\n *\n * client.has('app.registered', appRegistered); // true\n * client.has('app.activated', appRegistered); // false\n * ``\n */\n has (name, handler) {\n if (!this._messageHandlers[name]) { return false }\n return this._messageHandlers[name].indexOf(handler) !== -1\n }\n\n /**\n * #### client.trigger(name, [data])\n *\n * Triggers the specified event on the client.\n *\n * ##### Arguments\n *\n * * `name` the name of the event you want to trigger\n * * `data` (optional) data you want to pass to the handler\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.on('activation', () => {\n * console.log('activating!')\n * });\n *\n * client.trigger('activation') // activating!\n * ``\n */\n trigger (name, data) {\n this.postMessage('iframe.trigger:' + name, data)\n }\n\n /**\n * #### client.request(options)\n *\n * Dispatch [requests](./requests) via the Zendesk app.\n *\n * ##### Arguments\n *\n * * `options` the url of the request or an options object containing a url key/value\n *\n * ##### Returns\n *\n * A [Promises/A+](https://promisesaplus.com) conformant `promise` object.\n *\n * ```javascript\n * const client = ZAFClient.init();\n *\n * client.request('/api/v2/tickets.json').then(\n * (tickets) => {\n * console.log(tickets);\n * },\n * (response) => {\n * console.error(response.responseText);\n * }\n * );\n * ``\n */\n request (options) {\n if (this._parent) { return this._parent.request(options) }\n const requestKey = 'request:' + nextIdFor('request')\n\n return new Promise((resolve, reject) => {\n if (typeof options === 'string') {\n options = { url: options }\n }\n\n this.on(requestKey + '.done', (evt) => {\n resolve.apply(this, evt.responseArgs)\n })\n\n this.on(requestKey + '.fail', (evt) => {\n reject.apply(this, evt.responseArgs)\n })\n\n this.postMessage(requestKey, options)\n })\n }\n\n instance (instanceGuid) {\n if (!instanceGuid || typeof instanceGuid !== 'string') {\n throw new Error('The instance method expects an `instanceGuid` string.')\n }\n if (instanceGuid === this._instanceGuid) { return this }\n if (this._parent) { return this._parent.instance(instanceGuid) }\n let instanceClient = this._instanceClients[instanceGuid]\n if (!instanceClient) {\n instanceClient = new Client({\n parent: this,\n instanceGuid: instanceGuid\n })\n this._instanceClients[instanceGuid] = instanceClient\n }\n return instanceClient\n }\n\n metadata () {\n if (this._parent) { return this._parent.metadata() }\n return new Promise((resolve) => {\n if (this._metadata) {\n resolve(this._metadata)\n } else {\n this.on('app.registered', () => {\n resolve(this._metadata)\n })\n }\n })\n }\n\n context () {\n if (this._context) {\n return Promise.resolve(this._context)\n } else {\n if (this._instanceGuid && this._instanceGuid !== this._appGuid) {\n const key = 'instances.' + this._instanceGuid\n return this.get(key).then((data) => {\n this._context = data[key]\n return this._context\n })\n } else {\n return new Promise((resolve) => {\n this.on('app.registered', (data) => {\n resolve(data.context)\n })\n })\n }\n }\n }\n\n // Accepts string or array of strings.\n get (path) {\n const paths = Array.isArray(path) ? path : [path]\n\n if (arguments.length > 1 || paths.some((path) => { return !isString(path) })) {\n throw new Error('The get method accepts a string or array of strings.')\n }\n\n return wrappedPostMessage.call(this, 'get', paths).then(processResponse.bind(null, path))\n }\n\n set (key, val) {\n let obj = key\n\n if (typeof key === 'string') {\n if (arguments.length === 1) {\n throw new Error('The setter requires a value')\n }\n obj = {}\n obj[key] = val\n }\n\n if (!isObject(obj) || Array.isArray(obj)) {\n throw new Error('The set method accepts a key and value pair, or an object of key and value pairs.')\n }\n\n return wrappedPostMessage.call(this, 'set', obj).then(processResponse.bind(null, key))\n }\n\n invoke (keyOrObject) {\n let obj = {}\n\n if (typeof keyOrObject === 'string') {\n obj[keyOrObject] = Array.prototype.slice.call(arguments, 1)\n } else if (typeof keyOrObject === 'object') {\n // Validate object\n Object.keys(keyOrObject).forEach((key) => {\n const methodArgs = keyOrObject[key]\n\n if (!Array.isArray(methodArgs) || methodArgs.some((arg) => { return !isString(arg) })) {\n throw new Error('Invoke supports string arguments or an object with array of strings.')\n }\n })\n\n obj = keyOrObject\n } else {\n throw new Error('Invoke supports string arguments or an object with array of strings.')\n }\n\n return wrappedPostMessage.call(this, 'invoke', obj).then(processResponse.bind(null, keyOrObject))\n }\n}\n","import Client from './client'\nimport { queryParameters } from './utils'\n\n/**\n * ### ZAFClient API\n *\n * When you include the ZAF SDK on your website, you get access to the `ZAFClient` object.\n *\n * #### ZAFClient.init([callback(context)])\n *\n * Returns a [`client`](#client-object) object.\n *\n * ##### Arguments\n *\n * * `callback(context)` (optional) a function called as soon as communication with\n * the Zendesk app is established. The callback receives a context object with\n * data related to the Zendesk app, including `currentAccount`, `currentUser`, and `location`\n *\n * Example:\n *\n * ```javascript\n * const client = ZAFClient.init((context) => {\n * const currentUser = context.currentUser;\n * console.log('Hi ' + currentUser.name);\n * });\n * ```\n */\n\nconst ZAFClient = {\n init: function (callback, loc) {\n loc = loc || window.location\n const queryParams = queryParameters(loc.search)\n const hashParams = queryParameters(loc.hash)\n const origin = queryParams.origin || hashParams.origin\n const appGuid = queryParams.app_guid || hashParams.app_guid\n if (!origin || !appGuid) { return false }\n\n const client = new Client({ origin, appGuid })\n\n if (typeof callback === 'function') {\n client.on('app.registered', callback.bind(client))\n }\n\n return client\n }\n}\n\nexport default ZAFClient\n","/*! Native Promise Only\n v0.8.1 (c) Kyle Simpson\n MIT License: http://getify.mit-license.org\n*/\n\n(function UMD(name,context,definition){\n\t// special form of UMD for polyfilling across evironments\n\tcontext[name] = context[name] || definition();\n\tif (typeof module != \"undefined\" && module.exports) { module.exports = context[name]; }\n\telse if (typeof define == \"function\" && define.amd) { define(function $AMD$(){ return context[name]; }); }\n})(\"Promise\",typeof global != \"undefined\" ? global : this,function DEF(){\n\t/*jshint validthis:true */\n\t\"use strict\";\n\n\tvar builtInProp, cycle, scheduling_queue,\n\t\tToString = Object.prototype.toString,\n\t\ttimer = (typeof setImmediate != \"undefined\") ?\n\t\t\tfunction timer(fn) { return setImmediate(fn); } :\n\t\t\tsetTimeout\n\t;\n\n\t// dammit, IE8.\n\ttry {\n\t\tObject.defineProperty({},\"x\",{});\n\t\tbuiltInProp = function builtInProp(obj,name,val,config) {\n\t\t\treturn Object.defineProperty(obj,name,{\n\t\t\t\tvalue: val,\n\t\t\t\twritable: true,\n\t\t\t\tconfigurable: config !== false\n\t\t\t});\n\t\t};\n\t}\n\tcatch (err) {\n\t\tbuiltInProp = function builtInProp(obj,name,val) {\n\t\t\tobj[name] = val;\n\t\t\treturn obj;\n\t\t};\n\t}\n\n\t// Note: using a queue instead of array for efficiency\n\tscheduling_queue = (function Queue() {\n\t\tvar first, last, item;\n\n\t\tfunction Item(fn,self) {\n\t\t\tthis.fn = fn;\n\t\t\tthis.self = self;\n\t\t\tthis.next = void 0;\n\t\t}\n\n\t\treturn {\n\t\t\tadd: function add(fn,self) {\n\t\t\t\titem = new Item(fn,self);\n\t\t\t\tif (last) {\n\t\t\t\t\tlast.next = item;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfirst = item;\n\t\t\t\t}\n\t\t\t\tlast = item;\n\t\t\t\titem = void 0;\n\t\t\t},\n\t\t\tdrain: function drain() {\n\t\t\t\tvar f = first;\n\t\t\t\tfirst = last = cycle = void 0;\n\n\t\t\t\twhile (f) {\n\t\t\t\t\tf.fn.call(f.self);\n\t\t\t\t\tf = f.next;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t})();\n\n\tfunction schedule(fn,self) {\n\t\tscheduling_queue.add(fn,self);\n\t\tif (!cycle) {\n\t\t\tcycle = timer(scheduling_queue.drain);\n\t\t}\n\t}\n\n\t// promise duck typing\n\tfunction isThenable(o) {\n\t\tvar _then, o_type = typeof o;\n\n\t\tif (o != null &&\n\t\t\t(\n\t\t\t\to_type == \"object\" || o_type == \"function\"\n\t\t\t)\n\t\t) {\n\t\t\t_then = o.then;\n\t\t}\n\t\treturn typeof _then == \"function\" ? _then : false;\n\t}\n\n\tfunction notify() {\n\t\tfor (var i=0; i 0) {\n\t\t\t\t\tschedule(notify,self);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (err) {\n\t\t\treject.call(new MakeDefWrapper(self),err);\n\t\t}\n\t}\n\n\tfunction reject(msg) {\n\t\tvar self = this;\n\n\t\t// already triggered?\n\t\tif (self.triggered) { return; }\n\n\t\tself.triggered = true;\n\n\t\t// unwrap\n\t\tif (self.def) {\n\t\t\tself = self.def;\n\t\t}\n\n\t\tself.msg = msg;\n\t\tself.state = 2;\n\t\tif (self.chain.length > 0) {\n\t\t\tschedule(notify,self);\n\t\t}\n\t}\n\n\tfunction iteratePromises(Constructor,arr,resolver,rejecter) {\n\t\tfor (var idx=0; idx {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\n__webpack_require__(459);\nvar __webpack_exports__ = __webpack_require__(255);\n"],"names":["root","factory","exports","module","define","amd","self","isProduction","NODE_ENV","isDevelopment","isTest","USER_EVENTS","stateProperty","Symbol","setState","idleState","state","observers","call","constructor","timeout","this","hasActiveEvent","timer","hasFocus","userEventListenerAdded","refcount","handleVisibilityChange","bind","handleFocusChange","handleUserEvent","handleTimer","document","addEventListener","window","resetTimer","delete","undefined","removeEventListener","forEach","type","clearTimer","clearTimeout","setTimeout","markActive","event","includes","target","hidden","addObserver","observer","add","listeners","listener","find","findIndex","item","fn","index","push","count","splice","args","Promise","NativePromise","decode","s","decodeURIComponent","replace","queryParameters","queryString","keyValuePairs","keyAndValue","key","value","result","search","slice","length","split","i","isPromise","obj","then","shouldReject","val","Error","isString","when","items","resolveAll","rejectAll","allResolvedPromise","resolve","reject","remaining","settledWith","itemsCopy","Array","isArray","promise","res","err","data","resolveWith","catch","Tracker","client","startTime","Date","now","MIN_HOVER_TIME","handleMouseEnter","handleMouseLeave","overFor","invoke","handleClick","setup","$html","querySelector","PROMISE_TIMEOUT_LONG","NO_TIMEOUT_ACTIONS","ZAF_EVENT","pendingPromises","ids","defaultTimer","actions","callback","trackSDKRequestTimeout","collateActions","name","params","map","action","requestResponseTime","actionsTags","stripActionArgs","responseTimeTag","upperLimit","lowerRangeBound","timeMsToSecondsRange","postMessage","event_name","event_type","tags","concat","nextIdFor","isNaN","rawPostMessage","msg","forceReady","ready","_source","_origin","on","wrappedPostMessage","timeoutId","promiseStartTime","id","paramsArray","Object","keys","performance","matches","filter","indexOf","NaN","timeoutReject","JSON","stringify","request","appGuid","_appGuid","instanceGuid","_instanceGuid","removePromise","trackTimeoutWithResolutionTime","promiseResolutionTime","createError","error","path","message","stack","options","messageHandler","origin","source","isValidEvent","parse","e","pendingPromise","clientRecipient","recipientGuid","messageRecipient","_instanceClients","getMessageRecipient","finalizePendingPromise","test","needsReply","_repliesPending","_messageHandlers","reason","rejectMessage","postReplyWith","eventName","handler","triggerEvent","processResponse","errors","Client","_parent","parent","_metadata","_context","context","_iframe_session_timeout","iframe_session_timeout","_idleState","WHITELISTED_ORIGINS","isOriginValid","originHostname","URL","hostname","body","createElement","iframeHead","head","remove","clearDocument","errorMsg","errorElement","errorTextNode","createTextNode","appendChild","metadata","IdleState","version","pkgJson","subscriberCount","off","has","trigger","requestKey","url","evt","apply","responseArgs","instance","instanceClient","get","paths","arguments","some","set","isObject","keyOrObject","prototype","methodArgs","arg","init","loc","queryParams","location","hashParams","hash","app_guid","definition","g","builtInProp","cycle","scheduling_queue","ToString","toString","setImmediate","defineProperty","config","writable","configurable","schedule","drain","isThenable","o","_then","o_type","notify","chain","notifyIsolated","success","failure","cb","ret","TypeError","triggered","def","def_wrapper","MakeDefWrapper","iteratePromises","Constructor","arr","resolver","rejecter","idx","MakeDef","executor","__NPO__","first","last","Item","next","f","PromisePrototype","len","msgs","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","n","getter","__esModule","d","a","enumerable","globalThis","Function","prop","hasOwnProperty","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index 059744e4..80a6e9f5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,5 +1,5 @@ /* global URL */ -import version from 'version' +import pkgJson from '../package.json' import { when, isObject, isString } from './utils' import IdleState from './utils/idleState' import Tracker from './tracker' @@ -380,7 +380,7 @@ export default class Client { const tracker = new Tracker(this) tracker.setup() window.addEventListener('message', messageHandler.bind(null, this)) - this.postMessage('iframe.handshake', { version: version }) + this.postMessage('iframe.handshake', { version: pkgJson.version }) } /** diff --git a/package.json b/package.json index faafaf48..26306903 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zendesk_app_framework_sdk", "version": "2.0.33", - "main": "lib/zendesk-app-framework-sdk.js", + "main": "dist/zaf_sdk.min.js", "description": "The Zendesk App Framework (ZAF) SDK is a JavaScript library that simplifies cross-frame communication between iframed apps and ZAF.", "homepage": "http://developer.zendesk.com", "bugs": "support@zendesk.com", @@ -11,9 +11,7 @@ "url": "http://developer.zendesk.com" }, "engines": { - "node": ">=12.10.0", - "npm": ">=5.6.0", - "yarn": "Yarn is disabled for this project, use npm instead" + "node": ">=12.10.0" }, "repository": { "type": "git", @@ -82,5 +80,10 @@ "snyk-protect": "snyk protect", "prepare": "npm run snyk-protect" }, + "standard": { + "ignore": [ + "/dist/" + ] + }, "snyk": true } diff --git a/spec/client_spec.js b/spec/client_spec.js index 9faaa1d7..12487b08 100644 --- a/spec/client_spec.js +++ b/spec/client_spec.js @@ -2,7 +2,7 @@ /* global expect Promise */ import Client, * as clientUtils from '../lib/client' import Tracker from '../lib/tracker' -import version from 'version' +import pkgJson from '../package.json' import sinon from 'sinon' describe('#collateActions', () => { @@ -200,7 +200,7 @@ describe('Client', () => { it('posts an "iframe.handshake" message when initialised', () => { const data = { key: 'iframe.handshake', - message: { version: version }, + message: { version: pkgJson.version }, appGuid: appGuid, instanceGuid: appGuid } diff --git a/webpack.config.js b/webpack.config.js index dcb2bc4e..2b801206 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,4 @@ const path = require('path') -const packageJson = require('./package.json') const webpackMerge = require('webpack-merge') const TerserPlugin = require('terser-webpack-plugin') const Visualizer = require('webpack-visualizer-plugin') @@ -40,21 +39,20 @@ const commonConfig = { }, output: { - library: 'ZAFClient', - libraryExport: 'default', + library: { + name: 'ZAFClient', + type: 'umd', + export: 'default' + }, filename: '[name].js', sourceMapFilename: '[name].js.map', - path: path.resolve(__dirname, 'build') + path: path.resolve(__dirname, 'dist') }, - externals: { - version: `"${packageJson.version}"` - }, - - // Note: devServer does not serve from build/, but from cache. It also doesn't respect mode + // Note: devServer does not serve from dist/, but from cache. It also doesn't respect mode // so outputed files are very different from server/build/build:dev devServer: { - contentBase: path.join(__dirname, 'build'), + contentBase: path.join(__dirname, 'dist'), hot: false, inline: false, compress: true,