@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.
Files changed (308) hide show
  1. package/assets/css/pano-fallback-legacy.css +12381 -0
  2. package/assets/css/pano-fallback.css +3222 -0
  3. package/bin/__tests__/check/fixtures/plugin-contracts/market/controllers.json +4 -0
  4. package/bin/__tests__/check/fixtures/plugin-contracts/market/views.json +67 -0
  5. package/bin/__tests__/check/fixtures/routes.json +5 -0
  6. package/bin/__tests__/check/helpers.js +55 -0
  7. package/bin/__tests__/check/overrides.test.js +287 -0
  8. package/bin/__tests__/check/theme.test.js +332 -0
  9. package/bin/__tests__/cli/accept-and-list.test.js +159 -0
  10. package/bin/__tests__/cli/config-edit.test.js +213 -0
  11. package/bin/__tests__/cli/contracts-pull.test.js +187 -0
  12. package/bin/__tests__/cli/core-meta.test.js +305 -0
  13. package/bin/__tests__/cli/eject-view.test.js +356 -0
  14. package/bin/__tests__/cli/helpers.js +258 -0
  15. package/bin/__tests__/scaffold/scaffold.test.js +84 -0
  16. package/bin/bundle-internal-libs.js +14 -2
  17. package/bin/check.js +1150 -213
  18. package/bin/contracts.js +1643 -0
  19. package/bin/generate-contract.js +378 -0
  20. package/bin/generate-licenses.js +14 -2
  21. package/bin/generate-runtime-shims.js +27 -9
  22. package/bin/new.js +101 -2
  23. package/bin/package-zip.js +16 -2
  24. package/bin/sync.js +360 -7
  25. package/bin/theme-core.js +65 -107
  26. package/lang/en-US.json +1 -0
  27. package/lang/ru.json +1 -0
  28. package/lang/tr.json +1 -0
  29. package/package.json +7 -3
  30. package/skin-contract.json +864 -19
  31. package/src/kit/__tests__/hooks-server-fetch.test.js +56 -0
  32. package/src/kit/__tests__/route-map.test.js +154 -0
  33. package/src/kit/__tests__/theme-meta.test.js +249 -0
  34. package/src/kit/hooks-client.js +3 -0
  35. package/src/kit/hooks-server.js +79 -21
  36. package/src/kit/route-map.js +300 -0
  37. package/src/kit/specifiers.js +3 -0
  38. package/src/kit/svelte-config.js +3 -0
  39. package/src/kit/theme-meta.js +405 -0
  40. package/src/kit/vite-config.js +156 -12
  41. package/src/lib/NotificationManager.js +18 -0
  42. package/src/lib/PluginAPI.js +313 -9
  43. package/src/lib/Store.js +18 -5
  44. package/src/lib/__tests__/avatarVersion.test.js +25 -0
  45. package/src/lib/__tests__/check.test.js +201 -0
  46. package/src/lib/__tests__/controllerHost.test.js +363 -0
  47. package/src/lib/__tests__/cx03.test.js +245 -0
  48. package/src/lib/__tests__/engineBoot.test.js +151 -0
  49. package/src/lib/__tests__/engineParts.helper.js +284 -0
  50. package/src/lib/__tests__/engineParts.test.js +179 -0
  51. package/src/lib/__tests__/engineSidebars.helper.js +353 -0
  52. package/src/lib/__tests__/engineSidebars.test.js +273 -0
  53. package/src/lib/__tests__/engineStyles.test.js +227 -0
  54. package/src/lib/__tests__/engineWiring.test.js +1000 -0
  55. package/src/lib/__tests__/fallbackStyles.test.js +1254 -0
  56. package/src/lib/__tests__/fixtures/Probe.svelte +5 -0
  57. package/src/lib/__tests__/fixtures/engine-parts.ssr.json +29 -0
  58. package/src/lib/__tests__/fixtures/engine-sidebars.ssr.json +16 -0
  59. package/src/lib/__tests__/home.test.js +563 -0
  60. package/src/lib/__tests__/injectedScope.test.js +490 -0
  61. package/src/lib/__tests__/languageConcurrency.test.js +55 -0
  62. package/src/lib/__tests__/languageLayers.test.js +286 -0
  63. package/src/lib/__tests__/pageHead.test.js +167 -0
  64. package/src/lib/__tests__/pageMeta.util.test.js +216 -0
  65. package/src/lib/__tests__/pageTitle.util.test.js +96 -0
  66. package/src/lib/__tests__/pluginApiViews.test.js +529 -0
  67. package/src/lib/__tests__/plugins.test.js +53 -0
  68. package/src/lib/__tests__/profileNav.util.test.js +145 -0
  69. package/src/lib/__tests__/registryReady.test.js +26 -0
  70. package/src/lib/__tests__/returnTo.util.test.js +294 -0
  71. package/src/lib/__tests__/routeConfig.test.js +361 -0
  72. package/src/lib/__tests__/sidebarSpec.util.test.js +152 -0
  73. package/src/lib/__tests__/skinContract.test.js +558 -0
  74. package/src/lib/__tests__/svelteSsr.helper.js +68 -0
  75. package/src/lib/__tests__/tc03.test.js +427 -0
  76. package/src/lib/__tests__/tc11.test.js +184 -0
  77. package/src/lib/__tests__/translationLayers.test.js +161 -0
  78. package/src/lib/avatarVersion.js +39 -0
  79. package/src/lib/components/Breadcrumb.svelte +9 -40
  80. package/src/lib/components/Date.svelte +1 -1
  81. package/src/lib/components/DefaultToast.svelte +13 -3
  82. package/src/lib/components/FallbackLinks.svelte +28 -0
  83. package/src/lib/components/FallbackScope.svelte +24 -0
  84. package/src/lib/components/Footer.svelte +8 -8
  85. package/src/lib/components/Header.svelte +3 -3
  86. package/src/lib/components/Hook.svelte +12 -1
  87. package/src/lib/components/LoginFormBody.svelte +5 -5
  88. package/src/lib/components/Main.svelte +22 -47
  89. package/src/lib/components/Navbar.svelte +30 -29
  90. package/src/lib/components/NoContent.svelte +2 -2
  91. package/src/lib/components/NotificationContainer.svelte +31 -82
  92. package/src/lib/components/OnlineAdmins.svelte +3 -2
  93. package/src/lib/components/PageActions.svelte +1 -1
  94. package/src/lib/components/PageHead.svelte +50 -0
  95. package/src/lib/components/PageTitle.svelte +2 -2
  96. package/src/lib/components/Pagination.svelte +6 -6
  97. package/src/lib/components/PlayerHead.svelte +4 -4
  98. package/src/lib/components/PluginBlock.svelte +132 -0
  99. package/src/lib/components/PluginSlot.svelte +40 -0
  100. package/src/lib/components/Post.svelte +13 -230
  101. package/src/lib/components/Posts.svelte +7 -14
  102. package/src/lib/components/RegisterForm.svelte +12 -11
  103. package/src/lib/components/Sidebar.svelte +9 -7
  104. package/src/lib/components/TicketRow.svelte +8 -48
  105. package/src/lib/components/TicketStatus.svelte +10 -16
  106. package/src/lib/components/Tickets.svelte +8 -30
  107. package/src/lib/components/Toast.svelte +16 -14
  108. package/src/lib/components/ToastContainer.svelte +16 -9
  109. package/src/lib/components/ViewComponent.svelte +13 -1
  110. package/src/lib/components/modals/CloseTicketConfirmModal.svelte +15 -46
  111. package/src/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte +17 -39
  112. package/src/lib/components/modals/LogoutSessionConfirmModal.svelte +12 -30
  113. package/src/lib/components/sidebars/HomeSidebar.svelte +33 -284
  114. package/src/lib/components/sidebars/PlayerDetailSidebar.svelte +14 -63
  115. package/src/lib/components/sidebars/PluginSidebar.svelte +21 -0
  116. package/src/lib/components/sidebars/ProfileNavCard.svelte +24 -0
  117. package/src/lib/components/sidebars/ProfileSidebar.svelte +44 -84
  118. package/src/lib/components/sidebars/SupportSidebar.svelte +19 -22
  119. package/src/lib/components/sidebars/TicketCreateAndDetailSidebar.svelte +23 -35
  120. package/src/lib/components/sidebars/profileNav.util.js +105 -0
  121. package/src/lib/components/sidebars/sidebarSpec.util.js +92 -0
  122. package/src/lib/controllerHost.js +261 -0
  123. package/src/lib/fallbackStyles.js +317 -0
  124. package/src/lib/home.js +202 -0
  125. package/src/lib/language.util.js +70 -37
  126. package/src/lib/layouts/AppLayout.svelte +16 -8
  127. package/src/lib/layouts/AuthLayout.svelte +6 -4
  128. package/src/lib/layouts/MainLayout.svelte +17 -12
  129. package/src/lib/layouts/ProfileLayout.svelte +6 -4
  130. package/src/lib/layouts/ThemeSettingsLayout.svelte +6 -4
  131. package/src/lib/layouts/TicketsLayout.svelte +6 -5
  132. package/src/lib/pageMeta.util.js +212 -0
  133. package/src/lib/pageShape.js +33 -0
  134. package/src/lib/pageTitle.util.js +32 -0
  135. package/src/lib/pages/ActivateEmailPage.svelte +2 -7
  136. package/src/lib/pages/ConfirmNewEmailPage.svelte +2 -7
  137. package/src/lib/pages/ErrorPage.svelte +5 -2
  138. package/src/lib/pages/HomePage.svelte +31 -8
  139. package/src/lib/pages/LoginPage.svelte +38 -41
  140. package/src/lib/pages/NotificationsPage.svelte +2 -7
  141. package/src/lib/pages/PlayerDetailPage.svelte +2 -7
  142. package/src/lib/pages/PostDetailPage.svelte +2 -7
  143. package/src/lib/pages/PreviewPostPage.svelte +2 -7
  144. package/src/lib/pages/RegisterPage.svelte +10 -13
  145. package/src/lib/pages/RenewPasswordPage.svelte +2 -7
  146. package/src/lib/pages/ResetPasswordPage.svelte +2 -7
  147. package/src/lib/pages/RulesPage.svelte +3 -8
  148. package/src/lib/pages/SupportPage.svelte +2 -7
  149. package/src/lib/pages/ThemeSettingsPage.svelte +2 -7
  150. package/src/lib/pages/profile/ProfilePage.svelte +2 -7
  151. package/src/lib/pages/profile/SettingsPage.svelte +2 -7
  152. package/src/lib/pages/profile/TicketsPage.svelte +2 -7
  153. package/src/lib/pages/ticket/CreateTicketPage.svelte +2 -7
  154. package/src/lib/pages/ticket/TicketDetailPage.svelte +2 -7
  155. package/src/lib/plugins.js +61 -0
  156. package/src/lib/returnTo.util.js +116 -0
  157. package/src/lib/services/auth.js +11 -11
  158. package/src/lib/services/posts.js +21 -10
  159. package/src/lib/services/profile.js +5 -5
  160. package/src/lib/services/theme-setting.js +1 -1
  161. package/src/lib/services/tickets.js +36 -15
  162. package/src/lib/siteRealtime.js +55 -8
  163. package/src/lib/themePageLoad.js +38 -0
  164. package/src/lib/translationLayers.js +144 -0
  165. package/src/lib/ui-logics/layout-logics/AppLayoutLogics.js +160 -6
  166. package/src/lib/ui-logics/layout-logics/AuthLayoutLogics.js +3 -2
  167. package/src/lib/ui-logics/layout-logics/ProfileLayoutLogics.js +3 -2
  168. package/src/lib/ui-logics/layout-logics/TicketsLayoutLogics.js +3 -2
  169. package/src/lib/ui-logics/page-logics/ActiveEmailPageLogics.js +4 -4
  170. package/src/lib/ui-logics/page-logics/ConfirmNewEmailPageLogics.js +4 -4
  171. package/src/lib/ui-logics/page-logics/CreateTicketPageLogics.js +5 -5
  172. package/src/lib/ui-logics/page-logics/HomePageLogics.js +5 -3
  173. package/src/lib/ui-logics/page-logics/NotificationsPageLogics.js +40 -16
  174. package/src/lib/ui-logics/page-logics/PlayerDetailPageLogics.js +3 -3
  175. package/src/lib/ui-logics/page-logics/PostDetailPageLogics.js +3 -3
  176. package/src/lib/ui-logics/page-logics/PreviewPostPageLogics.js +1 -1
  177. package/src/lib/ui-logics/page-logics/RenewPasswordPageLogics.js +4 -4
  178. package/src/lib/ui-logics/page-logics/ResetPasswordPageLogics.js +6 -6
  179. package/src/lib/ui-logics/page-logics/SettingsPageLogics.js +8 -8
  180. package/src/lib/ui-logics/page-logics/TicketDetailPageLogics.js +3 -3
  181. package/src/lib/ui-logics/page-logics/TicketsPageLogics.js +5 -3
  182. package/src/lib/views/ActivateEmailView.samples.js +22 -0
  183. package/src/lib/views/ActivateEmailView.svelte +4 -4
  184. package/src/lib/views/AppLayoutView.samples.js +17 -0
  185. package/src/lib/views/AppLayoutView.svelte +1 -1
  186. package/src/lib/views/AuthLayoutView.samples.js +4 -0
  187. package/src/lib/views/AuthLayoutView.svelte +1 -1
  188. package/src/lib/views/Breadcrumb.samples.js +15 -0
  189. package/src/lib/views/CloseTicketConfirmModal.samples.js +12 -0
  190. package/src/lib/views/ConfirmNewEmailView.samples.js +22 -0
  191. package/src/lib/views/ConfirmNewEmailView.svelte +4 -4
  192. package/src/lib/views/ConfirmRemoveAllNotificationsModal.samples.js +9 -0
  193. package/src/lib/views/CreateTicketView.samples.js +21 -0
  194. package/src/lib/views/CreateTicketView.svelte +5 -5
  195. package/src/lib/views/Date.samples.js +9 -0
  196. package/src/lib/views/DefaultToast.samples.js +7 -0
  197. package/src/lib/views/ErrorView.samples.js +8 -0
  198. package/src/lib/views/ErrorView.svelte +4 -2
  199. package/src/lib/views/Footer.samples.js +8 -0
  200. package/src/lib/views/Header.samples.js +8 -0
  201. package/src/lib/views/HomeSidebar.samples.js +59 -0
  202. package/src/lib/views/HomeView.samples.js +34 -0
  203. package/src/lib/views/HomeView.svelte +14 -6
  204. package/src/lib/views/LoginFormBody.samples.js +8 -0
  205. package/src/lib/views/LoginView.samples.js +50 -0
  206. package/src/lib/views/LoginView.svelte +24 -22
  207. package/src/lib/views/LogoutSessionConfirmModal.samples.js +8 -0
  208. package/src/lib/views/Main.samples.js +23 -0
  209. package/src/lib/views/MainLayoutView.svelte +3 -4
  210. package/src/lib/views/Navbar.samples.js +8 -0
  211. package/src/lib/views/NoContent.samples.js +7 -0
  212. package/src/lib/views/NotificationContainer.samples.js +25 -0
  213. package/src/lib/views/NotificationsView.samples.js +36 -0
  214. package/src/lib/views/NotificationsView.svelte +21 -12
  215. package/src/lib/views/PageActions.samples.js +7 -0
  216. package/src/lib/views/PageTitle.samples.js +8 -0
  217. package/src/lib/views/Pagination.samples.js +7 -0
  218. package/src/lib/views/PlayerDetailSidebar.samples.js +35 -0
  219. package/src/lib/views/PlayerDetailView.samples.js +8 -0
  220. package/src/lib/views/PlayerDetailView.svelte +3 -3
  221. package/src/lib/views/PlayerHead.samples.js +8 -0
  222. package/src/lib/views/Post.samples.js +10 -0
  223. package/src/lib/views/PostDetailView.samples.js +28 -0
  224. package/src/lib/views/PostDetailView.svelte +24 -16
  225. package/src/lib/views/Posts.samples.js +9 -0
  226. package/src/lib/views/PreviewPostView.samples.js +20 -0
  227. package/src/lib/views/PreviewPostView.svelte +10 -10
  228. package/src/lib/views/ProfileLayoutView.samples.js +4 -0
  229. package/src/lib/views/ProfileSidebar.samples.js +33 -0
  230. package/src/lib/views/ProfileView.samples.js +29 -0
  231. package/src/lib/views/ProfileView.svelte +2 -2
  232. package/src/lib/views/RegisterForm.samples.js +7 -0
  233. package/src/lib/views/RegisterView.samples.js +28 -0
  234. package/src/lib/views/RegisterView.svelte +5 -3
  235. package/src/lib/views/RenewPasswordView.samples.js +24 -0
  236. package/src/lib/views/RenewPasswordView.svelte +6 -6
  237. package/src/lib/views/ResetPasswordView.samples.js +24 -0
  238. package/src/lib/views/ResetPasswordView.svelte +3 -3
  239. package/src/lib/views/RulesView.samples.js +14 -0
  240. package/src/lib/views/RulesView.svelte +3 -3
  241. package/src/lib/views/SettingsView.svelte +48 -17
  242. package/src/lib/views/Sidebar.samples.js +7 -0
  243. package/src/lib/views/SupportSidebar.samples.js +24 -0
  244. package/src/lib/views/SupportView.samples.js +16 -0
  245. package/src/lib/views/SupportView.svelte +8 -6
  246. package/src/lib/views/ThemeSettingsLayoutView.samples.js +9 -0
  247. package/src/lib/views/ThemeSettingsLayoutView.svelte +1 -1
  248. package/src/lib/views/ThemeSettingsView.svelte +89 -89
  249. package/src/lib/views/TicketCreateAndDetailSidebar.samples.js +33 -0
  250. package/src/lib/views/TicketDetailView.samples.js +34 -0
  251. package/src/lib/views/TicketDetailView.svelte +17 -15
  252. package/src/lib/views/TicketRow.samples.js +10 -0
  253. package/src/lib/views/TicketStatus.samples.js +8 -0
  254. package/src/lib/views/Tickets.samples.js +9 -0
  255. package/src/lib/views/TicketsLayoutView.samples.js +4 -0
  256. package/src/lib/views/TicketsView.samples.js +23 -0
  257. package/src/lib/views/TicketsView.svelte +11 -9
  258. package/src/lib/views/Toast.samples.js +9 -0
  259. package/src/lib/views/ToastContainer.samples.js +8 -0
  260. package/src/lib/views/parts/Breadcrumb.svelte +53 -0
  261. package/src/lib/views/parts/CloseTicketConfirmModal.svelte +63 -0
  262. package/src/lib/views/parts/ConfirmRemoveAllNotificationsModal.svelte +55 -0
  263. package/src/lib/views/parts/DefaultToast.svelte +22 -0
  264. package/src/lib/views/parts/HomeSidebar.svelte +334 -0
  265. package/src/lib/views/parts/LogoutSessionConfirmModal.svelte +46 -0
  266. package/src/lib/views/parts/Main.svelte +71 -0
  267. package/src/lib/views/parts/NotificationContainer.svelte +109 -0
  268. package/src/lib/views/parts/PlayerDetailSidebar.svelte +81 -0
  269. package/src/lib/views/parts/Post.svelte +255 -0
  270. package/src/lib/views/parts/Posts.svelte +25 -0
  271. package/src/lib/views/parts/ProfileSidebar.svelte +115 -0
  272. package/src/lib/views/parts/Sidebar.svelte +19 -0
  273. package/src/lib/views/parts/SupportSidebar.svelte +34 -0
  274. package/src/lib/views/parts/TicketCreateAndDetailSidebar.svelte +51 -0
  275. package/src/lib/views/parts/TicketRow.svelte +63 -0
  276. package/src/lib/views/parts/TicketStatus.svelte +24 -0
  277. package/src/lib/views/parts/Tickets.svelte +45 -0
  278. package/src/lib/views/parts/Toast.svelte +27 -0
  279. package/src/lib/views/parts/ToastContainer.svelte +17 -0
  280. package/src/lib/views/parts/engine-views.generated.js +63 -0
  281. package/src/lib/views/parts/publicHref.js +18 -0
  282. package/src/lib/views/parts/ticketStatuses.js +7 -0
  283. package/src/plugin-engine/__tests__/engine.test.js +161 -0
  284. package/src/plugin-engine/engine.js +80 -12
  285. package/src/registry/__tests__/registry.test.js +510 -0
  286. package/src/registry/__tests__/view.test.js +52 -0
  287. package/src/registry/index.js +700 -51
  288. package/src/registry/routes.js +62 -0
  289. package/src/registry/view.js +69 -0
  290. package/src/routes/RootLayout.svelte +24 -1
  291. package/src/routes/catalogue/List.svelte +163 -0
  292. package/src/routes/catalogue/Stage.svelte +355 -0
  293. package/src/routes/catalogue/__tests__/browserSafe.test.js +13 -0
  294. package/src/routes/catalogue/__tests__/catalogue.test.js +539 -0
  295. package/src/routes/catalogue/catalogue.js +129 -0
  296. package/src/routes/catalogue/deps.js +147 -0
  297. package/src/routes/catalogue/engineSamples.js +63 -0
  298. package/src/routes/catalogue/fixtures.js +77 -0
  299. package/src/routes/catalogue/list.js +37 -0
  300. package/src/routes/catalogue/model.js +286 -0
  301. package/src/routes/catalogue/stage.js +69 -0
  302. package/src/routes/catalogue/views-json.js +24 -0
  303. package/src/routes/plugin-ui/Layout.svelte +29 -4
  304. package/src/routes/plugin-ui/Page.svelte +86 -31
  305. package/src/routes/plugin-ui/load.js +173 -0
  306. package/src/routes/plugins-client-file.js +8 -3
  307. package/src/routes/plugins-ui-file.js +60 -0
  308. package/src/routes/root-layout-load.js +59 -2
@@ -0,0 +1,173 @@
1
+ // The load of a plugin page, shared by the `(plugin-ui)/[...path]` catch-all (`Page.svelte`) and the home
2
+ // route (`lib/pages/HomePage.svelte`) when the admin makes a plugin page the home page (doc 01 section 9).
3
+ //
4
+ // Engine-internal imports are relative: they resolve to the same files as the `$pano/...` alias, and this
5
+ // module stays loadable without the SvelteKit aliases. Everything that needs a `.svelte` file or the plugin
6
+ // manager (the host sidebars, the permission check, the page table) is handed in by the caller.
7
+ import { error, redirect } from "@sveltejs/kit";
8
+ // `panoApi.controllers` is this very singleton (lib/PluginAPI.js re-exports it); the direct import keeps this
9
+ // module free of the plugin manager.
10
+ import { controllers } from "@panomc/sdk/core/js/ControllerRegistry.js";
11
+
12
+ import { loadView, resolveViewModule, getThemeMeta } from "../../registry/index.js";
13
+ import { resolveSidebarSpec } from "../../lib/components/sidebars/sidebarSpec.util.js";
14
+ import { loginRedirectFor } from "../../lib/returnTo.util.js";
15
+ import { themePageLoad } from "../../lib/themePageLoad.js";
16
+
17
+ /**
18
+ * What a caller provides for the sidebar of a page whose `load` returns a string such as `"home"`.
19
+ * @typedef {{
20
+ * hosts: { home: object, profile: object },
21
+ * PluginSidebar: object,
22
+ * executeSidebarLoad: (sidebarId: string, event: any) => Promise<unknown>,
23
+ * countVisible: (sidebarId: string) => number,
24
+ * }} SidebarDeps
25
+ */
26
+
27
+ /**
28
+ * Loads the matched plugin page: the view through the registry (the theme's override or the plugin's
29
+ * default, plus the data of everything it places) or the legacy component, then its `load`.
30
+ * @param {any} event SvelteKit load event
31
+ * @param {any} registeredPage the entry of `registeredPages` (`findMatch` output, with `params`)
32
+ * @param {SidebarDeps} sidebar
33
+ * @returns {Promise<Record<string, any>>}
34
+ */
35
+ export async function loadPluginPage(event, registeredPage, sidebar) {
36
+ let componentOutput = {};
37
+
38
+ // Inject plugin-specific params into the event
39
+ if (registeredPage.params) {
40
+ event.params = { ...event.params, ...registeredPage.params };
41
+ }
42
+
43
+ // A page registered from a named view (`view: "<ns>:<Name>"`) goes through the registry: the theme's
44
+ // override (markup only) or the plugin's default, plus the `block:` data and slot loads of everything
45
+ // the view places. `component.load` is the default's, so an override gets the very same data.
46
+ let component = null;
47
+ let source = "default";
48
+ let blocks = {};
49
+
50
+ if (registeredPage.view) {
51
+ const { View: _view, ...blockData } = await loadView(event, registeredPage.view);
52
+ const resolved = await resolveViewModule(registeredPage.view);
53
+
54
+ if (!resolved) {
55
+ throw error(404, "Not found");
56
+ }
57
+
58
+ component = resolved.module;
59
+ source = resolved.source;
60
+ blocks = blockData;
61
+ } else {
62
+ component = await registeredPage.component();
63
+ }
64
+
65
+ if (component.load !== undefined) {
66
+ // A module `load` always wins.
67
+ componentOutput = await component.load(event);
68
+ } else if (registeredPage.view && registeredPage.controller) {
69
+ // A page declared with `view = { path, controller }` and no `load` of its own gets the controller's data
70
+ // (doc 02 section 4). `<ns>` is the namespace of the view id.
71
+ const ns = String(registeredPage.view).split(":")[0];
72
+ componentOutput =
73
+ (await controllers.load(`${ns}/${registeredPage.controller}`, { event, params: event.params })) ?? {};
74
+ }
75
+
76
+ const output = { registeredPage, component, props: componentOutput, viewSource: source, ...blocks };
77
+
78
+ // Expose layout-consumed fields from the component's load output
79
+ // at the top level so they end up on page.data (e.g. pageTitle is
80
+ // read by AppLayout/MainLayout to set <title> and the PageTitle component).
81
+ if (componentOutput && typeof componentOutput === "object") {
82
+ for (const key of ["pageTitle", "breadcrumbs", "sidebar", "sidebarProps", "meta"]) {
83
+ if (componentOutput[key] !== undefined) {
84
+ output[key] = componentOutput[key];
85
+ }
86
+ }
87
+ }
88
+
89
+ // `sidebar` as a string ("home", "profile", "plugin:<sidebarId>") names a host or engine
90
+ // sidebar instead of passing a component; a component value is left untouched.
91
+ const resolved = await resolveSidebarSpec({
92
+ sidebar: output.sidebar,
93
+ sidebarProps: output.sidebarProps,
94
+ event,
95
+ hosts: sidebar.hosts,
96
+ PluginSidebar: sidebar.PluginSidebar,
97
+ executeSidebarLoad: sidebar.executeSidebarLoad,
98
+ countVisible: sidebar.countVisible,
99
+ });
100
+
101
+ if (resolved) {
102
+ output.sidebar = resolved.sidebar;
103
+ if (resolved.sidebarProps !== undefined) output.sidebarProps = resolved.sidebarProps;
104
+ }
105
+
106
+ return output;
107
+ }
108
+
109
+ /**
110
+ * What `HomePage.svelte` hands in for a home page that is not the posts feed.
111
+ * @typedef {{
112
+ * sidebar: SidebarDeps,
113
+ * hasPermission: (permission: string, user: any) => boolean,
114
+ * findPage: (path: string) => any,
115
+ * }} HomeDeps
116
+ */
117
+
118
+ /**
119
+ * Loads the home page when it is a page of the theme (`kind: "page"`: its own `load` plus the blocks it places)
120
+ * or a plugin page (`kind: "path"`: `findMatch` on the canonical path, then the same load as the catch-all).
121
+ * The data carries `homeKind` for `HomePage.svelte`. Returns `null` when the page cannot be shown to this
122
+ * visitor (no page any more, or a permission the visitor lacks): the caller shows the posts feed then.
123
+ * A guest on a `loginRequired` page goes to login and comes back.
124
+ * @param {any} event SvelteKit load event
125
+ * @param {{ kind: "page", id: string } | { kind: "path", path: string }} home
126
+ * @param {HomeDeps} deps
127
+ * @returns {Promise<Record<string, any> | null>}
128
+ */
129
+ export async function loadHomeTarget(event, home, deps) {
130
+ if (home.kind === "page") {
131
+ const thunk = /** @type {any} */ (getThemeMeta()?.homePages)?.[home.id];
132
+
133
+ if (typeof thunk !== "function") {
134
+ return null;
135
+ }
136
+
137
+ const mod = await thunk();
138
+ const own = await themePageLoad(`home:${home.id}`, mod)(event);
139
+
140
+ return { ...own, homeKind: "page", HomeComponent: mod.default };
141
+ }
142
+
143
+ const registeredPage = deps.findPage(home.path);
144
+
145
+ if (!registeredPage) {
146
+ return null;
147
+ }
148
+
149
+ const {
150
+ session: { user },
151
+ } = await event.parent();
152
+
153
+ const loginTarget = loginRedirectFor(registeredPage, user, { pathname: event.url.pathname, search: event.url.search });
154
+
155
+ if (loginTarget) {
156
+ throw redirect(302, loginTarget);
157
+ }
158
+
159
+ if (registeredPage.permission && !deps.hasPermission(registeredPage.permission, user)) {
160
+ return null;
161
+ }
162
+
163
+ const output = await loadPluginPage(event, registeredPage, deps.sidebar);
164
+
165
+ // The page is served at `/` as well as at its own path: `/` is the address search engines should keep.
166
+ output.meta = { ...(output.meta && typeof output.meta === "object" ? output.meta : {}) };
167
+
168
+ if (output.meta.canonical === undefined) {
169
+ output.meta.canonical = "/";
170
+ }
171
+
172
+ return { ...output, homeKind: "path" };
173
+ }
@@ -11,8 +11,9 @@ const HASHED_CHUNK_RE = /-[0-9a-zA-Z_]{8,}\.m?js$/;
11
11
  * Pick a Cache-Control (and optional ETag) for a plugin client asset.
12
12
  * @param {string} fileName
13
13
  * @param {Buffer} data
14
+ * @param {boolean} [versioned] the request carries `?v=<hash>`: the URL changes with the content (doc 03 section 4.4)
14
15
  */
15
- function cacheHeadersFor(fileName, data) {
16
+ export function cacheHeadersFor(fileName, data, versioned = false) {
16
17
  if (fileName === "client.mjs") {
17
18
  // The entry point is not content-hashed, so it must always be revalidated. A trivial strong
18
19
  // ETag (content hash) lets the browser get a cheap 304 when nothing changed.
@@ -22,11 +23,15 @@ function cacheHeadersFor(fileName, data) {
22
23
  if (HASHED_CHUNK_RE.test(fileName)) {
23
24
  return { "Cache-Control": "public, max-age=31536000, immutable" };
24
25
  }
26
+ // `fallback.css` / `plugin.css` are linked as `...css?v=<hash>`, so a version is its own URL
27
+ if (versioned && fileName.endsWith(".css")) {
28
+ return { "Cache-Control": "public, max-age=31536000, immutable" };
29
+ }
25
30
  return { "Cache-Control": "no-cache" };
26
31
  }
27
32
 
28
33
  /** @type {import("@sveltejs/kit").RequestHandler} */
29
- export async function GET({ params, request }) {
34
+ export async function GET({ params, request, url }) {
30
35
  const { pluginId, fileName } = params;
31
36
 
32
37
  // Ensure pluginId and fileName are safe and sanitize inputs
@@ -57,7 +62,7 @@ export async function GET({ params, request }) {
57
62
  // Use mime-types to automatically determine the content type
58
63
  const contentType = mime.lookup(fileName) || "application/octet-stream"; // Default to 'application/octet-stream' if mime type is unknown
59
64
 
60
- const cacheHeaders = cacheHeadersFor(safeFileName, data);
65
+ const cacheHeaders = cacheHeadersFor(safeFileName, data, Boolean(url?.searchParams?.has("v")));
61
66
 
62
67
  // Honor conditional requests when we expose an ETag (client.mjs).
63
68
  if (cacheHeaders.ETag && request.headers.get("if-none-match") === cacheHeaders.ETag) {
@@ -0,0 +1,60 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import crypto from "crypto";
4
+ import mime from "mime-types";
5
+
6
+ /** The package folders a theme process serves (`client` has its own route). */
7
+ export const UI_FILE_KINDS = ["controllers", "contract", "samples"];
8
+
9
+ /**
10
+ * Resolves `plugins/<pluginId>/<kind>/<file>` and refuses anything outside `<kind>`.
11
+ * @returns {{ status: number } | { filePath: string }}
12
+ */
13
+ export function resolveUiFile(pluginId, kind, file, root = "plugins") {
14
+ if (typeof pluginId !== "string" || typeof kind !== "string" || typeof file !== "string") return { status: 400 };
15
+ if (!pluginId || !file) return { status: 400 };
16
+ if (!UI_FILE_KINDS.includes(kind)) return { status: 404 };
17
+ if (file.includes("\0") || file.includes("\\")) return { status: 403 };
18
+
19
+ const safePluginId = path.basename(pluginId);
20
+ if (safePluginId !== pluginId || safePluginId === "." || safePluginId === "..") return { status: 403 };
21
+
22
+ // trailing separator: ".../contract" must not match ".../contract-evil/..."
23
+ const baseDir = path.resolve(root, safePluginId, kind) + path.sep;
24
+ const filePath = path.resolve(baseDir, file);
25
+ if (!filePath.startsWith(baseDir)) return { status: 403 };
26
+ return { filePath };
27
+ }
28
+
29
+ /** @type {import("@sveltejs/kit").RequestHandler} */
30
+ export async function GET({ params, request }) {
31
+ const { pluginId, kind, file } = params;
32
+ const resolved = resolveUiFile(pluginId, kind, file);
33
+
34
+ if ("status" in resolved) {
35
+ const messages = { 400: "Invalid parameters.", 403: "Access to this file is forbidden.", 404: "File not found or unable to read." };
36
+ return new Response(messages[resolved.status], { status: resolved.status });
37
+ }
38
+
39
+ try {
40
+ const data = fs.readFileSync(resolved.filePath);
41
+ const ext = path.extname(resolved.filePath);
42
+ const contentType =
43
+ ext === ".svelte" ? "text/plain; charset=utf-8" : mime.lookup(resolved.filePath) || "application/octet-stream";
44
+ // These files are not content-hashed: always revalidate, a strong ETag makes it a cheap 304.
45
+ const etag = `"${crypto.createHash("sha1").update(data).digest("hex")}"`;
46
+ const headers = {
47
+ "Content-Type": contentType,
48
+ "Cache-Control": "no-cache",
49
+ ETag: etag,
50
+ "X-Content-Type-Options": "nosniff",
51
+ };
52
+
53
+ if (request.headers.get("if-none-match") === etag) {
54
+ return new Response(null, { status: 304, headers });
55
+ }
56
+ return new Response(data, { headers });
57
+ } catch {
58
+ return new Response("File not found or unable to read.", { status: 404 });
59
+ }
60
+ }
@@ -1,15 +1,72 @@
1
1
  import { load as loadApp } from "$pano/lib/layouts/AppLayout.svelte";
2
2
  import { load as loadMain } from "$pano/lib/layouts/MainLayout.svelte";
3
+ import { engineViews } from "$pano/lib/views/parts/engine-views.generated.js";
4
+ import { getThemeConfig, loadView, registerEngineViews } from "$pano/registry/index.js";
5
+
6
+ // The engine's own views (Main, Sidebar, Breadcrumb, the toasts and the modals ...) are the registered defaults
7
+ // a theme's override is checked against. This module runs on the server and in the browser (it is the root
8
+ // layout load), so the table is registered before the first `loadView` of either side.
9
+ registerEngineViews(engineViews);
10
+
11
+ /**
12
+ * Engine parts that are not rendered by a page or layout view: the six context
13
+ * components (AppLayoutLogics) and the always-mounted parts (doc 01 §8).
14
+ * Navbar / Header / Footer load in MainLayout.
15
+ */
16
+ export const CHROME_VIEWS = [
17
+ "Date",
18
+ "Pagination",
19
+ "NoContent",
20
+ "PageActions",
21
+ "PageTitle",
22
+ "PlayerHead",
23
+ "Main",
24
+ "Sidebar",
25
+ "Breadcrumb",
26
+ "Toast",
27
+ "DefaultToast",
28
+ "ToastContainer",
29
+ "NotificationContainer",
30
+ "CloseTicketConfirmModal",
31
+ "ConfirmRemoveAllNotificationsModal",
32
+ "LogoutSessionConfirmModal",
33
+ "HomeSidebar",
34
+ "ProfileSidebar",
35
+ "SupportSidebar",
36
+ "PlayerDetailSidebar",
37
+ "TicketCreateAndDetailSidebar",
38
+ ];
39
+
40
+ /**
41
+ * `loadView` for each chrome part the theme overrides: preloads the override and
42
+ * everything it places, and returns the `block:` data of its <PluginBlock>s.
43
+ * Parts without an override are skipped (no change for a theme that overrides
44
+ * nothing). The `View` key is dropped: it belongs to the page.
45
+ * @param {any} event SvelteKit load event
46
+ * @returns {Promise<Record<string, any>>}
47
+ */
48
+ export async function loadChrome(event) {
49
+ const views = getThemeConfig()?.views ?? {};
50
+ const names = CHROME_VIEWS.filter((name) => views[name]);
51
+ if (names.length === 0) return {};
52
+
53
+ const results = await Promise.all(names.map((name) => loadView(event, name)));
54
+ /** @type {Record<string, any>} */
55
+ const out = {};
56
+ for (const { View: _view, ...blocks } of results) Object.assign(out, blocks);
57
+ return out;
58
+ }
3
59
 
4
60
  /**
5
61
  * @type {import("@sveltejs/kit").LayoutLoad}
6
62
  */
7
63
  export async function load(event) {
8
64
  const appData = await loadApp(event);
9
- const mainData = await loadMain(event);
65
+ const [mainData, chromeData] = await Promise.all([loadMain(event), loadChrome(event)]);
10
66
 
11
67
  return {
12
68
  ...appData,
13
- ...mainData
69
+ ...mainData,
70
+ ...chromeData
14
71
  };
15
72
  }