@panomc/theme-core 1.0.0-dev.60 → 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 +79 -21
- 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
package/src/lib/services/auth.js
CHANGED
|
@@ -2,27 +2,27 @@ import ApiUtil from "$pano/lib/api.util";
|
|
|
2
2
|
|
|
3
3
|
export const sendLogout = async () => {
|
|
4
4
|
return ApiUtil.post({
|
|
5
|
-
path: "/
|
|
5
|
+
path: "/auth/logout",
|
|
6
6
|
});
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const sendLogin = async (body) => {
|
|
10
10
|
return ApiUtil.post({
|
|
11
|
-
path: "/
|
|
11
|
+
path: "/auth/login",
|
|
12
12
|
body,
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export const getCredentials = async (csrfToken) => {
|
|
17
17
|
return ApiUtil.get({
|
|
18
|
-
path: "/
|
|
18
|
+
path: "/auth/credentials",
|
|
19
19
|
csrfToken
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export const getCredentialsServerSide = async (token) => {
|
|
24
|
-
return ApiUtil.get({ path: "/
|
|
25
|
-
if (response.
|
|
24
|
+
return ApiUtil.get({ path: "/auth/credentials", token }).then((response) => {
|
|
25
|
+
if (!!response.error) {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -38,28 +38,28 @@ export const getCredentialsServerSide = async (token) => {
|
|
|
38
38
|
|
|
39
39
|
export const sendRegister = async (body) => {
|
|
40
40
|
return ApiUtil.post({
|
|
41
|
-
path: "/
|
|
41
|
+
path: "/auth/register",
|
|
42
42
|
body,
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export const sendVerifyEmail = async (token) => {
|
|
47
47
|
return ApiUtil.post({
|
|
48
|
-
path: "/
|
|
48
|
+
path: "/auth/verify-email",
|
|
49
49
|
body: { token },
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
export const sendVerifyNewEmail = async (token) => {
|
|
54
54
|
return ApiUtil.post({
|
|
55
|
-
path: "/
|
|
55
|
+
path: "/auth/verify-new-email",
|
|
56
56
|
body: { token },
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
export const sendResetPassword = async (usernameOrEmail) => {
|
|
61
61
|
return ApiUtil.post({
|
|
62
|
-
path: "/
|
|
62
|
+
path: "/auth/reset-password",
|
|
63
63
|
body: { usernameOrEmail },
|
|
64
64
|
});
|
|
65
65
|
};
|
|
@@ -71,14 +71,14 @@ export const sendRenewPassword = async (
|
|
|
71
71
|
token
|
|
72
72
|
) => {
|
|
73
73
|
return ApiUtil.post({
|
|
74
|
-
path: "/
|
|
74
|
+
path: "/auth/renew-password",
|
|
75
75
|
body: { newPassword, newPasswordRepeat, token },
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
export const verifyLinkCode = async (username, code) => {
|
|
80
80
|
return ApiUtil.post({
|
|
81
|
-
path: "/
|
|
81
|
+
path: "/auth/verify-link-code",
|
|
82
82
|
body: { username, code },
|
|
83
83
|
});
|
|
84
84
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ApiUtil, { buildQueryParams } from "$pano/lib/api.util.js";
|
|
2
|
+
import { readPage } from "$pano/lib/pageShape.js";
|
|
2
3
|
|
|
3
4
|
const VIEWER_ID_STORAGE_KEY = "pano:post-viewer-id:v1";
|
|
4
5
|
const VIEW_CACHE_STORAGE_KEY = "pano:post-view-cache:v1";
|
|
@@ -6,23 +7,33 @@ const VIEW_CACHE_LIMIT = 300;
|
|
|
6
7
|
|
|
7
8
|
const VIEW_DEDUPE_WINDOW_MS = 6 * 60 * 60 * 1000; // 6 hours
|
|
8
9
|
|
|
9
|
-
export const getPosts = async ({ page, categoryUrl, request, csrfToken }) => {
|
|
10
|
-
const queryParams = buildQueryParams({ page, categoryUrl });
|
|
10
|
+
export const getPosts = async ({ page, pageSize, categoryUrl, request, csrfToken }) => {
|
|
11
|
+
const queryParams = buildQueryParams({ page, pageSize, categoryUrl });
|
|
11
12
|
|
|
12
13
|
return ApiUtil.get({
|
|
13
|
-
path: `/
|
|
14
|
+
path: `/posts${queryParams}`,
|
|
14
15
|
request,
|
|
15
16
|
csrfToken
|
|
16
17
|
}).then((body) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const result = readPage(body);
|
|
19
|
+
|
|
20
|
+
if (result.failed) {
|
|
21
|
+
return result.body;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...result.rest,
|
|
26
|
+
posts: result.items,
|
|
27
|
+
postCount: result.count,
|
|
28
|
+
page: parseInt(page),
|
|
29
|
+
totalPages: result.totalPages
|
|
30
|
+
};
|
|
20
31
|
});
|
|
21
32
|
};
|
|
22
33
|
|
|
23
34
|
export const getPostDetail = async ({ url, request, csrfToken }) => {
|
|
24
35
|
return ApiUtil.get({
|
|
25
|
-
path: `/
|
|
36
|
+
path: `/posts/${url}`,
|
|
26
37
|
request,
|
|
27
38
|
csrfToken
|
|
28
39
|
}).then((body) => {
|
|
@@ -34,7 +45,7 @@ export const getPostDetail = async ({ url, request, csrfToken }) => {
|
|
|
34
45
|
|
|
35
46
|
export const getPostPreview = async ({ id, request, csrfToken }) => {
|
|
36
47
|
return ApiUtil.get({
|
|
37
|
-
path: `/
|
|
48
|
+
path: `/posts/previews/${id}`,
|
|
38
49
|
request,
|
|
39
50
|
csrfToken
|
|
40
51
|
}).then((body) => {
|
|
@@ -134,13 +145,13 @@ export const trackPostView = async ({ url, csrfToken }) => {
|
|
|
134
145
|
const headers = viewerId ? { "X-Post-Viewer-Id": viewerId } : undefined;
|
|
135
146
|
|
|
136
147
|
return ApiUtil.post({
|
|
137
|
-
path: `/
|
|
148
|
+
path: `/posts/${encodeURIComponent(url)}/view`,
|
|
138
149
|
body: {},
|
|
139
150
|
headers,
|
|
140
151
|
csrfToken
|
|
141
152
|
})
|
|
142
153
|
.then((body) => {
|
|
143
|
-
if (body?.
|
|
154
|
+
if (!body?.error) {
|
|
144
155
|
markViewAsTracked(url);
|
|
145
156
|
}
|
|
146
157
|
|
|
@@ -2,27 +2,27 @@ import ApiUtil from "$pano/lib/api.util.js";
|
|
|
2
2
|
|
|
3
3
|
export const getProfile = async ({ request }) => {
|
|
4
4
|
return ApiUtil.get({
|
|
5
|
-
path: `/
|
|
5
|
+
path: `/profile`,
|
|
6
6
|
request,
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const getPlayerProfile = async ({ request, username }) => {
|
|
11
11
|
return ApiUtil.get({
|
|
12
|
-
path: `/
|
|
12
|
+
path: `/profiles/${username}`,
|
|
13
13
|
request,
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const sendResetPassword = async () => {
|
|
18
18
|
return ApiUtil.post({
|
|
19
|
-
path: "/
|
|
19
|
+
path: "/profile/reset-password",
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export const sendChangeEmail = async (currentPassword, newEmail) => {
|
|
24
24
|
return ApiUtil.post({
|
|
25
|
-
path: "/
|
|
25
|
+
path: "/profile/change-email",
|
|
26
26
|
body: {
|
|
27
27
|
currentPassword,
|
|
28
28
|
newEmail,
|
|
@@ -32,6 +32,6 @@ export const sendChangeEmail = async (currentPassword, newEmail) => {
|
|
|
32
32
|
|
|
33
33
|
export const sendUpdateProfile = async (body) => {
|
|
34
34
|
return ApiUtil.put({
|
|
35
|
-
path: "/
|
|
35
|
+
path: "/profile", body
|
|
36
36
|
});
|
|
37
37
|
};
|
|
@@ -1,35 +1,56 @@
|
|
|
1
1
|
import ApiUtil, { buildQueryParams } from "../api.util.js";
|
|
2
|
+
import { readPage } from "../pageShape.js";
|
|
2
3
|
|
|
3
|
-
export const getTickets = async ({ page, pageType, categoryUrl, request, csrfToken }) => {
|
|
4
|
-
const queryParams = buildQueryParams({ page, pageType, categoryUrl });
|
|
4
|
+
export const getTickets = async ({ page, pageSize, pageType, categoryUrl, request, csrfToken }) => {
|
|
5
|
+
const queryParams = buildQueryParams({ page, pageSize, pageType, categoryUrl });
|
|
5
6
|
|
|
6
7
|
return ApiUtil.get({
|
|
7
|
-
path: `/
|
|
8
|
+
path: `/tickets${queryParams}`,
|
|
8
9
|
request,
|
|
9
10
|
csrfToken
|
|
10
11
|
}).then((body) => {
|
|
11
|
-
|
|
12
|
-
body.pageType = pageType;
|
|
12
|
+
const result = readPage(body);
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
if (result.failed) {
|
|
15
|
+
return result.body;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
...result.rest,
|
|
20
|
+
tickets: result.items,
|
|
21
|
+
ticketCount: result.count,
|
|
22
|
+
page: parseInt(page),
|
|
23
|
+
totalPages: result.totalPages,
|
|
24
|
+
pageType
|
|
25
|
+
};
|
|
15
26
|
});
|
|
16
27
|
};
|
|
17
28
|
|
|
18
|
-
export const getTicketCategories = async ({ page, request, csrfToken }) => {
|
|
29
|
+
export const getTicketCategories = async ({ page, pageSize, request, csrfToken }) => {
|
|
30
|
+
const queryParams = buildQueryParams({ page, pageSize });
|
|
31
|
+
|
|
19
32
|
return ApiUtil.get({
|
|
20
|
-
path: `/
|
|
33
|
+
path: `/ticket-categories${queryParams}`,
|
|
21
34
|
request,
|
|
22
35
|
csrfToken
|
|
23
36
|
}).then((body) => {
|
|
24
|
-
|
|
37
|
+
const result = readPage(body);
|
|
38
|
+
|
|
39
|
+
if (result.failed) {
|
|
40
|
+
return result.body;
|
|
41
|
+
}
|
|
25
42
|
|
|
26
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
...result.rest,
|
|
45
|
+
categories: result.items,
|
|
46
|
+
page: parseInt(page)
|
|
47
|
+
};
|
|
27
48
|
});
|
|
28
49
|
};
|
|
29
50
|
|
|
30
51
|
export const updateTicket = async ({ id, status, request, csrfToken }) => {
|
|
31
52
|
return ApiUtil.put({
|
|
32
|
-
path: `/
|
|
53
|
+
path: `/tickets/${id}`,
|
|
33
54
|
body: {
|
|
34
55
|
status,
|
|
35
56
|
},
|
|
@@ -46,7 +67,7 @@ export const createTicket = async ({
|
|
|
46
67
|
csrfToken
|
|
47
68
|
}) => {
|
|
48
69
|
return ApiUtil.post({
|
|
49
|
-
path: `/
|
|
70
|
+
path: `/tickets`,
|
|
50
71
|
body: {
|
|
51
72
|
title,
|
|
52
73
|
message,
|
|
@@ -59,7 +80,7 @@ export const createTicket = async ({
|
|
|
59
80
|
|
|
60
81
|
export const getTicketDetail = async ({ id, request, csrfToken }) => {
|
|
61
82
|
return ApiUtil.get({
|
|
62
|
-
path: `/
|
|
83
|
+
path: `/tickets/${id}`,
|
|
63
84
|
request,
|
|
64
85
|
csrfToken
|
|
65
86
|
});
|
|
@@ -72,7 +93,7 @@ export const loadMoreTicketMessages = async ({
|
|
|
72
93
|
csrfToken
|
|
73
94
|
}) => {
|
|
74
95
|
return ApiUtil.get({
|
|
75
|
-
path: `/
|
|
96
|
+
path: `/tickets/${id}/messages?lastMessageId=${lastMessageId}`,
|
|
76
97
|
request,
|
|
77
98
|
csrfToken
|
|
78
99
|
});
|
|
@@ -85,7 +106,7 @@ export const sendTicketMessage = async ({
|
|
|
85
106
|
csrfToken
|
|
86
107
|
}) => {
|
|
87
108
|
return ApiUtil.post({
|
|
88
|
-
path: `/
|
|
109
|
+
path: `/tickets/${ticketId}/messages`,
|
|
89
110
|
body: {
|
|
90
111
|
message,
|
|
91
112
|
},
|
package/src/lib/siteRealtime.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { base } from '$app/paths';
|
|
2
|
+
import ApiUtil from '$pano/lib/api.util';
|
|
2
3
|
|
|
3
4
|
const listeners = new Set();
|
|
4
5
|
let ws;
|
|
@@ -31,20 +32,47 @@ let consecutiveFastFailures = 0;
|
|
|
31
32
|
*/
|
|
32
33
|
let stoppedDueToAuth = false;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
/** True while a ticket is being fetched, so a second `connect()` does not start a second socket. */
|
|
36
|
+
let connecting = false;
|
|
37
|
+
|
|
38
|
+
function isLive() {
|
|
39
|
+
return !!ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @param {string} ticket the single-use ticket of `POST /auth/ws-ticket` */
|
|
43
|
+
function buildWsUrl(ticket) {
|
|
35
44
|
if (typeof window === 'undefined') return '';
|
|
36
|
-
const withBase = `${base || ''}/api/ws`.replace(/\/+/g, '/');
|
|
45
|
+
const withBase = `${base || ''}/api/v1/ws`.replace(/\/+/g, '/');
|
|
37
46
|
const path = withBase.startsWith('/') ? withBase : `/${withBase}`;
|
|
38
47
|
const u = new URL(path, window.location.origin);
|
|
39
48
|
u.protocol = u.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
49
|
+
u.searchParams.set('ticket', ticket);
|
|
40
50
|
return u.toString();
|
|
41
51
|
}
|
|
42
52
|
|
|
53
|
+
/**
|
|
54
|
+
* A fresh ticket (single use, 30 seconds; doc 05 section 6): the socket is opened with `?ticket=` instead of
|
|
55
|
+
* relying on an ambient cookie, so it also works for a page on another origin.
|
|
56
|
+
* @returns {Promise<{ ticket: string } | { failure: 'network' | 'rejected' }>}
|
|
57
|
+
*/
|
|
58
|
+
async function fetchTicket() {
|
|
59
|
+
let response;
|
|
60
|
+
try {
|
|
61
|
+
response = await ApiUtil.post({ path: '/auth/ws-ticket' });
|
|
62
|
+
} catch {
|
|
63
|
+
return { failure: 'network' };
|
|
64
|
+
}
|
|
65
|
+
if (response && typeof response.ticket === 'string' && response.ticket) {
|
|
66
|
+
return { ticket: response.ticket };
|
|
67
|
+
}
|
|
68
|
+
return { failure: response?.error?.code === 'NETWORK_ERROR' || !response?.error ? 'network' : 'rejected' };
|
|
69
|
+
}
|
|
70
|
+
|
|
43
71
|
function buildAuthProbeUrl() {
|
|
44
72
|
if (typeof window === 'undefined') return '';
|
|
45
73
|
// Logged-in-only endpoint: returns 200 when the session is valid, 401 otherwise.
|
|
46
74
|
// Cheap (small payload) and already used elsewhere by the notification UI.
|
|
47
|
-
const withBase = `${base || ''}/api/notifications/quick`.replace(/\/+/g, '/');
|
|
75
|
+
const withBase = `${base || ''}/api/v1/notifications/quick`.replace(/\/+/g, '/');
|
|
48
76
|
const path = withBase.startsWith('/') ? withBase : `/${withBase}`;
|
|
49
77
|
return new URL(path, window.location.origin).href;
|
|
50
78
|
}
|
|
@@ -113,21 +141,40 @@ async function probeAuthAndDecide() {
|
|
|
113
141
|
consecutiveFastFailures = 0;
|
|
114
142
|
}
|
|
115
143
|
|
|
116
|
-
function connect() {
|
|
144
|
+
async function connect() {
|
|
117
145
|
if (typeof window === 'undefined') {
|
|
118
146
|
return;
|
|
119
147
|
}
|
|
120
|
-
if (stoppedDueToAuth) {
|
|
148
|
+
if (stoppedDueToAuth || connecting) {
|
|
121
149
|
return;
|
|
122
150
|
}
|
|
123
|
-
if (
|
|
151
|
+
if (isLive()) {
|
|
124
152
|
return;
|
|
125
153
|
}
|
|
126
154
|
shouldReconnect = true;
|
|
155
|
+
connecting = true;
|
|
156
|
+
let granted;
|
|
157
|
+
try {
|
|
158
|
+
granted = await fetchTicket();
|
|
159
|
+
} finally {
|
|
160
|
+
connecting = false;
|
|
161
|
+
}
|
|
162
|
+
// The subscription may have been switched off, or another connect() may have won, while the ticket was fetched.
|
|
163
|
+
if (!shouldReconnect || !wantSiteNotifications || stoppedDueToAuth || isLive()) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (!('ticket' in granted)) {
|
|
167
|
+
if (granted.failure === 'rejected') {
|
|
168
|
+
// A refused ticket is most often "logged out": the same HTTP probe as for a rejected upgrade decides.
|
|
169
|
+
await probeAuthAndDecide();
|
|
170
|
+
}
|
|
171
|
+
scheduleReconnect();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
127
174
|
let attemptHasOpened = false;
|
|
128
175
|
const startedAt = Date.now();
|
|
129
176
|
try {
|
|
130
|
-
ws = new WebSocket(buildWsUrl());
|
|
177
|
+
ws = new WebSocket(buildWsUrl(granted.ticket));
|
|
131
178
|
} catch {
|
|
132
179
|
scheduleReconnect();
|
|
133
180
|
return;
|
|
@@ -221,7 +268,7 @@ function updateConnection() {
|
|
|
221
268
|
}
|
|
222
269
|
|
|
223
270
|
/**
|
|
224
|
-
* Keep a WebSocket for the logged-in site session (nudges re-fetch of /api/notifications/quick).
|
|
271
|
+
* Keep a WebSocket for the logged-in site session (nudges re-fetch of /api/v1/notifications/quick).
|
|
225
272
|
*
|
|
226
273
|
* The reconnect loop runs at [RECONNECT_MS] forever while active, until either:
|
|
227
274
|
* - the consumer calls setSiteNotificationsSubscription(false) (logout / unmount), or
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Load function of a page the theme adds itself (`routes.add`, `home.options.<id>.page`), doc 01
|
|
2
|
+
// section 9. The generated `+page.js` is:
|
|
3
|
+
//
|
|
4
|
+
// import * as mod from "<page file>";
|
|
5
|
+
// export const load = themePageLoad("route:/staff-team", mod);
|
|
6
|
+
//
|
|
7
|
+
// The result is the page's own `load` output plus the data of the `<PluginBlock>` placements the
|
|
8
|
+
// theme found in the page and in the views it renders (`block:<key>` entries, the same keys
|
|
9
|
+
// `loadView` gives an engine page), so those blocks are rendered on the server.
|
|
10
|
+
import { loadView } from "../registry/index.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} key `route:<path>` or `home:<id>`: the key the theme-meta scan stored the refs under
|
|
14
|
+
* @param {any} mod the page module (`import * as mod`), or a function returning it (or its promise)
|
|
15
|
+
* @returns {(event: any) => Promise<Record<string, any>>}
|
|
16
|
+
*/
|
|
17
|
+
export function themePageLoad(key, mod) {
|
|
18
|
+
return async function load(event) {
|
|
19
|
+
const resolved = typeof mod === "function" ? await mod() : await mod;
|
|
20
|
+
const own = typeof resolved?.load === "function" ? await resolved.load(event) : undefined;
|
|
21
|
+
|
|
22
|
+
const closure = await loadView(event, key).catch((e) => {
|
|
23
|
+
console.warn(`[theme-core] could not load the blocks of '${key}'`, e);
|
|
24
|
+
return {};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const blocks = {};
|
|
28
|
+
|
|
29
|
+
for (const [name, value] of Object.entries(closure ?? {})) {
|
|
30
|
+
if (name.startsWith("block:")) {
|
|
31
|
+
blocks[name] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The page's own keys win over a block key (a block key has a `block:` prefix, so a clash is unlikely).
|
|
36
|
+
return { ...blocks, ...(own && typeof own === "object" ? own : {}) };
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Pure merge of the four text layers (doc 03 section 5.3). No framework imports.
|
|
2
|
+
//
|
|
3
|
+
// Order, later wins:
|
|
4
|
+
// 1. plugin defaults api.plugins[id][key] for keys NOT in pluginAdminKeys[id]
|
|
5
|
+
// 2. theme file theme (core + theme-own keys)
|
|
6
|
+
// 3. theme plugin files themePlugins[folder][key] folder = plugin namespace or full id
|
|
7
|
+
// 4. admin edits every non-`plugins` key of api, plus api.plugins[id][key] for keys in
|
|
8
|
+
// pluginAdminKeys[id]
|
|
9
|
+
//
|
|
10
|
+
// The result is a FLAT dictionary: plugin keys are `plugins.<id>.<key>`. A plugin id may contain
|
|
11
|
+
// dots, so nothing here splits a key on "." after the id is attached.
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {object} TranslationLayers
|
|
15
|
+
* @property {Record<string, any>} [theme] `lang/<locale>.json`: core + theme-own keys, nested
|
|
16
|
+
* @property {Record<string, any>} [themePlugins] `lang/<locale>.plugins.json`: `{ <folder>: { ...nested } }`
|
|
17
|
+
* @property {Record<string, any>} [api] translations API `data`: nested, `plugins.<id>` holds plugin keys
|
|
18
|
+
* @property {Record<string, string[]>} [pluginAdminKeys] translations API `meta.pluginAdminKeys`
|
|
19
|
+
* @property {{ id: string, namespace: string }[]} [plugins] installed plugins
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
23
|
+
|
|
24
|
+
/** @param {unknown} value */
|
|
25
|
+
function isTree(value) {
|
|
26
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Flatten a nested tree into `out`, joining keys with ".". Arrays and scalars are leaves.
|
|
31
|
+
* @param {unknown} tree
|
|
32
|
+
* @param {string} prefix
|
|
33
|
+
* @param {Record<string, any>} out
|
|
34
|
+
* @param {(flatKey: string) => boolean} [skip] keys (relative to the tree) that are left out
|
|
35
|
+
* @param {string} [relative]
|
|
36
|
+
*/
|
|
37
|
+
function flatten(tree, prefix, out, skip, relative = "") {
|
|
38
|
+
if (!isTree(tree)) {
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const key of Object.keys(tree)) {
|
|
43
|
+
if (UNSAFE_KEYS.has(key)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const value = /** @type {Record<string, any>} */ (tree)[key];
|
|
48
|
+
const rel = relative ? `${relative}.${key}` : key;
|
|
49
|
+
|
|
50
|
+
if (isTree(value)) {
|
|
51
|
+
flatten(value, prefix, out, skip, rel);
|
|
52
|
+
} else if (!skip || !skip(rel)) {
|
|
53
|
+
out[prefix ? `${prefix}.${rel}` : rel] = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Resolve each `themePlugins` folder to an installed plugin id. A folder is the plugin's
|
|
62
|
+
* namespace or its full id; the full id wins when both could apply. Folders that match no
|
|
63
|
+
* installed plugin are ignored (the dev server warns about them).
|
|
64
|
+
* @param {Record<string, any>} themePlugins
|
|
65
|
+
* @param {{ id: string, namespace: string }[]} plugins
|
|
66
|
+
* @returns {{ id: string, tree: any }[]} namespace folders first, id folders after
|
|
67
|
+
*/
|
|
68
|
+
function resolveFolders(themePlugins, plugins) {
|
|
69
|
+
const byNamespace = [];
|
|
70
|
+
const byId = [];
|
|
71
|
+
|
|
72
|
+
for (const folder of Object.keys(themePlugins)) {
|
|
73
|
+
const plugin = plugins.find((p) => p.id === folder);
|
|
74
|
+
|
|
75
|
+
if (plugin) {
|
|
76
|
+
byId.push({ id: plugin.id, tree: themePlugins[folder] });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const owner = plugins.find((p) => p.namespace === folder);
|
|
81
|
+
|
|
82
|
+
if (owner) {
|
|
83
|
+
byNamespace.push({ id: owner.id, tree: themePlugins[folder] });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return [...byNamespace, ...byId];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {TranslationLayers} layers nested trees as fetched
|
|
92
|
+
* @returns {Record<string, string>} flat dictionary, plugin keys as `plugins.<id>.<key>`
|
|
93
|
+
*/
|
|
94
|
+
export function mergeTranslationLayers(layers) {
|
|
95
|
+
const { theme, themePlugins, api, pluginAdminKeys, plugins } = layers ?? {};
|
|
96
|
+
const adminKeys = isTree(pluginAdminKeys) ? pluginAdminKeys : {};
|
|
97
|
+
const installed = Array.isArray(plugins) ? plugins : [];
|
|
98
|
+
|
|
99
|
+
/** @type {Record<string, any>} */
|
|
100
|
+
const result = {};
|
|
101
|
+
|
|
102
|
+
const apiPlugins = isTree(api?.plugins) ? api.plugins : {};
|
|
103
|
+
const adminSets = new Map();
|
|
104
|
+
|
|
105
|
+
for (const id of Object.keys(apiPlugins)) {
|
|
106
|
+
const list = adminKeys[id];
|
|
107
|
+
|
|
108
|
+
adminSets.set(id, new Set(Array.isArray(list) ? list : []));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 1. plugin defaults (everything the admin did not edit)
|
|
112
|
+
for (const id of Object.keys(apiPlugins)) {
|
|
113
|
+
const admin = adminSets.get(id);
|
|
114
|
+
|
|
115
|
+
flatten(apiPlugins[id], `plugins.${id}`, result, (key) => admin.has(key));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 2. theme file
|
|
119
|
+
flatten(theme, "", result);
|
|
120
|
+
|
|
121
|
+
// 3. theme's plugin overrides
|
|
122
|
+
if (isTree(themePlugins)) {
|
|
123
|
+
for (const { id, tree } of resolveFolders(themePlugins, installed)) {
|
|
124
|
+
flatten(tree, `plugins.${id}`, result);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 4. admin edits: every non-plugins key of the API, then the edited plugin keys
|
|
129
|
+
if (isTree(api)) {
|
|
130
|
+
const { plugins: _plugins, ...rest } = /** @type {Record<string, any>} */ (api);
|
|
131
|
+
|
|
132
|
+
flatten(rest, "", result);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
for (const id of Object.keys(apiPlugins)) {
|
|
136
|
+
const admin = adminSets.get(id);
|
|
137
|
+
|
|
138
|
+
if (admin.size > 0) {
|
|
139
|
+
flatten(apiPlugins[id], `plugins.${id}`, result, (key) => !admin.has(key));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return result;
|
|
144
|
+
}
|