framework/extensions/pusher/js/dist/forum.js
flarum-bot 0e238a9c82 Bundled output for commit 64fa35f2f3
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-11-25 17:25:24 +00:00

3 lines
12 KiB
JavaScript
Generated

/*! For license information please see forum.js.LICENSE.txt */
(()=>{var t={440:(t,e,r)=>{var n=r(75).default;function o(){"use strict";t.exports=o=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},r=Object.prototype,i=r.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof v?e:v,i=Object.create(o.prototype),a=new S(n||[]);return u(i,"_invoke",{value:E(t,r,a)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var d={};function v(){}function m(){}function y(){}var g={};f(g,s,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(T([])));x&&x!==r&&i.call(x,s)&&(g=x);var b=y.prototype=v.prototype=Object.create(g);function L(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function r(o,u,a,s){var c=h(t[o],t,u);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&i.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var o;u(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function E(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var u=r.delegate;if(u){var a=j(u,r);if(a){if(a===d)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=h(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}function j(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=h(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,d;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function T(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(i.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:k}}function k(){return{value:void 0,done:!0}}return m.prototype=y,u(b,"constructor",{value:y,configurable:!0}),u(y,"constructor",{value:m,configurable:!0}),m.displayName=f(y,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,f(t,l,"GeneratorFunction")),t.prototype=Object.create(b),t},e.awrap=function(t){return{__await:t}},L(_.prototype),f(_.prototype,c,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var u=new _(p(t,r,n,o),i);return e.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},L(b),f(b,l,"Generator"),f(b,s,(function(){return this})),f(b,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return u.type="throw",u.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],u=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=i.call(o,"catchLoc"),s=i.call(o,"finallyLoc");if(a&&s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var u=o?o.completion:{};return u.type=t,u.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:T(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},75:t=>{function e(r){return t.exports=e="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.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},507:(t,e,r)=>{var n=r(440)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";function t(t,e,r,n,o,i,u){try{var a=t[i](u),s=a.value}catch(t){return void r(t)}a.done?e(s):Promise.resolve(s).then(n,o)}r.r(n);var e=r(507),o=r.n(e);const i=flarum.core.compat["forum/app"];var u=r.n(i);const a=flarum.core.compat["common/extend"],s=flarum.core.compat["forum/components/DiscussionList"];var c=r.n(s);const l=flarum.core.compat["forum/components/DiscussionPage"];var f=r.n(l);const p=flarum.core.compat["forum/components/IndexPage"];var h=r.n(p);const d=flarum.core.compat["common/components/Button"];var v=r.n(d);u().initializers.add("flarum-pusher",(function(){var e;u().pusher=(e=o().mark((function t(){var e;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,import("//cdn.jsdelivr.net/npm/pusher-js@7.0.3/dist/web/pusher.min.js");case 2:return e=new Pusher(u().forum.attribute("pusherKey"),{authEndpoint:u().forum.attribute("apiUrl")+"/pusher/auth",cluster:u().forum.attribute("pusherCluster"),auth:{headers:{"X-CSRF-Token":u().session.csrfToken}}}),t.abrupt("return",{channels:{main:e.subscribe("public"),user:u().session.user?e.subscribe("private-user"+u().session.user.id()):null},pusher:e});case 4:case"end":return t.stop()}}),t)})),function(){var r=this,n=arguments;return new Promise((function(o,i){var u=e.apply(r,n);function a(e){t(u,o,i,a,s,"next",e)}function s(e){t(u,o,i,a,s,"throw",e)}a(void 0)}))})(),u().pushedUpdates=[],(0,a.extend)(c().prototype,"oncreate",(function(){u().pusher.then((function(t){t.pusher.bind("newPost",(function(t){var e=u().discussions.getParams();if(!e.q&&!e.sort&&!e.filter){if(e.tags){var r=u().store.getBy("tags","slug",e.tags),n=null==r?void 0:r.id();if(!n||!t.tagIds.includes(n))return}var o=String(t.discussionId);u().current.get("discussion")&&o===u().current.get("discussion").id()||-1!==u().pushedUpdates.indexOf(o)||(u().pushedUpdates.push(o),u().current.matches(h())&&u().setTitleCount(u().pushedUpdates.length),m.redraw())}}))}))})),(0,a.extend)(c().prototype,"onremove",(function(){u().pusher.then((function(t){t.pusher.unbind("newPost")}))})),(0,a.extend)(c().prototype,"view",(function(t){var e=this;if(u().pushedUpdates){var r=u().pushedUpdates.length;r&&"object"==typeof t&&t&&"children"in t&&t.children instanceof Array&&t.children.unshift(v().component({className:"Button Button--block DiscussionList-update",onclick:function(){e.attrs.state.refresh().then((function(){e.loadingUpdated=!1,u().pushedUpdates=[],u().setTitleCount(0),m.redraw()})),e.loadingUpdated=!0},loading:this.loadingUpdated},u().translator.trans("flarum-pusher.forum.discussion_list.show_updates_text",{count:r})))}})),(0,a.extend)(f().prototype,"oncreate",(function(){var t=this;u().pusher.then((function(e){e.pusher.bind("newPost",(function(e){var r,n=String(e.discussionId),o=null==(r=t.discussion)?void 0:r.id();if(t.discussion&&o===n&&t.stream){var i,a=null!=(i=t.discussion.commentCount())?i:0;u().store.find("discussions",o).then((function(){var e,r,n;null==(e=t.stream)||e.update().then(m.redraw),document.hasFocus()||(u().setTitleCount(Math.max(0,(null!=(r=null==(n=t.discussion)?void 0:n.commentCount())?r:0)-a)),window.addEventListener("focus",(function(){return u().setTitleCount(0)}),{once:!0}))}))}}))}))})),(0,a.extend)(f().prototype,"onremove",(function(){u().pusher.then((function(t){t.pusher.unbind("newPost")}))})),(0,a.extend)(h().prototype,"actionItems",(function(t){t.remove("refresh")})),u().pusher.then((function(t){var e=t.channels;e.user&&e.user.bind("notification",(function(){var t,e;u().session.user&&u().session.user.pushAttributes({unreadNotificationCount:null!=(t=u().session.user.unreadNotificationCount())?t:1,newNotificationCount:null!=(e=u().session.user.newNotificationCount())?e:1}),u().notifications.clear(),m.redraw()}))}))}))})(),module.exports=n})();
//# sourceMappingURL=forum.js.map