@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.
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 +8 -9
  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 -62
  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,129 @@
1
+ // View catalogue, data part (doc 02 section 7): builds the rows the list, the stage and `views.json` share.
2
+ //
3
+ // Everything that touches the world (the registry, the plugin files, the engine's samples) arrives through
4
+ // `deps`, so the tests run it without SvelteKit. `deps.js` makes the real ones.
5
+
6
+ import { badgesOf, controllersOfSamples, engineRows, pluginRows, stateNames, statusOf } from "./model.js";
7
+
8
+ /**
9
+ * @typedef {object} CatalogueDeps
10
+ * @property {{ views?: Record<string, any> }} skinContract
11
+ * @property {Record<string, () => Promise<{ default?: any, notApplicable?: string[] }>>} engineSamples view name -> lazy `*.samples.js`
12
+ * @property {{
13
+ * resolveViewModule: (id: string) => Promise<{ source: "override" | "default" } | null>,
14
+ * describeView: (id: string) => { overridden: boolean, status?: string } | null,
15
+ * getIssues: () => Array<{ type: string, view: string, [k: string]: any }>,
16
+ * }} registry
17
+ * @property {() => Promise<string[]>} pluginIds plugins whose package is installed
18
+ * @property {(pluginId: string) => Promise<any | null>} pluginViews `contract/views.json` of a plugin
19
+ * @property {(pluginId: string) => Promise<{ default?: Record<string, any>, notApplicable?: Record<string, string[]> } | null>} pluginSamples `samples/samples.mjs`
20
+ */
21
+
22
+ /**
23
+ * @typedef {import("./model.js").Row & {
24
+ * block?: boolean, page?: any, inject?: any, widget?: any,
25
+ * notApplicable: string[], controllers: string[], hasSamples: boolean,
26
+ * }} CatalogueRow
27
+ */
28
+
29
+ /**
30
+ * The samples module of one view: `{ states, samples, notApplicable }`. A view with no samples file has no states.
31
+ * @param {CatalogueDeps} deps
32
+ * @param {{ id: string, name: string, pluginId: string | null }} row
33
+ * @param {Map<string, any>} pluginCache plugin id -> samples module (read once per plugin)
34
+ */
35
+ export async function samplesOf(deps, row, pluginCache = new Map()) {
36
+ try {
37
+ if (!row.pluginId) {
38
+ const load = deps.engineSamples?.[row.name];
39
+ const mod = load ? await load() : null;
40
+ const samples = mod?.default ?? null;
41
+
42
+ return { samples, states: stateNames(samples), notApplicable: mod?.notApplicable ?? [] };
43
+ }
44
+
45
+ if (!pluginCache.has(row.pluginId)) pluginCache.set(row.pluginId, deps.pluginSamples(row.pluginId).catch(() => null));
46
+ const mod = await pluginCache.get(row.pluginId);
47
+ const samples = mod?.default?.[row.name] ?? null;
48
+
49
+ return { samples, states: stateNames(samples), notApplicable: mod?.notApplicable?.[row.name] ?? [] };
50
+ } catch (e) {
51
+ console.warn(`[theme-core] catalogue: the samples of '${row.id}' could not be loaded`, e);
52
+
53
+ return { samples: null, states: [], notApplicable: [] };
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Status of a view from the registry: it is resolved first, because the registry only knows the
59
+ * outcome (override rendered or refused) after a resolution.
60
+ * @param {CatalogueDeps} deps
61
+ * @param {string} id
62
+ */
63
+ async function statusFor(deps, id) {
64
+ const described = deps.registry.describeView(id);
65
+ if (!described) return { status: "default", loaded: false };
66
+
67
+ let source = null;
68
+ try {
69
+ source = (await deps.registry.resolveViewModule(id))?.source ?? null;
70
+ } catch {
71
+ source = "default";
72
+ }
73
+
74
+ return { status: statusOf(described, source), loaded: true };
75
+ }
76
+
77
+ /**
78
+ * Every view the theme can show: the engine's from the skin contract, each installed plugin's from its
79
+ * `contract/views.json`.
80
+ * @param {CatalogueDeps} deps
81
+ * @param {{ only?: string }} [options] build only the row of this view id (the stage)
82
+ * @returns {Promise<CatalogueRow[]>}
83
+ */
84
+ export async function loadCatalogue(deps, { only } = {}) {
85
+ /** @type {any[]} */
86
+ const base = engineRows(deps.skinContract);
87
+ const wanted = (id) => !only || only === id;
88
+
89
+ let pluginIds = [];
90
+ try {
91
+ pluginIds = await deps.pluginIds();
92
+ } catch (e) {
93
+ console.warn("[theme-core] catalogue: the installed plugins could not be listed", e);
94
+ }
95
+
96
+ for (const pluginId of pluginIds) {
97
+ let viewsJson = null;
98
+ try {
99
+ viewsJson = await deps.pluginViews(pluginId);
100
+ } catch {
101
+ viewsJson = null;
102
+ }
103
+ if (!viewsJson) continue;
104
+ base.push(...pluginRows(viewsJson, pluginId));
105
+ }
106
+
107
+ const issues = deps.registry.getIssues();
108
+ const pluginCache = new Map();
109
+
110
+ const rows = await Promise.all(
111
+ base.filter((row) => wanted(row.id)).map(async (row) => {
112
+ const [{ status }, { samples, states, notApplicable }] = await Promise.all([statusFor(deps, row.id), samplesOf(deps, row, pluginCache)]);
113
+ const controllers = controllersOfSamples(samples);
114
+
115
+ return {
116
+ ...row,
117
+ status,
118
+ states,
119
+ notApplicable,
120
+ controllers,
121
+ hasSamples: states.length > 0,
122
+ badges: badgesOf(row, states, controllers),
123
+ issues: issues.filter((issue) => issue.view === row.id),
124
+ };
125
+ }),
126
+ );
127
+
128
+ return rows;
129
+ }
@@ -0,0 +1,147 @@
1
+ // View catalogue, the real dependencies of `catalogue.js` (doc 02 section 7).
2
+ //
3
+ // The catalogue runs in two places: the pages in the browser (the theme dev server, `ssr = false`) and
4
+ // `/__pano/views.json` in the theme process. A plugin's package is read over HTTP from the theme's own
5
+ // `plugins/<id>/resources/plugin-ui/...` route in the first and from `plugins/<id>/` on disk in the second.
6
+ // `$app/*` and the plugin manager are imported when `createDeps` runs, never when this file loads. The same goes for
7
+ // `node:*`: this file is bundled for the browser too, where a static `node:path` import is an externalized stub that
8
+ // throws as soon as a named import is read.
9
+
10
+ import skinContract from "../../../skin-contract.json";
11
+ import * as registry from "../../registry/index.js";
12
+ import { ENGINE_SAMPLES } from "./engineSamples.js";
13
+
14
+ const PLUGIN_UI = "resources/plugin-ui";
15
+
16
+ /** URL of a file of a plugin's package on the theme server (browser side). */
17
+ export function pluginFileUrl(base, pluginId, kind, file) {
18
+ return `${base}/plugins/${encodeURIComponent(pluginId)}/${PLUGIN_UI}/${kind}/${file}`;
19
+ }
20
+
21
+ /**
22
+ * Plugin packages in the browser: over the theme's `plugins/...` route.
23
+ * @param {{ fetch: typeof fetch, base: string, pluginIds: () => Promise<string[]> }} options
24
+ */
25
+ export function browserPluginSource({ fetch, base, pluginIds }) {
26
+ return {
27
+ pluginIds,
28
+ async pluginViews(pluginId) {
29
+ const response = await fetch(pluginFileUrl(base, pluginId, "contract", "views.json"));
30
+
31
+ return response.ok ? response.json() : null;
32
+ },
33
+ async pluginSamples(pluginId) {
34
+ // a module of the theme server, not of the bundle: the browser loads it as it is
35
+ return import(/* @vite-ignore */ pluginFileUrl(base, pluginId, "samples", "samples.mjs"));
36
+ },
37
+ async readText(pluginId, path) {
38
+ const response = await fetch(pluginFileUrl(base, pluginId, "contract", path));
39
+
40
+ return response.ok ? response.text() : null;
41
+ },
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Plugin packages on the theme server: `plugins/<id>/` on disk.
47
+ * @param {{ root?: string }} [options]
48
+ */
49
+ export function serverPluginSource({ root = "plugins" } = {}) {
50
+ const fs = () => import("node:fs");
51
+ const join = (...parts) => parts.join("/");
52
+
53
+ return {
54
+ async pluginIds() {
55
+ const { readdirSync, existsSync } = await fs();
56
+
57
+ if (!existsSync(root)) return [];
58
+
59
+ return readdirSync(root, { withFileTypes: true })
60
+ .filter((entry) => entry.isDirectory() && existsSync(join(root, entry.name, "contract", "views.json")))
61
+ .map((entry) => entry.name)
62
+ .sort();
63
+ },
64
+ async pluginViews(pluginId) {
65
+ const { readFileSync } = await fs();
66
+
67
+ try {
68
+ return JSON.parse(readFileSync(join(root, pluginId, "contract", "views.json"), "utf8"));
69
+ } catch {
70
+ return null;
71
+ }
72
+ },
73
+ async pluginSamples(pluginId) {
74
+ const { existsSync } = await fs();
75
+ const file = join(root, pluginId, "samples", "samples.mjs");
76
+
77
+ if (!existsSync(file)) return null;
78
+
79
+ const { pathToFileURL } = await import("node:url");
80
+ const { resolve } = await import("node:path");
81
+
82
+ return import(/* @vite-ignore */ pathToFileURL(resolve(process.cwd(), file)).href);
83
+ },
84
+ async readText() {
85
+ return null;
86
+ },
87
+ };
88
+ }
89
+
90
+ /**
91
+ * The readable source of an engine view (`src/lib/views/HomeView.svelte`, relative to the engine package),
92
+ * through the dev server's `?raw` import. null when the module cannot be fetched (no dev server).
93
+ * @param {string} path
94
+ */
95
+ export async function readEngineSource(path) {
96
+ try {
97
+ const url = new URL(`../../../${path}?raw`, import.meta.url).href;
98
+
99
+ return (await import(/* @vite-ignore */ url)).default ?? null;
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ /**
106
+ * The dependencies of `loadCatalogue` in this process.
107
+ * @param {{ fetch?: typeof fetch, parent?: () => Promise<any> }} [event] the SvelteKit load event (its `fetch` is the one to use)
108
+ */
109
+ export async function createDeps(event) {
110
+ const { browser } = await import("$app/environment");
111
+
112
+ /** @type {ReturnType<typeof browserPluginSource>} */
113
+ let source;
114
+ if (browser) {
115
+ // The installed plugins are known after the root layout load has initialised them. A page load runs beside its
116
+ // layouts unless it waits, and read too early the list is empty: every plugin view was "No view named ...".
117
+ await event?.parent?.().catch(() => {});
118
+
119
+ const { base } = await import("$app/paths");
120
+ const { get } = await import("svelte/store");
121
+
122
+ source = browserPluginSource({
123
+ fetch: event?.fetch ?? fetch,
124
+ base,
125
+ pluginIds: async () => {
126
+ const { plugins } = await import("$pano/lib/PluginManager.js");
127
+
128
+ return Object.keys(get(plugins) ?? {});
129
+ },
130
+ });
131
+ } else {
132
+ source = serverPluginSource();
133
+ }
134
+
135
+ return {
136
+ skinContract,
137
+ engineSamples: ENGINE_SAMPLES,
138
+ registry,
139
+ ...source,
140
+ readEngineSource,
141
+ components: {
142
+ List: () => import("./List.svelte"),
143
+ Stage: () => import("./Stage.svelte"),
144
+ },
145
+ browser,
146
+ };
147
+ }
@@ -0,0 +1,63 @@
1
+ // The engine's sample files (`lib/views/<Name>.samples.js`), one lazy import each (doc 02 section 7).
2
+ //
3
+ // Generated from the folder, not `import.meta.glob`: the glob's transform emits relative specifiers that
4
+ // vite's dependency scanner cannot resolve when the engine is a registry install (see plugin-ui/Layout.svelte).
5
+ // A test keeps this table equal to the files on disk; regenerate it when a samples file is added.
6
+
7
+ /** @type {Record<string, () => Promise<{ default: import("./model.js").Samples, notApplicable?: string[] }>>} */
8
+ export const ENGINE_SAMPLES = {
9
+ ActivateEmailView: () => import("../../lib/views/ActivateEmailView.samples.js"),
10
+ AppLayoutView: () => import("../../lib/views/AppLayoutView.samples.js"),
11
+ AuthLayoutView: () => import("../../lib/views/AuthLayoutView.samples.js"),
12
+ Breadcrumb: () => import("../../lib/views/Breadcrumb.samples.js"),
13
+ CloseTicketConfirmModal: () => import("../../lib/views/CloseTicketConfirmModal.samples.js"),
14
+ ConfirmNewEmailView: () => import("../../lib/views/ConfirmNewEmailView.samples.js"),
15
+ ConfirmRemoveAllNotificationsModal: () => import("../../lib/views/ConfirmRemoveAllNotificationsModal.samples.js"),
16
+ CreateTicketView: () => import("../../lib/views/CreateTicketView.samples.js"),
17
+ Date: () => import("../../lib/views/Date.samples.js"),
18
+ DefaultToast: () => import("../../lib/views/DefaultToast.samples.js"),
19
+ ErrorView: () => import("../../lib/views/ErrorView.samples.js"),
20
+ Footer: () => import("../../lib/views/Footer.samples.js"),
21
+ Header: () => import("../../lib/views/Header.samples.js"),
22
+ HomeSidebar: () => import("../../lib/views/HomeSidebar.samples.js"),
23
+ HomeView: () => import("../../lib/views/HomeView.samples.js"),
24
+ LoginFormBody: () => import("../../lib/views/LoginFormBody.samples.js"),
25
+ LoginView: () => import("../../lib/views/LoginView.samples.js"),
26
+ LogoutSessionConfirmModal: () => import("../../lib/views/LogoutSessionConfirmModal.samples.js"),
27
+ Main: () => import("../../lib/views/Main.samples.js"),
28
+ Navbar: () => import("../../lib/views/Navbar.samples.js"),
29
+ NoContent: () => import("../../lib/views/NoContent.samples.js"),
30
+ NotificationContainer: () => import("../../lib/views/NotificationContainer.samples.js"),
31
+ NotificationsView: () => import("../../lib/views/NotificationsView.samples.js"),
32
+ PageActions: () => import("../../lib/views/PageActions.samples.js"),
33
+ PageTitle: () => import("../../lib/views/PageTitle.samples.js"),
34
+ Pagination: () => import("../../lib/views/Pagination.samples.js"),
35
+ PlayerDetailSidebar: () => import("../../lib/views/PlayerDetailSidebar.samples.js"),
36
+ PlayerDetailView: () => import("../../lib/views/PlayerDetailView.samples.js"),
37
+ PlayerHead: () => import("../../lib/views/PlayerHead.samples.js"),
38
+ Post: () => import("../../lib/views/Post.samples.js"),
39
+ PostDetailView: () => import("../../lib/views/PostDetailView.samples.js"),
40
+ Posts: () => import("../../lib/views/Posts.samples.js"),
41
+ PreviewPostView: () => import("../../lib/views/PreviewPostView.samples.js"),
42
+ ProfileLayoutView: () => import("../../lib/views/ProfileLayoutView.samples.js"),
43
+ ProfileSidebar: () => import("../../lib/views/ProfileSidebar.samples.js"),
44
+ ProfileView: () => import("../../lib/views/ProfileView.samples.js"),
45
+ RegisterForm: () => import("../../lib/views/RegisterForm.samples.js"),
46
+ RegisterView: () => import("../../lib/views/RegisterView.samples.js"),
47
+ RenewPasswordView: () => import("../../lib/views/RenewPasswordView.samples.js"),
48
+ ResetPasswordView: () => import("../../lib/views/ResetPasswordView.samples.js"),
49
+ RulesView: () => import("../../lib/views/RulesView.samples.js"),
50
+ Sidebar: () => import("../../lib/views/Sidebar.samples.js"),
51
+ SupportSidebar: () => import("../../lib/views/SupportSidebar.samples.js"),
52
+ SupportView: () => import("../../lib/views/SupportView.samples.js"),
53
+ ThemeSettingsLayoutView: () => import("../../lib/views/ThemeSettingsLayoutView.samples.js"),
54
+ TicketCreateAndDetailSidebar: () => import("../../lib/views/TicketCreateAndDetailSidebar.samples.js"),
55
+ TicketDetailView: () => import("../../lib/views/TicketDetailView.samples.js"),
56
+ TicketRow: () => import("../../lib/views/TicketRow.samples.js"),
57
+ TicketStatus: () => import("../../lib/views/TicketStatus.samples.js"),
58
+ Tickets: () => import("../../lib/views/Tickets.samples.js"),
59
+ TicketsLayoutView: () => import("../../lib/views/TicketsLayoutView.samples.js"),
60
+ TicketsView: () => import("../../lib/views/TicketsView.samples.js"),
61
+ Toast: () => import("../../lib/views/Toast.samples.js"),
62
+ ToastContainer: () => import("../../lib/views/ToastContainer.samples.js"),
63
+ };
@@ -0,0 +1,77 @@
1
+ // Fixtures of the engine's sample files (`lib/views/<Name>.samples.js`, doc 02 section 7).
2
+ //
3
+ // Engine samples may build stores: several of the engine's view props are stores or functions (the
4
+ // controller hands them over, see `skin-contract.json`). Plugin samples are pure data; this file is
5
+ // the engine's own convenience and is not part of any contract.
6
+
7
+ import { readable, writable } from "svelte/store";
8
+
9
+ /** 2023-11-14, as the backend sends dates (epoch milliseconds in a string). */
10
+ export const SAMPLE_TIME = "1700000000000";
11
+
12
+ export const noop = () => {};
13
+
14
+ /** A function that does nothing and returns the value the real handler would not: samples never call the server. */
15
+ export const asyncNoop = async () => {};
16
+
17
+ export const siteInfo = {
18
+ websiteName: "Pano Sample",
19
+ websiteDescription: "A sample site for the view catalogue",
20
+ serverIp: "play.example.com",
21
+ supportEmail: "support@example.com",
22
+ isDemo: false,
23
+ registerEnabled: true,
24
+ };
25
+
26
+ export const sampleUser = {
27
+ id: 1,
28
+ username: "SampleUser",
29
+ email: "sample@example.com",
30
+ permissions: [],
31
+ emailVerified: true,
32
+ };
33
+
34
+ /** The `session` context store: `{ user, csrfToken, siteInfo }`. */
35
+ export const sessionStore = (user = null) => writable({ user, csrfToken: "sample-csrf-token", siteInfo });
36
+
37
+ export const post = (n, extra = {}) => ({
38
+ url: `sample-post-${n}`,
39
+ title: `Sample post ${n}`,
40
+ text: `<p>This is the text of sample post ${n}. ${"Lorem ipsum dolor sit amet. ".repeat(6)}</p>`,
41
+ views: 40 * n,
42
+ date: SAMPLE_TIME,
43
+ category: { title: n % 2 ? "News" : "-", url: n % 2 ? "news" : "-" },
44
+ writer: { username: `Writer${n}` },
45
+ thumbnailUrl: undefined,
46
+ ...extra,
47
+ });
48
+
49
+ export const posts = (count = 3) => Array.from({ length: count }, (_, i) => post(i + 1));
50
+
51
+ export const ticket = (n, status = "NEW", extra = {}) => ({
52
+ id: n,
53
+ title: `Sample ticket ${n}`,
54
+ status,
55
+ category: { title: n % 2 ? "-" : "Bug report", url: n % 2 ? "-" : "bug-report" },
56
+ lastUpdate: SAMPLE_TIME,
57
+ ...extra,
58
+ });
59
+
60
+ export const tickets = () => [ticket(1, "NEW"), ticket(2, "REPLIED"), ticket(3, "CLOSED")];
61
+
62
+ /** A store of plugin content items, as `panoApiClient.ui.*.content.get()` hands out. */
63
+ export const items = (list = []) => readable(list);
64
+
65
+ export const themeSettings = (extra = {}) => ({
66
+ themeColor: "dark",
67
+ postsEnabled: true,
68
+ postCoverImageEnabled: true,
69
+ postViewCountEnabled: true,
70
+ postAuthorImageEnabled: true,
71
+ postPreviousPageEnabled: true,
72
+ postNextPageEnabled: true,
73
+ sidebarEnabled: true,
74
+ ...extra,
75
+ });
76
+
77
+ export const avatarVersion = () => readable("sample");
@@ -0,0 +1,37 @@
1
+ // `/__pano/views` (doc 02 section 7): the list of every view the theme can show. Loaded by the generated
2
+ // `+page.js` behind `dev`; it returns `{ component, ... }` and the page only renders the component.
3
+
4
+ import { loadCatalogue } from "./catalogue.js";
5
+ import { createDeps } from "./deps.js";
6
+ import { filterOptions, filterRows } from "./model.js";
7
+
8
+ /** The three filters of the list, read from the query string. */
9
+ export function filtersFrom(searchParams) {
10
+ return {
11
+ plugin: searchParams.get("plugin") ?? "",
12
+ kind: searchParams.get("kind") ?? "",
13
+ status: searchParams.get("status") ?? "",
14
+ };
15
+ }
16
+
17
+ /**
18
+ * @param {{ url: URL, fetch?: typeof fetch }} event the SvelteKit load event
19
+ * @param {import("./catalogue.js").CatalogueDeps & { components?: { List: () => Promise<any> } } | null} [deps] tests only
20
+ */
21
+ export async function load(event, deps = null) {
22
+ const d = deps ?? (await createDeps(event));
23
+ const all = await loadCatalogue(d);
24
+ const filters = filtersFrom(event.url.searchParams);
25
+ const rows = filterRows(all, filters);
26
+ const components = d.components ?? { List: () => import("./List.svelte") };
27
+
28
+ return {
29
+ component: (await components.List()).default,
30
+ rows,
31
+ total: all.length,
32
+ filters,
33
+ options: filterOptions(all),
34
+ // one place for the colour of the status badge
35
+ issues: all.flatMap((row) => row.issues),
36
+ };
37
+ }