mirror of
https://github.com/flarum/framework.git
synced 2025-02-16 18:52:49 +08:00
1 line
10 KiB
Plaintext
Generated
1 line
10 KiB
Plaintext
Generated
{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,mBCAlF,MAAM,EAA+BI,OAAOC,IAAIP,IAAI,OAAQ,a,aCA5D,MAAM,EAA+BM,OAAOC,IAAIP,IAAI,OAAQ,iBCAtD,EAA+BM,OAAOC,IAAIP,IAAI,OAAQ,mC,aCA5D,MAAM,EAA+BM,OAAOC,IAAIP,IAAI,OAAQ,mC,aCA5D,MAAM,EAA+BM,OAAOC,IAAIP,IAAI,OAAQ,8B,aCA5D,MAAM,EAA+BM,OAAOC,IAAIP,IAAI,OAAQ,4B,aCM5D,iBAAiBQ,IAAI,iBAAiB,KACpC,WAAa,iBAELC,OAAO,iEAGb,MAAMC,EAAS,IAAIC,OAAO,UAAUC,UAAU,aAAc,CAC1DC,aAAc,GAAG,UAAUD,UAAU,wBACrCE,QAAS,UAAUF,UAAU,iBAC7BG,KAAM,CACJC,QAAS,CACP,eAAgB,YAAYC,cAIlC,MAAO,CACLC,SAAU,CACRC,KAAMT,EAAOU,UAAU,UACvBC,KAAM,YAAYA,KAAOX,EAAOU,UAAU,eAAe,YAAYC,KAAKC,QAAU,MAEtFC,OAAQb,EAEX,EArBY,GAsBb,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AOZ,EAAKa,cACjBA,EAAee,KAAKO,YAAYzC,KACtC,GAAIkC,KAAKO,YAActB,IAAiBnB,GAAMkC,KAAKQ,OAAQ,CACzD,MAAMC,EAAWT,KAAKO,WAAWG,gBAAkB,EACnD,UAAUC,KAAK,cAAe1B,GAAchB,MAAK,KAC/C+B,KAAKQ,QAAQI,SAAS3C,KAAKqB,EAAEC,QACxBsB,SAASC,aACZ,kBAAkBC,KAAKC,IAAI,GAAIhB,KAAKO,YAAYG,gBAAkB,GAAKD,IACvEQ,OAAOC,iBAAiB,SAAS,IAAM,kBAAkB,IAAI,CAC3DC,MAAM,IAEV,GAEJ,IACA,GAEN,KACA,IAAAnD,QAAO,cAA0B,YAAY,WAC3C,WAAWC,MAAKC,IACdA,EAAQH,OAAOyB,OAAO,UAAU,GAEpC,KACA,IAAAxB,QAAO,cAAqB,eAAeoD,IACzCA,EAAMC,OAAO,UAAU,IAEzB,WAAWpD,MAAKC,IACd,MAAMR,EAAWQ,EAAQR,SACrBA,EAASG,MACXH,EAASG,KAAKM,KAAK,gBAAgB,KAC7B,YAAYN,MACd,YAAYA,KAAKyD,eAAe,CAC9BC,wBAAyB,YAAY1D,KAAK0D,2BAA6B,EACvEC,qBAAsB,YAAY3D,KAAK2D,wBAA0B,IAGrE,kBAAkBC,QAClBnC,EAAEC,QAAQ,GAEd,GACA,G","sources":["webpack://@flarum/pusher/webpack/bootstrap","webpack://@flarum/pusher/webpack/runtime/compat get default export","webpack://@flarum/pusher/webpack/runtime/define property getters","webpack://@flarum/pusher/webpack/runtime/hasOwnProperty shorthand","webpack://@flarum/pusher/external root \"flarum.reg.get('core', 'forum/app')\"","webpack://@flarum/pusher/external root \"flarum.reg.get('core', 'common/extend')\"","webpack://@flarum/pusher/external root \"flarum.reg.get('core', 'forum/components/DiscussionList')\"","webpack://@flarum/pusher/external root \"flarum.reg.get('core', 'forum/components/DiscussionPage')\"","webpack://@flarum/pusher/external root \"flarum.reg.get('core', 'forum/components/IndexPage')\"","webpack://@flarum/pusher/external root \"flarum.reg.get('core', 'common/components/Button')\"","webpack://@flarum/pusher/./src/forum/index.tsx"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.reg.get('core', 'forum/app');","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.reg.get('core', 'common/extend');","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.reg.get('core', 'forum/components/DiscussionList');","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.reg.get('core', 'forum/components/DiscussionPage');","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.reg.get('core', 'forum/components/IndexPage');","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.reg.get('core', 'common/components/Button');","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport DiscussionList from 'flarum/forum/components/DiscussionList';\nimport DiscussionPage from 'flarum/forum/components/DiscussionPage';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport Button from 'flarum/common/components/Button';\napp.initializers.add('flarum-pusher', () => {\n app.pusher = (async () => {\n // @ts-expect-error\n await import('//cdn.jsdelivr.net/npm/pusher-js@7.0.3/dist/web/pusher.min.js' /* webpackIgnore: true, webpackPrefetch: true */);\n\n // @ts-expect-error Imported dynamically\n const socket = new Pusher(app.forum.attribute('pusherKey'), {\n authEndpoint: `${app.forum.attribute('apiUrl')}/pusher/auth`,\n cluster: app.forum.attribute('pusherCluster'),\n auth: {\n headers: {\n 'X-CSRF-Token': app.session.csrfToken\n }\n }\n });\n return {\n channels: {\n main: socket.subscribe('public'),\n user: app.session.user ? socket.subscribe(`private-user${app.session.user.id()}`) : null\n },\n pusher: socket\n };\n })();\n app.pushedUpdates = [];\n extend(DiscussionList.prototype, 'oncreate', function () {\n app.pusher.then(binding => {\n const pusher = binding.pusher;\n pusher.bind('newPost', data => {\n const params = app.discussions.getParams();\n if (!params.q && !params.sort && !params.filter) {\n if (params.tags) {\n const tag = app.store.getBy('tags', 'slug', params.tags);\n const tagId = tag?.id();\n if (!tagId || !data.tagIds.includes(tagId)) return;\n }\n const id = String(data.discussionId);\n if ((!app.current.get('discussion') || id !== app.current.get('discussion').id()) && app.pushedUpdates.indexOf(id) === -1) {\n app.pushedUpdates.push(id);\n if (app.current.matches(IndexPage)) {\n app.setTitleCount(app.pushedUpdates.length);\n }\n m.redraw();\n }\n }\n });\n });\n });\n extend(DiscussionList.prototype, 'onremove', function () {\n app.pusher.then(binding => {\n binding.pusher.unbind('newPost');\n });\n });\n extend(DiscussionList.prototype, 'view', function (vdom) {\n if (app.pushedUpdates) {\n const count = app.pushedUpdates.length;\n if (count && typeof vdom === 'object' && vdom && 'children' in vdom && vdom.children instanceof Array) {\n vdom.children.unshift(m(Button, {\n className: \"Button Button--block DiscussionList-update\",\n onclick: () => {\n this.attrs.state.refresh().then(() => {\n this.loadingUpdated = false;\n app.pushedUpdates = [];\n app.setTitleCount(0);\n m.redraw();\n });\n this.loadingUpdated = true;\n },\n loading: this.loadingUpdated\n }, app.translator.trans('flarum-pusher.forum.discussion_list.show_updates_text', {\n count\n })));\n }\n }\n });\n extend(DiscussionPage.prototype, 'oncreate', function () {\n app.pusher.then(binding => {\n const pusher = binding.pusher;\n pusher.bind('newPost', data => {\n const id = String(data.discussionId);\n const discussionId = this.discussion?.id();\n if (this.discussion && discussionId === id && this.stream) {\n const oldCount = this.discussion.commentCount() ?? 0;\n app.store.find('discussions', discussionId).then(() => {\n this.stream?.update().then(m.redraw);\n if (!document.hasFocus()) {\n app.setTitleCount(Math.max(0, (this.discussion?.commentCount() ?? 0) - oldCount));\n window.addEventListener('focus', () => app.setTitleCount(0), {\n once: true\n });\n }\n });\n }\n });\n });\n });\n extend(DiscussionPage.prototype, 'onremove', function () {\n app.pusher.then(binding => {\n binding.pusher.unbind('newPost');\n });\n });\n extend(IndexPage.prototype, 'actionItems', items => {\n items.remove('refresh');\n });\n app.pusher.then(binding => {\n const channels = binding.channels;\n if (channels.user) {\n channels.user.bind('notification', () => {\n if (app.session.user) {\n app.session.user.pushAttributes({\n unreadNotificationCount: app.session.user.unreadNotificationCount() ?? 0 + 1,\n newNotificationCount: app.session.user.newNotificationCount() ?? 0 + 1\n });\n }\n app.notifications.clear();\n m.redraw();\n });\n }\n });\n});"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","flarum","reg","add","import","socket","Pusher","attribute","authEndpoint","cluster","auth","headers","csrfToken","channels","main","subscribe","user","id","pusher","extend","then","binding","bind","data","params","getParams","q","sort","filter","tags","tag","getBy","tagId","tagIds","includes","String","discussionId","indexOf","push","matches","length","m","redraw","unbind","vdom","count","children","Array","unshift","className","onclick","this","attrs","state","refresh","loadingUpdated","loading","trans","discussion","stream","oldCount","commentCount","find","update","document","hasFocus","Math","max","window","addEventListener","once","items","remove","pushAttributes","unreadNotificationCount","newNotificationCount","clear"],"sourceRoot":""} |