diff --git a/assets/.htaccess b/assets/.htaccess new file mode 100644 index 000000000..efa53b69c --- /dev/null +++ b/assets/.htaccess @@ -0,0 +1,33 @@ + + ExpiresActive on + ExpiresDefault "access plus 1 month" + + # CSS + ExpiresByType text/css "access plus 1 year" + + # JavaScript + ExpiresByType application/javascript "access plus 1 year" + ExpiresByType application/x-javascript "access plus 1 year" + ExpiresByType text/javascript "access plus 1 year" + + # Web fonts + + # Embedded OpenType (EOT) + ExpiresByType application/vnd.ms-fontobject "access plus 1 month" + ExpiresByType font/eot "access plus 1 month" + + # OpenType + ExpiresByType font/opentype "access plus 1 month" + + # TrueType + ExpiresByType application/x-font-ttf "access plus 1 month" + + # Web Open Font Format (WOFF) 1.0 + ExpiresByType application/font-woff "access plus 1 month" + ExpiresByType application/x-font-woff "access plus 1 month" + ExpiresByType font/woff "access plus 1 month" + + # Web Open Font Format (WOFF) 2.0 + ExpiresByType application/font-woff2 "access plus 1 month" + + diff --git a/assets/139.820be3d5.js b/assets/139.820be3d5.js deleted file mode 100644 index 539fe6d73..000000000 --- a/assets/139.820be3d5.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunkreactphp_website=self.webpackChunkreactphp_website||[]).push([[139],{7399:function(e,t,i){"use strict";i.r(t),i.d(t,{init:function(){return n}});var a=i(261),c=i.n(a),r=0;function n(e){var t=e.getAttribute("id");t||(t="docsearch-"+r++,e.setAttribute("id",t)),c()({apiKey:"4c440463ddff54a35b4d7dc24afb010b",indexName:"reactphp",inputSelector:"#"+t,debug:"true"===e.getAttribute("data-docsearch-debug"),algoliaOptions:{hitsPerPage:5}})}},5525:function(){}}]); \ No newline at end of file diff --git a/assets/2.2aeb969d.js b/assets/2.2aeb969d.js new file mode 100644 index 000000000..61556f48a --- /dev/null +++ b/assets/2.2aeb969d.js @@ -0,0 +1,16 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{"+Ewk":function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default="2.6.2"},"+RWU":function(t,e,n){"use strict";t.exports=function(t,e,n){if("GET"!==e.method)return void n(new Error("Method "+e.method+" "+t+" is not supported by JSONP."));e.debug("JSONP: start");var o=!1,s=!1;i+=1;var a=document.getElementsByTagName("head")[0],u=document.createElement("script"),c="algoliaJSONP_"+i,l=!1;window[c]=function(t){!function(){try{delete window[c],delete window[c+"_loaded"]}catch(t){window[c]=window[c+"_loaded"]=void 0}}(),s?e.debug("JSONP: Late answer, ignoring"):(o=!0,f(),n(null,{body:t,responseText:JSON.stringify(t)}))},t+="&callback="+c,e.jsonBody&&e.jsonBody.params&&(t+="&"+e.jsonBody.params);var h=setTimeout(function(){e.debug("JSONP: Script timeout"),s=!0,f(),n(new r.RequestTimeout)},e.timeouts.complete);function p(){e.debug("JSONP: success"),l||s||(l=!0,o||(e.debug("JSONP: Fail. Script loaded but did not call the callback"),f(),n(new r.JSONPScriptFail)))}function f(){clearTimeout(h),u.onload=null,u.onreadystatechange=null,u.onerror=null,a.removeChild(u)}u.onreadystatechange=function(){"loaded"!==this.readyState&&"complete"!==this.readyState||p()},u.onload=p,u.onerror=function(){if(e.debug("JSONP: Script error"),l||s)return;f(),n(new r.JSONPScriptError)},u.async=!0,u.defer=!0,u.src=t,a.appendChild(u)};var r=n("Z4lL"),i=0},"/kzE":function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(e,r){var i,o,s,a;t.exports=(i=e,function(t){var e,n=1,r=Array.prototype.slice,o=t.isFunction,s=function(t){return"string"==typeof t},a={},u={},c="onfocusin"in i,l={focus:"focusin",blur:"focusout"},h={mouseenter:"mouseover",mouseleave:"mouseout"};function p(t){return t._zid||(t._zid=n++)}function f(t,e,n,r){if((e=d(e)).ns)var i=(o=e.ns,new RegExp("(?:^| )"+o.replace(" "," .* ?")+"(?: |$)"));var o;return(a[p(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||i.test(t.ns))&&(!n||p(t.fn)===p(n))&&(!r||t.sel==r)})}function d(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function m(t,e){return t.del&&!c&&t.e in l||!!e}function g(t){return h[t]||c&&l[t]||t}function y(n,r,i,o,s,u,c){var l=p(n),f=a[l]||(a[l]=[]);r.split(/\s/).forEach(function(r){if("ready"==r)return t(document).ready(i);var a=d(r);a.fn=i,a.sel=s,a.e in h&&(i=function(e){var n=e.relatedTarget;if(!n||n!==this&&!t.contains(this,n))return a.fn.apply(this,arguments)}),a.del=u;var l=u||i;a.proxy=function(t){if(!(t=x(t)).isImmediatePropagationStopped()){try{var r=Object.getOwnPropertyDescriptor(t,"data");r&&!r.writable||(t.data=o)}catch(t){}var i=l.apply(n,t._args==e?[t]:[t].concat(t._args));return!1===i&&(t.preventDefault(),t.stopPropagation()),i}},a.i=f.length,f.push(a),"addEventListener"in n&&n.addEventListener(g(a.e),a.proxy,m(a,c))})}function v(t,e,n,r,i){var o=p(t);(e||"").split(/\s/).forEach(function(e){f(t,e,n,r).forEach(function(e){delete a[o][e.i],"removeEventListener"in t&&t.removeEventListener(g(e.e),e.proxy,m(e,i))})})}u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",t.event={add:y,remove:v},t.proxy=function(e,n){var i=2 in arguments&&r.call(arguments,2);if(o(e)){var a=function(){return e.apply(n,i?i.concat(r.call(arguments)):arguments)};return a._zid=p(e),a}if(s(n))return i?(i.unshift(e[n],e),t.proxy.apply(null,i)):t.proxy(e[n],e);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var b=function(){return!0},w=function(){return!1},_=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,S={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function x(n,r){return!r&&n.isDefaultPrevented||(r||(r=n),t.each(S,function(t,e){var i=r[t];n[t]=function(){return this[e]=b,i&&i.apply(r,arguments)},n[e]=w}),n.timeStamp||(n.timeStamp=Date.now()),(r.defaultPrevented!==e?r.defaultPrevented:"returnValue"in r?!1===r.returnValue:r.getPreventDefault&&r.getPreventDefault())&&(n.isDefaultPrevented=b)),n}function C(t){var n,r={originalEvent:t};for(n in t)_.test(n)||t[n]===e||(r[n]=t[n]);return x(r,t)}t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(n,i,a,u,c){var l,h,p=this;return n&&!s(n)?(t.each(n,function(t,e){p.on(t,i,a,e,c)}),p):(s(i)||o(u)||!1===u||(u=a,a=i,i=e),u!==e&&!1!==a||(u=a,a=e),!1===u&&(u=w),p.each(function(e,o){c&&(l=function(t){return v(o,t.type,u),u.apply(this,arguments)}),i&&(h=function(e){var n,s=t(e.target).closest(i,o).get(0);if(s&&s!==o)return n=t.extend(C(e),{currentTarget:s,liveFired:o}),(l||u).apply(s,[n].concat(r.call(arguments,1)))}),y(o,n,u,a,i,h||l)}))},t.fn.off=function(n,r,i){var a=this;return n&&!s(n)?(t.each(n,function(t,e){a.off(t,r,e)}),a):(s(r)||o(i)||!1===i||(i=r,r=e),!1===i&&(i=w),a.each(function(){v(this,n,i,r)}))},t.fn.trigger=function(e,n){return(e=s(e)||t.isPlainObject(e)?t.Event(e):x(e))._args=n,this.each(function(){e.type in l&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,n){var r,i;return this.each(function(o,a){(r=C(s(e)?t.Event(e):e))._args=n,r.target=a,t.each(f(a,e.type||e),function(t,e){if(i=e.proxy(r),r.isImmediatePropagationStopped())return!1})}),i},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}}),t.Event=function(t,e){s(t)||(t=(e=t).type);var n=document.createEvent(u[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),x(n)}}(o=function(){var t,e,r,o,s,a,u=[],c=u.concat,l=u.filter,h=u.slice,p=i.document,f={},d={},m={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},g=/^\s*<(\w+|!)[^>]*>/,y=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,b=/^(?:body|html)$/i,w=/([A-Z])/g,_=["val","css","html","text","data","width","height","offset"],S=p.createElement("table"),x=p.createElement("tr"),C={tr:p.createElement("tbody"),tbody:S,thead:S,tfoot:S,td:x,th:x,"*":p.createElement("div")},A=/complete|loaded|interactive/,T=/^[\w-]*$/,k={},O=k.toString,E={},N=p.createElement("div"),j={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},R=Array.isArray||function(t){return t instanceof Array};function I(t){return null==t?String(t):k[O.call(t)]||"object"}function P(t){return"function"==I(t)}function D(t){return null!=t&&t==t.window}function $(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function L(t){return"object"==I(t)}function q(t){return L(t)&&!D(t)&&Object.getPrototypeOf(t)==Object.prototype}function M(t){var e=!!t&&"length"in t&&t.length,n=r.type(t);return"function"!=n&&!D(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function H(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function F(t){return t in d?d[t]:d[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function U(t,e){return"number"!=typeof e||m[H(t)]?e:e+"px"}function B(t){return"children"in t?h.call(t.children):r.map(t.childNodes,function(t){if(1==t.nodeType)return t})}function V(t,e){var n,r=t?t.length:0;for(n=0;n")),n===t&&(n=g.test(e)&&RegExp.$1),n in C||(n="*"),(a=C[n]).innerHTML=""+e,o=r.each(h.call(a.childNodes),function(){a.removeChild(this)})),q(i)&&(s=r(o),r.each(i,function(t,e){_.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},E.Z=function(t,e){return new V(t,e)},E.isZ=function(t){return t instanceof E.Z},E.init=function(e,n){var i,o;if(!e)return E.Z();if("string"==typeof e)if("<"==(e=e.trim())[0]&&g.test(e))i=E.fragment(e,RegExp.$1,n),e=null;else{if(n!==t)return r(n).find(e);i=E.qsa(p,e)}else{if(P(e))return r(p).ready(e);if(E.isZ(e))return e;if(R(e))o=e,i=l.call(o,function(t){return null!=t});else if(L(e))i=[e],e=null;else if(g.test(e))i=E.fragment(e.trim(),RegExp.$1,n),e=null;else{if(n!==t)return r(n).find(e);i=E.qsa(p,e)}}return E.Z(i,e)},(r=function(t,e){return E.init(t,e)}).extend=function(n){var r,i=h.call(arguments,1);return"boolean"==typeof n&&(r=n,n=i.shift()),i.forEach(function(i){!function n(r,i,o){for(e in i)o&&(q(i[e])||R(i[e]))?(q(i[e])&&!q(r[e])&&(r[e]={}),R(i[e])&&!R(r[e])&&(r[e]=[]),n(r[e],i[e],o)):i[e]!==t&&(r[e]=i[e])}(n,i,r)}),n},E.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:h.call(s&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},r.contains=p.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},r.type=I,r.isFunction=P,r.isWindow=D,r.isArray=R,r.isPlainObject=q,r.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},r.isNumeric=function(t){var e=Number(t),r=n(t);return null!=t&&"boolean"!=r&&("string"!=r||t.length)&&!isNaN(e)&&isFinite(e)||!1},r.inArray=function(t,e,n){return u.indexOf.call(e,t,n)},r.camelCase=s,r.trim=function(t){return null==t?"":String.prototype.trim.call(t)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(t,e){var n,i,o,s,a=[];if(M(t))for(i=0;i0?r.fn.concat.apply([],s):s},r.each=function(t,e){var n,r;if(M(t)){for(n=0;n=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return u.every.call(this,function(e,n){return!1!==t.call(e,n,e)}),this},filter:function(t){return P(t)?this.not(this.not(t)):r(l.call(this,function(e){return E.matches(e,t)}))},add:function(t,e){return r(a(this.concat(r(t,e))))},is:function(t){return this.length>0&&E.matches(this[0],t)},not:function(e){var n=[];if(P(e)&&e.call!==t)this.each(function(t){e.call(this,t)||n.push(this)});else{var i="string"==typeof e?this.filter(e):M(e)&&P(e.item)?h.call(e):r(e);this.forEach(function(t){i.indexOf(t)<0&&n.push(t)})}return r(n)},has:function(t){return this.filter(function(){return L(t)?r.contains(this,t):r(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!L(t)?t:r(t)},last:function(){var t=this[this.length-1];return t&&!L(t)?t:r(t)},find:function(t){var e=this;return t?"object"==n(t)?r(t).filter(function(){var t=this;return u.some.call(e,function(e){return r.contains(e,t)})}):1==this.length?r(E.qsa(this[0],t)):this.map(function(){return E.qsa(this,t)}):r()},closest:function(t,e){var i=[],o="object"==n(t)&&r(t);return this.each(function(n,r){for(;r&&!(o?o.indexOf(r)>=0:E.matches(r,t));)r=r!==e&&!$(r)&&r.parentNode;r&&i.indexOf(r)<0&&i.push(r)}),r(i)},parents:function(t){for(var e=[],n=this;n.length>0;)n=r.map(n,function(t){if((t=t.parentNode)&&!$(t)&&e.indexOf(t)<0)return e.push(t),t});return K(e,t)},parent:function(t){return K(a(this.pluck("parentNode")),t)},children:function(t){return K(this.map(function(){return B(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||h.call(this.childNodes)})},siblings:function(t){return K(this.map(function(t,e){return l.call(B(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return r.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=function(t){var e,n;f[t]||(e=p.createElement(t),p.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),f[t]=n);return f[t]}(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=P(t);if(this[0]&&!e)var n=r(t).get(0),i=n.parentNode||this.length>1;return this.each(function(o){r(this).wrapAll(e?t.call(this,o):i?n.cloneNode(!0):n)})},wrapAll:function(t){if(this[0]){var e;for(r(this[0]).before(t=r(t));(e=t.children()).length;)t=e.first();r(t).append(this)}return this},wrapInner:function(t){var e=P(t);return this.each(function(n){var i=r(this),o=i.contents(),s=e?t.call(this,n):t;o.length?o.wrapAll(s):i.append(s)})},unwrap:function(){return this.parent().each(function(){r(this).replaceWith(r(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(e){return this.each(function(){var n=r(this);(e===t?"none"==n.css("display"):e)?n.show():n.hide()})},prev:function(t){return r(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return r(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;r(this).empty().append(J(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=J(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(n,r){var i;return"string"!=typeof n||1 in arguments?this.each(function(t){if(1===this.nodeType)if(L(n))for(e in n)z(this,e,n[e]);else z(this,n,J(this,r,t,this.getAttribute(n)))}):0 in this&&1==this[0].nodeType&&null!=(i=this[0].getAttribute(n))?i:t},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){z(this,t)},this)})},prop:function(t,e){return t=j[t]||t,1 in arguments?this.each(function(n){this[t]=J(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=j[t]||t,this.each(function(){delete this[t]})},data:function(e,n){var r="data-"+e.replace(w,"-$1").toLowerCase(),i=1 in arguments?this.attr(r,n):this.attr(r);return null!==i?X(i):t},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=J(this,t,e,this.value)})):this[0]&&(this[0].multiple?r(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each(function(e){var n=r(this),i=J(this,t,e,n.offset()),o=n.offsetParent().offset(),s={top:i.top-o.top,left:i.left-o.left};"static"==n.css("position")&&(s.position="relative"),n.css(s)});if(!this.length)return null;if(p.documentElement!==this[0]&&!r.contains(p.documentElement,this[0]))return{top:0,left:0};var e=this[0].getBoundingClientRect();return{left:e.left+i.pageXOffset,top:e.top+i.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(t,n){if(arguments.length<2){var i=this[0];if("string"==typeof t){if(!i)return;return i.style[s(t)]||getComputedStyle(i,"").getPropertyValue(t)}if(R(t)){if(!i)return;var o={},a=getComputedStyle(i,"");return r.each(t,function(t,e){o[e]=i.style[s(e)]||a.getPropertyValue(e)}),o}}var u="";if("string"==I(t))n||0===n?u=H(t)+":"+U(t,n):this.each(function(){this.style.removeProperty(H(t))});else for(e in t)t[e]||0===t[e]?u+=H(e)+":"+U(e,t[e])+";":this.each(function(){this.style.removeProperty(H(e))});return this.each(function(){this.style.cssText+=";"+u})},index:function(t){return t?this.indexOf(r(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return!!t&&u.some.call(this,function(t){return this.test(W(t))},F(t))},addClass:function(t){return t?this.each(function(e){if("className"in this){o=[];var n=W(this),i=J(this,t,e,n);i.split(/\s+/g).forEach(function(t){r(this).hasClass(t)||o.push(t)},this),o.length&&W(this,n+(n?" ":"")+o.join(" "))}}):this},removeClass:function(e){return this.each(function(n){if("className"in this){if(e===t)return W(this,"");o=W(this),J(this,e,n,o).split(/\s+/g).forEach(function(t){o=o.replace(F(t)," ")}),W(this,o.trim())}})},toggleClass:function(e,n){return e?this.each(function(i){var o=r(this),s=J(this,e,i,W(this));s.split(/\s+/g).forEach(function(e){(n===t?!o.hasClass(e):n)?o.addClass(e):o.removeClass(e)})}):this},scrollTop:function(e){if(this.length){var n="scrollTop"in this[0];return e===t?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var n="scrollLeft"in this[0];return e===t?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),i=b.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(r(t).css("margin-top"))||0,n.left-=parseFloat(r(t).css("margin-left"))||0,i.top+=parseFloat(r(e[0]).css("border-top-width"))||0,i.left+=parseFloat(r(e[0]).css("border-left-width"))||0,{top:n.top-i.top,left:n.left-i.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||p.body;t&&!b.test(t.nodeName)&&"static"==r(t).css("position");)t=t.offsetParent;return t})}},r.fn.detach=r.fn.remove,["width","height"].forEach(function(e){var n=e.replace(/./,function(t){return t[0].toUpperCase()});r.fn[e]=function(i){var o,s=this[0];return i===t?D(s)?s["inner"+n]:$(s)?s.documentElement["scroll"+n]:(o=this.offset())&&o[e]:this.each(function(t){(s=r(this)).css(e,J(this,i,t,s[e]()))})}}),["after","prepend","before","append"].forEach(function(e,n){var o=n%2;r.fn[e]=function(){var e,s,a=r.map(arguments,function(n){var i=[];return"array"==(e=I(n))?(n.forEach(function(e){return e.nodeType!==t?i.push(e):r.zepto.isZ(e)?i=i.concat(e.get()):void(i=i.concat(E.fragment(e)))}),i):"object"==e||null==n?n:E.fragment(n)}),u=this.length>1;return a.length<1?this:this.each(function(t,e){s=o?e:e.parentNode,e=0==n?e.nextSibling:1==n?e.firstChild:2==n?e:null;var c=r.contains(p.documentElement,s);a.forEach(function(t){if(u)t=t.cloneNode(!0);else if(!s)return r(t).remove();s.insertBefore(t,e),c&&function t(e,n){n(e);for(var r=0,i=e.childNodes.length;r500&&void 0!==t.body&&(void 0!==t.body.params||void 0!==t.body.requests)?(t.body.apiKey=this.apiKey,s=this._computeRequestHeaders({additionalUA:u,withApiKey:!1,headers:t.headers})):s=this._computeRequestHeaders({additionalUA:u,headers:t.headers}),void 0!==t.body&&(e=l(t.body)),a("request start");var g=[];function y(t,e,n){return p._useCache&&t&&e&&void 0!==e[n]}function v(e,n){if(y(p._useRequestCache,c,o)&&e.catch(function(){delete c[o]}),"function"!=typeof t.callback)return e.then(n);e.then(function(e){i(function(){t.callback(null,n(e))},p._setTimeout||setTimeout)},function(e){i(function(){t.callback(e)},p._setTimeout||setTimeout)})}if(p._useCache&&p._useRequestCache&&(o=t.url),p._useCache&&p._useRequestCache&&e&&(o+="_body_"+e),y(p._useRequestCache,c,o)){a("serving request from cache");var b=c[o];return v("function"!=typeof b.then?p._promise.resolve({responseText:b}):b,function(t){return JSON.parse(t.responseText)})}var w=function n(i,v){p._checkAppIdData();var b=new Date;if(p._useCache&&!p._useRequestCache&&(o=t.url),p._useCache&&!p._useRequestCache&&e&&(o+="_body_"+v.body),y(!p._useRequestCache,c,o)){a("serving response from cache");var w=c[o];return p._promise.resolve({body:JSON.parse(w),responseText:w})}if(f>=p.hosts[t.hostType].length)return!m||d?(a("could not get any response"),p._promise.reject(new r.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+p.applicationID,{debugData:g}))):(a("switching to fallback"),f=0,v.method=t.fallback.method,v.url=t.fallback.url,v.jsonBody=t.fallback.body,v.jsonBody&&(v.body=l(v.jsonBody)),s=p._computeRequestHeaders({additionalUA:u,headers:t.headers}),v.timeouts=p._getTimeoutsForRequest(t.hostType),p._setHostIndexByType(0,t.hostType),d=!0,n(p._request.fallback,v));var _=p._getHostByType(t.hostType),S=_+v.url,x={body:v.body,jsonBody:v.jsonBody,method:v.method,headers:s,timeouts:v.timeouts,debug:a,forceAuthHeaders:v.forceAuthHeaders};return a("method: %s, url: %s, headers: %j, timeouts: %d",x.method,S,x.headers,x.timeouts),i===p._request.fallback&&a("using fallback"),i.call(p,S,x).then(function(t){var n=t&&t.body&&t.body.message&&t.body.status||t.statusCode||t&&t.body&&200;a("received response: statusCode: %s, computed statusCode: %d, headers: %j",t.statusCode,n,t.headers);var i=2===Math.floor(n/100),u=new Date;if(g.push({currentHost:_,headers:h(s),content:e||null,contentLength:void 0!==e?e.length:null,method:v.method,timeouts:v.timeouts,url:v.url,startTime:b,endTime:u,duration:u-b,statusCode:n}),i)return p._useCache&&!p._useRequestCache&&c&&(c[o]=t.responseText),{responseText:t.responseText,body:t.body};if(4!==Math.floor(n/100))return f+=1,C();a("unrecoverable error");var l=new r.AlgoliaSearchError(t.body&&t.body.message,{debugData:g,statusCode:n});return p._promise.reject(l)},function(o){a("error: %s, stack: %s",o.message,o.stack);var u=new Date;return g.push({currentHost:_,headers:h(s),content:e||null,contentLength:void 0!==e?e.length:null,method:v.method,timeouts:v.timeouts,url:v.url,startTime:b,endTime:u,duration:u-b}),o instanceof r.AlgoliaSearchError||(o=new r.Unknown(o&&o.message,o)),f+=1,o instanceof r.Unknown||o instanceof r.UnparsableJSON||f>=p.hosts[t.hostType].length&&(d||!m)?(o.debugData=g,p._promise.reject(o)):o instanceof r.RequestTimeout?(a("retrying request with higher timeout"),p._incrementHostIndex(t.hostType),p._incrementTimeoutMultipler(),v.timeouts=p._getTimeoutsForRequest(t.hostType),n(i,v)):C()});function C(){return a("retrying request"),p._incrementHostIndex(t.hostType),n(i,v)}}(p._request,{url:t.url,method:t.method,body:e,jsonBody:t.body,timeouts:p._getTimeoutsForRequest(t.hostType),forceAuthHeaders:t.forceAuthHeaders});return p._useCache&&p._useRequestCache&&c&&(c[o]=w),v(w,function(t){return t.body})},u.prototype._getSearchParams=function(t,e){if(null==t)return e;for(var n in t)null!==n&&void 0!==t[n]&&t.hasOwnProperty(n)&&(e+=""===e?"":"&",e+=n+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(t[n])?l(t[n]):t[n]));return e},u.prototype._computeRequestHeaders=function(t){var e=n("v61W"),r={"x-algolia-agent":t.additionalUA?this._ua+";"+t.additionalUA:this._ua,"x-algolia-application-id":this.applicationID};return!1!==t.withApiKey&&(r["x-algolia-api-key"]=this.apiKey),this.userToken&&(r["x-algolia-usertoken"]=this.userToken),this.securityTags&&(r["x-algolia-tagfilters"]=this.securityTags),e(this.extraHeaders,function(t,e){r[e]=t}),t.headers&&e(t.headers,function(t,e){r[e]=t}),r},u.prototype.search=function(t,e,r){var i=n("49sm"),o=n("7Ule");if(!i(t))throw new Error("Usage: client.search(arrayOfQueries[, callback])");"function"==typeof e?(r=e,e={}):void 0===e&&(e={});var s=this,a={requests:o(t,function(t){var e="";return void 0!==t.query&&(e+="query="+encodeURIComponent(t.query)),{indexName:t.indexName,params:s._getSearchParams(t.params,e)}})},u=o(a.requests,function(t,e){return e+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(t.indexName)+"?"+t.params)}).join("&");return void 0!==e.strategy&&(a.strategy=e.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:a,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:u}},callback:r})},u.prototype.searchForFacetValues=function(t){var e=n("49sm"),r=n("7Ule"),i="Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])";if(!e(t))throw new Error(i);var o=this;return o._promise.all(r(t,function(t){if(!t||void 0===t.indexName||void 0===t.params.facetName||void 0===t.params.facetQuery)throw new Error(i);var e=n("sLmk"),r=n("PGxr"),s=t.indexName,a=t.params,u=a.facetName,c=r(e(a),function(t){return"facetName"===t}),l=o._getSearchParams(c,"");return o._jsonRequest({cache:o.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(s)+"/facets/"+encodeURIComponent(u)+"/query",hostType:"read",body:{params:l}})}))},u.prototype.setSecurityTags=function(t){if("[object Array]"===Object.prototype.toString.call(t)){for(var e=[],n=0;na?this._resetInitialAppIdData(t):t},u.prototype._resetInitialAppIdData=function(t){var e=t||{};return e.hostIndexes={read:0,write:0},e.timeoutMultiplier=1,e.shuffleResult=e.shuffleResult||function(t){var e,n,r=t.length;for(;0!==r;)n=Math.floor(Math.random()*r),e=t[r-=1],t[r]=t[n],t[n]=e;return t}([1,2,3]),this._setAppIdData(e)},u.prototype._cacheAppIdData=function(t){this._hostIndexes=t.hostIndexes,this._timeoutMultiplier=t.timeoutMultiplier,this._shuffleResult=t.shuffleResult},u.prototype._partialAppIdDataUpdate=function(t){var e=n("v61W"),r=this._getAppIdData();return e(t,function(t,e){r[e]=t}),this._setAppIdData(r)},u.prototype._getHostByType=function(t){return this.hosts[t][this._getHostIndexByType(t)]},u.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},u.prototype._getHostIndexByType=function(t){return this._hostIndexes[t]},u.prototype._setHostIndexByType=function(t,e){var r=n("sLmk")(this._hostIndexes);return r[e]=t,this._partialAppIdDataUpdate({hostIndexes:r}),t},u.prototype._incrementHostIndex=function(t){return this._setHostIndexByType((this._getHostIndexByType(t)+1)%this.hosts[t].length,t)},u.prototype._incrementTimeoutMultipler=function(){var t=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:t})},u.prototype._getTimeoutsForRequest=function(t){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[t]*this._timeoutMultiplier}}}).call(this,n("KCCg"))},"1KsK":function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=Object.prototype.toString;t.exports=function(t){var e=i.call(t),n="[object Arguments]"===e;return n||(n="[object Array]"!==e&&null!==t&&"object"===r(t)&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===i.call(t.callee)),n}},"1seS":function(t,e,n){"use strict";var r=Array.prototype.slice,i=n("1KsK"),o=Object.keys,s=o?function(t){return o(t)}:n("sYn3"),a=Object.keys;s.shim=function(){Object.keys?function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2)||(Object.keys=function(t){return i(t)?a(r.call(t)):a(t)}):Object.keys=s;return Object.keys||s},t.exports=s},"1wyU":function(t,e,n){"use strict";var r=n("cUo3"),i=/\s+/;function o(t,e,n,r){var o;if(!n)return this;for(e=e.split(i),n=r?function(t,e){return t.bind?t.bind(e):function(){t.apply(e,[].slice.call(arguments,0))}}(n,r):n,this._callbacks=this._callbacks||{};o=e.shift();)this._callbacks[o]=this._callbacks[o]||{sync:[],async:[]},this._callbacks[o][t].push(n);return this}function s(t,e,n){return function(){for(var r,i=0,o=t.length;!r&&i=3&&n[1]>20&&((e=e||{}).additionalUA="autocomplete.js "+i),function(n,i){t.search(n,e,function(t,e){t?r.error(t.message):i(e.hits,e)})}}},"7kYT":function(t,e,n){"use strict";var r=Function.prototype.bind;t.exports=function(t){var e=function(){for(var e=arguments.length,n=Array(e),i=0;i'),this.$menu.append(this.$empty),this.$empty.hide()),this.datasets=r.map(t.datasets,function(e){return function(t,e,n){return new u.Dataset(r.mixin({$menu:t,cssClasses:n},e))}(s.$menu,e,t.cssClasses)}),r.each(this.datasets,function(t){var e=t.getRoot();e&&0===e.parent().length&&s.$menu.append(e),t.onSync("rendered",s._onRendered,s)}),t.templates&&t.templates.footer&&(this.templates.footer=r.templatify(t.templates.footer),this.$menu.append(this.templates.footer()));var l=this;i.element(window).resize(function(){l._redraw()})}r.mixin(u.prototype,o,{_onSuggestionClick:function(t){this.trigger("suggestionClicked",i.element(t.currentTarget))},_onSuggestionMouseEnter:function(t){var e=i.element(t.currentTarget);if(!e.hasClass(r.className(this.cssClasses.prefix,this.cssClasses.cursor,!0))){this._removeCursor();var n=this;setTimeout(function(){n._setCursor(e,!1)},0)}},_onSuggestionMouseLeave:function(t){if(t.relatedTarget&&i.element(t.relatedTarget).closest("."+r.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).length>0)return;this._removeCursor(),this.trigger("cursorRemoved")},_onRendered:function(t,e){if(this.isEmpty=r.every(this.datasets,function(t){return t.isEmpty()}),this.isEmpty)if(e.length>=this.minLength&&this.trigger("empty"),this.$empty)if(e.length=this.minLength?this._show():this._hide());this.trigger("datasetRendered")},_hide:function(){this.$container.hide()},_show:function(){this.$container.css("display","block"),this._redraw(),this.trigger("shown")},_redraw:function(){this.isOpen&&this.appendTo&&this.trigger("redrawn")},_getSuggestions:function(){return this.$menu.find(r.className(this.cssClasses.prefix,this.cssClasses.suggestion))},_getCursor:function(){return this.$menu.find(r.className(this.cssClasses.prefix,this.cssClasses.cursor)).first()},_setCursor:function(t,e){t.first().addClass(r.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).attr("aria-selected","true"),this.trigger("cursorMoved",e)},_removeCursor:function(){this._getCursor().removeClass(r.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).removeAttr("aria-selected")},_moveCursor:function(t){var e,n,r,i;this.isOpen&&(n=this._getCursor(),e=this._getSuggestions(),this._removeCursor(),-1!==(r=((r=e.index(n)+t)+1)%(e.length+1)-1)?(r<-1&&(r=e.length-1),this._setCursor(i=e.eq(r),!0),this._ensureVisible(i)):this.trigger("cursorRemoved"))},_ensureVisible:function(t){var e,n,r,i;n=(e=t.position().top)+t.height()+parseInt(t.css("margin-top"),10)+parseInt(t.css("margin-bottom"),10),r=this.$menu.scrollTop(),i=this.$menu.height()+parseInt(this.$menu.css("padding-top"),10)+parseInt(this.$menu.css("padding-bottom"),10),e<0?this.$menu.scrollTop(r+e):i0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var n=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*o;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(t);if("number"===l&&!1===isNaN(t))return e.long?u(c=t,s,"day")||u(c,o,"hour")||u(c,i,"minute")||u(c,r,"second")||c+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=r)return Math.round(t/r)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},GlCl:function(t,e,n){"use strict";var r;r={9:"tab",27:"esc",37:"left",39:"right",13:"enter",38:"up",40:"down"};var i=n("jgMb"),o=n("BoXp"),s=n("1wyU");function a(t){var e,n,s,a,u,c=this;(t=t||{}).input||i.error("input is missing"),e=i.bind(this._onBlur,this),n=i.bind(this._onFocus,this),s=i.bind(this._onKeydown,this),a=i.bind(this._onInput,this),this.$hint=o.element(t.hint),this.$input=o.element(t.input).on("blur.aa",e).on("focus.aa",n).on("keydown.aa",s),0===this.$hint.length&&(this.setHint=this.getHint=this.clearHint=this.clearHintIfInvalid=i.noop),i.isMsie()?this.$input.on("keydown.aa keypress.aa cut.aa paste.aa",function(t){r[t.which||t.keyCode]||i.defer(i.bind(c._onInput,c,t))}):this.$input.on("input.aa",a),this.query=this.$input.val(),this.$overflowHelper=(u=this.$input,o.element('').css({position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:u.css("font-family"),fontSize:u.css("font-size"),fontStyle:u.css("font-style"),fontVariant:u.css("font-variant"),fontWeight:u.css("font-weight"),wordSpacing:u.css("word-spacing"),letterSpacing:u.css("letter-spacing"),textIndent:u.css("text-indent"),textRendering:u.css("text-rendering"),textTransform:u.css("text-transform")}).insertAfter(u))}function u(t){return t.altKey||t.ctrlKey||t.metaKey||t.shiftKey}a.normalizeQuery=function(t){return(t||"").replace(/^\s*/g,"").replace(/\s{2,}/g," ")},i.mixin(a.prototype,s,{_onBlur:function(){this.resetInputValue(),this.$input.removeAttr("aria-activedescendant"),this.trigger("blurred")},_onFocus:function(){this.trigger("focused")},_onKeydown:function(t){var e=r[t.which||t.keyCode];this._managePreventDefault(e,t),e&&this._shouldTrigger(e,t)&&this.trigger(e+"Keyed",t)},_onInput:function(){this._checkInputValue()},_managePreventDefault:function(t,e){var n,r,i;switch(t){case"tab":r=this.getHint(),i=this.getInputValue(),n=r&&r!==i&&!u(e);break;case"up":case"down":n=!u(e);break;default:n=!1}n&&e.preventDefault()},_shouldTrigger:function(t,e){var n;switch(t){case"tab":n=!u(e);break;default:n=!0}return n},_checkInputValue:function(){var t,e,n,r,i;t=this.getInputValue(),r=t,i=this.query,n=!(!(e=a.normalizeQuery(r)===a.normalizeQuery(i))||!this.query)&&this.query.length!==t.length,this.query=t,e?n&&this.trigger("whitespaceChanged",this.query):this.trigger("queryChanged",this.query)},focus:function(){this.$input.focus()},blur:function(){this.$input.blur()},getQuery:function(){return this.query},setQuery:function(t){this.query=t},getInputValue:function(){return this.$input.val()},setInputValue:function(t,e){void 0===t&&(t=this.query),this.$input.val(t),e?this.clearHint():this._checkInputValue()},expand:function(){this.$input.attr("aria-expanded","true")},collapse:function(){this.$input.attr("aria-expanded","false")},setActiveDescendant:function(t){this.$input.attr("aria-activedescendant",t)},removeActiveDescendant:function(){this.$input.removeAttr("aria-activedescendant")},resetInputValue:function(){this.setInputValue(this.query,!0)},getHint:function(){return this.$hint.val()},setHint:function(t){this.$hint.val(t)},clearHint:function(){this.setHint("")},clearHintIfInvalid:function(){var t,e,n;n=(t=this.getInputValue())!==(e=this.getHint())&&0===e.indexOf(t),""!==t&&n&&!this.hasOverflow()||this.clearHint()},getLanguageDirection:function(){return(this.$input.css("direction")||"ltr").toLowerCase()},hasOverflow:function(){var t=this.$input.width()-2;return this.$overflowHelper.text(this.getInputValue()),this.$overflowHelper.width()>=t},isCursorAtEnd:function(){var t,e,n;return t=this.$input.val().length,e=this.$input[0].selectionStart,i.isNumber(e)?e===t:!document.selection||((n=document.selection.createRange()).moveStart("character",-t),t===n.text.length)},destroy:function(){this.$hint.off(".aa"),this.$input.off(".aa"),this.$hint=this.$input=this.$overflowHelper=null}}),t.exports=a},JRE2:function(t,e){t.exports=function(t,e){var n=t.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+t+"` was replaced by `"+e+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+n}},KCCg:function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var u,c=[],l=!1,h=-1;function p(){l&&u&&(l=!1,u.length?c=u.concat(c):h=-1,c.length&&f())}function f(){if(!l){var t=a(p);l=!0;for(var e=c.length;e;){for(u=c,c=[];++h1)for(var n=1;n=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(o())}).call(this,n("KCCg"))},P5ON:function(t,e,n){"use strict";var r=n("vgmO"),i=r.Promise||n("E2g8").Promise;t.exports=function(t,e){var o=n("P7XM"),s=n("Z4lL"),a=n("bQm7"),u=n("+RWU"),c=n("5b/b");function l(t,e,r){return(r=n("sLmk")(r||{}))._ua=r._ua||l.ua,new p(t,e,r)}e=e||"",l.version=n("DiRl"),l.ua="Algolia for vanilla JavaScript "+e+l.version,l.initPlaces=c(l),r.__algolia={debug:n("NOtv"),algoliasearch:l};var h={hasXMLHttpRequest:"XMLHttpRequest"in r,hasXDomainRequest:"XDomainRequest"in r};function p(){t.apply(this,arguments)}return h.hasXMLHttpRequest&&(h.cors="withCredentials"in new XMLHttpRequest),o(p,t),p.prototype._request=function(t,e){return new i(function(n,r){if(h.cors||h.hasXDomainRequest){t=a(t,e.headers);var i,o,u=e.body,c=h.cors?new XMLHttpRequest:new XDomainRequest,l=!1;i=setTimeout(p,e.timeouts.connect),c.onprogress=function(){l||f()},"onreadystatechange"in c&&(c.onreadystatechange=function(){!l&&c.readyState>1&&f()}),c.onload=function(){if(o)return;var t;clearTimeout(i);try{t={body:JSON.parse(c.responseText),responseText:c.responseText,statusCode:c.status,headers:c.getAllResponseHeaders&&c.getAllResponseHeaders()||{}}}catch(e){t=new s.UnparsableJSON({more:c.responseText})}t instanceof s.UnparsableJSON?r(t):n(t)},c.onerror=function(t){if(o)return;clearTimeout(i),r(new s.Network({more:t}))},c instanceof XMLHttpRequest?(c.open(e.method,t,!0),e.forceAuthHeaders&&(c.setRequestHeader("x-algolia-application-id",e.headers["x-algolia-application-id"]),c.setRequestHeader("x-algolia-api-key",e.headers["x-algolia-api-key"]))):c.open(e.method,t),h.cors&&(u&&("POST"===e.method?c.setRequestHeader("content-type","application/x-www-form-urlencoded"):c.setRequestHeader("content-type","application/json")),c.setRequestHeader("accept","application/json")),u?c.send(u):c.send()}else r(new s.Network("CORS not supported"));function p(){o=!0,c.abort(),r(new s.RequestTimeout)}function f(){l=!0,clearTimeout(i),i=setTimeout(p,e.timeouts.complete)}})},p.prototype._request.fallback=function(t,e){return t=a(t,e.headers),new i(function(n,r){u(t,e,function(t,e){t?r(t):n(e)})})},p.prototype._promise={reject:function(t){return i.reject(t)},resolve:function(t){return i.resolve(t)},delay:function(t){return new i(function(e){setTimeout(e,t)})},all:function(t){return i.all(t)}},l}},P7XM:function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},PGxr:function(t,e,n){t.exports=function(t,e){var r=n("1seS"),i=n("v61W"),o={};return i(r(t),function(n){!0!==e(n)&&(o[n]=t[n])}),o}},PKsF:function(t,e,n){!function(t){var e=/\S/,n=/\"/g,r=/\n/g,i=/\r/g,o=/\\/g,s=/\u2028/,a=/\u2029/;function u(t){"}"===t.n.substr(t.n.length-1)&&(t.n=t.n.substring(0,t.n.length-1))}function c(t){return t.trim?t.trim():t.replace(/^\s*|\s*$/g,"")}function l(t,e,n){if(e.charAt(n)!=t.charAt(0))return!1;for(var r=1,i=t.length;r":7,"=":8,_v:9,"{":10,"&":11,_t:12},t.scan=function(n,r){var i=n.length,o=0,s=null,a=null,h="",p=[],f=!1,d=0,m=0,g="{{",y="}}";function v(){h.length>0&&(p.push({tag:"_t",text:new String(h)}),h="")}function b(n,r){if(v(),n&&function(){for(var n=!0,r=m;r"==i.tag&&(i.indent=p[o].text.toString()),p.splice(o,1));else r||p.push({tag:"\n"});f=!1,m=p.length}function w(t,e){var n="="+y,r=t.indexOf(n,e),i=c(t.substring(t.indexOf("=",e)+1,r)).split(" ");return g=i[0],y=i[i.length-1],r+n.length-1}for(r&&(r=r.split(" "),g=r[0],y=r[1]),d=0;d":v,"<":function(e,n){var r={partials:{},code:"",subs:{},inPartial:!0};t.walk(e.nodes,r);var i=n.partials[v(e,n)];i.subs=r.subs,i.partials=r.partials},$:function(e,n){var r={subs:{},code:"",partials:n.partials,prefix:e.n};t.walk(e.nodes,r),n.subs[e.n]=r.code,n.inPartial||(n.code+='t.sub("'+g(e.n)+'",c,p,i);')},"\n":function(t,e){e.code+=w('"\\n"'+(t.last?"":" + i"))},_v:function(t,e){e.code+="t.b(t.v(t."+y(t.n)+'("'+g(t.n)+'",c,p,0)));'},_t:function(t,e){e.code+=w('"'+g(t.text)+'"')},"{":b,"&":b},t.walk=function(e,n){for(var r,i=0,o=e.length;i0;){if(c=n.shift(),s&&"<"==s.tag&&!(c.tag in h))throw new Error("Illegal content in < super tag.");if(t.tags[c.tag]<=t.tags.$||p(c,o))i.push(c),c.nodes=e(n,c.tag,i,o);else{if("/"==c.tag){if(0===i.length)throw new Error("Closing tag without opener: /"+c.n);if(u=i.pop(),c.n!=u.n&&!f(c.n,u.n,o))throw new Error("Nesting error: "+u.n+" vs. "+c.n);return u.end=c.i,a}"\n"==c.tag&&(c.last=0==n.length||"\n"==n[0].tag)}a.push(c)}if(i.length>0)throw new Error("missing closing tag: "+i.pop().n);return a}(e,0,[],(r=r||{}).sectionTags||[])},t.cache={},t.cacheKey=function(t,e){return[t,!!e.asString,!!e.disableLambda,e.delimiters,!!e.modelGet].join("||")},t.compile=function(e,n){n=n||{};var r=t.cacheKey(e,n),i=this.cache[r];if(i){var o=i.partials;for(var s in o)delete o[s].instance;return i}return i=this.generate(this.parse(this.scan(e,n.delimiters),e,n),e,n),this.cache[r]=i}}(e)},Ruv9:function(t,e,n){var r=n("PKsF");r.Template=n("cK6b").Template,r.template=r.Template,t.exports=r},"UjO/":function(t,e,n){"use strict";var r,i=n("YQXE"),o=(r=i)&&r.__esModule?r:{default:r};t.exports=o.default},X9Cu:function(t,e,n){"use strict";t.exports=function(t){var e=t.match(/Algolia for vanilla JavaScript (\d+\.)(\d+\.)(\d+)/);if(e)return[e[1],e[2],e[3]]}},YQXE:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=s(n("7kYT")),i=s(n("cq35")),o=s(n("+Ewk"));function s(t){return t&&t.__esModule?t:{default:t}}var a=(0,r.default)(i.default);a.version=o.default,e.default=a},Z4lL:function(t,e,n){"use strict";var r=n("P7XM");function i(t,e){var r=n("v61W"),i=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):i.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=t||"Unknown error",e&&r(e,function(t,e){i[e]=t})}function o(t,e){function n(){var n=Array.prototype.slice.call(arguments,0);"string"!=typeof n[0]&&n.unshift(e),i.apply(this,n),this.name="AlgoliaSearch"+t+"Error"}return r(n,i),n}r(i,Error),t.exports={AlgoliaSearchError:i,UnparsableJSON:o("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:o("RequestTimeout","Request timedout before getting a response"),Network:o("Network","Network issue, see err.more for details"),JSONPScriptFail:o("JSONPScriptFail"," - - - - - - - -
- -
- -
-
-
-
-

Async Changelog

- - - -

- - 2024 -

- - -

- - - 4.3.0 - - - (2024-06-04) - - Release on GitHub - - -

- -
    -
  • -

    Feature: Improve performance by avoiding unneeded references in FiberMap.
    -(#88 by @clue)

    -
  • -
  • -

    Feature: Improve PHP 8.4+ support by avoiding implicitly nullable type declarations.
    -(#87 by @clue)

    -
  • -
  • -

    Improve type safety for test environment.
    -(#86 by @SimonFrings)

    -
  • -
- -
-

- - 2023 -

- - -

- - - 4.2.0 - - - (2023-11-22) - - Release on GitHub - - -

- -
    -
  • -

    Feature: Add Promise v3 template types for all public functions.
    -(#40 by @WyriHaximus and @clue)

    -

    All our public APIs now use Promise v3 template types to guide IDEs and static
    -analysis tools (like PHPStan), helping with proper type usage and improving
    -code quality:

    -
    assertType('bool', await(resolve(true)));
    -assertType('PromiseInterface<bool>', async(fn(): bool => true)());
    -assertType('PromiseInterface<bool>', coroutine(fn(): bool => true));
    -
  • -
  • -

    Feature: Full PHP 8.3 compatibility.
    -(#81 by @clue)

    -
  • -
  • -

    Update test suite to avoid unhandled promise rejections.
    -(#79 by @clue)

    -
  • -
- -
- -

- - - 3.2.0 - - - (2023-11-22) - - Release on GitHub - - -

- -

This release contains backported features from the Async v4.2.0 release for those
-not yet on PHP 8.1+. Async v3 provides a compatible API, but may not take advantage
-of newer language features. We encourage upgrading to the latest version when possible.

-
    -
  • -

    Feature: Add Promise v3 template types for all public functions.
    -(#82 by @WyriHaximus and @clue)

    -

    All our public APIs now use Promise v3 template types to guide IDEs and static
    -analysis tools (like PHPStan), helping with proper type usage and improving
    -code quality:

    -
    assertType('bool', await(resolve(true)));
    -assertType('PromiseInterface<bool>', coroutine(fn(): bool => true));
    -
  • -
  • -

    Feature: Full PHP 8.3 compatibility.
    -(#83 by @clue)

    -
  • -
  • -

    Update test suite to avoid unhandled promise rejections.
    -(#80 by @clue)

    -
  • -
- -
- -

- - - 2.2.0 - - - (2023-11-22) - - Release on GitHub - - -

- -

This is a compatibility release to ensure a smooth upgrade path for those not yet
-on Async v4 or v3. We encourage upgrading to the latest version when possible, as
-Async v4 will be the way forward for this project.

-
    -
  • Feature: Full PHP 8.3 compatibility.
    -(#84 by @clue)
  • -
- -
- -

- - - 4.1.0 - - - (2023-06-22) - - Release on GitHub - - -

- -
    -
  • -

    Feature: Add new delay() function to delay program execution.
    -(#69 and #78 by @clue)

    -
    echo 'a';
    -Loop::addTimer(1.0, function () {
    -    echo 'b';
    -});
    -React\Async\delay(3.0);
    -echo 'c';
    -
    -// prints "a" at t=0.0s
    -// prints "b" at t=1.0s
    -// prints "c" at t=3.0s
    -
  • -
  • -

    Update test suite, add PHPStan with max level and report failed assertions.
    -(#66 and #76 by @clue and #61 and #73 by @WyriHaximus)

    -
  • -
- -
- -

- - - 3.1.0 - - - (2023-06-22) - - Release on GitHub - - -

- -
    -
  • -

    Feature: Add new delay() function to delay program execution.
    -(#71 by @clue)

    -
    echo 'a';
    -Loop::addTimer(1.0, function () {
    -    echo 'b';
    -});
    -React\Async\delay(3.0);
    -echo 'c';
    -
    -// prints "a" at t=0.0s
    -// prints "b" at t=1.0s
    -// prints "c" at t=3.0s
    -
  • -
  • -

    Update test suite, add PHPStan with max level and report failed assertions.
    -(#67 and #77 by @clue and #60 and #74 by @WyriHaximus)

    -
  • -
- -
- -

- - - 2.1.0 - - - (2023-06-22) - - Release on GitHub - - -

- -
    -
  • -

    Feature: Add new delay() function to delay program execution.
    -(#72 by @clue)

    -
    echo 'a';
    -Loop::addTimer(1.0, function () {
    -    echo 'b';
    -});
    -React\Async\delay(3.0);
    -echo 'c';
    -
    -// prints "a" at t=0.0s
    -// prints "b" at t=1.0s
    -// prints "c" at t=3.0s
    -
  • -
  • -

    Update test suite, run tests on PHP 8.2 and report failed assertions.
    -(#59 and #75 by @WyriHaximus and #68 by @clue)

    -
  • -
- -
-

- - 2022 -

- - -

- - - 4.0.0 - - - (2022-07-11) - - Release on GitHub - - -

- -

A major new feature release, see release announcement.

-
    -
  • -

    We'd like to emphasize that this component is production ready and battle-tested.
    -We plan to support all long-term support (LTS) releases for at least 24 months,
    -so you have a rock-solid foundation to build on top of.

    -
  • -
  • -

    The v4 release will be the way forward for this package. However, we will still
    -actively support v3 and v2 to provide a smooth upgrade path for those not yet
    -on PHP 8.1+. If you're using an older PHP version, you may use either version
    -which all provide a compatible API but may not take advantage of newer language
    -features. You may target multiple versions at the same time to support a wider range of
    -PHP versions:

    - -
  • -
-

This update involves some major new features and a minor BC break over the
-v3.0.0 release. We've tried hard to avoid BC breaks where possible and
-minimize impact otherwise. We expect that most consumers of this package will be
-affected by BC breaks, but updating should take no longer than a few minutes.
-See below for more details:

-
    -
  • -

    Feature / BC break: Require PHP 8.1+ and add mixed type declarations.
    -(#14 by @clue)

    -
  • -
  • -

    Feature: Add Fiber-based async() and await() functions.
    -(#15, #18, #19 and #20 by @WyriHaximus and #26, #28, #30, #32, #34, #55 and #57 by @clue)

    -
  • -
  • -

    Project maintenance, rename main branch to 4.x and update installation instructions.
    -(#29 by @clue)

    -
  • -
-

The following changes had to be ported to this release due to our branching
-strategy, but also appeared in the v3.0.0 release:

-
    -
  • -

    Feature: Support iterable type for parallel() + series() + waterfall().
    -(#49 by @clue)

    -
  • -
  • -

    Feature: Forward compatibility with upcoming Promise v3.
    -(#48 by @clue)

    -
  • -
  • -

    Minor documentation improvements.
    -(#36 by @SimonFrings and #51 by @nhedger)

    -
  • -
- -
- -

- - - 3.0.0 - - - (2022-07-11) - - Release on GitHub - - -

- -

A major new feature release, see release announcement.

-
    -
  • -

    We'd like to emphasize that this component is production ready and battle-tested.
    -We plan to support all long-term support (LTS) releases for at least 24 months,
    -so you have a rock-solid foundation to build on top of.

    -
  • -
  • -

    The v4 release will be the way forward for this package. However, we will still
    -actively support v3 and v2 to provide a smooth upgrade path for those not yet
    -on PHP 8.1+. If you're using an older PHP version, you may use either version
    -which all provide a compatible API but may not take advantage of newer language
    -features. You may target multiple versions at the same time to support a wider range of
    -PHP versions:

    - -
  • -
-

This update involves some major new features and a minor BC break over the
-v2.0.0 release. We've tried hard to avoid BC breaks where possible and
-minimize impact otherwise. We expect that most consumers of this package will be
-affected by BC breaks, but updating should take no longer than a few minutes.
-See below for more details:

-
    -
  • -

    Feature / BC break: Require PHP 7.1+ and add type declarations.
    -(#11 by @clue)

    -
  • -
  • -

    Feature: Add Generator-based coroutine() function.
    -(#12, #13 and #54 by @clue)

    -
  • -
  • -

    Feature: Support iterable type for parallel() + series() + waterfall().
    -(#45 by @clue)

    -
  • -
-

The following changes had to be ported to this release due to our branching
-strategy, but also appeared in the v2.0.0 release:

-
    -
  • -

    Feature: Only stop loop for await() if a pending promise resolves/rejects.
    -(#33 by @SimonFrings)

    -
  • -
  • -

    Feature: Forward compatibility with upcoming Promise v3.
    -(#47 by @clue)

    -
  • -
  • -

    Minor documentation improvements.
    -(#37 by @SimonFrings and #52 by @nhedger)

    -
  • -
- -
- -

- - - 2.0.0 - - - (2022-07-11) - - Release on GitHub - - -

- -

A major new feature release, see release announcement.

-
    -
  • -

    We'd like to emphasize that this component is production ready and battle-tested.
    -We plan to support all long-term support (LTS) releases for at least 24 months,
    -so you have a rock-solid foundation to build on top of.

    -
  • -
  • -

    The v4 release will be the way forward for this package. However, we will still
    -actively support v3 and v2 to provide a smooth upgrade path for those not yet
    -on PHP 8.1+. If you're using an older PHP version, you may use either version
    -which all provide a compatible API but may not take advantage of newer language
    -features. You may target multiple versions at the same time to support a wider range of
    -PHP versions:

    - -
  • -
-

This update involves some major changes over the previous v1.0.0 release that
-has been deprecated since 2013. Accordingly, most consumers of this package
-should not be affected by any BC breaks. See below for more details:

-
    -
  • -

    Feature / BC break: Change to Promise-based APIs instead of callbacks (continuation-passing style).
    -Support promise cancellation and upcoming Promise v3.
    -(#6, #7, #9 and #46 by @clue)

    -
  • -
  • -

    Feature: Add new await() function (import from clue/reactphp-block).
    -(#8 by @clue and #39 by @SimonFrings)

    -
  • -
  • -

    Minor documentation improvements.
    -(#38 by @SimonFrings and #53 by @nhedger)

    -
  • -
  • -

    Improve test suite and add .gitattributes to exclude dev files from exports.
    -Run tests on PHP 8.1, PHPUnit 9, switch to GitHub actions and clean up test suite.
    -(#2, #3, #4, #5 and #10 by @clue)

    -
  • -
- -
-

- - 2013 -

- - -

- - - 1.0.0 - - - (2013-02-06) - - Release on GitHub - - -

- -
-

Imported release from original tag date 2013-02-06.

-
-
    -
  • First tagged release
  • -
- -
- - -
- -
-
-
- - - - diff --git a/async/index.html b/async/index.html deleted file mode 100644 index c06f9e4ee..000000000 --- a/async/index.html +++ /dev/null @@ -1,932 +0,0 @@ - - - - - - - - Async: Async Utilities - ReactPHP - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
-
-
-

Async

- -

Async Utilities

-

CI status -installs on Packagist

-

Async utilities and fibers for ReactPHP.

-

This library allows you to manage async control flow. It provides a number of -combinators for Promise-based APIs. -Instead of nesting or chaining promise callbacks, you can declare them as a -list, which is resolved sequentially in an async manner. -React/Async will not automagically change blocking code to be async. You need -to have an actual event loop and non-blocking libraries interacting with that -event loop for it to work. As long as you have a Promise-based API that runs in -an event loop, it can be used with this library.

-

Table of Contents

- -

Usage

-

This lightweight library consists only of a few simple functions. -All functions reside under the React\Async namespace.

-

The below examples refer to all functions with their fully-qualified names like this:

-
React\Async\await(…);
-

As of PHP 5.6+ you can also import each required function into your code like this:

-
use function React\Async\await;
-
-await(…);
-

Alternatively, you can also use an import statement similar to this:

-
use React\Async;
-
-Async\await(…);
-

async()

-

The async(callable():(PromiseInterface<T>|T) $function): (callable():PromiseInterface<T>) function can be used to -return an async function for a function that uses await() internally.

-

This function is specifically designed to complement the await() function. -The await() function can be considered blocking from the -perspective of the calling code. You can avoid this blocking behavior by -wrapping it in an async() function call. Everything inside this function -will still be blocked, but everything outside this function can be executed -asynchronously without blocking:

-
Loop::addTimer(0.5, React\Async\async(function () {
-    echo 'a';
-    React\Async\await(React\Promise\Timer\sleep(1.0));
-    echo 'c';
-}));
-
-Loop::addTimer(1.0, function () {
-    echo 'b';
-});
-
-// prints "a" at t=0.5s
-// prints "b" at t=1.0s
-// prints "c" at t=1.5s
-

See also the await() function for more details.

-

Note that this function only works in tandem with the await() function. -In particular, this function does not "magically" make any blocking function -non-blocking:

-
Loop::addTimer(0.5, React\Async\async(function () {
-    echo 'a';
-    sleep(1); // broken: using PHP's blocking sleep() for demonstration purposes
-    echo 'c';
-}));
-
-Loop::addTimer(1.0, function () {
-    echo 'b';
-});
-
-// prints "a" at t=0.5s
-// prints "c" at t=1.5s: Correct timing, but wrong order
-// prints "b" at t=1.5s: Triggered too late because it was blocked
-

As an alternative, you should always make sure to use this function in tandem -with the await() function and an async API returning a promise -as shown in the previous example.

-

The async() function is specifically designed for cases where it is used -as a callback (such as an event loop timer, event listener, or promise -callback). For this reason, it returns a new function wrapping the given -$function instead of directly invoking it and returning its value.

-
use function React\Async\async;
-
-Loop::addTimer(1.0, async(function () { … }));
-$connection->on('close', async(function () { … }));
-$stream->on('data', async(function ($data) { … }));
-$promise->then(async(function (int $result) { … }));
-

You can invoke this wrapping function to invoke the given $function with -any arguments given as-is. The function will always return a Promise which -will be fulfilled with whatever your $function returns. Likewise, it will -return a promise that will be rejected if you throw an Exception or -Throwable from your $function. This allows you to easily create -Promise-based functions:

-
$promise = React\Async\async(function (): int {
-    $browser = new React\Http\Browser();
-    $urls = [
-        'https://example.com/alice',
-        'https://example.com/bob'
-    ];
-
-    $bytes = 0;
-    foreach ($urls as $url) {
-        $response = React\Async\await($browser->get($url));
-        assert($response instanceof Psr\Http\Message\ResponseInterface);
-        $bytes += $response->getBody()->getSize();
-    }
-    return $bytes;
-})();
-
-$promise->then(function (int $bytes) {
-    echo 'Total size: ' . $bytes . PHP_EOL;
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

The previous example uses await() inside a loop to highlight how -this vastly simplifies consuming asynchronous operations. At the same time, -this naive example does not leverage concurrent execution, as it will -essentially "await" between each operation. In order to take advantage of -concurrent execution within the given $function, you can "await" multiple -promises by using a single await() together with Promise-based -primitives like this:

-
$promise = React\Async\async(function (): int {
-    $browser = new React\Http\Browser();
-    $urls = [
-        'https://example.com/alice',
-        'https://example.com/bob'
-    ];
-
-    $promises = [];
-    foreach ($urls as $url) {
-        $promises[] = $browser->get($url);
-    }
-
-    try {
-        $responses = React\Async\await(React\Promise\all($promises));
-    } catch (Exception $e) {
-        foreach ($promises as $promise) {
-            $promise->cancel();
-        }
-        throw $e;
-    }
-
-    $bytes = 0;
-    foreach ($responses as $response) {
-        assert($response instanceof Psr\Http\Message\ResponseInterface);
-        $bytes += $response->getBody()->getSize();
-    }
-    return $bytes;
-})();
-
-$promise->then(function (int $bytes) {
-    echo 'Total size: ' . $bytes . PHP_EOL;
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

The returned promise is implemented in such a way that it can be cancelled -when it is still pending. Cancelling a pending promise will cancel any awaited -promises inside that fiber or any nested fibers. As such, the following example -will only output ab and cancel the pending delay(). -The await() calls in this example would throw a RuntimeException -from the cancelled delay() call that bubbles up through the fibers.

-
$promise = async(static function (): int {
-    echo 'a';
-    await(async(static function (): void {
-        echo 'b';
-        delay(2);
-        echo 'c';
-    })());
-    echo 'd';
-
-    return time();
-})();
-
-$promise->cancel();
-await($promise);
-

await()

-

The await(PromiseInterface<T> $promise): T function can be used to -block waiting for the given $promise to be fulfilled.

-
$result = React\Async\await($promise);
-

This function will only return after the given $promise has settled, i.e. -either fulfilled or rejected. While the promise is pending, this function -can be considered blocking from the perspective of the calling code. -You can avoid this blocking behavior by wrapping it in an async() function -call. Everything inside this function will still be blocked, but everything -outside this function can be executed asynchronously without blocking:

-
Loop::addTimer(0.5, React\Async\async(function () {
-    echo 'a';
-    React\Async\await(React\Promise\Timer\sleep(1.0));
-    echo 'c';
-}));
-
-Loop::addTimer(1.0, function () {
-    echo 'b';
-});
-
-// prints "a" at t=0.5s
-// prints "b" at t=1.0s
-// prints "c" at t=1.5s
-

See also the async() function for more details.

-

Once the promise is fulfilled, this function will return whatever the promise -resolved to.

-

Once the promise is rejected, this will throw whatever the promise rejected -with. If the promise did not reject with an Exception or Throwable, then -this function will throw an UnexpectedValueException instead.

-
try {
-    $result = React\Async\await($promise);
-    // promise successfully fulfilled with $result
-    echo 'Result: ' . $result;
-} catch (Throwable $e) {
-    // promise rejected with $e
-    echo 'Error: ' . $e->getMessage();
-}
-

coroutine()

-

The coroutine(callable(mixed ...$args):(\Generator|PromiseInterface<T>|T) $function, mixed ...$args): PromiseInterface<T> function can be used to -execute a Generator-based coroutine to "await" promises.

-
React\Async\coroutine(function () {
-    $browser = new React\Http\Browser();
-
-    try {
-        $response = yield $browser->get('https://example.com/');
-        assert($response instanceof Psr\Http\Message\ResponseInterface);
-        echo $response->getBody();
-    } catch (Exception $e) {
-        echo 'Error: ' . $e->getMessage() . PHP_EOL;
-    }
-});
-

Using Generator-based coroutines is an alternative to directly using the -underlying promise APIs. For many use cases, this makes using promise-based -APIs much simpler, as it resembles a synchronous code flow more closely. -The above example performs the equivalent of directly using the promise APIs:

-
$browser = new React\Http\Browser();
-
-$browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) {
-    echo $response->getBody();
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

The yield keyword can be used to "await" a promise resolution. Internally, -it will turn the entire given $function into a Generator. -This allows the execution to be interrupted and resumed at the same place -when the promise is fulfilled. The yield statement returns whatever the -promise is fulfilled with. If the promise is rejected, it will throw an -Exception or Throwable.

-

The coroutine() function will always return a Promise which will be -fulfilled with whatever your $function returns. Likewise, it will return -a promise that will be rejected if you throw an Exception or Throwable -from your $function. This allows you to easily create Promise-based -functions:

-
$promise = React\Async\coroutine(function () {
-    $browser = new React\Http\Browser();
-    $urls = [
-        'https://example.com/alice',
-        'https://example.com/bob'
-    ];
-
-    $bytes = 0;
-    foreach ($urls as $url) {
-        $response = yield $browser->get($url);
-        assert($response instanceof Psr\Http\Message\ResponseInterface);
-        $bytes += $response->getBody()->getSize();
-    }
-    return $bytes;
-});
-
-$promise->then(function (int $bytes) {
-    echo 'Total size: ' . $bytes . PHP_EOL;
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

The previous example uses a yield statement inside a loop to highlight how -this vastly simplifies consuming asynchronous operations. At the same time, -this naive example does not leverage concurrent execution, as it will -essentially "await" between each operation. In order to take advantage of -concurrent execution within the given $function, you can "await" multiple -promises by using a single yield together with Promise-based primitives -like this:

-
$promise = React\Async\coroutine(function () {
-    $browser = new React\Http\Browser();
-    $urls = [
-        'https://example.com/alice',
-        'https://example.com/bob'
-    ];
-
-    $promises = [];
-    foreach ($urls as $url) {
-        $promises[] = $browser->get($url);
-    }
-
-    try {
-        $responses = yield React\Promise\all($promises);
-    } catch (Exception $e) {
-        foreach ($promises as $promise) {
-            $promise->cancel();
-        }
-        throw $e;
-    }
-
-    $bytes = 0;
-    foreach ($responses as $response) {
-        assert($response instanceof Psr\Http\Message\ResponseInterface);
-        $bytes += $response->getBody()->getSize();
-    }
-    return $bytes;
-});
-
-$promise->then(function (int $bytes) {
-    echo 'Total size: ' . $bytes . PHP_EOL;
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

delay()

-

The delay(float $seconds): void function can be used to -delay program execution for duration given in $seconds.

-
React\Async\delay($seconds);
-

This function will only return after the given number of $seconds have -elapsed. If there are no other events attached to this loop, it will behave -similar to PHP's sleep() function.

-
echo 'a';
-React\Async\delay(1.0);
-echo 'b';
-
-// prints "a" at t=0.0s
-// prints "b" at t=1.0s
-

Unlike PHP's sleep() function, -this function may not necessarily halt execution of the entire process thread. -Instead, it allows the event loop to run any other events attached to the -same loop until the delay returns:

-
echo 'a';
-Loop::addTimer(1.0, function (): void {
-    echo 'b';
-});
-React\Async\delay(3.0);
-echo 'c';
-
-// prints "a" at t=0.0s
-// prints "b" at t=1.0s
-// prints "c" at t=3.0s
-

This behavior is especially useful if you want to delay the program execution -of a particular routine, such as when building a simple polling or retry -mechanism:

-
try {
-    something();
-} catch (Throwable) {
-    // in case of error, retry after a short delay
-    React\Async\delay(1.0);
-    something();
-}
-

Because this function only returns after some time has passed, it can be -considered blocking from the perspective of the calling code. You can avoid -this blocking behavior by wrapping it in an async() function call. -Everything inside this function will still be blocked, but everything outside -this function can be executed asynchronously without blocking:

-
Loop::addTimer(0.5, React\Async\async(function (): void {
-    echo 'a';
-    React\Async\delay(1.0);
-    echo 'c';
-}));
-
-Loop::addTimer(1.0, function (): void {
-    echo 'b';
-});
-
-// prints "a" at t=0.5s
-// prints "b" at t=1.0s
-// prints "c" at t=1.5s
-

See also the async() function for more details.

-

Internally, the $seconds argument will be used as a timer for the loop so that -it keeps running until this timer triggers. This implies that if you pass a -really small (or negative) value, it will still start a timer and will thus -trigger at the earliest possible time in the future.

-

The function is implemented in such a way that it can be cancelled when it is -running inside an async() function. Cancelling the resulting -promise will clean up any pending timers and throw a RuntimeException from -the pending delay which in turn would reject the resulting promise.

-
$promise = async(function (): void {
-    echo 'a';
-    delay(3.0);
-    echo 'b';
-})();
-
-Loop::addTimer(2.0, function () use ($promise): void {
-    $promise->cancel();
-});
-
-// prints "a" at t=0.0s
-// rejects $promise at t=2.0
-// never prints "b"
-

parallel()

-

The parallel(iterable<callable():PromiseInterface<T>> $tasks): PromiseInterface<array<T>> function can be used -like this:

-
<?php
-
-use React\EventLoop\Loop;
-use React\Promise\Promise;
-
-React\Async\parallel([
-    function () {
-        return new Promise(function ($resolve) {
-            Loop::addTimer(1, function () use ($resolve) {
-                $resolve('Slept for a whole second');
-            });
-        });
-    },
-    function () {
-        return new Promise(function ($resolve) {
-            Loop::addTimer(1, function () use ($resolve) {
-                $resolve('Slept for another whole second');
-            });
-        });
-    },
-    function () {
-        return new Promise(function ($resolve) {
-            Loop::addTimer(1, function () use ($resolve) {
-                $resolve('Slept for yet another whole second');
-            });
-        });
-    },
-])->then(function (array $results) {
-    foreach ($results as $result) {
-        var_dump($result);
-    }
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

series()

-

The series(iterable<callable():PromiseInterface<T>> $tasks): PromiseInterface<array<T>> function can be used -like this:

-
<?php
-
-use React\EventLoop\Loop;
-use React\Promise\Promise;
-
-React\Async\series([
-    function () {
-        return new Promise(function ($resolve) {
-            Loop::addTimer(1, function () use ($resolve) {
-                $resolve('Slept for a whole second');
-            });
-        });
-    },
-    function () {
-        return new Promise(function ($resolve) {
-            Loop::addTimer(1, function () use ($resolve) {
-                $resolve('Slept for another whole second');
-            });
-        });
-    },
-    function () {
-        return new Promise(function ($resolve) {
-            Loop::addTimer(1, function () use ($resolve) {
-                $resolve('Slept for yet another whole second');
-            });
-        });
-    },
-])->then(function (array $results) {
-    foreach ($results as $result) {
-        var_dump($result);
-    }
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

waterfall()

-

The waterfall(iterable<callable(mixed=):PromiseInterface<T>> $tasks): PromiseInterface<T> function can be used -like this:

-
<?php
-
-use React\EventLoop\Loop;
-use React\Promise\Promise;
-
-$addOne = function ($prev = 0) {
-    return new Promise(function ($resolve) use ($prev) {
-        Loop::addTimer(1, function () use ($prev, $resolve) {
-            $resolve($prev + 1);
-        });
-    });
-};
-
-React\Async\waterfall([
-    $addOne,
-    $addOne,
-    $addOne
-])->then(function ($prev) {
-    echo "Final result is $prev\n";
-}, function (Exception $e) {
-    echo 'Error: ' . $e->getMessage() . PHP_EOL;
-});
-

Todo

-
    -
  • Implement queue()
  • -
-

Install

-

The recommended way to install this library is through Composer. -New to Composer?

-

This project follows SemVer. -This will install the latest supported version from this branch:

-
composer require react/async:^4.3
-

See also the CHANGELOG for details about version upgrades.

-

This project aims to run on any platform and thus does not require any PHP -extensions and supports running on PHP 8.1+. -It's highly recommended to use the latest supported PHP version for this project.

-

We're committed to providing long-term support (LTS) options and to provide a -smooth upgrade path. If you're using an older PHP version, you may use the -3.x branch (PHP 7.1+) or -2.x branch (PHP 5.3+) which both -provide a compatible API but do not take advantage of newer language features. -You may target multiple versions at the same time to support a wider range of -PHP versions like this:

-
composer require "react/async:^4 || ^3 || ^2"
-

Tests

-

To run the test suite, you first need to clone this repo and then install all -dependencies through Composer:

-
composer install
-

To run the test suite, go to the project root and run:

-
vendor/bin/phpunit
-

On top of this, we use PHPStan on max level to ensure type safety across the project:

-
vendor/bin/phpstan
-

License

-

MIT, see LICENSE file.

-

This project is heavily influenced by async.js.

-
- -
-
-
- - - - diff --git a/async/license.html b/async/license.html deleted file mode 100644 index 219a06d63..000000000 --- a/async/license.html +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - Async: License - ReactPHP - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
-
-
-

Async License

- -

Copyright (c) 2012 Christian Lück, Cees-Jan Kiewiet, Jan Sorgalla, Chris Boden, Igor Wiedler

-

Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions:

-

The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software.

-

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.

-
- -
-
-
- - - - diff --git a/cache/changelog.html b/cache/changelog.html index 1bdaba591..c9fd5d268 100644 --- a/cache/changelog.html +++ b/cache/changelog.html @@ -20,13 +20,13 @@ - - + + - - - + + + @@ -49,7 +49,7 @@ -