mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 22:53:37 +08:00
05f80b7b83
Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci]
2 lines
41 KiB
JavaScript
Executable File
Generated
2 lines
41 KiB
JavaScript
Executable File
Generated
(()=>{var t={3:function(t){t.exports=function(){"use strict";var t,a,e=1e3,n=6e4,r=36e5,s=864e5,i=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,o=31536e6,l=2592e6,c=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,u={years:o,months:l,days:s,hours:r,minutes:n,seconds:e,milliseconds:1,weeks:6048e5},m=function(t){return t instanceof v},d=function(t,a,e){return new v(t,e,a.$l)},p=function(t){return a.p(t)+"s"},f=function(t){return t<0},g=function(t){return f(t)?Math.ceil(t):Math.floor(t)},h=function(t){return Math.abs(t)},k=function(t,a){return t?f(t)?{negative:!0,format:""+h(t)+a}:{negative:!1,format:""+t+a}:{negative:!1,format:""}},v=function(){function f(t,a,e){var n=this;if(this.$d={},this.$l=e,void 0===t&&(this.$ms=0,this.parseFromMilliseconds()),a)return d(t*u[p(a)],this);if("number"==typeof t)return this.$ms=t,this.parseFromMilliseconds(),this;if("object"==typeof t)return Object.keys(t).forEach((function(a){n.$d[p(a)]=t[a]})),this.calMilliseconds(),this;if("string"==typeof t){var r=t.match(c);if(r){var s=r.slice(2).map((function(t){return null!=t?Number(t):0}));return this.$d.years=s[0],this.$d.months=s[1],this.$d.weeks=s[2],this.$d.days=s[3],this.$d.hours=s[4],this.$d.minutes=s[5],this.$d.seconds=s[6],this.calMilliseconds(),this}}return this}var h=f.prototype;return h.calMilliseconds=function(){var t=this;this.$ms=Object.keys(this.$d).reduce((function(a,e){return a+(t.$d[e]||0)*u[e]}),0)},h.parseFromMilliseconds=function(){var t=this.$ms;this.$d.years=g(t/o),t%=o,this.$d.months=g(t/l),t%=l,this.$d.days=g(t/s),t%=s,this.$d.hours=g(t/r),t%=r,this.$d.minutes=g(t/n),t%=n,this.$d.seconds=g(t/e),t%=e,this.$d.milliseconds=t},h.toISOString=function(){var t=k(this.$d.years,"Y"),a=k(this.$d.months,"M"),e=+this.$d.days||0;this.$d.weeks&&(e+=7*this.$d.weeks);var n=k(e,"D"),r=k(this.$d.hours,"H"),s=k(this.$d.minutes,"M"),i=this.$d.seconds||0;this.$d.milliseconds&&(i+=this.$d.milliseconds/1e3);var o=k(i,"S"),l=t.negative||a.negative||n.negative||r.negative||s.negative||o.negative,c=r.format||s.format||o.format?"T":"",u=(l?"-":"")+"P"+t.format+a.format+n.format+c+r.format+s.format+o.format;return"P"===u||"-P"===u?"P0D":u},h.toJSON=function(){return this.toISOString()},h.format=function(t){var e=t||"YYYY-MM-DDTHH:mm:ss",n={Y:this.$d.years,YY:a.s(this.$d.years,2,"0"),YYYY:a.s(this.$d.years,4,"0"),M:this.$d.months,MM:a.s(this.$d.months,2,"0"),D:this.$d.days,DD:a.s(this.$d.days,2,"0"),H:this.$d.hours,HH:a.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:a.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:a.s(this.$d.seconds,2,"0"),SSS:a.s(this.$d.milliseconds,3,"0")};return e.replace(i,(function(t,a){return a||String(n[t])}))},h.as=function(t){return this.$ms/u[p(t)]},h.get=function(t){var a=this.$ms,e=p(t);return"milliseconds"===e?a%=1e3:a="weeks"===e?g(a/u[e]):this.$d[e],0===a?0:a},h.add=function(t,a,e){var n;return n=a?t*u[p(a)]:m(t)?t.$ms:d(t,this).$ms,d(this.$ms+n*(e?-1:1),this)},h.subtract=function(t,a){return this.add(t,a,!0)},h.locale=function(t){var a=this.clone();return a.$l=t,a},h.clone=function(){return d(this.$ms,this)},h.humanize=function(a){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!a)},h.milliseconds=function(){return this.get("milliseconds")},h.asMilliseconds=function(){return this.as("milliseconds")},h.seconds=function(){return this.get("seconds")},h.asSeconds=function(){return this.as("seconds")},h.minutes=function(){return this.get("minutes")},h.asMinutes=function(){return this.as("minutes")},h.hours=function(){return this.get("hours")},h.asHours=function(){return this.as("hours")},h.days=function(){return this.get("days")},h.asDays=function(){return this.as("days")},h.weeks=function(){return this.get("weeks")},h.asWeeks=function(){return this.as("weeks")},h.months=function(){return this.get("months")},h.asMonths=function(){return this.as("months")},h.years=function(){return this.get("years")},h.asYears=function(){return this.as("years")},f}();return function(e,n,r){t=r,a=r().$utils(),r.duration=function(t,a){var e=r.locale();return d(t,{$l:e},a)},r.isDuration=m;var s=n.prototype.add,i=n.prototype.subtract;n.prototype.add=function(t,a){return m(t)&&(t=t.asMilliseconds()),s.bind(this)(t,a)},n.prototype.subtract=function(t,a){return m(t)&&(t=t.asMilliseconds()),i.bind(this)(t,a)}}}()}},a={};function e(n){var r=a[n];if(void 0!==r)return r.exports;var s=a[n]={exports:{}};return t[n].call(s.exports,s,s.exports,e),s.exports}e.n=t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},e.d=(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},e.o=(t,a)=>Object.prototype.hasOwnProperty.call(t,a),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";e.r(n);const t=flarum.core.compat["common/extend"],a=flarum.core.compat["admin/app"];var r=e.n(a);const s=flarum.core.compat["admin/components/ExtensionPage"];var i=e.n(s);const o=flarum.core.compat["common/components/Button"];var l=e.n(o);const c=flarum.core.compat["admin/components/LoadingModal"];var u=e.n(c);const d=flarum.core.compat["admin/utils/isExtensionEnabled"];var p=e.n(d);function f(t,a){return f=Object.setPrototypeOf||function(t,a){return t.__proto__=a,t},f(t,a)}function g(t,a){t.prototype=Object.create(a.prototype),t.prototype.constructor=t,f(t,a)}function h(t,a){if(null==t)return{};var e,n,r={},s=Object.keys(t);for(n=0;n<s.length;n++)e=s[n],a.indexOf(e)>=0||(r[e]=t[e]);return r}const k=flarum.core.compat["common/Component"];var v=e.n(k);const y=flarum.core.compat["common/components/LoadingIndicator"];var b=e.n(y);const x=flarum.core.compat["common/components/Tooltip"];var w=e.n(x);const N=flarum.core.compat["common/helpers/icon"];var _=e.n(N);const M=flarum.core.compat["common/utils/ItemList"];var P=e.n(M);const U=flarum.core.compat["common/utils/extractText"];var j=e.n(U);const T=flarum.core.compat["common/utils/classList"];var q=e.n(T),B=["className","type"],S=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.view=function(t){var a=this.attrs,e=a.className,n=(a.type,h(a,B));return m("span",Object.assign({className:q()(["Label","Label--"+this.attrs.type,e])},n),t.children)},a}(v());const L=flarum.core.compat["common/components/Modal"];var O=e.n(L),A=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.className=function(){return"Modal--large QuickModal"},e.title=function(){return r().translator.trans("flarum-package-manager.admin.sections.queue.operations."+this.attrs.task.operation())},e.content=function(){return m("div",{className:"Modal-body"},m("div",{className:"TaskOutputModal-data"},m("div",{className:"Form-group"},m("label",null,r().translator.trans("flarum-package-manager.admin.sections.queue.output_modal.command")),m("div",{className:"FormControl TaskOutputModal-data-command"},m("code",null,"$ composer ",this.attrs.task.command()))),m("div",{className:"Form-group"},m("label",null,r().translator.trans("flarum-package-manager.admin.sections.queue.output_modal.output")),m("div",{className:"FormControl TaskOutputModal-data-output"},m("code",null,m("pre",null,this.attrs.task.output()))))))},a}(O()),C=e(3),E=e.n(C),I=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.view=function(){var t=this;return m("nav",{class:"Pagination UserListPage-gridPagination"},m(l(),{disabled:!this.attrs.list.hasPrev(),title:r().translator.trans("core.admin.users.pagination.back_button"),onclick:function(){return t.attrs.list.prev()},icon:"fas fa-chevron-left",className:"Button Button--icon UserListPage-backBtn"}),m("span",{class:"UserListPage-pageNumber"},r().translator.trans("core.admin.users.pagination.page_counter",{current:this.attrs.list.pageNumber()+1,total:this.attrs.list.getTotalPages()})),m(l(),{disabled:!this.attrs.list.hasNext(),title:r().translator.trans("core.admin.users.pagination.next_button"),onclick:function(){return t.attrs.list.next()},icon:"fas fa-chevron-right",className:"Button Button--icon UserListPage-nextBtn"}))},a}(v()),F=["label","content"],D=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.oninit=function(a){t.prototype.oninit.call(this,a),r().packageManager.queue.load()},e.view=function(){return m("section",{id:"PackageManager-queueSection",className:"ExtensionPage-permissions PackageManager-queueSection"},m("div",{className:"ExtensionPage-permissions-header PackageManager-queueSection-header"},m("div",{className:"container"},m("h2",{className:"ExtensionTitle"},r().translator.trans("flarum-package-manager.admin.sections.queue.title")),m(l(),{className:"Button Button--icon",icon:"fas fa-sync-alt",onclick:function(){return r().packageManager.queue.load()},"aria-label":r().translator.trans("flarum-package-manager.admin.sections.queue.refresh")}))),m("div",{className:"container"},this.queueTable()))},e.columns=function(){var t=this,a=new(P());return a.add("operation",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.operation")),content:function(a){return m("div",{className:"PackageManager-queueTable-operation"},m("span",{className:"PackageManager-queueTable-operation-icon"},t.operationIcon(a.operation())),m("span",{className:"PackageManager-queueTable-operation-name"},r().translator.trans("flarum-package-manager.admin.sections.queue.operations."+a.operation())))}},80),a.add("package",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.package")),content:function(t){var a,e=r().data.extensions[null==(a=t.package())?void 0:a.replace(/(\/flarum-|\/flarum-ext-|\/)/g,"-")];return e?m("div",{className:"PackageManager-queueTable-package"},m("div",{className:"PackageManager-queueTable-package-icon ExtensionIcon",style:e.icon},e.icon?_()(e.icon.name):""),m("div",{className:"PackageManager-queueTable-package-details"},m("span",{className:"PackageManager-queueTable-package-title"},e.extra["flarum-extension"].title),m("span",{className:"PackageManager-queueTable-package-name"},t.package()))):t.package()}},75),a.add("status",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.status")),content:function(t){return m(S,{className:"PackageManager-queueTable-status",type:{running:"neutral",failure:"error",pending:"warning",success:"success"}[t.status()]},r().translator.trans("flarum-package-manager.admin.sections.queue.statuses."+t.status()))}},70),a.add("elapsedTime",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.elapsed_time")),content:function(t){return t.startedAt()?m(w(),{text:dayjs(t.startedAt()).format("LL LTS")+" "+dayjs(t.finishedAt()).format("LL LTS")},m("span",null,function(t,a){dayjs.extend(E());var e=dayjs(a).diff(t);return dayjs.duration(e).humanize()}(t.startedAt(),t.finishedAt()))):r().translator.trans("flarum-package-manager.admin.sections.queue.task_just_started")}},65),a.add("memoryUsed",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.peak_memory_used")),content:function(t){return m("span",null,t.peakMemoryUsed())}},60),a.add("details",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.details")),content:function(t){return m(l(),{className:"Button Button--icon Table-controls-item",icon:"fas fa-file-alt","aria-label":r().translator.trans("flarum-package-manager.admin.sections.queue.columns.details"),onclick:function(){return r().modal.show(A,{task:t})}})},className:"Table-controls"},55),a},e.queueTable=function(){var t=r().packageManager.queue.getItems();if(!t)return m(b(),null);if(t&&!t.length)return m("h3",{className:"ExtensionPage-subHeader"},r().translator.trans("flarum-package-manager.admin.sections.queue.none"));var a=this.columns();return m("[",null,m("table",{className:"Table PackageManager-queueTable"},m("thead",null,m("tr",null,a.toArray().map((function(t,a){return m("th",{key:a},t.label)})))),m("tbody",null,t.map((function(t,e){return m("tr",{key:e},a.toArray().map((function(a,e){a.label;var n=a.content,r=h(a,F);return m("td",Object.assign({key:e},r),n(t))})))})))),m(I,{list:r().packageManager.queue}))},e.operationIcon=function(t){return _()({update_check:"fas fa-sync-alt",update_major:"fas fa-play",update_minor:"fas fa-play",update_global:"fas fa-play",extension_install:"fas fa-download",extension_remove:"fas fa-times",extension_update:"fas fa-arrow-alt-circle-up",why_not:"fas fa-exclamation-circle"}[t])},a}(v());const Y=flarum.core.compat["common/components/Alert"];var H=e.n(Y);const R=flarum.core.compat["common/utils/Stream"];var W=e.n(R);function z(t){var a=t.response.errors[0];if(!["composer_command_failure","extension_already_installed","extension_not_installed"].includes(a.code))throw t;switch(a.code){case"composer_command_failure":a.guessed_cause?(r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.guessed_cause."+a.guessed_cause)),r().modal.close()):r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.composer_command_failure"));break;case"extension_already_installed":r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.extension_already_installed")),r().modal.close();break;case"extension_not_installed":r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.extension_not_installed")),r().modal.close()}}function G(){r().modal.close(),m.route.set(r().route("extension",{id:"flarum-package-manager"})),r().packageManager.queue.load(),setTimeout((function(){var t;null==(t=document.getElementById("PackageManager-queueSection"))||t.scrollIntoView({block:"nearest"})}),200)}window.jumpToQueue=G;var V=function(t){function a(){for(var a,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(a=t.call.apply(t,[this].concat(n))||this).packageName=void 0,a}g(a,t);var e=a.prototype;return e.oninit=function(a){t.prototype.oninit.call(this,a),this.packageName=W()("")},e.view=function(){return m("div",{className:"Form-group PackageManager-installer"},m("label",{htmlFor:"install-extension"},r().translator.trans("flarum-package-manager.admin.extensions.install")),m("p",{className:"helpText"},r().translator.trans("flarum-package-manager.admin.extensions.install_help",{extiverse:m("a",{href:"https://extiverse.com"},"extiverse.com")})),m("div",{className:"FormControl-container"},m("input",{className:"FormControl",id:"install-extension",placeholder:"vendor/package-name",bidi:this.packageName}),m(l(),{className:"Button",icon:"fas fa-download",onclick:this.onsubmit.bind(this),loading:r().packageManager.control.isLoading("extension-install"),disabled:r().packageManager.control.isLoadingOtherThan("extension-install")},r().translator.trans("flarum-package-manager.admin.extensions.proceed"))))},e.data=function(){return{package:this.packageName()}},e.onsubmit=function(){r().packageManager.control.setLoading("extension-install"),r().modal.show(u()),r().request({method:"POST",url:r().forum.attribute("apiUrl")+"/package-manager/extensions",body:{data:this.data()},errorHandler:z}).then((function(t){if(t.processing)G();else{var a=t.id;r().alerts.show({type:"success"},r().translator.trans("flarum-package-manager.admin.extensions.successful_install",{extension:a})),window.location.href=r().forum.attribute("adminUrl")+"#/extension/"+a,window.location.reload()}})).finally((function(){r().packageManager.control.setLoading(null),m.redraw()}))},a}(v());const Z=flarum.core.compat["common/helpers/humanTime"];var J=e.n(Z),K=function(t){function a(){for(var a,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(a=t.call.apply(t,[this].concat(n))||this).loading=!0,a.whyNot=null,a}g(a,t);var e=a.prototype;return e.className=function(){return"Modal--large WhyNotModal"},e.title=function(){return r().translator.trans("flarum-package-manager.admin.why_not_modal.title")},e.oncreate=function(a){t.prototype.oncreate.call(this,a),this.requestWhyNot()},e.content=function(){return m("div",{className:"Modal-body"},this.loading?m(b(),null):m("pre",{className:"WhyNotModal-contents"},this.whyNot))},e.requestWhyNot=function(){var t=this;r().request({method:"POST",url:r().forum.attribute("apiUrl")+"/package-manager/why-not",body:{data:{package:this.attrs.package}},errorHandler:z}).then((function(a){t.loading=!1,t.whyNot=a.data.reason,m.redraw()}))},a}(O()),Q=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.view=function(t){var a,e=this.attrs,n=e.extension,s=e.updates,i=e.onClickUpdate,o=e.whyNotWarning,c=e.isCore,u=e.isDanger,d=null!=(a=s["latest-minor"])?a:s["latest-major"]&&!c?s["latest-major"]:null;return m("div",{className:q()({"PackageManager-extension":!0,"PackageManager-extension--core":c,"PackageManager-extension--danger":u})},m("div",{className:"PackageManager-extension-icon ExtensionIcon",style:n.icon},n.icon?_()(n.icon.name):""),m("div",{className:"PackageManager-extension-info"},m("div",{className:"PackageManager-extension-name"},n.extra["flarum-extension"].title),m("div",{className:"PackageManager-extension-version"},m("span",{className:"PackageManager-extension-version-current"},this.version(s.version)),d?m(S,{className:"PackageManager-extension-version-latest",type:s["latest-minor"]?"success":"warning"},this.version(d)):null)),m("div",{className:"PackageManager-extension-controls"},i?m(w(),{text:r().translator.trans("flarum-package-manager.admin.extensions.update")},m(l(),{icon:"fas fa-arrow-alt-circle-up",className:"Button Button--icon Button--flat",onclick:i,"aria-label":r().translator.trans("flarum-package-manager.admin.extensions.update")})):null,o?m(w(),{text:r().translator.trans("flarum-package-manager.admin.extensions.check_why_it_failed_updating")},m(l(),{icon:"fas fa-exclamation-circle",className:"Button Button--icon Button--flat Button--danger",onclick:function(){return r().modal.show(K,{package:n.name})},"aria-label":r().translator.trans("flarum-package-manager.admin.extensions.check_why_it_failed_updating")})):null))},e.version=function(t){return"v"+t.replace("v","")},a}(v()),X=function(t){function a(){for(var a,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(a=t.call.apply(t,[this].concat(n))||this).updateState=void 0,a}g(a,t);var e=a.prototype;return e.oninit=function(a){t.prototype.oninit.call(this,a),this.updateState=this.attrs.updateState},e.view=function(){return m("div",{className:"Form-group Form-group--danger PackageManager-majorUpdate"},m("img",{alt:"flarum logo",src:r().forum.attribute("baseUrl")+"/assets/extensions/flarum-package-manager/flarum.svg"}),m("label",null,r().translator.trans("flarum-package-manager.admin.major_updater.title",{version:this.attrs.coreUpdate["latest-major"]})),m("p",{className:"helpText"},r().translator.trans("flarum-package-manager.admin.major_updater.description")),m("div",{className:"PackageManager-updaterControls"},m(w(),{text:r().translator.trans("flarum-package-manager.admin.major_updater.dry_run_help")},m(l(),{className:"Button",icon:"fas fa-vial",onclick:this.update.bind(this,!0),disabled:r().packageManager.control.isLoadingOtherThan("major-update-dry-run")},r().translator.trans("flarum-package-manager.admin.major_updater.dry_run"))),m(l(),{className:"Button Button--danger",icon:"fas fa-play",onclick:this.update.bind(this,!1),disabled:r().packageManager.control.isLoadingOtherThan("major-update")},r().translator.trans("flarum-package-manager.admin.major_updater.update"))),this.updateState.incompatibleExtensions.length?m("div",{className:"PackageManager-majorUpdate-incompatibleExtensions PackageManager-extensions-grid"},this.updateState.incompatibleExtensions.map((function(t){return m(Q,{extension:r().data.extensions[t.replace("flarum-","").replace("flarum-ext-","").replace("/","-")],updates:{},onClickUpdate:null,isDanger:!0})}))):null,"failure"===this.updateState.status?m(H(),{type:"error",className:"PackageManager-majorUpdate-failure",dismissible:!1,controls:[m(l(),{className:"Button Button--text PackageManager-majorUpdate-failure-details",icon:"fas fa-question-circle",onclick:function(){return r().modal.show(K,{package:"flarum/core"})}},r().translator.trans("flarum-package-manager.admin.major_updater.failure.why"))]},m("p",{className:"PackageManager-majorUpdate-failure-desc"},r().translator.trans("flarum-package-manager.admin.major_updater.failure.desc"))):null)},e.update=function(t){var a=this;r().packageManager.control.setLoading(t?"major-update-dry-run":"major-update"),r().modal.show(u()),r().request({method:"POST",url:r().forum.attribute("apiUrl")+"/package-manager/major-update",body:{data:{dryRun:t}},errorHandler:z}).then((function(t){null!=t&&t.processing?G():(r().alerts.show({type:"success"},r().translator.trans("flarum-package-manager.admin.update_successful")),window.location.reload())})).catch((function(t){var e,n,s;r().modal.close(),a.updateState.status="failure",a.updateState.incompatibleExtensions=null==(e=t.response)||null==(n=e.errors)||null==(s=n.pop())?void 0:s.incompatible_extensions})).finally((function(){r().packageManager.control.setLoading(null),m.redraw()}))},a}(v());function tt(){return tt=Object.assign||function(t){for(var a=1;a<arguments.length;a++){var e=arguments[a];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},tt.apply(this,arguments)}function at(t,a){for(var e=0;e<a.length;e++){var n=a[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function et(t,a,e){return a&&at(t.prototype,a),e&&at(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function nt(t){var a=typeof t;return"function"===a||"object"===a&&!!t}var rt=function(t,a){this.content=void 0,this.priority=void 0,this.content=t,this.priority=a},st=function(){function t(){this._items={}}var a=t.prototype;return a.isEmpty=function(){return 0===Object.keys(this._items).length},a.has=function(t){return Object.keys(this._items).includes(t)},a.get=function(t){return this._items[t].content},a.getPriority=function(t){return this._items[t].priority},a.add=function(t,a,e){return void 0===e&&(e=0),this._items[t]=new rt(a,e),this},a.replace=function(t,a,e){return void 0===a&&(a=null),void 0===e&&(e=null),this.has(t)?(null!==a&&(this._items[t].content=a),null!==e&&(this._items[t].priority=e),this):this},a.setContent=function(t,a){if(!this.has(t))throw new Error("[ItemList] Cannot set content of Item. Key `"+t+"` is not present.");return this.replace(t,a)},a.setPriority=function(t,a){if(!this.has(t))throw new Error("[ItemList] Cannot set priority of Item. Key `"+t+"` is not present.");return this._items[t].priority=a,this},a.remove=function(t){return delete this._items[t],this},a.merge=function(t){var a=this;return Object.keys(t._items).forEach((function(e){var n=t._items[e];n instanceof rt&&(a._items[e]=n)})),this},a.toArray=function(t){var a=this;return void 0===t&&(t=!1),Object.keys(this._items).map((function(e,n){var r=a._items[e];return!t||nt(r.content)?tt({},r,{content:a.createItemContentProxy(nt(r.content)?r.content:Object(r.content),e)}):tt({},r)})).sort((function(t,a){return a.priority-t.priority})).map((function(t){return t.content}))},a.toObject=function(){var t=this;return Object.keys(this._items).reduce((function(a,e){var n={content:t.get(e),itemName:e,priority:t.getPriority(e)};return a[e]=n,a}),{})},a.createItemContentProxy=function(t,a){return new Proxy(t,{get:function(t,e,n){return"itemName"===e?a:Reflect.get(t,e,n)},set:function(t,e,n,r){if(null!==a&&"itemName"===e)throw new Error("`itemName` property is read-only");return Reflect.set(t,e,n,r)}})},et(t,[{key:"items",get:function(){return new Proxy(this._items,{set:function(){return console.warn("Modifying `ItemList.items` is not allowed."),!1}})}}]),t}(),it=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.view=function(){var t=r().packageManager.control.coreUpdate;return[m("div",{className:"Form-group"},m("label",null,r().translator.trans("flarum-package-manager.admin.updater.updater_title")),m("p",{className:"helpText"},r().translator.trans("flarum-package-manager.admin.updater.updater_help")),this.lastUpdateCheckView(),m("div",{className:"PackageManager-updaterControls"},this.controlItems().toArray()),this.availableUpdatesView()),t&&t.package["latest-major"]?m(X,{coreUpdate:t.package,updateState:r().packageManager.control.lastUpdateRun.major}):null]},e.lastUpdateCheckView=function(){var t;return(null==(t=r().packageManager.control.lastUpdateCheck)?void 0:t.checkedAt)&&m("p",{className:"PackageManager-lastUpdatedAt"},m("span",{className:"PackageManager-lastUpdatedAt-label"},r().translator.trans("flarum-package-manager.admin.updater.last_update_checked_at")),m("span",{className:"PackageManager-lastUpdatedAt-value"},J()(r().packageManager.control.lastUpdateCheck.checkedAt)))||null},e.availableUpdatesView=function(){var t=r().packageManager.control;return r().packageManager.control.isLoading()?m("div",{className:"PackageManager-extensions"},m(b(),null)):t.extensionUpdates.length||t.coreUpdate?m("div",{className:"PackageManager-extensions"},m("div",{className:"PackageManager-extensions-grid"},t.coreUpdate?m(Q,{extension:t.coreUpdate.extension,updates:t.coreUpdate.package,isCore:!0,onClickUpdate:function(){return t.updateCoreMinor()},whyNotWarning:t.lastUpdateRun.limitedPackages().includes("flarum/core")}):null,t.extensionUpdates.map((function(a){return m(Q,{extension:a,updates:t.packageUpdates[a.id],onClickUpdate:function(){return t.updateExtension(a)},whyNotWarning:t.lastUpdateRun.limitedPackages().includes(a.name)})})))):m("div",{className:"PackageManager-extensions"},m(H(),{type:"success",dismissible:!1},r().translator.trans("flarum-package-manager.admin.updater.up_to_date")))},e.controlItems=function(){var t=new st;return t.add("updateCheck",m(l(),{className:"Button",icon:"fas fa-sync-alt",onclick:function(){return r().packageManager.control.checkForUpdates()},loading:r().packageManager.control.isLoading("check"),disabled:r().packageManager.control.isLoadingOtherThan("check")},r().translator.trans("flarum-package-manager.admin.updater.check_for_updates")),100),t.add("globalUpdate",m(l(),{className:"Button",icon:"fas fa-play",onclick:function(){return r().packageManager.control.updateGlobally()},loading:r().packageManager.control.isLoading("global-update"),disabled:r().packageManager.control.isLoadingOtherThan("global-update")},r().translator.trans("flarum-package-manager.admin.updater.run_global_update"))),t},a}(v()),ot=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.oninit=function(a){t.prototype.oninit.call(this,a)},e.view=function(){return m("div",{className:"ExtensionPage-permissions PackageManager-controlSection"},m("div",{className:"ExtensionPage-permissions-header"},m("div",{className:"container"},m("h2",{className:"ExtensionTitle"},r().translator.trans("flarum-package-manager.admin.sections.control.title")))),m("div",{className:"container"},r().data["flarum-package-manager.writable_dirs"]?m("[",null,m(V,null),m(it,null)):m("div",{className:"Form-group"},m(H(),{type:"warning",dismissible:!1},r().translator.trans("flarum-package-manager.admin.file_permissions")))))},a}(v()),lt=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.sections=function(a){var e=t.prototype.sections.call(this,a);return e.setPriority("content",10),e.add("control",m(ot,null),8),parseInt(r().data.settings["flarum-package-manager.queue_jobs"])&&e.add("queue",m(D,null),5),e.setPriority("permissions",0),e},a}(i());const ct=flarum.core.compat["common/Model"];var ut=e.n(ct),mt=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],dt=["B","kiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],pt=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],ft=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],gt=function(t,a,e){var n=t;return"string"==typeof a||Array.isArray(a)?n=t.toLocaleString(a,e):!0!==a&&void 0===e||(n=t.toLocaleString(void 0,e)),n},ht=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.status=function(){return ut().attribute("status").call(this)},e.operation=function(){return ut().attribute("operation").call(this)},e.command=function(){return ut().attribute("command").call(this)},e.package=function(){return ut().attribute("package").call(this)},e.output=function(){return ut().attribute("output").call(this)},e.createdAt=function(){return ut().attribute("createdAt",ut().transformDate).call(this)},e.startedAt=function(){return ut().attribute("startedAt",ut().transformDate).call(this)},e.finishedAt=function(){return ut().attribute("finishedAt",ut().transformDate).call(this)},e.peakMemoryUsed=function(){return function(t,a){if(!Number.isFinite(t))throw new TypeError("Expected a finite number, got "+typeof t+": "+t);var e=(a=tt({bits:!1,binary:!1},a)).bits?a.binary?ft:pt:a.binary?dt:mt;if(a.signed&&0===t)return" 0 "+e[0];var n,r=t<0,s=r?"-":a.signed?"+":"";if(r&&(t=-t),void 0!==a.minimumFractionDigits&&(n={minimumFractionDigits:a.minimumFractionDigits}),void 0!==a.maximumFractionDigits&&(n=tt({maximumFractionDigits:a.maximumFractionDigits},n)),t<1)return s+gt(t,a.locale,n)+" "+e[0];var i=Math.min(Math.floor(a.binary?Math.log(t)/Math.log(1024):Math.log10(t)/3),e.length-1);return t/=Math.pow(a.binary?1024:1e3,i),n||(t=t.toPrecision(3)),s+gt(Number(t),a.locale,n)+" "+e[i]}(1024*ut().attribute("peakMemoryUsed").call(this))},a}(ut()),kt=function(){function t(){this.tasks=null,this.limit=20,this.offset=0,this.total=0}var a=t.prototype;return a.load=function(t){var a,e=this;return this.tasks=null,t=tt({page:tt({limit:this.limit,offset:this.offset},null==(a=t)?void 0:a.page)},t),r().store.find("package-manager-tasks",t||{}).then((function(t){var a;return e.tasks=t,e.total=null==(a=t.payload.meta)?void 0:a.total,m.redraw(),t}))},a.getItems=function(){return this.tasks},a.getTotalPages=function(){return Math.ceil(this.total/this.limit)},a.pageNumber=function(){return Math.ceil(this.offset/this.limit)},a.hasPrev=function(){return 0!==this.pageNumber()},a.hasNext=function(){return this.offset+this.limit<this.total},a.prev=function(){this.hasPrev()&&(this.offset-=this.limit,this.load())},a.next=function(){this.hasNext()&&(this.offset+=this.limit,this.load())},t}(),vt=function(){function t(){this.loading=null,this.packageUpdates={},this.lastUpdateCheck=void 0,this.extensionUpdates=void 0,this.coreUpdate=null,this.lastUpdateCheck=JSON.parse(r().data.settings["flarum-package-manager.last_update_check"]),this.extensionUpdates=this.formatExtensionUpdates(this.lastUpdateCheck),this.coreUpdate=this.formatCoreUpdate(this.lastUpdateCheck)}var a=t.prototype;return a.isLoading=function(t){return void 0===t&&(t=null),t&&this.loading===t||!t&&null!==this.loading},a.isLoadingOtherThan=function(t){return null!==this.loading&&this.loading!==t},a.setLoading=function(t){this.loading=t},a.checkForUpdates=function(){var t=this;this.setLoading("check"),r().request({method:"POST",url:r().forum.attribute("apiUrl")+"/package-manager/check-for-updates",errorHandler:z}).then((function(a){a.processing?G():(t.lastUpdateCheck=a,t.extensionUpdates=t.formatExtensionUpdates(a),t.coreUpdate=t.formatCoreUpdate(a),m.redraw())})).finally((function(){t.setLoading(null),m.redraw()}))},a.updateCoreMinor=function(){var t=this;confirm(j()(r().translator.trans("flarum-package-manager.admin.minor_update_confirmation.content")))&&(r().modal.show(u()),this.setLoading("minor-update"),r().request({method:"POST",url:r().forum.attribute("apiUrl")+"/package-manager/minor-update",errorHandler:z}).then((function(t){null!=t&&t.processing?G():(r().alerts.show({type:"success"},r().translator.trans("flarum-package-manager.admin.update_successful")),window.location.reload())})).finally((function(){t.setLoading(null),r().modal.close(),m.redraw()})))},a.updateExtension=function(t){var a=this;r().modal.show(u()),this.setLoading("extension-update"),r().request({method:"PATCH",url:r().forum.attribute("apiUrl")+"/package-manager/extensions/"+t.id,errorHandler:z}).then((function(a){null!=a&&a.processing?G():(r().alerts.show({type:"success"},r().translator.trans("flarum-package-manager.admin.extensions.successful_update",{extension:t.extra["flarum-extension"].title})),window.location.reload())})).finally((function(){a.setLoading(null),r().modal.close(),m.redraw()}))},a.updateGlobally=function(){var t=this;r().modal.show(u()),this.setLoading("global-update"),r().request({method:"POST",url:r().forum.attribute("apiUrl")+"/package-manager/global-update",errorHandler:z}).then((function(t){null!=t&&t.processing?G():(r().alerts.show({type:"success"},r().translator.trans("flarum-package-manager.admin.updater.global_update_successful")),window.location.reload())})).finally((function(){t.setLoading(null),r().modal.close(),m.redraw()}))},a.formatExtensionUpdates=function(t){var a,e,n=this;return this.packageUpdates={},null==t||null==(a=t.updates)||null==(e=a.installed)||e.filter((function(t){var a=t.name.replace("/","-").replace(/(flarum-ext-)|(flarum-)/,""),e=r().data.extensions[a],s=["semver-safe-update","update-possible"].includes(t["latest-status"]);return e&&s&&(n.packageUpdates[e.id]=t),e&&s})),Object.values(r().data.extensions).filter((function(t){return n.packageUpdates[t.id]}))},a.formatCoreUpdate=function(t){var a,e,n=null==t||null==(a=t.updates)||null==(e=a.installed)?void 0:e.filter((function(t){return"flarum/core"===t.name})).pop();return n?{package:n,extension:{id:"flarum-core",name:"flarum/core",version:r().data.settings.version,icon:{backgroundImage:"url("+r().forum.attribute("baseUrl")+"/assets/extensions/flarum-package-manager/flarum.svg"},extra:{"flarum-extension":{title:j()(r().translator.trans("flarum-package-manager.admin.updater.flarum"))}}}}:null},et(t,[{key:"lastUpdateRun",get:function(){var t=JSON.parse(r().data.settings["flarum-package-manager.last_update_run"]);return t.limitedPackages=function(){return[].concat(t.major.limitedPackages,t.minor.limitedPackages,t.global.limitedPackages)},t}}]),t}(),yt=function(){this.queue=new kt,this.control=new vt},bt=function(){function t(){this.element=void 0,this.attrs=void 0,this.state=void 0}var a=t.prototype;return a.oninit=function(t){this.setAttrs(t.attrs)},a.oncreate=function(t){this.element=t.dom},a.onbeforeupdate=function(t){this.setAttrs(t.attrs)},a.onupdate=function(t){},a.onbeforeremove=function(t){},a.onremove=function(t){},a.$=function(t){function a(a){return t.apply(this,arguments)}return a.toString=function(){return t.toString()},a}((function(t){var a=$(this.element);return t?a.find(t):a})),t.component=function(t,a){void 0===t&&(t={}),void 0===a&&(a=null);var e=tt({},t);return m(this,e,a)},a.setAttrs=function(t){if(void 0===t&&(t={}),this.constructor.initAttrs(t),t){if("children"in t)throw new Error("["+this.constructor.name+'] The "children" attribute of attrs should never be used. Either pass children in as the vnode children or rename the attribute');if("tag"in t)throw new Error("["+this.constructor.name+'] You cannot use the "tag" attribute name with Mithril 2.')}this.attrs=t},t.initAttrs=function(t){},t}(),xt=window;const wt=new Proxy({},{get:function(t,a){return Reflect.get(xt.app,a,xt.app)},set:function(t,a,e){return Reflect.set(xt.app,a,e,xt.app)}});function Nt(t,a){return void 0===a&&(a={}),a.className="icon "+t+" "+(a.className||""),m("i",Object.assign({"aria-hidden":"true"},a))}function _t(t){var a,e,n="";if("string"==typeof t||"number"==typeof t)n+=t;else if("object"==typeof t)if(Array.isArray(t))for(a=0;a<t.length;a++)t[a]&&(e=_t(t[a]))&&(n&&(n+=" "),n+=e);else for(a in t)t[a]&&(n&&(n+=" "),n+=a);return n}const Mt=function(){for(var t,a,e=0,n="";e<arguments.length;)(t=arguments[e++])&&(a=_t(t))&&(n&&(n+=" "),n+=a);return n};function Pt(t){return t instanceof Array?t.map((function(t){return Pt(t)})).join(""):"object"==typeof t&&null!==t?t.children?Pt(t.children):String(t.text):String(t)}var Ut=["display","size","containerClassName","className"],jt=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.view=function(){var t=this.attrs,a=t.display,e=void 0===a?"block":a,n=t.size,r=void 0===n?"medium":n,s=t.containerClassName,i=t.className,o=h(t,Ut),l=Mt("LoadingIndicator",i),c=Mt("LoadingIndicator-container","unset"!==e&&"LoadingIndicator-container--"+e,r&&"LoadingIndicator-container--"+r,s);return m("div",Object.assign({"aria-label":wt.translator.trans("core.lib.loading_indicator.accessible_label"),role:"status"},o.containerAttrs,{"data-size":r,className:c}),m("div",Object.assign({"aria-hidden":"true",className:l},o)))},a}(bt),$t=["type","title","aria-label","icon","disabled","loading","className","class"],Tt=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.view=function(t){var a=this.attrs,e=a.type,n=a.title,r=a["aria-label"],s=a.icon,i=a.disabled,o=a.loading,l=a.className,c=a.class,u=h(a,$t);e||(e="button"),r||(r=n),"object"==typeof r&&(r=Pt(r)),(i||o)&&delete u.onclick;var d=tt({disabled:i,className:l=Mt(c,l,{hasIcon:s,disabled:i||o,loading:o}),type:e,"aria-label":r},u);return m("button",d,this.getButtonContent(t.children))},e.oncreate=function(e){var n;t.prototype.oncreate.call(this,e);var r=this.attrs["aria-label"];this.view!==a.prototype.view||r||Pt(e.children)||null!=(n=this.element)&&null!=n.getAttribute&&n.getAttribute("aria-label")||function(){var t;wt.forum.attribute("debug")&&(t=console).warn.apply(t,arguments)}('[Flarum Accessibility Warning] Button has no content and no accessible label. This means that screen-readers will not be able to interpret its meaning and just read "Button". Consider providing accessible text via the `aria-label` attribute. https://web.dev/button-name',this.element)},e.getButtonContent=function(t){var a=this.attrs.icon;return[a&&Nt(a,{className:"Button-icon"}),t&&m("span",{className:"Button-label"},t),this.attrs.loading&&m(jt,{size:"small",display:"inline"})]},a}(bt),qt=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.view=function(){return m("li",{className:"Dropdown-separator"})},a}(bt);qt.isListItem=!0;const Bt=qt;function St(t){return"object"==typeof t&&null!==t&&"tag"in t}function Lt(t){return St(t)&&t.tag===Bt}function Ot(t,a){var e=t[a];return delete t[a],e}var At=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.view=function(t){var a=Object.assign({},this.attrs),e=Ot(a,"type");a.className=Mt("Alert","Alert--"+e,a.className);var n=Ot(a,"title"),r=Ot(a,"icon"),s=Ot(a,"content")||t.children,i=Ot(a,"controls")||[],o=Ot(a,"dismissible"),l=Ot(a,"ondismiss"),c=[];return(o||void 0===o)&&c.push(m(Tt,{"aria-label":wt.translator.trans("core.lib.alert.dismiss_a11y_label"),icon:"fas fa-times",class:"Button Button--link Button--icon Alert-dismiss",onclick:l})),m("div",a,!!n&&m("div",{class:"Alert-title"},!!r&&m("span",{class:"Alert-title-icon"},Nt(r)),m("span",{class:"Alert-title-text"},n)),m("span",{class:"Alert-body"},s),m("ul",{class:"Alert-controls"},function(t,a,e){void 0===a&&(a="li"),void 0===e&&(e={});var n,r,s,i=a;return(n=t instanceof Array?t:[t],s=[],n.filter(Boolean).forEach((function(t,a){(!Lt(t)||r&&!Lt(r)&&a!==n.length-1)&&(r=t,s.push(t))})),s).map((function(t){var a,n,r=[t.itemName&&"item-"+t.itemName];if(St(t)&&t.tag.isListItem)return t.attrs=t.attrs||{},t.attrs.key=t.attrs.key||t.itemName,t.key=t.attrs.key,t;St(t)&&(r.push((null==(n=t.attrs)?void 0:n.itemClassName)||t.itemClassName),null!=t.tag.isActive&&t.tag.isActive(t.attrs)&&r.push("active"));var s=St(t)&&(null==t||null==(a=t.attrs)?void 0:a.key)||t.itemName;return m(i,Object.assign({className:Mt(r),key:s},e),t)}))}(i.concat(c))))},a}(bt);r().initializers.add("flarum-package-manager",(function(a){a.store.models["package-manager-tasks"]=ht,a.packageManager=new yt,a.extensionData.for("flarum-package-manager").registerSetting((function(){return m("div",{className:"Form-group"},m(At,{type:"warning",dismissible:!1},a.translator.trans("flarum-package-manager.admin.settings.access_warning")))})).registerSetting({setting:"flarum-package-manager.queue_jobs",label:a.translator.trans("flarum-package-manager.admin.settings.queue_jobs"),help:m.trust(j()(a.translator.trans("flarum-package-manager.admin.settings.queue_jobs_help",{basic_impl_link:"https://discuss.flarum.org/d/28151-database-queue-the-simplest-queue-even-for-shared-hosting",adv_impl_link:"https://discuss.flarum.org/d/21873-redis-sessions-cache-queues",php_version:"<strong>"+a.data.phpVersion+"</strong>",folder_perms_link:"https://docs.flarum.org/install#folder-ownership"}))),default:!1,type:"boolean",disabled:a.data["flarum-package-manager.using_sync_queue"]}).registerPage(lt),(0,t.extend)(i().prototype,"topItems",(function(t){var e=this;"flarum-package-manager"===this.extension.id||p()(this.extension.id)||t.add("remove",m(l(),{className:"Button Button--danger",icon:"fas fa-times",onclick:function(){a.modal.show(u()),a.request({url:a.forum.attribute("apiUrl")+"/package-manager/extensions/"+e.extension.id,method:"DELETE"}).then((function(t){null!=t&&t.processing?G():(a.alerts.show({type:"success"},a.translator.trans("flarum-package-manager.admin.extensions.successful_remove")),window.location=a.forum.attribute("adminUrl"))})).finally((function(){a.modal.close()}))}},"Remove"))}))}))})(),module.exports=n})();
|
|
//# sourceMappingURL=admin.js.map
|