mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-25 15:22:53 +02:00
Updates package dependencies to more modern versions, also adds .nvmrc and package-lock.json as followups to [43683] and [43571]. See #44600. Fixes #45064. Built from https://develop.svn.wordpress.org/branches/5.0@43684 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
!function(f,w,e){w.wp=w.wp||{},w.wp.heartbeat=new function(){var e,n,t,a,r=f(document),i={suspend:!1,suspendEnabled:!0,screenId:"",url:"",lastTick:0,queue:{},mainInterval:60,tempInterval:0,originalInterval:0,minimalInterval:0,countdown:0,connecting:!1,connectionError:!1,errorcount:0,hasConnected:!1,hasFocus:!0,userActivity:0,userActivityEvents:!1,checkFocusTimer:0,beatTimer:0};function o(){return(new Date).getTime()}function c(e){var n,t=e.src;if(t&&/^https?:\/\//.test(t)&&(n=w.location.origin?w.location.origin:w.location.protocol+"//"+w.location.host,0!==t.indexOf(n)))return!1;try{if(e.contentWindow.document)return!0}catch(e){}return!1}function u(){i.hasFocus&&!document.hasFocus()?v():!i.hasFocus&&document.hasFocus()&&d()}function s(e,n){var t;if(e){switch(e){case"abort":break;case"timeout":t=!0;break;case"error":if(503===n&&i.hasConnected){t=!0;break}case"parsererror":case"empty":case"unknown":i.errorcount++,2<i.errorcount&&i.hasConnected&&(t=!0)}t&&!p()&&(i.connectionError=!0,r.trigger("heartbeat-connection-lost",[e,n]))}}function l(){var e,n;i.connecting||i.suspend||(i.lastTick=o(),n=f.extend({},i.queue),i.queue={},r.trigger("heartbeat-send",[n]),e={data:n,interval:i.tempInterval?i.tempInterval/1e3:i.mainInterval/1e3,_nonce:"object"==typeof w.heartbeatSettings?w.heartbeatSettings.nonce:"",action:"heartbeat",screen_id:i.screenId,has_focus:i.hasFocus},"customize"===i.screenId&&(e.wp_customize="on"),i.connecting=!0,i.xhr=f.ajax({url:i.url,type:"post",timeout:3e4,data:e,dataType:"json"}).always(function(){i.connecting=!1,m()}).done(function(e,n,t){var a;e?(i.hasConnected=!0,p()&&(i.errorcount=0,i.connectionError=!1,r.trigger("heartbeat-connection-restored")),e.nonces_expired&&r.trigger("heartbeat-nonces-expired"),e.heartbeat_interval&&(a=e.heartbeat_interval,delete e.heartbeat_interval),r.trigger("heartbeat-tick",[e,n,t]),a&&b(a)):s("empty")}).fail(function(e,n,t){s(n||"unknown",e.status),r.trigger("heartbeat-error",[e,n,t])}))}function m(){var e=o()-i.lastTick,n=i.mainInterval;i.suspend||(i.hasFocus?0<i.countdown&&i.tempInterval&&(n=i.tempInterval,i.countdown--,i.countdown<1&&(i.tempInterval=0)):n=12e4,i.minimalInterval&&n<i.minimalInterval&&(n=i.minimalInterval),w.clearTimeout(i.beatTimer),e<n?i.beatTimer=w.setTimeout(function(){l()},n-e):l())}function v(){i.hasFocus=!1}function d(){i.userActivity=o(),i.suspend=!1,i.hasFocus||(i.hasFocus=!0,m())}function h(){i.userActivityEvents=!1,r.off(".wp-heartbeat-active"),f("iframe").each(function(e,n){c(n)&&f(n.contentWindow).off(".wp-heartbeat-active")}),d()}function I(){var e=i.userActivity?o()-i.userActivity:0;3e5<e&&i.hasFocus&&v(),(i.suspendEnabled&&6e5<e||36e5<e)&&(i.suspend=!0),i.userActivityEvents||(r.on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active touchend.wp-heartbeat-active",function(){h()}),f("iframe").each(function(e,n){c(n)&&f(n.contentWindow).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active touchend.wp-heartbeat-active",function(){h()})}),i.userActivityEvents=!0)}function p(){return i.connectionError}function b(e,n){var t,a=i.tempInterval?i.tempInterval:i.mainInterval;if(e){switch(e){case"fast":case 5:t=5e3;break;case 15:t=15e3;break;case 30:t=3e4;break;case 60:t=6e4;break;case 120:t=12e4;break;case"long-polling":return i.mainInterval=0;default:t=i.originalInterval}i.minimalInterval&&t<i.minimalInterval&&(t=i.minimalInterval),5e3===t?(n=(n=parseInt(n,10)||30)<1||30<n?30:n,i.countdown=n,i.tempInterval=t):(i.countdown=0,i.tempInterval=0,i.mainInterval=t),t!==a&&m()}return i.tempInterval?i.tempInterval/1e3:i.mainInterval/1e3}return"string"==typeof w.pagenow&&(i.screenId=w.pagenow),"string"==typeof w.ajaxurl&&(i.url=w.ajaxurl),"object"==typeof w.heartbeatSettings&&(e=w.heartbeatSettings,!i.url&&e.ajaxurl&&(i.url=e.ajaxurl),e.interval&&(i.mainInterval=e.interval,i.mainInterval<15?i.mainInterval=15:120<i.mainInterval&&(i.mainInterval=120)),e.minimalInterval&&(e.minimalInterval=parseInt(e.minimalInterval,10),i.minimalInterval=0<e.minimalInterval&&e.minimalInterval<=600?1e3*e.minimalInterval:0),i.minimalInterval&&i.mainInterval<i.minimalInterval&&(i.mainInterval=i.minimalInterval),i.screenId||(i.screenId=e.screenId||"front"),"disable"===e.suspension&&(i.suspendEnabled=!1)),i.mainInterval=1e3*i.mainInterval,i.originalInterval=i.mainInterval,void 0!==document.hidden?(n="hidden",a="visibilitychange",t="visibilityState"):void 0!==document.msHidden?(n="msHidden",a="msvisibilitychange",t="msVisibilityState"):void 0!==document.webkitHidden&&(n="webkitHidden",a="webkitvisibilitychange",t="webkitVisibilityState"),n&&(document[n]&&(i.hasFocus=!1),r.on(a+".wp-heartbeat",function(){"hidden"===document[t]?(v(),w.clearInterval(i.checkFocusTimer)):(d(),document.hasFocus&&(i.checkFocusTimer=w.setInterval(u,1e4)))})),document.hasFocus&&(i.checkFocusTimer=w.setInterval(u,1e4)),f(w).on("unload.wp-heartbeat",function(){i.suspend=!0,i.xhr&&4!==i.xhr.readyState&&i.xhr.abort()}),w.setInterval(I,3e4),r.ready(function(){i.lastTick=o(),m()}),{hasFocus:function(){return i.hasFocus},connectNow:function(){i.lastTick=0,m()},disableSuspend:function(){i.suspendEnabled=!1},interval:b,hasConnectionError:p,enqueue:function(e,n,t){return!(!e||t&&this.isQueued(e)||(i.queue[e]=n,0))},dequeue:function(e){e&&delete i.queue[e]},isQueued:function(e){if(e)return i.queue.hasOwnProperty(e)},getQueuedItem:function(e){if(e)return this.isQueued(e)?i.queue[e]:void 0}}}}(jQuery,window); |