@panomc/theme-core 1.0.0-dev.60 → 1.0.0-dev.62
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 +8 -9
- 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 +79 -21
- package/src/kit/route-map.js +300 -0
- package/src/kit/specifiers.js +3 -62
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<script context="module">
|
|
4
4
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/PlayerDetailPageLogics";
|
|
5
|
-
import {
|
|
5
|
+
import { loadView } from "$pano/registry/index.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -11,14 +11,9 @@
|
|
|
11
11
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
12
12
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
13
13
|
// view instead of an await-pending branch.
|
|
14
|
-
const viewPromise = resolveView(
|
|
15
|
-
"PlayerDetailView",
|
|
16
|
-
() => import("../views/PlayerDetailView.svelte"),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
14
|
const loadData = await processLoad(event);
|
|
20
15
|
|
|
21
|
-
return { ...loadData,
|
|
16
|
+
return { ...loadData, ...(await loadView(event, "PlayerDetailView", () => import("../views/PlayerDetailView.svelte"))) };
|
|
22
17
|
}
|
|
23
18
|
</script>
|
|
24
19
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<script context="module">
|
|
4
4
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/PostDetailPageLogics";
|
|
5
|
-
import {
|
|
5
|
+
import { loadView } from "$pano/registry/index.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -11,14 +11,9 @@
|
|
|
11
11
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
12
12
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
13
13
|
// view instead of an await-pending branch.
|
|
14
|
-
const viewPromise = resolveView(
|
|
15
|
-
"PostDetailView",
|
|
16
|
-
() => import("../views/PostDetailView.svelte"),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
14
|
const data = await processLoad(event);
|
|
20
15
|
|
|
21
|
-
return { ...data,
|
|
16
|
+
return { ...data, ...(await loadView(event, "PostDetailView", () => import("../views/PostDetailView.svelte"))) };
|
|
22
17
|
}
|
|
23
18
|
</script>
|
|
24
19
|
|
|
@@ -10,20 +10,15 @@
|
|
|
10
10
|
* @type {import("@sveltejs/kit").Load}
|
|
11
11
|
*/
|
|
12
12
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/PreviewPostPageLogics";
|
|
13
|
-
import {
|
|
13
|
+
import { loadView } from "$pano/registry/index.js";
|
|
14
14
|
|
|
15
15
|
export async function load(event) {
|
|
16
16
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
17
17
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
18
18
|
// view instead of an await-pending branch.
|
|
19
|
-
const viewPromise = resolveView(
|
|
20
|
-
"PreviewPostView",
|
|
21
|
-
() => import("../views/PreviewPostView.svelte"),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
19
|
const loadData = await processLoad(event);
|
|
25
20
|
|
|
26
|
-
return { ...loadData,
|
|
21
|
+
return { ...loadData, ...(await loadView(event, "PreviewPostView", () => import("../views/PreviewPostView.svelte"))) };
|
|
27
22
|
}
|
|
28
23
|
</script>
|
|
29
24
|
|
|
@@ -15,17 +15,12 @@
|
|
|
15
15
|
|
|
16
16
|
<script context="module">
|
|
17
17
|
import { executeLifecycle, executeViewLoad, panoApiServer } from "$pano/lib/PluginAPI";
|
|
18
|
-
import {
|
|
18
|
+
import { loadView } from "$pano/registry/index.js";
|
|
19
19
|
|
|
20
20
|
export async function load(event) {
|
|
21
21
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
22
22
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
23
23
|
// view instead of an await-pending branch.
|
|
24
|
-
const viewPromise = resolveView(
|
|
25
|
-
"RegisterView",
|
|
26
|
-
() => import("../views/RegisterView.svelte"),
|
|
27
|
-
);
|
|
28
|
-
|
|
29
24
|
const { parent } = event;
|
|
30
25
|
await parent();
|
|
31
26
|
|
|
@@ -43,15 +38,16 @@
|
|
|
43
38
|
initialError: lifecycleData.error || null,
|
|
44
39
|
initialUsername: lifecycleData.username || null,
|
|
45
40
|
pageTitle: "components.modals.register.title",
|
|
46
|
-
|
|
41
|
+
...(await loadView(event, "RegisterView", () => import("../views/RegisterView.svelte")))
|
|
47
42
|
};
|
|
48
43
|
}
|
|
49
44
|
</script>
|
|
50
45
|
|
|
51
46
|
<script>
|
|
52
47
|
import { getContext, onMount } from "svelte";
|
|
53
|
-
import { writable } from "svelte/store";
|
|
48
|
+
import { get, writable } from "svelte/store";
|
|
54
49
|
import { goto } from "$app/navigation";
|
|
50
|
+
import { page } from "$app/stores";
|
|
55
51
|
|
|
56
52
|
import { NETWORK_ERROR } from "$pano/lib/api.util";
|
|
57
53
|
|
|
@@ -60,6 +56,7 @@
|
|
|
60
56
|
|
|
61
57
|
import { sendRegister, getCredentials } from "$pano/lib/services/auth.js";
|
|
62
58
|
import { panoApiClient } from "$pano/lib/PluginAPI.js";
|
|
59
|
+
import { returnToFromUrl } from "$pano/lib/returnTo.util.js";
|
|
63
60
|
|
|
64
61
|
export let data;
|
|
65
62
|
|
|
@@ -97,7 +94,7 @@
|
|
|
97
94
|
recaptcha: "",
|
|
98
95
|
})
|
|
99
96
|
.then(async (body) => {
|
|
100
|
-
if (body.
|
|
97
|
+
if (!body.error) {
|
|
101
98
|
if (body.login) {
|
|
102
99
|
const csrfToken = body.csrfToken;
|
|
103
100
|
const credsBody = await getCredentials(csrfToken);
|
|
@@ -116,7 +113,7 @@
|
|
|
116
113
|
});
|
|
117
114
|
|
|
118
115
|
await showSuccessToast("successes.LOGIN_SUCCESSFUL");
|
|
119
|
-
await goto(
|
|
116
|
+
await goto(returnToFromUrl(get(page).url));
|
|
120
117
|
loading.set(false);
|
|
121
118
|
return;
|
|
122
119
|
}
|
|
@@ -124,10 +121,10 @@
|
|
|
124
121
|
successMessage.set("REGISTER_SUCCESSFUL");
|
|
125
122
|
loading.set(false);
|
|
126
123
|
} else {
|
|
127
|
-
if (body.error === "PLUGIN_DENIED_LOGIN" && body.reason) {
|
|
128
|
-
error.set(body.reason);
|
|
124
|
+
if (body.error.code === "PLUGIN_DENIED_LOGIN" && body.error.details?.reason) {
|
|
125
|
+
error.set(body.error.details.reason);
|
|
129
126
|
} else {
|
|
130
|
-
error.set(body.
|
|
127
|
+
error.set(body.error.code || NETWORK_ERROR);
|
|
131
128
|
}
|
|
132
129
|
loading.set(false);
|
|
133
130
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
<script context="module">
|
|
13
13
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/RenewPasswordPageLogics";
|
|
14
|
-
import {
|
|
14
|
+
import { loadView } from "$pano/registry/index.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @type {import('@sveltejs/kit').PageLoad}
|
|
@@ -20,14 +20,9 @@
|
|
|
20
20
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
21
21
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
22
22
|
// view instead of an await-pending branch.
|
|
23
|
-
const viewPromise = resolveView(
|
|
24
|
-
"RenewPasswordView",
|
|
25
|
-
() => import("../views/RenewPasswordView.svelte"),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
23
|
const loadData = await processLoad(event);
|
|
29
24
|
|
|
30
|
-
return { ...loadData,
|
|
25
|
+
return { ...loadData, ...(await loadView(event, "RenewPasswordView", () => import("../views/RenewPasswordView.svelte"))) };
|
|
31
26
|
}
|
|
32
27
|
</script>
|
|
33
28
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
<script context="module">
|
|
13
13
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/ResetPasswordPageLogics";
|
|
14
|
-
import {
|
|
14
|
+
import { loadView } from "$pano/registry/index.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @type {import('@sveltejs/kit').LayoutLoad}
|
|
@@ -20,14 +20,9 @@
|
|
|
20
20
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
21
21
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
22
22
|
// view instead of an await-pending branch.
|
|
23
|
-
const viewPromise = resolveView(
|
|
24
|
-
"ResetPasswordView",
|
|
25
|
-
() => import("../views/ResetPasswordView.svelte"),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
23
|
const loadData = await processLoad(event);
|
|
29
24
|
|
|
30
|
-
return { ...loadData,
|
|
25
|
+
return { ...loadData, ...(await loadView(event, "ResetPasswordView", () => import("../views/ResetPasswordView.svelte"))) };
|
|
31
26
|
}
|
|
32
27
|
</script>
|
|
33
28
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { error } from "@sveltejs/kit";
|
|
5
5
|
|
|
6
6
|
import ApiUtil from "$pano/lib/api.util";
|
|
7
|
-
import {
|
|
7
|
+
import { loadView } from "$pano/registry/index.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @type {import("@sveltejs/kit").PageLoad}
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
14
14
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
15
15
|
// view instead of an await-pending branch.
|
|
16
|
-
const viewPromise = resolveView(
|
|
17
|
-
"RulesView",
|
|
18
|
-
() => import("../views/RulesView.svelte"),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
16
|
const parentData = await event.parent();
|
|
22
17
|
const session = parentData.session;
|
|
23
18
|
|
|
@@ -29,7 +24,7 @@
|
|
|
29
24
|
let registerAgreement;
|
|
30
25
|
try {
|
|
31
26
|
const body = await ApiUtil.get({
|
|
32
|
-
path: "/
|
|
27
|
+
path: "/register-agreement",
|
|
33
28
|
request: event,
|
|
34
29
|
csrfToken
|
|
35
30
|
});
|
|
@@ -42,7 +37,7 @@
|
|
|
42
37
|
...parentData,
|
|
43
38
|
pageTitle: "pages.rules.title",
|
|
44
39
|
registerAgreement,
|
|
45
|
-
|
|
40
|
+
...(await loadView(event, "RulesView", () => import("../views/RulesView.svelte")))
|
|
46
41
|
};
|
|
47
42
|
}
|
|
48
43
|
</script>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<script context="module">
|
|
4
4
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/SupportPageLogics";
|
|
5
|
-
import {
|
|
5
|
+
import { loadView } from "$pano/registry/index.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -11,14 +11,9 @@
|
|
|
11
11
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
12
12
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
13
13
|
// view instead of an await-pending branch.
|
|
14
|
-
const viewPromise = resolveView(
|
|
15
|
-
"SupportView",
|
|
16
|
-
() => import("../views/SupportView.svelte"),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
14
|
const loadData = await processLoad(event);
|
|
20
15
|
|
|
21
|
-
return { ...loadData,
|
|
16
|
+
return { ...loadData, ...(await loadView(event, "SupportView", () => import("../views/SupportView.svelte"))) };
|
|
22
17
|
}
|
|
23
18
|
</script>
|
|
24
19
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
<script context="module">
|
|
40
40
|
import { writable } from "svelte/store";
|
|
41
|
-
import {
|
|
41
|
+
import { loadView } from "$pano/registry/index.js";
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* @type {import("@sveltejs/kit").Load}
|
|
@@ -47,15 +47,10 @@
|
|
|
47
47
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
48
48
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
49
49
|
// view instead of an await-pending branch.
|
|
50
|
-
const viewPromise = resolveView(
|
|
51
|
-
"ThemeSettingsView",
|
|
52
|
-
() => import("../views/ThemeSettingsView.svelte"),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
50
|
const { parent } = event;
|
|
56
51
|
|
|
57
52
|
const { themeSettings } = await parent();
|
|
58
|
-
return { themeSettings,
|
|
53
|
+
return { themeSettings, ...(await loadView(event, "ThemeSettingsView", () => import("../views/ThemeSettingsView.svelte"))) };
|
|
59
54
|
}
|
|
60
55
|
</script>
|
|
61
56
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<script context="module">
|
|
4
4
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/ProfilePageLogics";
|
|
5
|
-
import {
|
|
5
|
+
import { loadView } from "$pano/registry/index.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -11,14 +11,9 @@
|
|
|
11
11
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
12
12
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
13
13
|
// view instead of an await-pending branch.
|
|
14
|
-
const viewPromise = resolveView(
|
|
15
|
-
"ProfileView",
|
|
16
|
-
() => import("../../views/ProfileView.svelte"),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
14
|
const loadData = await processLoad(event);
|
|
20
15
|
|
|
21
|
-
return { ...loadData,
|
|
16
|
+
return { ...loadData, ...(await loadView(event, "ProfileView", () => import("../../views/ProfileView.svelte"))) };
|
|
22
17
|
}
|
|
23
18
|
</script>
|
|
24
19
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
<script context="module">
|
|
38
38
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/SettingsPageLogics";
|
|
39
|
-
import {
|
|
39
|
+
import { loadView } from "$pano/registry/index.js";
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -45,14 +45,9 @@
|
|
|
45
45
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
46
46
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
47
47
|
// view instead of an await-pending branch.
|
|
48
|
-
const viewPromise = resolveView(
|
|
49
|
-
"SettingsView",
|
|
50
|
-
() => import("../../views/SettingsView.svelte"),
|
|
51
|
-
);
|
|
52
|
-
|
|
53
48
|
const loadData = await processLoad(event);
|
|
54
49
|
|
|
55
|
-
return { ...loadData,
|
|
50
|
+
return { ...loadData, ...(await loadView(event, "SettingsView", () => import("../../views/SettingsView.svelte"))) };
|
|
56
51
|
}
|
|
57
52
|
</script>
|
|
58
53
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
<script context="module">
|
|
11
11
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/TicketsPageLogics";
|
|
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
|
-
"TicketsView",
|
|
23
|
-
() => import("../../views/TicketsView.svelte"),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
21
|
const loadData = await processLoad(event);
|
|
27
22
|
|
|
28
|
-
return { ...loadData,
|
|
23
|
+
return { ...loadData, ...(await loadView(event, "TicketsView", () => import("../../views/TicketsView.svelte"))) };
|
|
29
24
|
}
|
|
30
25
|
</script>
|
|
31
26
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
<script context="module">
|
|
12
12
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/CreateTicketPageLogics.js";
|
|
13
|
-
import {
|
|
13
|
+
import { loadView } from "$pano/registry/index.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -19,14 +19,9 @@
|
|
|
19
19
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
20
20
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
21
21
|
// view instead of an await-pending branch.
|
|
22
|
-
const viewPromise = resolveView(
|
|
23
|
-
"CreateTicketView",
|
|
24
|
-
() => import("../../views/CreateTicketView.svelte"),
|
|
25
|
-
);
|
|
26
|
-
|
|
27
22
|
const result = await processLoad(event);
|
|
28
23
|
|
|
29
|
-
return { ...result,
|
|
24
|
+
return { ...result, ...(await loadView(event, "CreateTicketView", () => import("../../views/CreateTicketView.svelte"))) };
|
|
30
25
|
}
|
|
31
26
|
</script>
|
|
32
27
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<script context="module">
|
|
17
17
|
import { processLoad } from "$pano/lib/ui-logics/page-logics/TicketDetailPageLogics.js";
|
|
18
|
-
import {
|
|
18
|
+
import { loadView } from "$pano/registry/index.js";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @type {import('@sveltejs/kit').Load}
|
|
@@ -24,14 +24,9 @@
|
|
|
24
24
|
// Resolved in load (not {#await} in markup): universal load data is not
|
|
25
25
|
// serialized, so the component class can travel in it, and SSR renders the
|
|
26
26
|
// view instead of an await-pending branch.
|
|
27
|
-
const viewPromise = resolveView(
|
|
28
|
-
"TicketDetailView",
|
|
29
|
-
() => import("../../views/TicketDetailView.svelte"),
|
|
30
|
-
);
|
|
31
|
-
|
|
32
27
|
const loadData = await processLoad(event);
|
|
33
28
|
|
|
34
|
-
return { ...loadData,
|
|
29
|
+
return { ...loadData, ...(await loadView(event, "TicketDetailView", () => import("../../views/TicketDetailView.svelte"))) };
|
|
35
30
|
}
|
|
36
31
|
</script>
|
|
37
32
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// "Is plugin X installed?" for theme code (`$pano/lib/plugins.js`).
|
|
2
|
+
//
|
|
3
|
+
// The answer is `siteInfo.plugins` (GET /api/v1/site-info): one entry per installed AND running plugin, keyed by the
|
|
4
|
+
// full plugin id, `{ version: string | null, uiHash: string, dependencies: string[] }`. It is the same object the layout
|
|
5
|
+
// already carries in `session.siteInfo`, so these helpers take it as an argument and keep no state of their own: that
|
|
6
|
+
// is what makes them safe during SSR (nothing is shared between requests) and reactive in a component (pass the store
|
|
7
|
+
// value, `$session.siteInfo`, and the markup follows the store). The plugin list is read once per page load and changes
|
|
8
|
+
// only when the site info is reloaded (a plugin is installed or switched on by restarting Pano).
|
|
9
|
+
import { pluginIdOf } from "@panomc/sdk/core/js/ControllerRegistry.js";
|
|
10
|
+
|
|
11
|
+
/** @typedef {{ version: string | null, uiHash: string, dependencies: string[] }} PluginEntry */
|
|
12
|
+
|
|
13
|
+
const has = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The key of `idOrNamespace` in the plugins map, or null. The full plugin id (`pano-plugin-market`) is canonical;
|
|
17
|
+
* the short namespace (`market`) is accepted too, resolved like `plugin('market')` does: the namespace the plugin
|
|
18
|
+
* registered its controllers under, else `pano-plugin-<namespace>`.
|
|
19
|
+
* @param {Record<string, PluginEntry> | null | undefined} plugins
|
|
20
|
+
* @param {unknown} idOrNamespace
|
|
21
|
+
* @returns {string | null}
|
|
22
|
+
*/
|
|
23
|
+
function keyOf(plugins, idOrNamespace) {
|
|
24
|
+
if (!plugins || typeof plugins !== "object" || typeof idOrNamespace !== "string" || !idOrNamespace) return null;
|
|
25
|
+
|
|
26
|
+
if (has(plugins, idOrNamespace)) return idOrNamespace;
|
|
27
|
+
|
|
28
|
+
const registered = pluginIdOf(idOrNamespace);
|
|
29
|
+
if (registered && has(plugins, registered)) return registered;
|
|
30
|
+
|
|
31
|
+
const conventional = `pano-plugin-${idOrNamespace}`;
|
|
32
|
+
return has(plugins, conventional) ? conventional : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The site info entry of an installed, running plugin (`{ version, uiHash, dependencies }`), or null.
|
|
37
|
+
* @param {{ plugins?: Record<string, PluginEntry> } | null | undefined} siteInfo `session.siteInfo`
|
|
38
|
+
* @param {string} idOrNamespace `"pano-plugin-market"` (canonical) or `"market"`
|
|
39
|
+
* @returns {PluginEntry | null}
|
|
40
|
+
*/
|
|
41
|
+
export function pluginInfo(siteInfo, idOrNamespace) {
|
|
42
|
+
const plugins = siteInfo?.plugins;
|
|
43
|
+
const key = keyOf(plugins, idOrNamespace);
|
|
44
|
+
return key === null ? null : plugins[key];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* True when the plugin is installed and running. False for an unknown plugin and while there is no site info yet.
|
|
49
|
+
* @example
|
|
50
|
+
* // in a +page.js / load()
|
|
51
|
+
* const { session } = await parent();
|
|
52
|
+
* const shop = hasPlugin(session.siteInfo, "market");
|
|
53
|
+
* // in a component
|
|
54
|
+
* {#if hasPlugin($session.siteInfo, "pano-plugin-market")} ... {/if}
|
|
55
|
+
* @param {{ plugins?: Record<string, PluginEntry> } | null | undefined} siteInfo `session.siteInfo`
|
|
56
|
+
* @param {string} idOrNamespace `"pano-plugin-market"` (canonical) or `"market"`
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
export function hasPlugin(siteInfo, idOrNamespace) {
|
|
60
|
+
return keyOf(siteInfo?.plugins, idOrNamespace) !== null;
|
|
61
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Pure helpers for the login return URL (`/login?redirect=<site-relative target>`).
|
|
2
|
+
// No framework imports: this module is shared by the SvelteKit load functions, the login /
|
|
3
|
+
// register pages, `pano.auth` and the unit tests.
|
|
4
|
+
|
|
5
|
+
const BASE = "http://pano.invalid";
|
|
6
|
+
const MAX_LENGTH = 2048;
|
|
7
|
+
|
|
8
|
+
// The auth route set of `bin/sync.js`. A return target inside it would loop (or land on a page
|
|
9
|
+
// that bounces a logged-in visitor away), so it falls back instead.
|
|
10
|
+
const AUTH_PATHS = [
|
|
11
|
+
"/login",
|
|
12
|
+
"/register",
|
|
13
|
+
"/reset-password",
|
|
14
|
+
"/renew-password",
|
|
15
|
+
"/activate",
|
|
16
|
+
"/activate-new-email",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function safeDecode(value) {
|
|
20
|
+
try {
|
|
21
|
+
return decodeURIComponent(value);
|
|
22
|
+
} catch {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isAuthPath(pathname) {
|
|
28
|
+
// Check the raw and the decoded form: the router matches the decoded path, so `/%6Cogin` is `/login`.
|
|
29
|
+
return [pathname, safeDecode(pathname)].some((candidate) => {
|
|
30
|
+
const lower = candidate.toLowerCase();
|
|
31
|
+
return AUTH_PATHS.some((p) => lower === p || lower.startsWith(`${p}/`));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {unknown} value
|
|
37
|
+
* @param {string} [fallback]
|
|
38
|
+
* @returns {string} a safe site-relative target, or `fallback`.
|
|
39
|
+
*/
|
|
40
|
+
export function sanitizeReturnTo(value, fallback = "/") {
|
|
41
|
+
if (typeof value !== "string") return fallback;
|
|
42
|
+
if (value.length < 1 || value.length > MAX_LENGTH) return fallback;
|
|
43
|
+
if (value[0] !== "/") return fallback;
|
|
44
|
+
if (value[1] === "/" || value[1] === "\\") return fallback;
|
|
45
|
+
|
|
46
|
+
for (let i = 0; i < value.length; i++) {
|
|
47
|
+
const code = value.charCodeAt(i);
|
|
48
|
+
if (code === 0x5c || code <= 0x1f || code === 0x7f) return fallback;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let parsed;
|
|
52
|
+
try {
|
|
53
|
+
parsed = new URL(value, BASE);
|
|
54
|
+
} catch {
|
|
55
|
+
return fallback;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (parsed.origin !== BASE) return fallback;
|
|
59
|
+
if (isAuthPath(parsed.pathname)) return fallback;
|
|
60
|
+
|
|
61
|
+
// Dot-segment removal can create a leading `//` (`/.//evil.com` -> `//evil.com`), which the
|
|
62
|
+
// browser reads as a protocol-relative URL: validate the normalised form too.
|
|
63
|
+
const out = parsed.pathname + parsed.search + parsed.hash;
|
|
64
|
+
if (out[0] !== "/" || out[1] === "/" || out[1] === "\\" || out.includes("\\")) return fallback;
|
|
65
|
+
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {unknown} returnTo
|
|
71
|
+
* @returns {string} `/login` or `/login?redirect=<encoded target>`
|
|
72
|
+
*/
|
|
73
|
+
export function buildLoginUrl(returnTo) {
|
|
74
|
+
const safe = sanitizeReturnTo(returnTo);
|
|
75
|
+
|
|
76
|
+
return safe === "/" ? "/login" : `/login?redirect=${encodeURIComponent(safe)}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Reads `?redirect=` from a URL (a `URL`, a string, or anything with `searchParams`).
|
|
81
|
+
* @param {URL | string | { searchParams?: URLSearchParams } | null | undefined} url
|
|
82
|
+
* @param {string} [fallback]
|
|
83
|
+
*/
|
|
84
|
+
export function returnToFromUrl(url, fallback = "/") {
|
|
85
|
+
if (url === null || url === undefined) return fallback;
|
|
86
|
+
|
|
87
|
+
let params;
|
|
88
|
+
try {
|
|
89
|
+
if (typeof url === "string") {
|
|
90
|
+
params = new URL(url, BASE).searchParams;
|
|
91
|
+
} else if (url.searchParams) {
|
|
92
|
+
params = url.searchParams;
|
|
93
|
+
} else {
|
|
94
|
+
return fallback;
|
|
95
|
+
}
|
|
96
|
+
} catch {
|
|
97
|
+
return fallback;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return sanitizeReturnTo(params.get("redirect"), fallback);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Where a guest on a `loginRequired` plugin page must be sent, or `null` when no redirect is due.
|
|
105
|
+
* @param {{ loginRequired?: boolean } | null | undefined} registeredPage
|
|
106
|
+
* @param {unknown} user the session user (falsy for a guest)
|
|
107
|
+
* @param {{ pathname: string, search?: string }} url
|
|
108
|
+
* @returns {string | null}
|
|
109
|
+
*/
|
|
110
|
+
export function loginRedirectFor(registeredPage, user, url) {
|
|
111
|
+
if (registeredPage?.loginRequired && !user) {
|
|
112
|
+
return buildLoginUrl(url.pathname + (url.search ?? ""));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return null;
|
|
116
|
+
}
|