@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.
Files changed (166) hide show
  1. package/bin/bundle-internal-libs.js +104 -0
  2. package/bin/check.js +253 -0
  3. package/bin/generate-licenses.js +125 -0
  4. package/bin/generate-runtime-shims.js +180 -0
  5. package/bin/license/file-fingerprint.js +74 -0
  6. package/bin/license/finalize-fingerprint.js +72 -0
  7. package/bin/license/generate-license-constants.js +335 -0
  8. package/bin/new.js +281 -0
  9. package/bin/package-zip.js +57 -0
  10. package/bin/sync.js +326 -0
  11. package/bin/templates/app.html +59 -0
  12. package/bin/theme-core.js +103 -0
  13. package/package.json +77 -0
  14. package/src/index.js +15 -0
  15. package/src/kit/hooks-client.js +128 -0
  16. package/src/kit/hooks-server.js +319 -0
  17. package/src/kit/license-runtime.js +373 -0
  18. package/src/kit/resolve.js +71 -0
  19. package/src/kit/specifiers.js +62 -0
  20. package/src/kit/svelte-config.js +74 -0
  21. package/src/kit/vite-config.js +249 -0
  22. package/src/lib/NotificationManager.js +1 -0
  23. package/src/lib/PluginAPI.js +368 -0
  24. package/src/lib/PluginManager.js +1 -0
  25. package/src/lib/Store.js +43 -0
  26. package/src/lib/api.util.js +5 -0
  27. package/src/lib/auth.util.js +77 -0
  28. package/src/lib/components/App.svelte +10 -0
  29. package/src/lib/components/Breadcrumb.svelte +88 -0
  30. package/src/lib/components/CardHeader.svelte +42 -0
  31. package/src/lib/components/Date.svelte +34 -0
  32. package/src/lib/components/DefaultToast.svelte +11 -0
  33. package/src/lib/components/ErrorAlert.svelte +16 -0
  34. package/src/lib/components/Footer.svelte +223 -0
  35. package/src/lib/components/Header.svelte +122 -0
  36. package/src/lib/components/Hook.svelte +71 -0
  37. package/src/lib/components/LinkCodeInput.svelte +129 -0
  38. package/src/lib/components/LoginFormBody.svelte +90 -0
  39. package/src/lib/components/Main.svelte +76 -0
  40. package/src/lib/components/Navbar.svelte +462 -0
  41. package/src/lib/components/NoContent.svelte +14 -0
  42. package/src/lib/components/NotificationContainer.svelte +304 -0
  43. package/src/lib/components/OnlineAdmins.svelte +64 -0
  44. package/src/lib/components/PageActions.svelte +39 -0
  45. package/src/lib/components/PageTitle.svelte +36 -0
  46. package/src/lib/components/Pagination.svelte +65 -0
  47. package/src/lib/components/PlayerHead.svelte +58 -0
  48. package/src/lib/components/PlayerPermissionBadge.svelte +19 -0
  49. package/src/lib/components/PlayerStatusBadge.svelte +63 -0
  50. package/src/lib/components/Post.svelte +240 -0
  51. package/src/lib/components/Posts.svelte +19 -0
  52. package/src/lib/components/RegisterForm.svelte +125 -0
  53. package/src/lib/components/Sidebar.svelte +12 -0
  54. package/src/lib/components/SuccessAlert.svelte +14 -0
  55. package/src/lib/components/TicketRow.svelte +61 -0
  56. package/src/lib/components/TicketStatus.svelte +24 -0
  57. package/src/lib/components/Tickets.svelte +43 -0
  58. package/src/lib/components/Toast.svelte +13 -0
  59. package/src/lib/components/ToastContainer.svelte +83 -0
  60. package/src/lib/components/ViewComponent.svelte +8 -0
  61. package/src/lib/components/modals/CloseTicketConfirmModal.svelte +121 -0
  62. package/src/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte +93 -0
  63. package/src/lib/components/modals/LogoutSessionConfirmModal.svelte +61 -0
  64. package/src/lib/components/sidebars/HomeSidebar.svelte +333 -0
  65. package/src/lib/components/sidebars/PlayerDetailSidebar.svelte +124 -0
  66. package/src/lib/components/sidebars/ProfileSidebar.svelte +149 -0
  67. package/src/lib/components/sidebars/SupportSidebar.svelte +54 -0
  68. package/src/lib/components/sidebars/TicketCreateAndDetailSidebar.svelte +84 -0
  69. package/src/lib/csrf.js +5 -0
  70. package/src/lib/init.libs.js +2 -0
  71. package/src/lib/language.util.js +154 -0
  72. package/src/lib/layouts/AppLayout.svelte +59 -0
  73. package/src/lib/layouts/AuthLayout.svelte +29 -0
  74. package/src/lib/layouts/MainLayout.svelte +60 -0
  75. package/src/lib/layouts/ProfileLayout.svelte +29 -0
  76. package/src/lib/layouts/ThemeSettingsLayout.svelte +37 -0
  77. package/src/lib/layouts/TicketsLayout.svelte +31 -0
  78. package/src/lib/loginInput.util.js +4 -0
  79. package/src/lib/orderNavLinks.util.js +58 -0
  80. package/src/lib/pages/ActivateEmailPage.svelte +48 -0
  81. package/src/lib/pages/ConfirmNewEmailPage.svelte +48 -0
  82. package/src/lib/pages/ErrorPage.svelte +41 -0
  83. package/src/lib/pages/HomePage.svelte +35 -0
  84. package/src/lib/pages/LoginPage.svelte +448 -0
  85. package/src/lib/pages/NotificationsPage.svelte +70 -0
  86. package/src/lib/pages/PlayerDetailPage.svelte +29 -0
  87. package/src/lib/pages/PostDetailPage.svelte +36 -0
  88. package/src/lib/pages/PreviewPostPage.svelte +38 -0
  89. package/src/lib/pages/RegisterPage.svelte +144 -0
  90. package/src/lib/pages/RenewPasswordPage.svelte +49 -0
  91. package/src/lib/pages/ResetPasswordPage.svelte +55 -0
  92. package/src/lib/pages/RulesPage.svelte +52 -0
  93. package/src/lib/pages/SupportPage.svelte +36 -0
  94. package/src/lib/pages/ThemeSettingsPage.svelte +551 -0
  95. package/src/lib/pages/profile/ProfilePage.svelte +32 -0
  96. package/src/lib/pages/profile/SettingsPage.svelte +163 -0
  97. package/src/lib/pages/profile/TicketsPage.svelte +54 -0
  98. package/src/lib/pages/ticket/CreateTicketPage.svelte +48 -0
  99. package/src/lib/pages/ticket/TicketDetailPage.svelte +59 -0
  100. package/src/lib/services/auth.js +85 -0
  101. package/src/lib/services/posts.js +152 -0
  102. package/src/lib/services/profile.js +37 -0
  103. package/src/lib/services/theme-setting.js +22 -0
  104. package/src/lib/services/tickets.js +95 -0
  105. package/src/lib/siteRealtime.js +244 -0
  106. package/src/lib/string.util.js +27 -0
  107. package/src/lib/tooltip.util.js +5 -0
  108. package/src/lib/ui-logics/layout-logics/AppLayoutLogics.js +321 -0
  109. package/src/lib/ui-logics/layout-logics/AuthLayoutLogics.js +10 -0
  110. package/src/lib/ui-logics/layout-logics/MainLayoutLogics.js +19 -0
  111. package/src/lib/ui-logics/layout-logics/ProfileLayoutLogics.js +10 -0
  112. package/src/lib/ui-logics/layout-logics/ThemeSettingsLayoutLogics.js +215 -0
  113. package/src/lib/ui-logics/layout-logics/TicketsLayoutLogics.js +10 -0
  114. package/src/lib/ui-logics/page-logics/ActiveEmailPageLogics.js +45 -0
  115. package/src/lib/ui-logics/page-logics/ConfirmNewEmailPageLogics.js +42 -0
  116. package/src/lib/ui-logics/page-logics/CreateTicketPageLogics.js +83 -0
  117. package/src/lib/ui-logics/page-logics/HomePageLogics.js +65 -0
  118. package/src/lib/ui-logics/page-logics/NotificationsPageLogics.js +264 -0
  119. package/src/lib/ui-logics/page-logics/PlayerDetailPageLogics.js +40 -0
  120. package/src/lib/ui-logics/page-logics/PostDetailPageLogics.js +58 -0
  121. package/src/lib/ui-logics/page-logics/PreviewPostPageLogics.js +53 -0
  122. package/src/lib/ui-logics/page-logics/ProfilePageLogics.js +44 -0
  123. package/src/lib/ui-logics/page-logics/RenewPasswordPageLogics.js +44 -0
  124. package/src/lib/ui-logics/page-logics/ResetPasswordPageLogics.js +53 -0
  125. package/src/lib/ui-logics/page-logics/SettingsPageLogics.js +230 -0
  126. package/src/lib/ui-logics/page-logics/SupportPageLogics.js +60 -0
  127. package/src/lib/ui-logics/page-logics/TicketDetailPageLogics.js +160 -0
  128. package/src/lib/ui-logics/page-logics/TicketsPageLogics.js +132 -0
  129. package/src/lib/variables.js +1 -0
  130. package/src/lib/views/ActivateEmailView.svelte +71 -0
  131. package/src/lib/views/AppLayoutView.svelte +31 -0
  132. package/src/lib/views/AuthLayoutView.svelte +23 -0
  133. package/src/lib/views/ConfirmNewEmailView.svelte +71 -0
  134. package/src/lib/views/CreateTicketView.svelte +73 -0
  135. package/src/lib/views/ErrorView.svelte +38 -0
  136. package/src/lib/views/HomeView.svelte +72 -0
  137. package/src/lib/views/LoginView.svelte +372 -0
  138. package/src/lib/views/MainLayoutView.svelte +86 -0
  139. package/src/lib/views/NotificationsView.svelte +129 -0
  140. package/src/lib/views/PlayerDetailView.svelte +31 -0
  141. package/src/lib/views/PostDetailView.svelte +199 -0
  142. package/src/lib/views/PreviewPostView.svelte +151 -0
  143. package/src/lib/views/ProfileLayoutView.svelte +16 -0
  144. package/src/lib/views/ProfileView.svelte +68 -0
  145. package/src/lib/views/RegisterView.svelte +113 -0
  146. package/src/lib/views/RenewPasswordView.svelte +98 -0
  147. package/src/lib/views/ResetPasswordView.svelte +88 -0
  148. package/src/lib/views/RulesView.svelte +26 -0
  149. package/src/lib/views/SettingsView.svelte +471 -0
  150. package/src/lib/views/SupportView.svelte +79 -0
  151. package/src/lib/views/ThemeSettingsLayoutView.svelte +19 -0
  152. package/src/lib/views/ThemeSettingsView.svelte +1508 -0
  153. package/src/lib/views/TicketDetailView.svelte +185 -0
  154. package/src/lib/views/TicketsLayoutView.svelte +21 -0
  155. package/src/lib/views/TicketsView.svelte +87 -0
  156. package/src/plugin-engine/engine.js +484 -0
  157. package/src/registry/index.js +86 -0
  158. package/src/routes/RootLayout.svelte +21 -0
  159. package/src/routes/plugin-ui/Layout.svelte +291 -0
  160. package/src/routes/plugin-ui/Page.svelte +117 -0
  161. package/src/routes/plugin-ui/layout.js +8 -0
  162. package/src/routes/plugin-ui/page.js +8 -0
  163. package/src/routes/plugins-client-file.js +76 -0
  164. package/src/routes/root-layout-load.js +15 -0
  165. package/src/routes/theme-api-languages.js +52 -0
  166. package/src/routes/theme-api-licenses.js +28 -0
@@ -0,0 +1,264 @@
1
+ import { onDestroy, onMount } from "svelte";
2
+ import { get, writable } from "svelte/store";
3
+
4
+ import { formatDistanceToNow } from "date-fns";
5
+ import { sanitize } from "@jill64/universal-sanitizer";
6
+
7
+ import { browser } from "$app/environment";
8
+
9
+ import ApiUtil from "$pano/lib/api.util.js";
10
+ import { onNotificationRefresh } from "$pano/lib/siteRealtime.js";
11
+ import { requireLogin } from "$pano/lib/Store.js";
12
+
13
+ import ProfileSidebar, { load as loadSidebar } from "$pano/lib/components/sidebars/ProfileSidebar.svelte";
14
+
15
+ import {
16
+ setCallback as setDeleteAllNotificationsModalCallback,
17
+ show as showDeleteAllNotificationsModal
18
+ } from "$pano/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte";
19
+
20
+ Array.prototype.insert = function(index, item) {
21
+ this.splice(index, 0, item);
22
+
23
+ return this;
24
+ };
25
+
26
+ Array.prototype.remove = function(index) {
27
+ this.splice(index, 1);
28
+
29
+ return this;
30
+ };
31
+
32
+ /**
33
+ * Panel ile aynı: satırda kısa süre "okunmamış" vurgusu, 3 sn sonra yerelde READ (API ayrı).
34
+ * @param {import('svelte/store').Writable} notificationsStore
35
+ * @param {unknown[] | null | undefined} sourceList
36
+ * @param {number | null} limit - ilk N (panel load: 5); `null` = tüm liste (WS yenilemesi)
37
+ */
38
+ export function scheduleMarkReadVisualEffects(notificationsStore, sourceList, limit) {
39
+ if (!browser || !sourceList?.length) {
40
+ return;
41
+ }
42
+ const slice = limit != null ? sourceList.slice(0, limit) : sourceList;
43
+ slice.forEach((notification) => {
44
+ if (notification.status !== "NOT_READ") {
45
+ return;
46
+ }
47
+ const notificationId = notification.id;
48
+ setTimeout(() => {
49
+ notificationsStore.update((list) =>
50
+ list.map((sub) =>
51
+ sub.id === notificationId ? { ...sub, status: "READ" } : sub
52
+ )
53
+ );
54
+ }, 3000);
55
+ });
56
+ }
57
+
58
+ function setNotifications(notifications, newNotifications) {
59
+ if (get(notifications).length === 0 || newNotifications.length === 0)
60
+ notifications.set(newNotifications);
61
+ else {
62
+ const listOfFilterIsNotificationExists = [];
63
+
64
+ newNotifications.forEach((item, index) => {
65
+ listOfFilterIsNotificationExists[index] = get(notifications).filter(
66
+ (filterItem) => filterItem.id === item.id
67
+ );
68
+ });
69
+
70
+ newNotifications.forEach((item, index) => {
71
+ if (listOfFilterIsNotificationExists[index].length === 0) {
72
+ notifications.set(get(notifications).insert(index, item));
73
+ }
74
+ });
75
+ }
76
+ }
77
+
78
+ async function loadData({ request }) {
79
+ return new Promise((resolve, reject) => {
80
+ ApiUtil.get({
81
+ path: "/api/notifications",
82
+ request
83
+ }).then((body) => {
84
+ if (body.result === "ok") {
85
+ resolve(body);
86
+ } else {
87
+ reject(body);
88
+ }
89
+ });
90
+ });
91
+ }
92
+
93
+ /**
94
+ * @type {import("@sveltejs/kit").PageLoad}
95
+ */
96
+ export async function processLoad(event) {
97
+ const { parent } = event;
98
+ const parentData = await parent();
99
+
100
+ const { session } = parentData;
101
+
102
+ requireLogin(session);
103
+
104
+ // if (event.stuff.NETWORK_ERROR) {
105
+ // output.props.data.NETWORK_ERROR = true;
106
+ //
107
+ // return output;
108
+ // }
109
+
110
+ const [{ notifications, notificationCount }] = await Promise.all([
111
+ loadData({ request: event }),
112
+ loadSidebar(event)
113
+ ]);
114
+
115
+ return {
116
+ notifications,
117
+ notificationCount: parseInt(notificationCount),
118
+ sidebar: ProfileSidebar,
119
+ sidebarProps: { showDeleteAll: true },
120
+ pageTitle: "pages.notifications.page-title"
121
+ };
122
+ }
123
+
124
+ function getNotifications(notifications, notificationProcessID, count, id) {
125
+ loadData({}).then((data) => {
126
+ if (get(notificationProcessID) !== id) {
127
+ return;
128
+ }
129
+ if (data.result === "ok") {
130
+ setNotifications(notifications, data.notifications);
131
+
132
+ count.set(parseInt(data.notificationCount));
133
+ scheduleMarkReadVisualEffects(notifications, data.notifications, null);
134
+ }
135
+ });
136
+ }
137
+
138
+ export function loadMore(notifications, loadMoreLoading) {
139
+ loadMoreLoading.set(true);
140
+
141
+ ApiUtil.get({
142
+ path: `/api/notifications/${
143
+ get(notifications)[get(notifications).length - 1].id
144
+ }/more`
145
+ }).then((body) => {
146
+ if (body.result === "ok") {
147
+ body.notifications.forEach((notification) => {
148
+ notifications.update((value) =>
149
+ value.insert(value.length, notification)
150
+ );
151
+ });
152
+
153
+ loadMoreLoading.set(false);
154
+ }
155
+ });
156
+ }
157
+
158
+ export function onDeleteNotificationClick(notifications, count, id) {
159
+ ApiUtil.delete({
160
+ path: `/api/notifications/${id}`
161
+ }).then((body) => {
162
+ if (body.result === "ok") {
163
+
164
+ get(notifications).forEach((notification) => {
165
+ if (notification.id === id) {
166
+ notifications.update((value) => {
167
+ return value.remove(value.indexOf(notification));
168
+ }
169
+ );
170
+
171
+ count.update((value) => {
172
+ value--;
173
+
174
+ return value;
175
+ });
176
+ }
177
+ });
178
+ }
179
+ });
180
+ }
181
+
182
+ function startNotificationsCountdown(notifications, notificationProcessID, count) {
183
+ notificationProcessID.update(notificationProcessID => {
184
+ notificationProcessID++;
185
+ return notificationProcessID;
186
+ });
187
+
188
+ const id = get(notificationProcessID);
189
+
190
+ getNotifications(notifications, notificationProcessID, count, id);
191
+ }
192
+
193
+ function stopNotificationsCountdown(notificationProcessID, interval) {
194
+ notificationProcessID.update(notificationProcessID => {
195
+ notificationProcessID++;
196
+ return notificationProcessID;
197
+ });
198
+
199
+ clearInterval(get(interval));
200
+ }
201
+
202
+ export function getTime(check, time, locale) {
203
+ return formatDistanceToNow(time, { addSuffix: true, locale });
204
+ }
205
+
206
+ export function onDeleteAllClick(notificationProcessID, interval) {
207
+ stopNotificationsCountdown(notificationProcessID, interval);
208
+
209
+ showDeleteAllNotificationsModal();
210
+ }
211
+
212
+ export function init(data) {
213
+ const notifications = writable(data.notifications || []);
214
+ const count = writable(data.notificationCount || 0);
215
+ const notificationProcessID = writable(0);
216
+ const checkTime = writable(0);
217
+ const interval = writable();
218
+
219
+ const page = writable(0);
220
+ const loadMoreLoading = writable(false);
221
+
222
+ let unsubNotificationRefresh = () => {};
223
+ if (browser) {
224
+ unsubNotificationRefresh = onNotificationRefresh(() => {
225
+ startNotificationsCountdown(notifications, notificationProcessID, count);
226
+ });
227
+ }
228
+
229
+ onMount(() => {
230
+ scheduleMarkReadVisualEffects(notifications, get(notifications), 5);
231
+ interval.set(setInterval(() => {
232
+ checkTime.update(checkTime => {
233
+ checkTime += 1;
234
+ return checkTime;
235
+ });
236
+ }, 1000));
237
+ });
238
+
239
+ onDestroy(() => {
240
+ unsubNotificationRefresh();
241
+ stopNotificationsCountdown(notificationProcessID, interval);
242
+ });
243
+
244
+ setDeleteAllNotificationsModalCallback(() => {
245
+ startNotificationsCountdown(notifications, notificationProcessID, count);
246
+ });
247
+
248
+ return {
249
+ notifications,
250
+ count,
251
+ notificationProcessID,
252
+ page,
253
+ loadMoreLoading,
254
+ checkTime,
255
+ interval
256
+ };
257
+ }
258
+
259
+ export function sanitizeObject(obj) {
260
+ return Object.keys(obj).reduce((sanitizedObj, key) => {
261
+ sanitizedObj[key] = sanitize(obj[key]);
262
+ return sanitizedObj;
263
+ }, {});
264
+ }
@@ -0,0 +1,40 @@
1
+ import { error } from "@sveltejs/kit";
2
+
3
+ import { getPlayerProfile } from "$pano/lib/services/profile";
4
+
5
+ import PlayerDetailSidebar, { load as loadSidebar } from "$pano/lib/components/sidebars/PlayerDetailSidebar.svelte";
6
+
7
+ /**
8
+ * @type {import("@sveltejs/kit").Load}
9
+ */
10
+ export async function processLoad(event) {
11
+ const { parent } = event;
12
+ await parent();
13
+
14
+ let data = {
15
+ registerDate: 0
16
+ };
17
+
18
+ // Sidebar and player profile API are independent — run in parallel
19
+ const [, profileBody] = await Promise.all([
20
+ loadSidebar(event),
21
+ getPlayerProfile({ username: event.params.player, request: event })
22
+ ]);
23
+
24
+ if (profileBody.error) {
25
+ if (profileBody.error === "NOT_EXISTS") {
26
+ throw error(404, profileBody.error);
27
+ }
28
+
29
+ throw error(500, profileBody.error);
30
+ }
31
+
32
+ data = profileBody;
33
+
34
+ return {
35
+ ...data,
36
+ sidebar: PlayerDetailSidebar,
37
+ sidebarProps: { side: "left" },
38
+ pageTitle: "pages.player-profile.title"
39
+ };
40
+ }
@@ -0,0 +1,58 @@
1
+ import { error } from "@sveltejs/kit";
2
+
3
+ import { getPostDetail } from "$pano/lib/services/posts";
4
+ import { executeHookLoad, executeLifecycle } from "$pano/lib/PluginAPI.js";
5
+
6
+ /**
7
+ * @type {import("@sveltejs/kit").Load}
8
+ */
9
+ export async function processLoad(event) {
10
+ const { parent } = event;
11
+ const { hookProps: parentHookProps } = await parent();
12
+
13
+ let data = {
14
+ post: {
15
+ id: -1,
16
+ title: "",
17
+ category: "-",
18
+ writer: {
19
+ username: "",
20
+ },
21
+ text: "",
22
+ date: 0,
23
+ status: 1,
24
+ image: "",
25
+ views: 0,
26
+ url: "",
27
+ },
28
+ previousPost: "-",
29
+ nextPost: "-",
30
+ };
31
+
32
+ await getPostDetail({ url: event.params.url, request: event }).then(
33
+ (body) => {
34
+ if (body.error) {
35
+ if (body.error === "POST_NOT_FOUND") {
36
+ throw error(404, body.error);
37
+ }
38
+
39
+ throw error(500, body.error);
40
+ }
41
+
42
+ data = body;
43
+ },
44
+ );
45
+
46
+ data.hookProps = { ...parentHookProps };
47
+
48
+ await executeLifecycle("theme:post-detail:load", data, event);
49
+
50
+ data.hookProps["theme:post-detail:bottom"] = {
51
+ ...data.hookProps["theme:post-detail:bottom"],
52
+ ...(await executeHookLoad("theme:post-detail:bottom", event)),
53
+ };
54
+
55
+ data.pageTitle = data.post.title;
56
+
57
+ return { ...data };
58
+ }
@@ -0,0 +1,53 @@
1
+ import { getPostPreview } from "$pano/lib/services/posts";
2
+
3
+ /**
4
+ * @type {import("@sveltejs/kit").Load}
5
+ */
6
+ export async function processLoad(event) {
7
+ const { parent } = event;
8
+
9
+ const parentData = await parent();
10
+
11
+ const { session } = parentData;
12
+ const { user } = session;
13
+
14
+ if (!user && !user.panelAccess) {
15
+ return {
16
+ status: 302,
17
+ redirect: "/"
18
+ };
19
+ }
20
+
21
+ let data = {
22
+ post: {
23
+
24
+ id: -1,
25
+ title: "",
26
+ category: "-",
27
+ writer: {
28
+ username: ""
29
+ },
30
+ text: "",
31
+ date: 0,
32
+ status: 1,
33
+ image: "",
34
+ views: 0
35
+ },
36
+ previousPost: "-",
37
+ nextPost: "-"
38
+ };
39
+
40
+ await getPostPreview({ id: event.params.id, request: event }).then(
41
+ (body) => {
42
+ if (body.error) {
43
+ data = {};
44
+
45
+ return;
46
+ }
47
+
48
+ data.post = body;
49
+ }
50
+ );
51
+
52
+ return data;
53
+ }
@@ -0,0 +1,44 @@
1
+ import { getProfile } from "$pano/lib/services/profile";
2
+ import { executeLifecycle, executeViewLoad, panoApiServer } from "$pano/lib/PluginAPI";
3
+
4
+ import ProfileSidebar, { load as loadSidebar } from "$pano/lib/components/sidebars/ProfileSidebar.svelte";
5
+
6
+ /**
7
+ * @type {import("@sveltejs/kit").Load}
8
+ */
9
+ export async function processLoad(event) {
10
+ const { parent } = event;
11
+ await parent();
12
+
13
+ let data = {
14
+ registerDate: 0,
15
+ lastLoginDate: 0
16
+ };
17
+
18
+ // Initialize profile content
19
+ panoApiServer.ui.profile.content.edit((items) => {
20
+ items.push({ id: "profile-card", priority: 100, hidden: false });
21
+ });
22
+
23
+ // Initialize profile card rows
24
+ panoApiServer.ui.profile.cardRows.edit((items) => {
25
+ items.push(
26
+ { id: "register-date", priority: 100, hidden: false },
27
+ { id: "last-login", priority: 90, hidden: false }
28
+ );
29
+ });
30
+
31
+ await executeLifecycle("theme:profile:load", {}, event);
32
+
33
+ // View loads, sidebar, and API call are all independent — run in parallel
34
+ const [, , , profileBody] = await Promise.all([
35
+ executeViewLoad("profile-content", event),
36
+ executeViewLoad("profile-card-rows", event),
37
+ loadSidebar(event),
38
+ getProfile({ request: event })
39
+ ]);
40
+
41
+ data = profileBody;
42
+
43
+ return { ...data, sidebar: ProfileSidebar, pageTitle: "pages.profile.title" };
44
+ }
@@ -0,0 +1,44 @@
1
+ import { get } from "svelte/store";
2
+
3
+ import { sendRenewPassword } from "$pano/lib/services/auth";
4
+ import { NETWORK_ERROR } from "$pano/lib/api.util";
5
+ import { executeLifecycle, executeViewLoad } from "$pano/lib/PluginAPI";
6
+
7
+ export async function processLoad(event) {
8
+ const { parent, url: { searchParams } } = event;
9
+ await parent();
10
+
11
+ const token = searchParams.get("token") || "";
12
+
13
+ await executeLifecycle("theme:renew-password:load", { token }, event);
14
+ await executeViewLoad("renew-password-content", event);
15
+
16
+ return { token, pageTitle: "pages.renew-password.title" };
17
+ }
18
+
19
+ export async function onSubmit(error, message, loading, newPassword, newPasswordRepeat, data) {
20
+ error.set(null);
21
+ message.set(null);
22
+ loading.set(true);
23
+
24
+ await sendRenewPassword(get(newPassword), get(newPasswordRepeat), data.token)
25
+ .then((body) => {
26
+ loading.set(false);
27
+
28
+ if (body.result === "ok") {
29
+ message.set("RENEW_PASSWORD_SUCCESSFUL");
30
+
31
+ return;
32
+ }
33
+
34
+ if (body.error === "PLUGIN_DENIED_LOGIN" && body.reason) {
35
+ error.set(body.reason);
36
+ } else {
37
+ error.set(body.error);
38
+ }
39
+ })
40
+ .catch(() => {
41
+ error.set(NETWORK_ERROR);
42
+ loading.set(false);
43
+ });
44
+ }
@@ -0,0 +1,53 @@
1
+ import { get } from "svelte/store";
2
+
3
+ import { NETWORK_ERROR } from "$pano/lib/api.util";
4
+ import { executeLifecycle, executeViewLoad } from "$pano/lib/PluginAPI";
5
+ import { sendResetPassword } from "$pano/lib/services/auth";
6
+ import { requireNotLogin } from "$pano/lib/Store";
7
+
8
+ export async function processLoad(event) {
9
+ const { parent } = event;
10
+ const parentData = await parent();
11
+
12
+ const { session } = parentData;
13
+
14
+ requireNotLogin(session);
15
+
16
+ await executeLifecycle("theme:reset-password:load", {}, event);
17
+ await executeViewLoad("reset-password-content", event);
18
+
19
+ return { pageTitle: "pages.reset-password.title" };
20
+ }
21
+
22
+ export async function onSubmit(error, message, loading, usernameOrEmail) {
23
+ error.set(null);
24
+ message.set(null);
25
+ loading.set(true);
26
+
27
+ await sendResetPassword(get(usernameOrEmail))
28
+ .then((body) => {
29
+ loading.set(false);
30
+
31
+ if (body.result === "ok") {
32
+ message.set("RESET_PASSWORD_SUCCESSFUL");
33
+
34
+ return;
35
+ }
36
+
37
+ if (body.error === "NOT_EXISTS") {
38
+ message.set("RESET_PASSWORD_SUCCESSFUL");
39
+
40
+ return;
41
+ }
42
+
43
+ if (body.error === "PLUGIN_DENIED_LOGIN" && body.reason) {
44
+ error.set(body.reason);
45
+ } else {
46
+ error.set(body.error);
47
+ }
48
+ })
49
+ .catch(() => {
50
+ error.set(NETWORK_ERROR);
51
+ loading.set(false);
52
+ });
53
+ }