@panomc/theme-core 1.0.0-dev.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bundle-internal-libs.js +104 -0
- package/bin/check.js +253 -0
- package/bin/generate-licenses.js +125 -0
- package/bin/generate-runtime-shims.js +180 -0
- package/bin/license/file-fingerprint.js +74 -0
- package/bin/license/finalize-fingerprint.js +72 -0
- package/bin/license/generate-license-constants.js +335 -0
- package/bin/new.js +281 -0
- package/bin/package-zip.js +57 -0
- package/bin/sync.js +326 -0
- package/bin/templates/app.html +59 -0
- package/bin/theme-core.js +103 -0
- package/package.json +77 -0
- package/src/index.js +15 -0
- package/src/kit/hooks-client.js +128 -0
- package/src/kit/hooks-server.js +319 -0
- package/src/kit/license-runtime.js +373 -0
- package/src/kit/resolve.js +71 -0
- package/src/kit/specifiers.js +62 -0
- package/src/kit/svelte-config.js +74 -0
- package/src/kit/vite-config.js +249 -0
- package/src/lib/NotificationManager.js +1 -0
- package/src/lib/PluginAPI.js +368 -0
- package/src/lib/PluginManager.js +1 -0
- package/src/lib/Store.js +43 -0
- package/src/lib/api.util.js +5 -0
- package/src/lib/auth.util.js +77 -0
- package/src/lib/components/App.svelte +10 -0
- package/src/lib/components/Breadcrumb.svelte +88 -0
- package/src/lib/components/CardHeader.svelte +42 -0
- package/src/lib/components/Date.svelte +34 -0
- package/src/lib/components/DefaultToast.svelte +11 -0
- package/src/lib/components/ErrorAlert.svelte +16 -0
- package/src/lib/components/Footer.svelte +223 -0
- package/src/lib/components/Header.svelte +122 -0
- package/src/lib/components/Hook.svelte +71 -0
- package/src/lib/components/LinkCodeInput.svelte +129 -0
- package/src/lib/components/LoginFormBody.svelte +90 -0
- package/src/lib/components/Main.svelte +76 -0
- package/src/lib/components/Navbar.svelte +462 -0
- package/src/lib/components/NoContent.svelte +14 -0
- package/src/lib/components/NotificationContainer.svelte +304 -0
- package/src/lib/components/OnlineAdmins.svelte +64 -0
- package/src/lib/components/PageActions.svelte +39 -0
- package/src/lib/components/PageTitle.svelte +36 -0
- package/src/lib/components/Pagination.svelte +65 -0
- package/src/lib/components/PlayerHead.svelte +58 -0
- package/src/lib/components/PlayerPermissionBadge.svelte +19 -0
- package/src/lib/components/PlayerStatusBadge.svelte +63 -0
- package/src/lib/components/Post.svelte +240 -0
- package/src/lib/components/Posts.svelte +19 -0
- package/src/lib/components/RegisterForm.svelte +125 -0
- package/src/lib/components/Sidebar.svelte +12 -0
- package/src/lib/components/SuccessAlert.svelte +14 -0
- package/src/lib/components/TicketRow.svelte +61 -0
- package/src/lib/components/TicketStatus.svelte +24 -0
- package/src/lib/components/Tickets.svelte +43 -0
- package/src/lib/components/Toast.svelte +13 -0
- package/src/lib/components/ToastContainer.svelte +83 -0
- package/src/lib/components/ViewComponent.svelte +8 -0
- package/src/lib/components/modals/CloseTicketConfirmModal.svelte +121 -0
- package/src/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte +93 -0
- package/src/lib/components/modals/LogoutSessionConfirmModal.svelte +61 -0
- package/src/lib/components/sidebars/HomeSidebar.svelte +333 -0
- package/src/lib/components/sidebars/PlayerDetailSidebar.svelte +124 -0
- package/src/lib/components/sidebars/ProfileSidebar.svelte +149 -0
- package/src/lib/components/sidebars/SupportSidebar.svelte +54 -0
- package/src/lib/components/sidebars/TicketCreateAndDetailSidebar.svelte +84 -0
- package/src/lib/csrf.js +5 -0
- package/src/lib/init.libs.js +2 -0
- package/src/lib/language.util.js +154 -0
- package/src/lib/layouts/AppLayout.svelte +59 -0
- package/src/lib/layouts/AuthLayout.svelte +29 -0
- package/src/lib/layouts/MainLayout.svelte +60 -0
- package/src/lib/layouts/ProfileLayout.svelte +29 -0
- package/src/lib/layouts/ThemeSettingsLayout.svelte +37 -0
- package/src/lib/layouts/TicketsLayout.svelte +31 -0
- package/src/lib/loginInput.util.js +4 -0
- package/src/lib/orderNavLinks.util.js +58 -0
- package/src/lib/pages/ActivateEmailPage.svelte +48 -0
- package/src/lib/pages/ConfirmNewEmailPage.svelte +48 -0
- package/src/lib/pages/ErrorPage.svelte +41 -0
- package/src/lib/pages/HomePage.svelte +35 -0
- package/src/lib/pages/LoginPage.svelte +448 -0
- package/src/lib/pages/NotificationsPage.svelte +70 -0
- package/src/lib/pages/PlayerDetailPage.svelte +29 -0
- package/src/lib/pages/PostDetailPage.svelte +36 -0
- package/src/lib/pages/PreviewPostPage.svelte +38 -0
- package/src/lib/pages/RegisterPage.svelte +144 -0
- package/src/lib/pages/RenewPasswordPage.svelte +49 -0
- package/src/lib/pages/ResetPasswordPage.svelte +55 -0
- package/src/lib/pages/RulesPage.svelte +52 -0
- package/src/lib/pages/SupportPage.svelte +36 -0
- package/src/lib/pages/ThemeSettingsPage.svelte +551 -0
- package/src/lib/pages/profile/ProfilePage.svelte +32 -0
- package/src/lib/pages/profile/SettingsPage.svelte +163 -0
- package/src/lib/pages/profile/TicketsPage.svelte +54 -0
- package/src/lib/pages/ticket/CreateTicketPage.svelte +48 -0
- package/src/lib/pages/ticket/TicketDetailPage.svelte +59 -0
- package/src/lib/services/auth.js +85 -0
- package/src/lib/services/posts.js +152 -0
- package/src/lib/services/profile.js +37 -0
- package/src/lib/services/theme-setting.js +22 -0
- package/src/lib/services/tickets.js +95 -0
- package/src/lib/siteRealtime.js +244 -0
- package/src/lib/string.util.js +27 -0
- package/src/lib/tooltip.util.js +5 -0
- package/src/lib/ui-logics/layout-logics/AppLayoutLogics.js +321 -0
- package/src/lib/ui-logics/layout-logics/AuthLayoutLogics.js +10 -0
- package/src/lib/ui-logics/layout-logics/MainLayoutLogics.js +19 -0
- package/src/lib/ui-logics/layout-logics/ProfileLayoutLogics.js +10 -0
- package/src/lib/ui-logics/layout-logics/ThemeSettingsLayoutLogics.js +215 -0
- package/src/lib/ui-logics/layout-logics/TicketsLayoutLogics.js +10 -0
- package/src/lib/ui-logics/page-logics/ActiveEmailPageLogics.js +45 -0
- package/src/lib/ui-logics/page-logics/ConfirmNewEmailPageLogics.js +42 -0
- package/src/lib/ui-logics/page-logics/CreateTicketPageLogics.js +83 -0
- package/src/lib/ui-logics/page-logics/HomePageLogics.js +65 -0
- package/src/lib/ui-logics/page-logics/NotificationsPageLogics.js +264 -0
- package/src/lib/ui-logics/page-logics/PlayerDetailPageLogics.js +40 -0
- package/src/lib/ui-logics/page-logics/PostDetailPageLogics.js +58 -0
- package/src/lib/ui-logics/page-logics/PreviewPostPageLogics.js +53 -0
- package/src/lib/ui-logics/page-logics/ProfilePageLogics.js +44 -0
- package/src/lib/ui-logics/page-logics/RenewPasswordPageLogics.js +44 -0
- package/src/lib/ui-logics/page-logics/ResetPasswordPageLogics.js +53 -0
- package/src/lib/ui-logics/page-logics/SettingsPageLogics.js +230 -0
- package/src/lib/ui-logics/page-logics/SupportPageLogics.js +60 -0
- package/src/lib/ui-logics/page-logics/TicketDetailPageLogics.js +160 -0
- package/src/lib/ui-logics/page-logics/TicketsPageLogics.js +132 -0
- package/src/lib/variables.js +1 -0
- package/src/lib/views/ActivateEmailView.svelte +71 -0
- package/src/lib/views/AppLayoutView.svelte +31 -0
- package/src/lib/views/AuthLayoutView.svelte +23 -0
- package/src/lib/views/ConfirmNewEmailView.svelte +71 -0
- package/src/lib/views/CreateTicketView.svelte +73 -0
- package/src/lib/views/ErrorView.svelte +38 -0
- package/src/lib/views/HomeView.svelte +72 -0
- package/src/lib/views/LoginView.svelte +372 -0
- package/src/lib/views/MainLayoutView.svelte +86 -0
- package/src/lib/views/NotificationsView.svelte +129 -0
- package/src/lib/views/PlayerDetailView.svelte +31 -0
- package/src/lib/views/PostDetailView.svelte +199 -0
- package/src/lib/views/PreviewPostView.svelte +151 -0
- package/src/lib/views/ProfileLayoutView.svelte +16 -0
- package/src/lib/views/ProfileView.svelte +68 -0
- package/src/lib/views/RegisterView.svelte +113 -0
- package/src/lib/views/RenewPasswordView.svelte +98 -0
- package/src/lib/views/ResetPasswordView.svelte +88 -0
- package/src/lib/views/RulesView.svelte +26 -0
- package/src/lib/views/SettingsView.svelte +471 -0
- package/src/lib/views/SupportView.svelte +79 -0
- package/src/lib/views/ThemeSettingsLayoutView.svelte +19 -0
- package/src/lib/views/ThemeSettingsView.svelte +1508 -0
- package/src/lib/views/TicketDetailView.svelte +185 -0
- package/src/lib/views/TicketsLayoutView.svelte +21 -0
- package/src/lib/views/TicketsView.svelte +87 -0
- package/src/plugin-engine/engine.js +484 -0
- package/src/registry/index.js +86 -0
- package/src/routes/RootLayout.svelte +21 -0
- package/src/routes/plugin-ui/Layout.svelte +291 -0
- package/src/routes/plugin-ui/Page.svelte +117 -0
- package/src/routes/plugin-ui/layout.js +8 -0
- package/src/routes/plugin-ui/page.js +8 -0
- package/src/routes/plugins-client-file.js +76 -0
- package/src/routes/root-layout-load.js +15 -0
- package/src/routes/theme-api-languages.js +52 -0
- package/src/routes/theme-api-licenses.js +28 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { baseAPI, pageAPI } from "@panomc/sdk/core/js/PluginAPI";
|
|
2
|
+
import { get, writable } from "svelte/store";
|
|
3
|
+
import { plugins } from "@panomc/sdk/core/js/PluginManager.js";
|
|
4
|
+
import { sortSiteNavLinks } from "./orderNavLinks.util.js";
|
|
5
|
+
import { avatarVersion } from "./Store.js";
|
|
6
|
+
import { browser } from "$app/environment";
|
|
7
|
+
import {
|
|
8
|
+
createHookEngine,
|
|
9
|
+
createLifecycleRegistry,
|
|
10
|
+
createSlotRegistry,
|
|
11
|
+
} from "$pano/plugin-engine/engine.js";
|
|
12
|
+
|
|
13
|
+
// All the ordering / SSR-safe-clone / hook-load machinery lives in the shared plugin engine.
|
|
14
|
+
// This file is the THEME profile: it composes the engine registries into the theme's `pano.ui.*`
|
|
15
|
+
// namespace tree and re-exports the host contract (init, panoApiClient, panoApiServer).
|
|
16
|
+
const lifecycle = createLifecycleRegistry();
|
|
17
|
+
const hooks = createHookEngine();
|
|
18
|
+
const slots = createSlotRegistry({
|
|
19
|
+
getPlugins: () => get(plugins),
|
|
20
|
+
browser,
|
|
21
|
+
executeLifecycle: lifecycle.executeLifecycle,
|
|
22
|
+
lifecyclePrefix: "theme",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Theme-specific: the ordered site navigation links (uses the theme's sort util, not a plain slot).
|
|
26
|
+
const siteNavLinks = writable([]);
|
|
27
|
+
|
|
28
|
+
export async function init() {
|
|
29
|
+
hooks.reset();
|
|
30
|
+
slots.reset();
|
|
31
|
+
siteNavLinks.set([]);
|
|
32
|
+
lifecycle.reset();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const executeLifecycle = lifecycle.executeLifecycle;
|
|
36
|
+
export const executeSidebarLoad = slots.executeSidebarLoad;
|
|
37
|
+
export const executeViewLoad = slots.executeViewLoad;
|
|
38
|
+
export const executeHookLoad = hooks.executeHookLoad;
|
|
39
|
+
|
|
40
|
+
export const panoApi = {
|
|
41
|
+
...baseAPI,
|
|
42
|
+
ui: {
|
|
43
|
+
...pageAPI,
|
|
44
|
+
nav: {
|
|
45
|
+
site: {
|
|
46
|
+
editNavLinks(callback) {
|
|
47
|
+
siteNavLinks.update((links) => {
|
|
48
|
+
const next = callback(links) || links;
|
|
49
|
+
return sortSiteNavLinks(next);
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
getNavLinks() {
|
|
53
|
+
return siteNavLinks;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
profileDropdown: {
|
|
57
|
+
edit(callback) {
|
|
58
|
+
slots.edit("navbar-profile-dropdown", callback);
|
|
59
|
+
},
|
|
60
|
+
get() {
|
|
61
|
+
return panoApi.ui.view.get("navbar-profile-dropdown");
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
rightComponents: {
|
|
65
|
+
edit(callback) {
|
|
66
|
+
slots.edit("navbar-right", callback);
|
|
67
|
+
},
|
|
68
|
+
get() {
|
|
69
|
+
return panoApi.ui.view.get("navbar-right");
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
onLoad(handler) {
|
|
73
|
+
panoApi.ui.lifecycle.on("theme:navbar:load", handler);
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
profile: {
|
|
77
|
+
content: {
|
|
78
|
+
edit(callback) {
|
|
79
|
+
slots.edit("profile-content", callback);
|
|
80
|
+
},
|
|
81
|
+
get() {
|
|
82
|
+
return panoApi.ui.view.get("profile-content");
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
cardRows: {
|
|
86
|
+
edit(callback) {
|
|
87
|
+
slots.edit("profile-card-rows", callback);
|
|
88
|
+
},
|
|
89
|
+
get() {
|
|
90
|
+
return panoApi.ui.view.get("profile-card-rows");
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
onLoad(handler) {
|
|
94
|
+
panoApi.ui.lifecycle.on("theme:profile:load", handler);
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
settings: {
|
|
98
|
+
content: {
|
|
99
|
+
edit(callback) {
|
|
100
|
+
slots.edit("settings-content", callback);
|
|
101
|
+
},
|
|
102
|
+
get() {
|
|
103
|
+
return panoApi.ui.view.get("settings-content");
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
cardRows: {
|
|
107
|
+
edit(callback) {
|
|
108
|
+
slots.edit("settings-card-rows", callback);
|
|
109
|
+
},
|
|
110
|
+
get() {
|
|
111
|
+
return panoApi.ui.view.get("settings-card-rows");
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
onLoad(handler) {
|
|
115
|
+
panoApi.ui.lifecycle.on("theme:settings:load", handler);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
tickets: {
|
|
119
|
+
content: {
|
|
120
|
+
edit(callback) {
|
|
121
|
+
slots.edit("tickets-content", callback);
|
|
122
|
+
},
|
|
123
|
+
get() {
|
|
124
|
+
return panoApi.ui.view.get("tickets-content");
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
onLoad(handler) {
|
|
128
|
+
panoApi.ui.lifecycle.on("theme:tickets:load", handler);
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
auth: {
|
|
132
|
+
login: {
|
|
133
|
+
content: {
|
|
134
|
+
edit(callback) {
|
|
135
|
+
slots.edit("login-content", callback);
|
|
136
|
+
},
|
|
137
|
+
get() {
|
|
138
|
+
return panoApi.ui.view.get("login-content");
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
alternativeMethods: {
|
|
142
|
+
add(method) {
|
|
143
|
+
slots.upsert("login-alt-methods", method);
|
|
144
|
+
},
|
|
145
|
+
get() {
|
|
146
|
+
return panoApi.ui.view.get("login-alt-methods");
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
onLoad(handler) {
|
|
150
|
+
panoApi.ui.lifecycle.on("theme:login:load", handler);
|
|
151
|
+
},
|
|
152
|
+
// A plugin page that presents a login (e.g. social login) runs the same load as the
|
|
153
|
+
// theme's login page, so login-content plugins (captcha, 2FA, …) populate and render.
|
|
154
|
+
async load(event) {
|
|
155
|
+
const data = { error: null, username: null, event };
|
|
156
|
+
await executeLifecycle("theme:login:load", data, event);
|
|
157
|
+
await executeViewLoad("login-content", event);
|
|
158
|
+
await executeViewLoad("login-alt-methods", event);
|
|
159
|
+
return data;
|
|
160
|
+
},
|
|
161
|
+
// Theme-provided login form body. Entry-adapter plugins (social-login, magic-link, …)
|
|
162
|
+
// mount this Svelte component so their pages look identical to the theme's /login form.
|
|
163
|
+
form: {
|
|
164
|
+
async get() {
|
|
165
|
+
// Registry-resolved: a theme overriding LoginFormBody restyles the
|
|
166
|
+
// form everywhere plugins mount it, too.
|
|
167
|
+
const { resolveView } = await import("$pano/registry/index.js");
|
|
168
|
+
return resolveView(
|
|
169
|
+
"LoginFormBody",
|
|
170
|
+
() => import("$pano/lib/components/LoginFormBody.svelte"),
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
register: {
|
|
176
|
+
content: {
|
|
177
|
+
edit(callback) {
|
|
178
|
+
slots.edit("register-content", callback);
|
|
179
|
+
},
|
|
180
|
+
get() {
|
|
181
|
+
return panoApi.ui.view.get("register-content");
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
alternativeMethods: {
|
|
185
|
+
add(method) {
|
|
186
|
+
slots.upsert("register-alt-methods", method);
|
|
187
|
+
},
|
|
188
|
+
get() {
|
|
189
|
+
return panoApi.ui.view.get("register-alt-methods");
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
onLoad(handler) {
|
|
193
|
+
panoApi.ui.lifecycle.on("theme:register:load", handler);
|
|
194
|
+
},
|
|
195
|
+
// A plugin page that presents a registration (e.g. social register) runs the same load as
|
|
196
|
+
// the theme's register page, so register-content plugins (captcha, …) populate and render.
|
|
197
|
+
async load(event) {
|
|
198
|
+
const data = { error: null, username: null, event };
|
|
199
|
+
await executeLifecycle("theme:register:load", data, event);
|
|
200
|
+
await executeViewLoad("register-content", event);
|
|
201
|
+
await executeViewLoad("register-alt-methods", event);
|
|
202
|
+
return data;
|
|
203
|
+
},
|
|
204
|
+
// Theme-provided register form body. See login.form for rationale.
|
|
205
|
+
form: {
|
|
206
|
+
async get() {
|
|
207
|
+
const { resolveView } = await import("$pano/registry/index.js");
|
|
208
|
+
return resolveView(
|
|
209
|
+
"RegisterForm",
|
|
210
|
+
() => import("$pano/lib/components/RegisterForm.svelte"),
|
|
211
|
+
);
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
resetPassword: {
|
|
216
|
+
content: {
|
|
217
|
+
edit(callback) {
|
|
218
|
+
slots.edit("reset-password-content", callback);
|
|
219
|
+
},
|
|
220
|
+
get() {
|
|
221
|
+
return panoApi.ui.view.get("reset-password-content");
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
onLoad(handler) {
|
|
225
|
+
panoApi.ui.lifecycle.on("theme:reset-password:load", handler);
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
activate: {
|
|
229
|
+
content: {
|
|
230
|
+
edit(callback) {
|
|
231
|
+
slots.edit("activate-content", callback);
|
|
232
|
+
},
|
|
233
|
+
get() {
|
|
234
|
+
return panoApi.ui.view.get("activate-content");
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
onLoad(handler) {
|
|
238
|
+
panoApi.ui.lifecycle.on("theme:activate:load", handler);
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
activateNewEmail: {
|
|
242
|
+
content: {
|
|
243
|
+
edit(callback) {
|
|
244
|
+
slots.edit("activate-new-email-content", callback);
|
|
245
|
+
},
|
|
246
|
+
get() {
|
|
247
|
+
return panoApi.ui.view.get("activate-new-email-content");
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
onLoad(handler) {
|
|
251
|
+
panoApi.ui.lifecycle.on("theme:activate-new-email:load", handler);
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
renewPassword: {
|
|
255
|
+
content: {
|
|
256
|
+
edit(callback) {
|
|
257
|
+
slots.edit("renew-password-content", callback);
|
|
258
|
+
},
|
|
259
|
+
get() {
|
|
260
|
+
return panoApi.ui.view.get("renew-password-content");
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
onLoad(handler) {
|
|
264
|
+
panoApi.ui.lifecycle.on("theme:renew-password:load", handler);
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
app: {
|
|
269
|
+
onLoad(handler) {
|
|
270
|
+
panoApi.ui.lifecycle.on("theme:app:load", handler);
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
view: {
|
|
274
|
+
register(options) {
|
|
275
|
+
slots.register(options);
|
|
276
|
+
},
|
|
277
|
+
hide(viewId, id) {
|
|
278
|
+
slots.hide(viewId, id);
|
|
279
|
+
},
|
|
280
|
+
show(viewId, id) {
|
|
281
|
+
slots.show(viewId, id);
|
|
282
|
+
},
|
|
283
|
+
move(viewId, id, priority) {
|
|
284
|
+
slots.move(viewId, id, priority);
|
|
285
|
+
},
|
|
286
|
+
get(viewId) {
|
|
287
|
+
return slots.get(viewId);
|
|
288
|
+
},
|
|
289
|
+
onLoad(viewId, handler) {
|
|
290
|
+
panoApi.ui.lifecycle.on(`theme:view:${viewId}:load`, handler);
|
|
291
|
+
},
|
|
292
|
+
// General: a plugin page hosting a theme view slot can run its load lifecycle and get the
|
|
293
|
+
// resolved (plugin-contributed) items, so injected components render exactly as in the theme.
|
|
294
|
+
async load(viewId, event) {
|
|
295
|
+
return await executeViewLoad(viewId, event);
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
sidebar: {
|
|
299
|
+
register(options) {
|
|
300
|
+
const { sidebarId, ...rest } = options;
|
|
301
|
+
panoApi.ui.view.register({ viewId: sidebarId, ...rest });
|
|
302
|
+
},
|
|
303
|
+
hide(sidebarId, id) {
|
|
304
|
+
panoApi.ui.view.hide(sidebarId, id);
|
|
305
|
+
},
|
|
306
|
+
show(sidebarId, id) {
|
|
307
|
+
panoApi.ui.view.show(sidebarId, id);
|
|
308
|
+
},
|
|
309
|
+
move(sidebarId, id, priority) {
|
|
310
|
+
panoApi.ui.view.move(sidebarId, id, priority);
|
|
311
|
+
},
|
|
312
|
+
get(sidebarId) {
|
|
313
|
+
return panoApi.ui.view.get(sidebarId);
|
|
314
|
+
},
|
|
315
|
+
onLoad(sidebarId, handler) {
|
|
316
|
+
panoApi.ui.lifecycle.on(`theme:sidebar:${sidebarId}:load`, handler);
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
post: {
|
|
320
|
+
onLoad(handler) {
|
|
321
|
+
panoApi.ui.lifecycle.on("theme:post-detail:load", handler);
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
support: {
|
|
325
|
+
onLoad(handler) {
|
|
326
|
+
panoApi.ui.lifecycle.on("theme:support:load", handler);
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
lifecycle: {
|
|
330
|
+
on(name, handler) {
|
|
331
|
+
lifecycle.on(name, handler);
|
|
332
|
+
},
|
|
333
|
+
// General primitive: run any theme lifecycle so plugin pages can take part in theme flows
|
|
334
|
+
// (e.g. a plugin login/register page running the same lifecycle the theme's own pages do).
|
|
335
|
+
async execute(name, data = {}, event) {
|
|
336
|
+
await lifecycle.executeLifecycle(name, data, event);
|
|
337
|
+
return data;
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
hook: {
|
|
341
|
+
register(options) {
|
|
342
|
+
hooks.register(options);
|
|
343
|
+
},
|
|
344
|
+
get(name) {
|
|
345
|
+
return hooks.get(name);
|
|
346
|
+
},
|
|
347
|
+
setVisible(name, component, visible) {
|
|
348
|
+
hooks.setVisible(name, component, visible);
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
avatar: {
|
|
352
|
+
updateVersion() {
|
|
353
|
+
avatarVersion.set(`&v=${Date.now()}`);
|
|
354
|
+
},
|
|
355
|
+
getVersion() {
|
|
356
|
+
return avatarVersion;
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
export const panoApiServer = {
|
|
363
|
+
...panoApi,
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export const panoApiClient = {
|
|
367
|
+
...panoApi,
|
|
368
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@panomc/sdk/core/js/PluginManager.js";
|
package/src/lib/Store.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
|
|
3
|
+
import { sendLogout } from "$pano/lib/services/auth.js";
|
|
4
|
+
import { goto } from "$app/navigation";
|
|
5
|
+
import { redirect } from "@sveltejs/kit";
|
|
6
|
+
import { show as showToast } from "$pano/lib/components/ToastContainer.svelte";
|
|
7
|
+
|
|
8
|
+
export const notificationsCount = writable(0);
|
|
9
|
+
export const quickNotifications = writable([]);
|
|
10
|
+
|
|
11
|
+
export const initialized = writable(false);
|
|
12
|
+
export const avatarVersion = writable('');
|
|
13
|
+
|
|
14
|
+
export async function logout(session) {
|
|
15
|
+
sendLogout().then(async () => {
|
|
16
|
+
if (typeof localStorage !== 'undefined') {
|
|
17
|
+
localStorage.removeItem('pano_demo_bubble_shown');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (session) {
|
|
21
|
+
session.update((data) => {
|
|
22
|
+
data.user = null;
|
|
23
|
+
data.csrfToken = null;
|
|
24
|
+
return data;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await showToast("toasts.session-logged-out-successful");
|
|
29
|
+
await goto("/");
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function requireLogin(session, goto = "/login") {
|
|
34
|
+
if (!session.user) {
|
|
35
|
+
throw redirect(302, goto);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function requireNotLogin(session) {
|
|
40
|
+
if (session.user) {
|
|
41
|
+
throw redirect(302, "/");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { get } from "svelte/store";
|
|
2
|
+
import { page } from "$app/stores";
|
|
3
|
+
import { browser } from "$app/environment";
|
|
4
|
+
|
|
5
|
+
export const Permissions = Object.freeze({
|
|
6
|
+
ACCESS_PANEL: "ACCESS_PANEL",
|
|
7
|
+
MANAGE_SERVERS: "MANAGE_SERVERS",
|
|
8
|
+
MANAGE_POSTS: "MANAGE_POSTS",
|
|
9
|
+
MANAGE_TICKETS: "MANAGE_TICKETS",
|
|
10
|
+
MANAGE_PLAYERS: "MANAGE_PLAYERS",
|
|
11
|
+
MANAGE_VIEW: "MANAGE_VIEW",
|
|
12
|
+
MANAGE_ADDONS: "MANAGE_ADDONS",
|
|
13
|
+
MANAGE_PLATFORM_SETTINGS: "MANAGE_PLATFORM_SETTINGS",
|
|
14
|
+
MANAGE_PERMISSION_GROUPS: "MANAGE_PERMISSION_GROUPS",
|
|
15
|
+
ACCESS_ACTIVITY_LOGS: "ACCESS_ACTIVITY_LOGS",
|
|
16
|
+
MANAGE_TRANSLATIONS: "MANAGE_TRANSLATIONS",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export function hasPermission(permission, user) {
|
|
20
|
+
if (!permission) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!user) {
|
|
25
|
+
let pageUser;
|
|
26
|
+
|
|
27
|
+
if (browser) {
|
|
28
|
+
pageUser = get(page).data?.session?.user;
|
|
29
|
+
} else {
|
|
30
|
+
pageUser = get(page).data?.user;
|
|
31
|
+
|
|
32
|
+
if (!pageUser) {
|
|
33
|
+
pageUser = get(page).data?.session?.user;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
user = pageUser;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const userObject = user;
|
|
40
|
+
|
|
41
|
+
if (!userObject) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (userObject.admin) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!userObject.permissions) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const toPermNode = (p) => {
|
|
54
|
+
const raw = String(p || "").trim();
|
|
55
|
+
if (!raw) return "";
|
|
56
|
+
|
|
57
|
+
const lower = raw.toLowerCase();
|
|
58
|
+
|
|
59
|
+
// old enum format: MANAGE_PERMISSION_GROUPS -> pano.panel.manage.permission.groups
|
|
60
|
+
return lower.replaceAll("_", ".");
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const wantedNode = toPermNode(permission);
|
|
64
|
+
const wantedKey = String(permission || "")
|
|
65
|
+
.trim()
|
|
66
|
+
.toUpperCase();
|
|
67
|
+
const perms = Array.isArray(userObject.permissions)
|
|
68
|
+
? userObject.permissions
|
|
69
|
+
: [];
|
|
70
|
+
const permsLower = perms.map((x) => String(x || "").toLowerCase());
|
|
71
|
+
|
|
72
|
+
// Prefer node-style checks; keep legacy key check for backward compatibility.
|
|
73
|
+
return (
|
|
74
|
+
(wantedNode && permsLower.includes(wantedNode)) ||
|
|
75
|
+
(wantedKey && perms.includes(wantedKey))
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import { _ } from "svelte-i18n";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Breadcrumb items are supplied manually by pages via the `breadcrumbs`
|
|
7
|
+
* key returned from their load() function. When a page doesn't provide
|
|
8
|
+
* `breadcrumbs`, the component renders nothing.
|
|
9
|
+
*
|
|
10
|
+
* Each item can be either:
|
|
11
|
+
* - A string: treated as an i18n translation key.
|
|
12
|
+
* - An object with shape:
|
|
13
|
+
* {
|
|
14
|
+
* label: string, // i18n key, or raw text if raw=true
|
|
15
|
+
* labelValues?: object, // i18n interpolation values
|
|
16
|
+
* href?: string, // makes the item a link
|
|
17
|
+
* icon?: string, // e.g. "fas fa-home"
|
|
18
|
+
* raw?: boolean, // bypass i18n, use label as-is
|
|
19
|
+
* html?: boolean // render label as HTML (raw implied)
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* The last item is always treated as the active/current page.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const breadcrumbsStore = getContext("breadcrumbs");
|
|
26
|
+
|
|
27
|
+
function resolveLabel(item) {
|
|
28
|
+
if (item == null) return "";
|
|
29
|
+
if (typeof item === "string") return $_(item);
|
|
30
|
+
if (item.raw || item.html) return item.label ?? "";
|
|
31
|
+
if (!item.label) return "";
|
|
32
|
+
return $_(item.label, { values: item.labelValues || {} });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function normalize(item) {
|
|
36
|
+
if (typeof item === "string") {
|
|
37
|
+
return { label: resolveLabel(item) };
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
label: resolveLabel(item),
|
|
41
|
+
href: item?.href,
|
|
42
|
+
icon: item?.icon,
|
|
43
|
+
html: !!item?.html
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
$: items = Array.isArray($breadcrumbsStore) ? $breadcrumbsStore.map(normalize) : [];
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
{#if items.length > 0}
|
|
51
|
+
<nav aria-label="breadcrumb">
|
|
52
|
+
<ol class="breadcrumb justify-content-center mb-0">
|
|
53
|
+
{#each items as crumb, i}
|
|
54
|
+
{@const isLast = i === items.length - 1}
|
|
55
|
+
<li
|
|
56
|
+
class="breadcrumb-item"
|
|
57
|
+
class:active={isLast}
|
|
58
|
+
aria-current={isLast ? "page" : undefined}>
|
|
59
|
+
{#if isLast || !crumb.href}
|
|
60
|
+
{#if crumb.icon}
|
|
61
|
+
<i class={crumb.icon}></i>
|
|
62
|
+
{:else if crumb.html}
|
|
63
|
+
{@html crumb.label}
|
|
64
|
+
{:else}
|
|
65
|
+
{crumb.label}
|
|
66
|
+
{/if}
|
|
67
|
+
{:else}
|
|
68
|
+
<a href={crumb.href} class="text-decoration-none badge text-bg-primary rounded-pill px-1">
|
|
69
|
+
{#if crumb.icon}
|
|
70
|
+
<i class={crumb.icon}></i>
|
|
71
|
+
{:else if crumb.html}
|
|
72
|
+
{@html crumb.label}
|
|
73
|
+
{:else}
|
|
74
|
+
{crumb.label}
|
|
75
|
+
{/if}
|
|
76
|
+
</a>
|
|
77
|
+
{/if}
|
|
78
|
+
</li>
|
|
79
|
+
{/each}
|
|
80
|
+
</ol>
|
|
81
|
+
</nav>
|
|
82
|
+
{/if}
|
|
83
|
+
|
|
84
|
+
<style>
|
|
85
|
+
.breadcrumb {
|
|
86
|
+
--bs-breadcrumb-divider: "•";
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<div class="card-header py-3 {headerClasses}">
|
|
2
|
+
<div class="row d-flex align-items-center gx-0 gy-2">
|
|
3
|
+
<div
|
|
4
|
+
class="{$$slots.middle
|
|
5
|
+
? $$slots.right && showRight
|
|
6
|
+
? 'col-lg-3'
|
|
7
|
+
: 'col-lg-6'
|
|
8
|
+
: $$slots.right && showRight
|
|
9
|
+
? 'col-lg-6'
|
|
10
|
+
: 'col-12'} d-flex {$$slots.right && showRight && !$$slots.middle
|
|
11
|
+
? 'justify-content-lg-between'
|
|
12
|
+
: 'justify-content-lg-start'} justify-content-center text-center text-lg-start {truncateLeft
|
|
13
|
+
? 'text-truncate text-nowrap'
|
|
14
|
+
: 'min-w-0 text-wrap text-break'} {leftClasses}">
|
|
15
|
+
<slot name="left" />
|
|
16
|
+
</div>
|
|
17
|
+
{#if $$slots.middle}
|
|
18
|
+
<div class="col-lg-6 d-flex justify-content-center {middleClasses}">
|
|
19
|
+
<slot name="middle" />
|
|
20
|
+
</div>
|
|
21
|
+
{/if}
|
|
22
|
+
{#if $$slots.right && showRight}
|
|
23
|
+
<div
|
|
24
|
+
class="{$$slots.middle
|
|
25
|
+
? 'col-lg-3'
|
|
26
|
+
: 'col-lg-6'} d-flex justify-content-lg-end justify-content-center {rightClasses}">
|
|
27
|
+
<!-- Filters -->
|
|
28
|
+
<slot name="right" />
|
|
29
|
+
</div>
|
|
30
|
+
{/if}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
export let headerClasses = '';
|
|
36
|
+
export let leftClasses = '';
|
|
37
|
+
export let rightClasses = '';
|
|
38
|
+
export let middleClasses = '';
|
|
39
|
+
export let showRight = true;
|
|
40
|
+
/** When false, left slot text wraps (e.g. long subtitles); default truncates for compact headers */
|
|
41
|
+
export let truncateLeft = true;
|
|
42
|
+
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<span
|
|
2
|
+
use:tooltip="{[
|
|
3
|
+
format(new Date(parseInt(date)), 'dd/MM/yyyy, HH:mm'),
|
|
4
|
+
{ placement: 'bottom', locale: locales[$currentLanguage['date-fns-code']] },
|
|
5
|
+
]}">
|
|
6
|
+
<slot>
|
|
7
|
+
{#if relativeFormat}
|
|
8
|
+
{formatRelative(new Date(parseInt(date)), new Date(), {
|
|
9
|
+
locale: locales[$currentLanguage.dateFnsCode],
|
|
10
|
+
}).capitalize()}
|
|
11
|
+
{:else}
|
|
12
|
+
{format(new Date(parseInt(date)), "dd MMMM yyyy", {
|
|
13
|
+
locale: locales[$currentLanguage.dateFnsCode],
|
|
14
|
+
})}
|
|
15
|
+
{/if}
|
|
16
|
+
</slot>
|
|
17
|
+
</span>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import { format, formatRelative } from "date-fns";
|
|
21
|
+
import * as locales from "date-fns/locale";
|
|
22
|
+
|
|
23
|
+
import tooltip from "$pano/lib/tooltip.util";
|
|
24
|
+
import { currentLanguage } from "$pano/lib/language.util.js";
|
|
25
|
+
|
|
26
|
+
String.prototype.capitalize = function () {
|
|
27
|
+
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export let time;
|
|
31
|
+
export let relativeFormat = false;
|
|
32
|
+
|
|
33
|
+
$: date = time;
|
|
34
|
+
</script>
|