@panomc/theme-core 1.0.0-dev.59 → 1.0.0-dev.61
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/assets/css/pano-fallback-legacy.css +12381 -0
- package/assets/css/pano-fallback.css +3222 -0
- package/bin/__tests__/check/fixtures/plugin-contracts/market/controllers.json +4 -0
- package/bin/__tests__/check/fixtures/plugin-contracts/market/views.json +67 -0
- package/bin/__tests__/check/fixtures/routes.json +5 -0
- package/bin/__tests__/check/helpers.js +55 -0
- package/bin/__tests__/check/overrides.test.js +287 -0
- package/bin/__tests__/check/theme.test.js +332 -0
- package/bin/__tests__/cli/accept-and-list.test.js +159 -0
- package/bin/__tests__/cli/config-edit.test.js +213 -0
- package/bin/__tests__/cli/contracts-pull.test.js +187 -0
- package/bin/__tests__/cli/core-meta.test.js +305 -0
- package/bin/__tests__/cli/eject-view.test.js +356 -0
- package/bin/__tests__/cli/helpers.js +258 -0
- package/bin/__tests__/scaffold/scaffold.test.js +84 -0
- package/bin/bundle-internal-libs.js +14 -2
- package/bin/check.js +1150 -213
- package/bin/contracts.js +1643 -0
- package/bin/generate-contract.js +378 -0
- package/bin/generate-licenses.js +14 -2
- package/bin/generate-runtime-shims.js +27 -9
- package/bin/new.js +101 -2
- package/bin/package-zip.js +16 -2
- package/bin/sync.js +360 -7
- package/bin/theme-core.js +65 -107
- package/lang/en-US.json +1 -0
- package/lang/ru.json +1 -0
- package/lang/tr.json +1 -0
- package/package.json +7 -3
- package/skin-contract.json +864 -19
- package/src/kit/__tests__/hooks-server-fetch.test.js +56 -0
- package/src/kit/__tests__/route-map.test.js +154 -0
- package/src/kit/__tests__/theme-meta.test.js +249 -0
- package/src/kit/hooks-client.js +3 -0
- package/src/kit/hooks-server.js +91 -7
- package/src/kit/route-map.js +300 -0
- package/src/kit/specifiers.js +3 -0
- package/src/kit/svelte-config.js +3 -0
- package/src/kit/theme-meta.js +405 -0
- package/src/kit/vite-config.js +156 -12
- package/src/lib/NotificationManager.js +18 -0
- package/src/lib/PluginAPI.js +313 -9
- package/src/lib/Store.js +18 -5
- package/src/lib/__tests__/avatarVersion.test.js +25 -0
- package/src/lib/__tests__/check.test.js +201 -0
- package/src/lib/__tests__/controllerHost.test.js +363 -0
- package/src/lib/__tests__/cx03.test.js +245 -0
- package/src/lib/__tests__/engineBoot.test.js +151 -0
- package/src/lib/__tests__/engineParts.helper.js +284 -0
- package/src/lib/__tests__/engineParts.test.js +179 -0
- package/src/lib/__tests__/engineSidebars.helper.js +353 -0
- package/src/lib/__tests__/engineSidebars.test.js +273 -0
- package/src/lib/__tests__/engineStyles.test.js +227 -0
- package/src/lib/__tests__/engineWiring.test.js +1000 -0
- package/src/lib/__tests__/fallbackStyles.test.js +1254 -0
- package/src/lib/__tests__/fixtures/Probe.svelte +5 -0
- package/src/lib/__tests__/fixtures/engine-parts.ssr.json +29 -0
- package/src/lib/__tests__/fixtures/engine-sidebars.ssr.json +16 -0
- package/src/lib/__tests__/home.test.js +563 -0
- package/src/lib/__tests__/injectedScope.test.js +490 -0
- package/src/lib/__tests__/languageConcurrency.test.js +55 -0
- package/src/lib/__tests__/languageLayers.test.js +286 -0
- package/src/lib/__tests__/pageHead.test.js +167 -0
- package/src/lib/__tests__/pageMeta.util.test.js +216 -0
- package/src/lib/__tests__/pageTitle.util.test.js +96 -0
- package/src/lib/__tests__/pluginApiViews.test.js +529 -0
- package/src/lib/__tests__/plugins.test.js +53 -0
- package/src/lib/__tests__/profileNav.util.test.js +145 -0
- package/src/lib/__tests__/registryReady.test.js +26 -0
- package/src/lib/__tests__/returnTo.util.test.js +294 -0
- package/src/lib/__tests__/routeConfig.test.js +361 -0
- package/src/lib/__tests__/sidebarSpec.util.test.js +152 -0
- package/src/lib/__tests__/skinContract.test.js +558 -0
- package/src/lib/__tests__/svelteSsr.helper.js +68 -0
- package/src/lib/__tests__/tc03.test.js +427 -0
- package/src/lib/__tests__/tc11.test.js +184 -0
- package/src/lib/__tests__/translationLayers.test.js +161 -0
- package/src/lib/avatarVersion.js +39 -0
- package/src/lib/components/Breadcrumb.svelte +9 -40
- package/src/lib/components/Date.svelte +1 -1
- package/src/lib/components/DefaultToast.svelte +13 -3
- package/src/lib/components/FallbackLinks.svelte +28 -0
- package/src/lib/components/FallbackScope.svelte +24 -0
- package/src/lib/components/Footer.svelte +8 -8
- package/src/lib/components/Header.svelte +3 -3
- package/src/lib/components/Hook.svelte +12 -1
- package/src/lib/components/LoginFormBody.svelte +5 -5
- package/src/lib/components/Main.svelte +22 -47
- package/src/lib/components/Navbar.svelte +30 -29
- package/src/lib/components/NoContent.svelte +2 -2
- package/src/lib/components/NotificationContainer.svelte +31 -82
- package/src/lib/components/OnlineAdmins.svelte +3 -2
- package/src/lib/components/PageActions.svelte +1 -1
- package/src/lib/components/PageHead.svelte +50 -0
- package/src/lib/components/PageTitle.svelte +2 -2
- package/src/lib/components/Pagination.svelte +6 -6
- package/src/lib/components/PlayerHead.svelte +4 -4
- package/src/lib/components/PluginBlock.svelte +132 -0
- package/src/lib/components/PluginSlot.svelte +40 -0
- package/src/lib/components/Post.svelte +13 -230
- package/src/lib/components/Posts.svelte +7 -14
- package/src/lib/components/RegisterForm.svelte +12 -11
- package/src/lib/components/Sidebar.svelte +9 -7
- package/src/lib/components/TicketRow.svelte +8 -48
- package/src/lib/components/TicketStatus.svelte +10 -16
- package/src/lib/components/Tickets.svelte +8 -30
- package/src/lib/components/Toast.svelte +16 -14
- package/src/lib/components/ToastContainer.svelte +16 -9
- package/src/lib/components/ViewComponent.svelte +13 -1
- package/src/lib/components/modals/CloseTicketConfirmModal.svelte +15 -46
- package/src/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte +17 -39
- package/src/lib/components/modals/LogoutSessionConfirmModal.svelte +12 -30
- package/src/lib/components/sidebars/HomeSidebar.svelte +33 -284
- package/src/lib/components/sidebars/PlayerDetailSidebar.svelte +14 -63
- package/src/lib/components/sidebars/PluginSidebar.svelte +21 -0
- package/src/lib/components/sidebars/ProfileNavCard.svelte +24 -0
- package/src/lib/components/sidebars/ProfileSidebar.svelte +44 -84
- package/src/lib/components/sidebars/SupportSidebar.svelte +19 -22
- package/src/lib/components/sidebars/TicketCreateAndDetailSidebar.svelte +23 -35
- package/src/lib/components/sidebars/profileNav.util.js +105 -0
- package/src/lib/components/sidebars/sidebarSpec.util.js +92 -0
- package/src/lib/controllerHost.js +261 -0
- package/src/lib/fallbackStyles.js +317 -0
- package/src/lib/home.js +202 -0
- package/src/lib/language.util.js +70 -37
- package/src/lib/layouts/AppLayout.svelte +16 -8
- package/src/lib/layouts/AuthLayout.svelte +6 -4
- package/src/lib/layouts/MainLayout.svelte +17 -12
- package/src/lib/layouts/ProfileLayout.svelte +6 -4
- package/src/lib/layouts/ThemeSettingsLayout.svelte +6 -4
- package/src/lib/layouts/TicketsLayout.svelte +6 -5
- package/src/lib/pageMeta.util.js +212 -0
- package/src/lib/pageShape.js +33 -0
- package/src/lib/pageTitle.util.js +32 -0
- package/src/lib/pages/ActivateEmailPage.svelte +2 -7
- package/src/lib/pages/ConfirmNewEmailPage.svelte +2 -7
- package/src/lib/pages/ErrorPage.svelte +5 -2
- package/src/lib/pages/HomePage.svelte +31 -8
- package/src/lib/pages/LoginPage.svelte +38 -41
- package/src/lib/pages/NotificationsPage.svelte +2 -7
- package/src/lib/pages/PlayerDetailPage.svelte +2 -7
- package/src/lib/pages/PostDetailPage.svelte +2 -7
- package/src/lib/pages/PreviewPostPage.svelte +2 -7
- package/src/lib/pages/RegisterPage.svelte +10 -13
- package/src/lib/pages/RenewPasswordPage.svelte +2 -7
- package/src/lib/pages/ResetPasswordPage.svelte +2 -7
- package/src/lib/pages/RulesPage.svelte +3 -8
- package/src/lib/pages/SupportPage.svelte +2 -7
- package/src/lib/pages/ThemeSettingsPage.svelte +2 -7
- package/src/lib/pages/profile/ProfilePage.svelte +2 -7
- package/src/lib/pages/profile/SettingsPage.svelte +2 -7
- package/src/lib/pages/profile/TicketsPage.svelte +2 -7
- package/src/lib/pages/ticket/CreateTicketPage.svelte +2 -7
- package/src/lib/pages/ticket/TicketDetailPage.svelte +2 -7
- package/src/lib/plugins.js +61 -0
- package/src/lib/returnTo.util.js +116 -0
- package/src/lib/services/auth.js +11 -11
- package/src/lib/services/posts.js +21 -10
- package/src/lib/services/profile.js +5 -5
- package/src/lib/services/theme-setting.js +1 -1
- package/src/lib/services/tickets.js +36 -15
- package/src/lib/siteRealtime.js +55 -8
- package/src/lib/themePageLoad.js +38 -0
- package/src/lib/translationLayers.js +144 -0
- package/src/lib/ui-logics/layout-logics/AppLayoutLogics.js +160 -6
- package/src/lib/ui-logics/layout-logics/AuthLayoutLogics.js +3 -2
- package/src/lib/ui-logics/layout-logics/ProfileLayoutLogics.js +3 -2
- package/src/lib/ui-logics/layout-logics/TicketsLayoutLogics.js +3 -2
- package/src/lib/ui-logics/page-logics/ActiveEmailPageLogics.js +4 -4
- package/src/lib/ui-logics/page-logics/ConfirmNewEmailPageLogics.js +4 -4
- package/src/lib/ui-logics/page-logics/CreateTicketPageLogics.js +5 -5
- package/src/lib/ui-logics/page-logics/HomePageLogics.js +5 -3
- package/src/lib/ui-logics/page-logics/NotificationsPageLogics.js +40 -16
- package/src/lib/ui-logics/page-logics/PlayerDetailPageLogics.js +3 -3
- package/src/lib/ui-logics/page-logics/PostDetailPageLogics.js +3 -3
- package/src/lib/ui-logics/page-logics/PreviewPostPageLogics.js +1 -1
- package/src/lib/ui-logics/page-logics/RenewPasswordPageLogics.js +4 -4
- package/src/lib/ui-logics/page-logics/ResetPasswordPageLogics.js +6 -6
- package/src/lib/ui-logics/page-logics/SettingsPageLogics.js +8 -8
- package/src/lib/ui-logics/page-logics/TicketDetailPageLogics.js +3 -3
- package/src/lib/ui-logics/page-logics/TicketsPageLogics.js +5 -3
- package/src/lib/views/ActivateEmailView.samples.js +22 -0
- package/src/lib/views/ActivateEmailView.svelte +4 -4
- package/src/lib/views/AppLayoutView.samples.js +17 -0
- package/src/lib/views/AppLayoutView.svelte +1 -1
- package/src/lib/views/AuthLayoutView.samples.js +4 -0
- package/src/lib/views/AuthLayoutView.svelte +1 -1
- package/src/lib/views/Breadcrumb.samples.js +15 -0
- package/src/lib/views/CloseTicketConfirmModal.samples.js +12 -0
- package/src/lib/views/ConfirmNewEmailView.samples.js +22 -0
- package/src/lib/views/ConfirmNewEmailView.svelte +4 -4
- package/src/lib/views/ConfirmRemoveAllNotificationsModal.samples.js +9 -0
- package/src/lib/views/CreateTicketView.samples.js +21 -0
- package/src/lib/views/CreateTicketView.svelte +5 -5
- package/src/lib/views/Date.samples.js +9 -0
- package/src/lib/views/DefaultToast.samples.js +7 -0
- package/src/lib/views/ErrorView.samples.js +8 -0
- package/src/lib/views/ErrorView.svelte +4 -2
- package/src/lib/views/Footer.samples.js +8 -0
- package/src/lib/views/Header.samples.js +8 -0
- package/src/lib/views/HomeSidebar.samples.js +59 -0
- package/src/lib/views/HomeView.samples.js +34 -0
- package/src/lib/views/HomeView.svelte +14 -6
- package/src/lib/views/LoginFormBody.samples.js +8 -0
- package/src/lib/views/LoginView.samples.js +50 -0
- package/src/lib/views/LoginView.svelte +24 -22
- package/src/lib/views/LogoutSessionConfirmModal.samples.js +8 -0
- package/src/lib/views/Main.samples.js +23 -0
- package/src/lib/views/MainLayoutView.svelte +3 -4
- package/src/lib/views/Navbar.samples.js +8 -0
- package/src/lib/views/NoContent.samples.js +7 -0
- package/src/lib/views/NotificationContainer.samples.js +25 -0
- package/src/lib/views/NotificationsView.samples.js +36 -0
- package/src/lib/views/NotificationsView.svelte +21 -12
- package/src/lib/views/PageActions.samples.js +7 -0
- package/src/lib/views/PageTitle.samples.js +8 -0
- package/src/lib/views/Pagination.samples.js +7 -0
- package/src/lib/views/PlayerDetailSidebar.samples.js +35 -0
- package/src/lib/views/PlayerDetailView.samples.js +8 -0
- package/src/lib/views/PlayerDetailView.svelte +3 -3
- package/src/lib/views/PlayerHead.samples.js +8 -0
- package/src/lib/views/Post.samples.js +10 -0
- package/src/lib/views/PostDetailView.samples.js +28 -0
- package/src/lib/views/PostDetailView.svelte +24 -16
- package/src/lib/views/Posts.samples.js +9 -0
- package/src/lib/views/PreviewPostView.samples.js +20 -0
- package/src/lib/views/PreviewPostView.svelte +10 -10
- package/src/lib/views/ProfileLayoutView.samples.js +4 -0
- package/src/lib/views/ProfileSidebar.samples.js +33 -0
- package/src/lib/views/ProfileView.samples.js +29 -0
- package/src/lib/views/ProfileView.svelte +2 -2
- package/src/lib/views/RegisterForm.samples.js +7 -0
- package/src/lib/views/RegisterView.samples.js +28 -0
- package/src/lib/views/RegisterView.svelte +5 -3
- package/src/lib/views/RenewPasswordView.samples.js +24 -0
- package/src/lib/views/RenewPasswordView.svelte +6 -6
- package/src/lib/views/ResetPasswordView.samples.js +24 -0
- package/src/lib/views/ResetPasswordView.svelte +3 -3
- package/src/lib/views/RulesView.samples.js +14 -0
- package/src/lib/views/RulesView.svelte +3 -3
- package/src/lib/views/SettingsView.svelte +48 -17
- package/src/lib/views/Sidebar.samples.js +7 -0
- package/src/lib/views/SupportSidebar.samples.js +24 -0
- package/src/lib/views/SupportView.samples.js +16 -0
- package/src/lib/views/SupportView.svelte +8 -6
- package/src/lib/views/ThemeSettingsLayoutView.samples.js +9 -0
- package/src/lib/views/ThemeSettingsLayoutView.svelte +1 -1
- package/src/lib/views/ThemeSettingsView.svelte +89 -89
- package/src/lib/views/TicketCreateAndDetailSidebar.samples.js +33 -0
- package/src/lib/views/TicketDetailView.samples.js +34 -0
- package/src/lib/views/TicketDetailView.svelte +17 -15
- package/src/lib/views/TicketRow.samples.js +10 -0
- package/src/lib/views/TicketStatus.samples.js +8 -0
- package/src/lib/views/Tickets.samples.js +9 -0
- package/src/lib/views/TicketsLayoutView.samples.js +4 -0
- package/src/lib/views/TicketsView.samples.js +23 -0
- package/src/lib/views/TicketsView.svelte +11 -9
- package/src/lib/views/Toast.samples.js +9 -0
- package/src/lib/views/ToastContainer.samples.js +8 -0
- package/src/lib/views/parts/Breadcrumb.svelte +53 -0
- package/src/lib/views/parts/CloseTicketConfirmModal.svelte +63 -0
- package/src/lib/views/parts/ConfirmRemoveAllNotificationsModal.svelte +55 -0
- package/src/lib/views/parts/DefaultToast.svelte +22 -0
- package/src/lib/views/parts/HomeSidebar.svelte +334 -0
- package/src/lib/views/parts/LogoutSessionConfirmModal.svelte +46 -0
- package/src/lib/views/parts/Main.svelte +71 -0
- package/src/lib/views/parts/NotificationContainer.svelte +109 -0
- package/src/lib/views/parts/PlayerDetailSidebar.svelte +81 -0
- package/src/lib/views/parts/Post.svelte +255 -0
- package/src/lib/views/parts/Posts.svelte +25 -0
- package/src/lib/views/parts/ProfileSidebar.svelte +115 -0
- package/src/lib/views/parts/Sidebar.svelte +19 -0
- package/src/lib/views/parts/SupportSidebar.svelte +34 -0
- package/src/lib/views/parts/TicketCreateAndDetailSidebar.svelte +51 -0
- package/src/lib/views/parts/TicketRow.svelte +63 -0
- package/src/lib/views/parts/TicketStatus.svelte +24 -0
- package/src/lib/views/parts/Tickets.svelte +45 -0
- package/src/lib/views/parts/Toast.svelte +27 -0
- package/src/lib/views/parts/ToastContainer.svelte +17 -0
- package/src/lib/views/parts/engine-views.generated.js +63 -0
- package/src/lib/views/parts/publicHref.js +18 -0
- package/src/lib/views/parts/ticketStatuses.js +7 -0
- package/src/plugin-engine/__tests__/engine.test.js +161 -0
- package/src/plugin-engine/engine.js +80 -12
- package/src/registry/__tests__/registry.test.js +510 -0
- package/src/registry/__tests__/view.test.js +52 -0
- package/src/registry/index.js +700 -51
- package/src/registry/routes.js +62 -0
- package/src/registry/view.js +69 -0
- package/src/routes/RootLayout.svelte +24 -1
- package/src/routes/catalogue/List.svelte +163 -0
- package/src/routes/catalogue/Stage.svelte +355 -0
- package/src/routes/catalogue/__tests__/browserSafe.test.js +13 -0
- package/src/routes/catalogue/__tests__/catalogue.test.js +539 -0
- package/src/routes/catalogue/catalogue.js +129 -0
- package/src/routes/catalogue/deps.js +147 -0
- package/src/routes/catalogue/engineSamples.js +63 -0
- package/src/routes/catalogue/fixtures.js +77 -0
- package/src/routes/catalogue/list.js +37 -0
- package/src/routes/catalogue/model.js +286 -0
- package/src/routes/catalogue/stage.js +69 -0
- package/src/routes/catalogue/views-json.js +24 -0
- package/src/routes/plugin-ui/Layout.svelte +29 -4
- package/src/routes/plugin-ui/Page.svelte +86 -31
- package/src/routes/plugin-ui/load.js +173 -0
- package/src/routes/plugins-client-file.js +8 -3
- package/src/routes/plugins-ui-file.js +60 -0
- package/src/routes/root-layout-load.js +59 -2
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Pure helpers for the page head metadata a load() may return as `meta` (spec 15 section 4.3).
|
|
2
|
+
// No framework imports: shared by <PageHead> and the unit tests. Every value that reaches the
|
|
3
|
+
// served HTML is validated here, because plugin pages are third-party code.
|
|
4
|
+
|
|
5
|
+
const DEFAULT_ORIGIN_BASE = "http://pano.invalid";
|
|
6
|
+
const MAX_DESCRIPTION = 300;
|
|
7
|
+
const MAX_IMAGE_ALT = 200;
|
|
8
|
+
const MAX_URL_LENGTH = 2048;
|
|
9
|
+
const MAX_JSON_LD = 16384;
|
|
10
|
+
|
|
11
|
+
const ROBOTS_TOKENS = [
|
|
12
|
+
"index",
|
|
13
|
+
"noindex",
|
|
14
|
+
"follow",
|
|
15
|
+
"nofollow",
|
|
16
|
+
"noarchive",
|
|
17
|
+
"nosnippet",
|
|
18
|
+
"noimageindex",
|
|
19
|
+
];
|
|
20
|
+
const OG_TYPES = ["website", "article", "product"];
|
|
21
|
+
const REFERRER_POLICIES = ["no-referrer", "same-origin", "strict-origin-when-cross-origin"];
|
|
22
|
+
|
|
23
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
24
|
+
|
|
25
|
+
function text(value, max) {
|
|
26
|
+
if (typeof value !== "string") return null;
|
|
27
|
+
|
|
28
|
+
const collapsed = value.replace(/\s+/g, " ").trim();
|
|
29
|
+
if (!collapsed) return null;
|
|
30
|
+
|
|
31
|
+
return collapsed.length > max ? collapsed.slice(0, max).trimEnd() : collapsed;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function hasUnsafeChars(value) {
|
|
35
|
+
for (let i = 0; i < value.length; i++) {
|
|
36
|
+
const code = value.charCodeAt(i);
|
|
37
|
+
if (code === 0x5c || code <= 0x20 || code === 0x7f) return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The site base: `siteInfo.websiteUrl` without trailing slash when it is an http(s) URL, else the
|
|
44
|
+
* request origin.
|
|
45
|
+
* @returns {{ base: string, origin: string }}
|
|
46
|
+
*/
|
|
47
|
+
function siteBase(siteInfo, url) {
|
|
48
|
+
const configured = typeof siteInfo?.websiteUrl === "string" ? siteInfo.websiteUrl.trim() : "";
|
|
49
|
+
|
|
50
|
+
if (configured) {
|
|
51
|
+
try {
|
|
52
|
+
const parsed = new URL(configured);
|
|
53
|
+
|
|
54
|
+
if (parsed.protocol === "http:" || parsed.protocol === "https:") {
|
|
55
|
+
return { base: configured.replace(/\/+$/, ""), origin: parsed.origin };
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
// fall through to the request origin
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const origin = typeof url?.origin === "string" ? url.origin : "";
|
|
63
|
+
|
|
64
|
+
return { base: origin, origin };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A site-relative path (`/…`): not protocol-relative, no backslash / control characters, and still
|
|
69
|
+
* a same-origin path after dot-segment normalisation. Same checks as `sanitizeReturnTo` minus the
|
|
70
|
+
* auth-page guard.
|
|
71
|
+
* @returns {string | null} the normalised `pathname + search`, or null
|
|
72
|
+
*/
|
|
73
|
+
function sitePath(value) {
|
|
74
|
+
if (typeof value !== "string") return null;
|
|
75
|
+
if (value.length < 1 || value.length > MAX_URL_LENGTH) return null;
|
|
76
|
+
if (value[0] !== "/" || value[1] === "/" || value[1] === "\\") return null;
|
|
77
|
+
if (hasUnsafeChars(value)) return null;
|
|
78
|
+
|
|
79
|
+
let parsed;
|
|
80
|
+
try {
|
|
81
|
+
parsed = new URL(value, DEFAULT_ORIGIN_BASE);
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (parsed.origin !== DEFAULT_ORIGIN_BASE) return null;
|
|
87
|
+
|
|
88
|
+
const out = parsed.pathname + parsed.search;
|
|
89
|
+
if (out[0] !== "/" || out[1] === "/" || out[1] === "\\" || out.includes("\\")) return null;
|
|
90
|
+
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function absoluteHttpUrl(value) {
|
|
95
|
+
if (typeof value !== "string" || value.length > MAX_URL_LENGTH || hasUnsafeChars(value)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let parsed;
|
|
100
|
+
try {
|
|
101
|
+
parsed = new URL(value);
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed : null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function normalizeImage(value, base) {
|
|
110
|
+
if (typeof value !== "string") return null;
|
|
111
|
+
|
|
112
|
+
const trimmed = value.trim();
|
|
113
|
+
|
|
114
|
+
if (/^https?:\/\//i.test(trimmed)) return absoluteHttpUrl(trimmed)?.href ?? null;
|
|
115
|
+
|
|
116
|
+
const path = trimmed.startsWith("/") ? sitePath(trimmed) : null;
|
|
117
|
+
|
|
118
|
+
return path && base ? base + path : null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function normalizeCanonical(value, base, origin) {
|
|
122
|
+
if (typeof value !== "string") return null;
|
|
123
|
+
|
|
124
|
+
const trimmed = value.trim();
|
|
125
|
+
|
|
126
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
127
|
+
const parsed = absoluteHttpUrl(trimmed);
|
|
128
|
+
if (!parsed || parsed.origin !== origin) return null;
|
|
129
|
+
|
|
130
|
+
return parsed.origin + parsed.pathname + parsed.search;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const path = sitePath(trimmed);
|
|
134
|
+
|
|
135
|
+
return path && base ? base + path : null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function normalizeRobots(value) {
|
|
139
|
+
if (typeof value !== "string") return null;
|
|
140
|
+
|
|
141
|
+
const kept = [];
|
|
142
|
+
for (const token of value.split(",")) {
|
|
143
|
+
const normalized = token.trim().toLowerCase();
|
|
144
|
+
if (ROBOTS_TOKENS.includes(normalized) && !kept.includes(normalized)) kept.push(normalized);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return kept.length ? kept.join(", ") : null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* `JSON.stringify` the structured data and replace every `<` so the result can sit inside a
|
|
152
|
+
* `<script>` element without ever containing `</script>`.
|
|
153
|
+
* @returns {string | null}
|
|
154
|
+
*/
|
|
155
|
+
function serializeJsonLd(value) {
|
|
156
|
+
const valid = Array.isArray(value)
|
|
157
|
+
? value.length > 0 && value.every(isRecord)
|
|
158
|
+
: isRecord(value);
|
|
159
|
+
if (!valid) return null;
|
|
160
|
+
|
|
161
|
+
let json;
|
|
162
|
+
try {
|
|
163
|
+
json = JSON.stringify(value);
|
|
164
|
+
} catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
if (typeof json !== "string") return null;
|
|
168
|
+
|
|
169
|
+
json = json.replace(/</g, "\\u003c");
|
|
170
|
+
|
|
171
|
+
return json.length > MAX_JSON_LD ? null : json;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @param {unknown} meta the `meta` object a load() returned (anything else is treated as `{}`)
|
|
176
|
+
* @param {{ siteInfo?: object, url?: URL | { origin?: string, pathname?: string }, title?: string }} context
|
|
177
|
+
* @returns {{
|
|
178
|
+
* description: string | null, ogTitle: string | null, ogDescription: string | null,
|
|
179
|
+
* ogType: string, ogUrl: string | null, ogImage: string | null, ogImageAlt: string | null,
|
|
180
|
+
* siteName: string | null, twitterCard: string, canonical: string | null, robots: string | null,
|
|
181
|
+
* referrer: string | null, jsonLd: string | null
|
|
182
|
+
* }}
|
|
183
|
+
*/
|
|
184
|
+
export function normalizePageMeta(meta, { siteInfo, url, title } = {}) {
|
|
185
|
+
const input = isRecord(meta) ? meta : {};
|
|
186
|
+
const { base, origin } = siteBase(siteInfo, url);
|
|
187
|
+
|
|
188
|
+
const siteDescription = text(siteInfo?.websiteDescription, Infinity);
|
|
189
|
+
const description = text(input.description, MAX_DESCRIPTION) ?? siteDescription;
|
|
190
|
+
const siteName = text(siteInfo?.websiteName, Infinity);
|
|
191
|
+
|
|
192
|
+
const ogTitle = text(input.title, Infinity) ?? text(title, Infinity) ?? siteName;
|
|
193
|
+
const canonical = normalizeCanonical(input.canonical, base, origin);
|
|
194
|
+
const pathname = typeof url?.pathname === "string" ? url.pathname : "";
|
|
195
|
+
const ogImage = normalizeImage(input.image, base);
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
description,
|
|
199
|
+
ogTitle,
|
|
200
|
+
ogDescription: description,
|
|
201
|
+
ogType: OG_TYPES.includes(input.type) ? input.type : "website",
|
|
202
|
+
ogUrl: canonical ?? (base ? base + pathname : null),
|
|
203
|
+
ogImage,
|
|
204
|
+
ogImageAlt: ogImage ? text(input.imageAlt, MAX_IMAGE_ALT) : null,
|
|
205
|
+
siteName,
|
|
206
|
+
twitterCard: ogImage ? "summary_large_image" : "summary",
|
|
207
|
+
canonical,
|
|
208
|
+
robots: normalizeRobots(input.robots),
|
|
209
|
+
referrer: REFERRER_POLICIES.includes(input.referrer) ? input.referrer : null,
|
|
210
|
+
jsonLd: serializeJsonLd(input.jsonLd),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The one list shape of the public API (doc 04 section 4): `{ items, page: { number, size, totalItems, totalPages } }`
|
|
2
|
+
// plus extra top-level keys. The services below turn it into the page data the views have always read
|
|
3
|
+
// (`posts` + `postCount`, `tickets` + `ticketCount`, a numeric `page`, `totalPages`).
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {{ number: number, size: number, totalItems: number, totalPages: number }} PageInfo
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Splits a list body into its items, page numbers and the extra keys; an error body comes back untouched.
|
|
11
|
+
* @param {any} body answer of a list endpoint
|
|
12
|
+
* @returns {{ failed: true, body: any } | { failed: false, items: any[], count: number, number: number, totalPages: number, rest: Record<string, any> }}
|
|
13
|
+
*/
|
|
14
|
+
export function readPage(body) {
|
|
15
|
+
if (!body || body.error) {
|
|
16
|
+
return { failed: true, body };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { items, page, ...rest } = body;
|
|
20
|
+
const info = /** @type {Partial<PageInfo>} */ (page && typeof page === "object" ? page : {});
|
|
21
|
+
const list = Array.isArray(items) ? items : [];
|
|
22
|
+
const count = info.totalItems ?? list.length;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
failed: false,
|
|
26
|
+
items: list,
|
|
27
|
+
count,
|
|
28
|
+
number: info.number ?? 1,
|
|
29
|
+
// an empty list still has one (empty) page to show, as it always had
|
|
30
|
+
totalPages: Math.max(1, info.totalPages ?? 1),
|
|
31
|
+
rest,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Pure helper for the `pageTitle` a load() may return (spec 15 section 4.4).
|
|
2
|
+
//
|
|
3
|
+
// Forms: a string (i18n key), or an object { title, titleValues, subtitle, subtitleValues, html,
|
|
4
|
+
// subtitleHtml, raw, hidden }. `raw` uses title / subtitle verbatim (no translation); `hidden`
|
|
5
|
+
// keeps the value for the document <title> only (no visible <PageTitle>).
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {unknown} pt the pageTitle value (null, a string or an object)
|
|
9
|
+
* @param {(key: string, options?: { values?: object }) => string} translate
|
|
10
|
+
* @returns {{ title: string, subtitle: string, hidden: boolean }}
|
|
11
|
+
*/
|
|
12
|
+
export function resolvePageTitle(pt, translate) {
|
|
13
|
+
if (typeof pt === "string") {
|
|
14
|
+
return { title: pt ? translate(pt) : "", subtitle: "", hidden: false };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!pt || typeof pt !== "object") return { title: "", subtitle: "", hidden: false };
|
|
18
|
+
|
|
19
|
+
const raw = pt.raw === true;
|
|
20
|
+
const resolve = (value, values) => {
|
|
21
|
+
if (!value) return "";
|
|
22
|
+
if (raw) return String(value);
|
|
23
|
+
|
|
24
|
+
return translate(value, { values: values || {} });
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
title: resolve(pt.title, pt.titleValues),
|
|
29
|
+
subtitle: resolve(pt.subtitle, pt.subtitleValues),
|
|
30
|
+
hidden: pt.hidden === true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
<script context="module">
|
|
11
11
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/ActiveEmailPageLogics.js";
|
|
12
|
-
import {
|
|
12
|
+
import { loadView } from "$pano/registry/index.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -18,14 +18,9 @@
|
|
|
18
18
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
19
19
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
20
20
|
// view instead of an await-pending branch.
|
|
21
|
-
const viewPromise = resolveView(
|
|
22
|
-
"ActivateEmailView",
|
|
23
|
-
() => import("../views/ActivateEmailView.svelte"),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
21
|
const loadData = await processLoad(event);
|
|
27
22
|
|
|
28
|
-
return { ...loadData,
|
|
23
|
+
return { ...loadData, ...(await loadView(event, "ActivateEmailView", () => import("../views/ActivateEmailView.svelte"))) };
|
|
29
24
|
}
|
|
30
25
|
</script>
|
|
31
26
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
<script context="module">
|
|
11
11
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/ConfirmNewEmailPageLogics";
|
|
12
|
-
import {
|
|
12
|
+
import { loadView } from "$pano/registry/index.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -18,14 +18,9 @@
|
|
|
18
18
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
19
19
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
20
20
|
// view instead of an await-pending branch.
|
|
21
|
-
const viewPromise = resolveView(
|
|
22
|
-
"ConfirmNewEmailView",
|
|
23
|
-
() => import("../views/ConfirmNewEmailView.svelte"),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
21
|
const loadData = await processLoad(event);
|
|
27
22
|
|
|
28
|
-
return { ...loadData,
|
|
23
|
+
return { ...loadData, ...(await loadView(event, "ConfirmNewEmailView", () => import("../views/ConfirmNewEmailView.svelte"))) };
|
|
29
24
|
}
|
|
30
25
|
</script>
|
|
31
26
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<svelte:component this={data?.View ?? View} {data} {page} />
|
|
2
2
|
|
|
3
3
|
<script context="module">
|
|
4
|
-
import { resolveView } from "$pano/registry/index.js";
|
|
4
|
+
import { loadView, resolveView } from "$pano/registry/index.js";
|
|
5
5
|
|
|
6
6
|
// This page is wired as +error.svelte by the shim, and SvelteKit never runs
|
|
7
7
|
// a load function for error pages — so unlike other controllers the view
|
|
@@ -27,7 +27,10 @@
|
|
|
27
27
|
export async function load(event) {
|
|
28
28
|
const parentData = await event.parent();
|
|
29
29
|
|
|
30
|
-
return {
|
|
30
|
+
return {
|
|
31
|
+
...parentData,
|
|
32
|
+
...(await loadView(event, "ErrorView", () => import("../views/ErrorView.svelte")))
|
|
33
|
+
};
|
|
31
34
|
}
|
|
32
35
|
</script>
|
|
33
36
|
|
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
{#if data.homeKind === "page"}
|
|
2
|
+
<svelte:component this={data.HomeComponent} {data} />
|
|
3
|
+
{:else if data.homeKind === "path"}
|
|
4
|
+
<Page {data} />
|
|
5
|
+
{:else}
|
|
6
|
+
<svelte:component this={data.View} {data} {themeSettings} {onPageClick} />
|
|
7
|
+
{/if}
|
|
2
8
|
|
|
3
9
|
<script context="module">
|
|
4
10
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/HomePageLogics";
|
|
5
|
-
import {
|
|
11
|
+
import { loadView } from "$pano/registry/index.js";
|
|
12
|
+
import { registeredPages, findMatch } from "$pano/lib/PluginManager.js";
|
|
13
|
+
import { hasPermission } from "$pano/lib/auth.util.js";
|
|
14
|
+
import { resolveHomeFor } from "$pano/lib/home.js";
|
|
15
|
+
import { loadHomeTarget } from "$pano/routes/plugin-ui/load.js";
|
|
16
|
+
import Page, { sidebarDeps } from "$pano/routes/plugin-ui/Page.svelte";
|
|
6
17
|
|
|
7
18
|
/**
|
|
19
|
+
* `/` shows what the admin picked as the home page (the posts feed unless a plugin page or a page of the
|
|
20
|
+
* theme was picked); `/posts` is the same controller and always shows the feed (doc 01 section 9).
|
|
8
21
|
* @type {import('@sveltejs/kit').PageLoad}
|
|
9
22
|
*/
|
|
10
23
|
export async function load(event) {
|
|
24
|
+
const home = await resolveHomeFor(event, () => registeredPages);
|
|
25
|
+
|
|
26
|
+
if (home.kind === "page" || home.kind === "path") {
|
|
27
|
+
const target = await loadHomeTarget(event, home, {
|
|
28
|
+
sidebar: sidebarDeps,
|
|
29
|
+
hasPermission,
|
|
30
|
+
findPage: (path) => findMatch(registeredPages, path),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// null: the page cannot be shown to this visitor, the feed is shown instead
|
|
34
|
+
if (target) {
|
|
35
|
+
return target;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
11
39
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
12
40
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
13
41
|
// view instead of an await-pending branch.
|
|
14
|
-
const viewPromise = resolveView(
|
|
15
|
-
"HomeView",
|
|
16
|
-
() => import("../views/HomeView.svelte"),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
42
|
const data = await processLoad(event);
|
|
20
43
|
|
|
21
|
-
return { ...data,
|
|
44
|
+
return { ...data, ...(await loadView(event, "HomeView", () => import("../views/HomeView.svelte"))) };
|
|
22
45
|
}
|
|
23
46
|
</script>
|
|
24
47
|
|
|
@@ -28,17 +28,12 @@
|
|
|
28
28
|
|
|
29
29
|
<script context="module">
|
|
30
30
|
import { executeLifecycle, executeViewLoad, panoApiServer } from "$pano/lib/PluginAPI";
|
|
31
|
-
import {
|
|
31
|
+
import { loadView } from "$pano/registry/index.js";
|
|
32
32
|
|
|
33
33
|
export async function load(event) {
|
|
34
34
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
35
35
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
36
36
|
// view instead of an await-pending branch.
|
|
37
|
-
const viewPromise = resolveView(
|
|
38
|
-
"LoginView",
|
|
39
|
-
() => import("../views/LoginView.svelte"),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
37
|
const { parent } = event;
|
|
43
38
|
await parent();
|
|
44
39
|
|
|
@@ -52,17 +47,18 @@
|
|
|
52
47
|
await executeViewLoad("login-content", event);
|
|
53
48
|
await executeViewLoad("login-alt-methods", event);
|
|
54
49
|
|
|
55
|
-
return { initialError: lifecycleData.error || null, pageTitle: "components.modals.login.title",
|
|
50
|
+
return { initialError: lifecycleData.error || null, pageTitle: "components.modals.login.title", ...(await loadView(event, "LoginView", () => import("../views/LoginView.svelte"))) };
|
|
56
51
|
}
|
|
57
52
|
</script>
|
|
58
53
|
|
|
59
54
|
<script>
|
|
60
55
|
import { getContext, onMount } from "svelte";
|
|
61
|
-
import { writable } from "svelte/store";
|
|
56
|
+
import { get, writable } from "svelte/store";
|
|
62
57
|
import { format } from "date-fns";
|
|
63
58
|
import * as locales from "date-fns/locale";
|
|
64
59
|
|
|
65
60
|
import { afterNavigate, goto } from "$app/navigation";
|
|
61
|
+
import { page } from "$app/stores";
|
|
66
62
|
|
|
67
63
|
import { NETWORK_ERROR } from "$pano/lib/api.util";
|
|
68
64
|
import { currentLanguage } from "$pano/lib/language.util";
|
|
@@ -72,6 +68,7 @@
|
|
|
72
68
|
|
|
73
69
|
import { stripIdentifierWhitespace } from "$pano/lib/loginInput.util.js";
|
|
74
70
|
import { panoApiClient } from "$pano/lib/PluginAPI.js";
|
|
71
|
+
import { returnToFromUrl } from "$pano/lib/returnTo.util.js";
|
|
75
72
|
|
|
76
73
|
export let data;
|
|
77
74
|
|
|
@@ -163,7 +160,7 @@
|
|
|
163
160
|
|
|
164
161
|
try {
|
|
165
162
|
const body = await verifyLinkCode($usernameOrEmail, $linkCode);
|
|
166
|
-
if (body.
|
|
163
|
+
if (!body.error) {
|
|
167
164
|
registerToken = body.token;
|
|
168
165
|
// Assuming backend returns username associated with code
|
|
169
166
|
if (body.username) {
|
|
@@ -171,10 +168,10 @@
|
|
|
171
168
|
}
|
|
172
169
|
$viewState = "REGISTER";
|
|
173
170
|
} else {
|
|
174
|
-
if (body.error === "PLUGIN_DENIED_LOGIN" && body.reason) {
|
|
175
|
-
$error = body.reason;
|
|
171
|
+
if (body.error.code === "PLUGIN_DENIED_LOGIN" && body.error.details?.reason) {
|
|
172
|
+
$error = body.error.details.reason;
|
|
176
173
|
} else {
|
|
177
|
-
$error = body.
|
|
174
|
+
$error = body.error.code || NETWORK_ERROR;
|
|
178
175
|
}
|
|
179
176
|
}
|
|
180
177
|
} catch (err) {
|
|
@@ -201,8 +198,8 @@
|
|
|
201
198
|
agreement: $agreement,
|
|
202
199
|
});
|
|
203
200
|
|
|
204
|
-
if (body.
|
|
205
|
-
if (body.error === "INVALID_TOKEN") {
|
|
201
|
+
if (body.error) {
|
|
202
|
+
if (body.error.code === "INVALID_TOKEN") {
|
|
206
203
|
$viewState = "LOGIN";
|
|
207
204
|
$error = null;
|
|
208
205
|
$autoVerifyDone = false;
|
|
@@ -210,7 +207,7 @@
|
|
|
210
207
|
$loading = false;
|
|
211
208
|
return;
|
|
212
209
|
}
|
|
213
|
-
$error = body.
|
|
210
|
+
$error = body.error.code || NETWORK_ERROR;
|
|
214
211
|
$loading = false;
|
|
215
212
|
return;
|
|
216
213
|
}
|
|
@@ -233,7 +230,7 @@
|
|
|
233
230
|
});
|
|
234
231
|
|
|
235
232
|
await showSuccessToast("successes.LOGIN_SUCCESSFUL");
|
|
236
|
-
await goto(
|
|
233
|
+
await goto(returnToFromUrl(get(page).url));
|
|
237
234
|
return;
|
|
238
235
|
}
|
|
239
236
|
|
|
@@ -250,8 +247,8 @@
|
|
|
250
247
|
await showSuccessToast("successes.REGISTER_SUCCESSFUL");
|
|
251
248
|
|
|
252
249
|
const loginBody = await sendLogin({ usernameOrEmail: $usernameOrEmail, password: $password });
|
|
253
|
-
if (loginBody.
|
|
254
|
-
$error = loginBody.error;
|
|
250
|
+
if (loginBody.error) {
|
|
251
|
+
$error = loginBody.error.code;
|
|
255
252
|
$loading = false;
|
|
256
253
|
return;
|
|
257
254
|
}
|
|
@@ -272,7 +269,7 @@
|
|
|
272
269
|
return data;
|
|
273
270
|
});
|
|
274
271
|
|
|
275
|
-
await goto(
|
|
272
|
+
await goto(returnToFromUrl(get(page).url));
|
|
276
273
|
|
|
277
274
|
} catch (err) {
|
|
278
275
|
console.error(err);
|
|
@@ -293,9 +290,12 @@
|
|
|
293
290
|
newUsername: $viewState === "SET_USERNAME" ? $newUsername : undefined
|
|
294
291
|
})
|
|
295
292
|
.then(async (body) => {
|
|
296
|
-
if (body.
|
|
293
|
+
if (body.error) {
|
|
297
294
|
$loading = false;
|
|
298
|
-
|
|
295
|
+
const errorCode = body.error.code;
|
|
296
|
+
const errorDetails = body.error.details ?? {};
|
|
297
|
+
|
|
298
|
+
if (errorCode === "LINK_CODE_REQUIRED") {
|
|
299
299
|
$viewState = "LINK_CODE";
|
|
300
300
|
$passwordVisible = false;
|
|
301
301
|
$password = "";
|
|
@@ -303,17 +303,17 @@
|
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
if (
|
|
306
|
+
if (errorCode === "LOGIN_EMAIL_NOT_VERIFIED") {
|
|
307
307
|
if ($emailRequired) {
|
|
308
308
|
$emailVerificationSent = true;
|
|
309
309
|
$error = null;
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
|
-
$error = { key: "LOGIN_EMAIL_NOT_VERIFIED", props: { email:
|
|
312
|
+
$error = { key: "LOGIN_EMAIL_NOT_VERIFIED", props: { email: errorDetails.email } };
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
if (
|
|
316
|
+
if (errorCode === "REGISTER_EMAIL_REQUIRED") {
|
|
317
317
|
$emailRequired = true;
|
|
318
318
|
$passwordVisible = true;
|
|
319
319
|
if ($session?.siteInfo?.isDemo && $usernameOrEmail === "demo") {
|
|
@@ -324,15 +324,15 @@
|
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
if (
|
|
328
|
-
$usernameRequiredUserId =
|
|
327
|
+
if (errorCode === "USERNAME_REQUIRED") {
|
|
328
|
+
$usernameRequiredUserId = errorDetails.userId;
|
|
329
329
|
$viewState = "SET_USERNAME";
|
|
330
330
|
$error = null;
|
|
331
331
|
setTimeout(() => document.getElementById("newUsername")?.focus(), 50);
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
if (
|
|
335
|
+
if (errorCode === "LOGIN_IS_INVALID" && !$passwordVisible) {
|
|
336
336
|
$passwordVisible = true;
|
|
337
337
|
if ($session?.siteInfo?.isDemo && $usernameOrEmail === "demo") {
|
|
338
338
|
$password = "123456";
|
|
@@ -342,28 +342,25 @@
|
|
|
342
342
|
return;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
if (
|
|
346
|
-
$error =
|
|
345
|
+
if (errorCode === "PLUGIN_DENIED_LOGIN" && errorDetails.reason) {
|
|
346
|
+
$error = errorDetails.reason;
|
|
347
347
|
return;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
$error =
|
|
350
|
+
$error = errorCode || NETWORK_ERROR;
|
|
351
351
|
|
|
352
|
-
if (
|
|
353
|
-
|
|
354
|
-
body.error === "LOGIN_USER_IS_BANNED"
|
|
355
|
-
) {
|
|
356
|
-
if (!body.until) {
|
|
352
|
+
if (errorCode === "LOGIN_USER_IS_BANNED") {
|
|
353
|
+
if (!errorDetails.until) {
|
|
357
354
|
$error = { key: "LOGIN_USER_IS_BANNED_PERMANENTLY" };
|
|
358
|
-
if (
|
|
355
|
+
if (errorDetails.reason) {
|
|
359
356
|
$error = {
|
|
360
357
|
key: "LOGIN_USER_IS_BANNED_PERMANENTLY_WITH_REASON",
|
|
361
|
-
props: { reason: `'${
|
|
358
|
+
props: { reason: `'${errorDetails.reason}'` }
|
|
362
359
|
};
|
|
363
360
|
}
|
|
364
361
|
} else {
|
|
365
362
|
const formattedUntil = format(
|
|
366
|
-
new Date(
|
|
363
|
+
new Date(errorDetails.until),
|
|
367
364
|
"dd/MM/yyyy HH:mm",
|
|
368
365
|
{
|
|
369
366
|
locale: locales[$currentLanguage.dateFnsCode]
|
|
@@ -375,11 +372,11 @@
|
|
|
375
372
|
props: { untilTime: formattedUntil }
|
|
376
373
|
};
|
|
377
374
|
|
|
378
|
-
if (
|
|
375
|
+
if (errorDetails.reason) {
|
|
379
376
|
$error = {
|
|
380
377
|
key: "LOGIN_USER_IS_BANNED_TEMPORARY_WITH_REASON",
|
|
381
378
|
props: {
|
|
382
|
-
reason: `'${
|
|
379
|
+
reason: `'${errorDetails.reason}'`,
|
|
383
380
|
untilTime: formattedUntil
|
|
384
381
|
}
|
|
385
382
|
};
|
|
@@ -410,7 +407,7 @@
|
|
|
410
407
|
|
|
411
408
|
await showSuccessToast("successes.LOGIN_SUCCESSFUL");
|
|
412
409
|
|
|
413
|
-
await goto(
|
|
410
|
+
await goto(returnToFromUrl(get(page).url));
|
|
414
411
|
|
|
415
412
|
$loading = false;
|
|
416
413
|
});
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
<script context="module">
|
|
19
19
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/NotificationsPageLogics";
|
|
20
|
-
import {
|
|
20
|
+
import { loadView } from "$pano/registry/index.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @type {import('@sveltejs/kit').PageLoad}
|
|
@@ -26,14 +26,9 @@
|
|
|
26
26
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
27
27
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
28
28
|
// view instead of an await-pending branch.
|
|
29
|
-
const viewPromise = resolveView(
|
|
30
|
-
"NotificationsView",
|
|
31
|
-
() => import("../views/NotificationsView.svelte"),
|
|
32
|
-
);
|
|
33
|
-
|
|
34
29
|
const loadData = await processLoad(event);
|
|
35
30
|
|
|
36
|
-
return { ...loadData,
|
|
31
|
+
return { ...loadData, ...(await loadView(event, "NotificationsView", () => import("../views/NotificationsView.svelte"))) };
|
|
37
32
|
}
|
|
38
33
|
</script>
|
|
39
34
|
|