@panomc/theme-core 1.0.0-dev.59 → 1.0.0-dev.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +91 -7
  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,62 @@
1
+ // Route config of the active theme (doc 01 section 9). `route(path)` turns a canonical path into
2
+ // the path the theme publishes; `createReroute(themeConfig)` is the SvelteKit `reroute` hook that
3
+ // does the opposite for incoming requests.
4
+ import { createRouteMap } from "../kit/route-map.js";
5
+
6
+ /** Where a disabled route lands: the `(plugin-ui)/[...path]` catch-all answers it with a 404. */
7
+ export const DISABLED_PATH = "/__pano-disabled";
8
+
9
+ const identity = createRouteMap();
10
+ let current = identity;
11
+
12
+ /** @param {any} themeConfig */
13
+ function mapOf(themeConfig) {
14
+ const routes = themeConfig?.routes;
15
+
16
+ return routes && (routes.rename || routes.disable)
17
+ ? createRouteMap({ rename: routes.rename, disable: routes.disable })
18
+ : identity;
19
+ }
20
+
21
+ /**
22
+ * Remember the route config of the theme. Call it once at start-up (the generated `hooks.js`);
23
+ * no argument (or a config without `routes`) goes back to "no renames".
24
+ * @param {any} [themeConfig] the default export of `theme.config.js`
25
+ */
26
+ export function setRouteConfig(themeConfig) {
27
+ current = mapOf(themeConfig);
28
+ }
29
+
30
+ /**
31
+ * Public path for a canonical path: `route("/store")` is `"/shop"` in a theme that renames it.
32
+ * @param {string} path
33
+ * @returns {string}
34
+ */
35
+ export function route(path) {
36
+ return typeof path === "string" ? current.toPublic(path) : path;
37
+ }
38
+
39
+ /** Inbound side of `route`, for `catch-all` pages: public pathname -> canonical (or `null` = disabled). */
40
+ export function resolveCanonical(pathname) {
41
+ return current.toCanonical(pathname);
42
+ }
43
+
44
+ /**
45
+ * SvelteKit `reroute` hook: public -> canonical, disabled -> `/__pano-disabled`. Returns
46
+ * nothing when the path does not change, as SvelteKit expects.
47
+ * @param {any} themeConfig
48
+ * @returns {(input: { url: URL }) => string | undefined}
49
+ */
50
+ export function createReroute(themeConfig) {
51
+ const map = mapOf(themeConfig);
52
+
53
+ return ({ url }) => {
54
+ const canonical = map.toCanonical(url.pathname);
55
+
56
+ if (canonical === null) {
57
+ return DISABLED_PATH;
58
+ }
59
+
60
+ return canonical === url.pathname ? undefined : canonical;
61
+ };
62
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Small, framework-light helpers on top of the view registry (doc 01 §5).
3
+ *
4
+ * blockKey(id, props) the key under which `loadView` returns the data of one
5
+ * <PluginBlock> placement and under which PluginBlock
6
+ * reads it back from `$page.data`
7
+ * pluginView(id) a component that renders the registered view `id`
8
+ * (the theme's override, else the plugin's default)
9
+ *
10
+ * registry/index.js imports blockKey from here and this file imports the sync
11
+ * getters from there; every export below is a function declaration, and nothing
12
+ * runs at module-evaluation time, so the cycle is harmless.
13
+ */
14
+
15
+ import { getDefault, getOverride } from "./index.js";
16
+
17
+ /**
18
+ * Only string, number and boolean props take part in a block's identity (the
19
+ * theme-meta scan only sees literal attributes, doc 01 §4 "Theme meta").
20
+ * @param {unknown} value
21
+ */
22
+ function isPrimitiveProp(value) {
23
+ const t = typeof value;
24
+ return t === "string" || t === "boolean" || (t === "number" && Number.isFinite(value));
25
+ }
26
+
27
+ /**
28
+ * Stable JSON of the primitive props, keys sorted. Non-primitive and undefined
29
+ * props are left out, so `{ a: 1, onclick: fn }` and `{ a: 1 }` are one block.
30
+ * @param {Record<string, unknown> | null | undefined} props
31
+ * @returns {string}
32
+ */
33
+ export function stableJson(props) {
34
+ /** @type {Record<string, string | number | boolean>} */
35
+ const sorted = {};
36
+ for (const key of Object.keys(props ?? {}).sort()) {
37
+ const value = /** @type {any} */ (props)[key];
38
+ if (isPrimitiveProp(value)) sorted[key] = value;
39
+ }
40
+ return JSON.stringify(sorted);
41
+ }
42
+
43
+ /**
44
+ * `"block:" + id + "#" + stableJson(primitive props, sorted)`.
45
+ * @param {string} id view id exactly as written at the placement
46
+ * @param {Record<string, unknown> | null | undefined} [props]
47
+ * @returns {string}
48
+ */
49
+ export function blockKey(id, props) {
50
+ return "block:" + id + "#" + stableJson(props);
51
+ }
52
+
53
+ /** Renders nothing: a Svelte 5 component with an empty body. */
54
+ function Empty() {}
55
+
56
+ /**
57
+ * A component that renders the registered view `id` at render time:
58
+ * override first, then the plugin's default, nothing when the view is unknown.
59
+ * Both are read synchronously, so the view (and its closure) must have been
60
+ * preloaded by `loadView` / `preloadViews`.
61
+ * @param {string} id `<ns>:<Name>`, `<pluginId>:<Name>` or an engine name
62
+ * @returns {(anchorOrPayload: any, props?: any) => any}
63
+ */
64
+ export function pluginView(id) {
65
+ return function PluginView(anchorOrPayload, props) {
66
+ const Component = getOverride(id) ?? getDefault(id) ?? Empty;
67
+ return Component(anchorOrPayload, props);
68
+ };
69
+ }
@@ -1,17 +1,37 @@
1
1
  <script>
2
- import { onMount } from "svelte";
2
+ import { onMount, setContext } from "svelte";
3
3
  import { page } from "$app/stores";
4
+ import { browser } from "$app/environment";
5
+ import { markAvatarVersionHydrated } from "$pano/lib/avatarVersion.js";
4
6
  import { markAppBooted } from "$pano/kit/hooks-client.js";
5
7
  import AppLayout from "$pano/lib/layouts/AppLayout.svelte";
8
+ import FallbackLinks from "$pano/lib/components/FallbackLinks.svelte";
6
9
  import MainLayout from "$pano/lib/layouts/MainLayout.svelte";
10
+ import { getThemeProvides } from "$pano/registry/index.js";
11
+ import {
12
+ createFallbackStyles,
13
+ setActiveFallbackStyles,
14
+ STYLES_CONTEXT,
15
+ } from "$pano/lib/fallbackStyles.js";
7
16
 
8
17
  export let data;
9
18
 
19
+ // The stylesheets of the plugin views this render uses (doc 03 section 4.4): views add keys while they render,
20
+ // the links below are rendered after the page, so the server has collected every key by then.
21
+ const styles = createFallbackStyles({ browser });
22
+
23
+ setContext(STYLES_CONTEXT, styles);
24
+ setActiveFallbackStyles(styles);
25
+
26
+ $: provides = getThemeProvides();
27
+ $: plugins = data.pluginStyles ?? {};
28
+
10
29
  $: isThemeSettings = $page.route.id?.includes("(theme-settings)");
11
30
  $: isResetLayout = $page.data.resetLayout;
12
31
  $: showMainLayout = !isThemeSettings && !isResetLayout;
13
32
 
14
33
  onMount(() => {
34
+ markAvatarVersionHydrated();
15
35
  // Arms the hydration watchdog's "booted" state only after the page really rendered. An
16
36
  // error render (a route chunk that failed to load) keeps it unarmed so the watchdog can
17
37
  // still issue its one recovery reload.
@@ -30,3 +50,6 @@
30
50
  <slot />
31
51
  {/if}
32
52
  </AppLayout>
53
+
54
+ <!-- after the page: a child component runs where it is placed, so the server has collected every key (FallbackLinks) -->
55
+ <FallbackLinks {styles} {plugins} {provides} />
@@ -0,0 +1,163 @@
1
+ <!--
2
+ View catalogue, the list (doc 02 section 7). Theme dev mode only: the generated route imports this file
3
+ dynamically behind `dev`.
4
+ -->
5
+ <svelte:head>
6
+ <title>Views - catalogue</title>
7
+ </svelte:head>
8
+
9
+ <div class="catalogue">
10
+ <header class="head">
11
+ <h1>View catalogue</h1>
12
+ <p class="muted">
13
+ {data.rows.length} of {data.total} views
14
+ <span class="sep">·</span>
15
+ <a href="/__pano/views.json">views.json</a>
16
+ </p>
17
+ </header>
18
+
19
+ <form class="filters" method="get" action="/__pano/views">
20
+ {#each FILTERS as filter (filter.key)}
21
+ <label>
22
+ <span>{filter.label}</span>
23
+ <select name={filter.key} value={data.filters[filter.key]} onchange={(event) => event.currentTarget.form.requestSubmit()}>
24
+ <option value="">all</option>
25
+ {#each data.options[filter.key] as option (option)}
26
+ <option value={option} selected={data.filters[filter.key] === option}>{option === "pano" ? "pano (engine)" : option}</option>
27
+ {/each}
28
+ </select>
29
+ </label>
30
+ {/each}
31
+ {#if data.filters.plugin || data.filters.kind || data.filters.status}
32
+ <a class="reset" href="/__pano/views">clear</a>
33
+ {/if}
34
+ </form>
35
+
36
+ <table>
37
+ <thead>
38
+ <tr>
39
+ <th>View</th>
40
+ <th>Kind</th>
41
+ <th>Contract</th>
42
+ <th>Status</th>
43
+ <th>Sample states</th>
44
+ <th>Badges</th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ {#each data.rows as row (row.id)}
49
+ <tr>
50
+ <td>
51
+ <a class="id" href={row.url}>{row.id}</a>
52
+ {#if row.pluginId}<span class="muted small">{row.pluginId}</span>{/if}
53
+ </td>
54
+ <td>{row.kind}</td>
55
+ <td>{row.contract}</td>
56
+ <td><span class="status" data-status={row.status.replace(" ", "-")}>{row.status}</span></td>
57
+ <td>
58
+ {#each row.states as state (state)}
59
+ <a class="chip" href={stageUrl(row.id, { state })}>{state}</a>
60
+ {:else}
61
+ <span class="muted small"
62
+ >{row.pluginId ? "none: run " : "none: add "}<code>{row.pluginId ? `pano-plugin samples ${row.name}` : `${row.name}.samples.js`}</code></span>
63
+ {/each}
64
+ </td>
65
+ <td>
66
+ {#each row.badges as badge (badge)}
67
+ <span class="badge">{badge}</span>
68
+ {/each}
69
+ </td>
70
+ </tr>
71
+ {:else}
72
+ <tr><td colspan="6" class="muted">No view matches the filters.</td></tr>
73
+ {/each}
74
+ </tbody>
75
+ </table>
76
+ </div>
77
+
78
+ <script>
79
+ import { stageUrl } from "./model.js";
80
+
81
+ let { data } = $props();
82
+
83
+ const FILTERS = [
84
+ { key: "plugin", label: "Plugin" },
85
+ { key: "kind", label: "Kind" },
86
+ { key: "status", label: "Status" },
87
+ ];
88
+ </script>
89
+
90
+ <style>
91
+ .catalogue {
92
+ font-family: system-ui, sans-serif;
93
+ color: var(--bs-body-color, #1c1c1c);
94
+ padding: 1rem 0;
95
+ }
96
+ .head h1 {
97
+ font-size: 1.5rem;
98
+ margin: 0 0 0.25rem;
99
+ }
100
+ .muted {
101
+ opacity: 0.7;
102
+ }
103
+ .small {
104
+ font-size: 0.8rem;
105
+ }
106
+ .sep {
107
+ margin: 0 0.4rem;
108
+ }
109
+ .filters {
110
+ display: flex;
111
+ flex-wrap: wrap;
112
+ gap: 1rem;
113
+ align-items: end;
114
+ margin: 1rem 0;
115
+ }
116
+ .filters label {
117
+ display: grid;
118
+ gap: 0.2rem;
119
+ font-size: 0.8rem;
120
+ }
121
+ .filters select {
122
+ min-width: 11rem;
123
+ padding: 0.3rem 0.4rem;
124
+ }
125
+ table {
126
+ width: 100%;
127
+ border-collapse: collapse;
128
+ font-size: 0.9rem;
129
+ }
130
+ th,
131
+ td {
132
+ text-align: left;
133
+ padding: 0.4rem 0.6rem;
134
+ border-bottom: 1px solid rgba(128, 128, 128, 0.3);
135
+ vertical-align: top;
136
+ }
137
+ .id {
138
+ font-weight: 600;
139
+ margin-right: 0.4rem;
140
+ }
141
+ .chip,
142
+ .badge,
143
+ .status {
144
+ display: inline-block;
145
+ padding: 0.05rem 0.45rem;
146
+ margin: 0 0.2rem 0.2rem 0;
147
+ border-radius: 999px;
148
+ border: 1px solid rgba(128, 128, 128, 0.5);
149
+ font-size: 0.75rem;
150
+ text-decoration: none;
151
+ }
152
+ .status[data-status="overridden"] {
153
+ border-color: #2c8a4b;
154
+ color: #2c8a4b;
155
+ }
156
+ .status[data-status="override-outdated"] {
157
+ border-color: #c0392b;
158
+ color: #c0392b;
159
+ }
160
+ code {
161
+ font-size: 0.8rem;
162
+ }
163
+ </style>
@@ -0,0 +1,355 @@
1
+ <!--
2
+ View catalogue, the stage (doc 02 section 7): one view with one sample state. Theme dev mode only.
3
+
4
+ While this component is mounted the controller registry is in sample mode: every `use()` returns a
5
+ fixed-state controller (the sample's patch merged over its initial state) whose actions only record
6
+ `{ name, args }`, and the real cache is never touched. Leaving the stage turns it off again.
7
+ -->
8
+ <svelte:head>
9
+ <title>{data.id} - catalogue</title>
10
+ </svelte:head>
11
+
12
+ <div class="stage-page" class:bare={data.bare}>
13
+ {#if !data.bare}
14
+ <header class="bar">
15
+ <div>
16
+ <a class="back" href="/__pano/views">views</a>
17
+ <h1>{data.id}</h1>
18
+ <span class="status" data-status={data.row.status.replace(" ", "-")}>{data.row.status}</span>
19
+ <span class="muted small">{data.row.kind} · contract {data.row.contract}</span>
20
+ </div>
21
+
22
+ <nav class="switches" aria-label="Stage options">
23
+ <div>
24
+ <span class="label">State</span>
25
+ {#each data.row.states as state (state)}
26
+ <a class="chip" class:on={state === data.state} href={stageUrl(data.id, { state, palette: data.palette, source: data.source })}>{state}</a>
27
+ {:else}
28
+ <span class="muted small">no samples</span>
29
+ {/each}
30
+ </div>
31
+ <div>
32
+ <span class="label">Palette</span>
33
+ <a class="chip" class:on={!data.palette} href={stageUrl(data.id, { state: data.state, source: data.source })}>theme</a>
34
+ {#each PALETTES as palette (palette)}
35
+ <a class="chip" class:on={palette === data.palette} href={stageUrl(data.id, { state: data.state, palette, source: data.source })}>{palette}</a>
36
+ {/each}
37
+ </div>
38
+ <div>
39
+ <span class="label">Source</span>
40
+ {#each ["theme", "default"] as source (source)}
41
+ <a class="chip" class:on={source === data.source} href={stageUrl(data.id, { state: data.state, palette: data.palette, source })}>{source}</a>
42
+ {/each}
43
+ <a class="chip" href={stageUrl(data.id, { state: data.state, palette: data.palette, source: data.source, bare: true })}>bare</a>
44
+ </div>
45
+ </nav>
46
+ </header>
47
+ {/if}
48
+
49
+ <div class="layout">
50
+ {#key data.stageKey}
51
+ <div class="canvas" data-bs-theme={data.palette ?? undefined} data-pano-stage={data.id} data-pano-state={data.state ?? ""}>
52
+ {#if !sampleReady}
53
+ <!-- sample mode is switched on before the view is created -->
54
+ {:else if !data.View}
55
+ <p class="note">
56
+ <strong>{data.id}</strong> is not loaded in this theme process: its plugin has not registered it (is the plugin installed and its UI built?).
57
+ </p>
58
+ {:else if !data.sample}
59
+ <p class="note">
60
+ <strong>{data.id}</strong> has no sample state{data.row.states.length ? ` named '${data.requestedState}'` : ""}.
61
+ {#if data.row.pluginId}Run <code>pano-plugin samples {data.row.name}</code> in the plugin.{:else}Add <code>{data.row.name}.samples.js</code> to the engine.{/if}
62
+ </p>
63
+ {:else}
64
+ <View {...data.sample.props}>
65
+ <p class="slot-note">default slot content</p>
66
+ </View>
67
+ {/if}
68
+ </div>
69
+ {/key}
70
+
71
+ {#if !data.bare}
72
+ <aside class="panel">
73
+ {#if data.missing.length}
74
+ <section class="warn">
75
+ <h2>Missing props</h2>
76
+ <p>The sample does not give: {data.missing.join(", ")}</p>
77
+ </section>
78
+ {/if}
79
+
80
+ {#if data.row.issues.length}
81
+ <section class="warn">
82
+ <h2>Issues</h2>
83
+ <ul>
84
+ {#each data.row.issues as issue (issue.type + (issue.controller ?? ""))}
85
+ <li><code>{issue.type}</code>{issue.controller ? ` (${issue.controller})` : ""}</li>
86
+ {/each}
87
+ </ul>
88
+ </section>
89
+ {/if}
90
+
91
+ <section>
92
+ <h2>Props contract</h2>
93
+ {#if propEntries.length}
94
+ <dl>
95
+ {#each propEntries as [name, spec] (name)}
96
+ <dt>{name}{spec.required ? " *" : ""}</dt>
97
+ <dd>{spec.text}</dd>
98
+ {/each}
99
+ </dl>
100
+ {:else}
101
+ <p class="muted small">This view takes no props.</p>
102
+ {/if}
103
+ </section>
104
+
105
+ <section>
106
+ <h2>Controllers</h2>
107
+ {#each controllerNames as name (name)}
108
+ <div class="controller">
109
+ <code>{name}</code>
110
+ {#if name in (data.sample?.controllers ?? {})}<span class="muted small">patched: {JSON.stringify(data.sample.controllers[name])}</span>{/if}
111
+ </div>
112
+ {:else}
113
+ <p class="muted small">None used by the sample.</p>
114
+ {/each}
115
+ </section>
116
+
117
+ <section>
118
+ <h2>Recorded calls</h2>
119
+ {#each calls as call, index (index)}
120
+ <div class="call"><code>{call.controller}.{call.name}({call.args.map((arg) => JSON.stringify(arg)).join(", ")})</code></div>
121
+ {:else}
122
+ <p class="muted small">No action called yet.</p>
123
+ {/each}
124
+ </section>
125
+
126
+ <section>
127
+ <h2>Eject</h2>
128
+ <pre class="command">{data.eject}</pre>
129
+ </section>
130
+
131
+ <section>
132
+ <h2>Source <span class="muted small">{data.row.source}</span></h2>
133
+ {#await data.sourceText}
134
+ <p class="muted small">Reading...</p>
135
+ {:then text}
136
+ {#if text}
137
+ <pre class="source">{text}</pre>
138
+ {:else}
139
+ <p class="muted small">The readable source is not available from here.</p>
140
+ {/if}
141
+ {/await}
142
+ </section>
143
+ </aside>
144
+ {/if}
145
+ </div>
146
+ </div>
147
+
148
+ <script>
149
+ import { getContext, onMount, setContext } from "svelte";
150
+ import { derived, readable, writable } from "svelte/store";
151
+ import { list, setSamples, use } from "@panomc/sdk/core/js/ControllerRegistry.js";
152
+
153
+ import { PALETTES, stageUrl } from "./model.js";
154
+
155
+ let { data } = $props();
156
+
157
+ // Sample mode is on before the view is created and off when the stage leaves.
158
+ let sampleReady = $state(false);
159
+
160
+ $effect.pre(() => {
161
+ setSamples(data.sample?.controllers ?? {});
162
+ sampleReady = true;
163
+ });
164
+
165
+ onMount(() => () => setSamples(null));
166
+
167
+ // `session: "guest" | "user"` of a state: the stage's subtree sees that session, the page's own is untouched.
168
+ const FAKE_USER = { id: 1, username: "sample", email: "sample@example.com", permissions: [] };
169
+ const parentSession = getContext("session");
170
+ const sessionMode = writable(null);
171
+
172
+ setContext(
173
+ "session",
174
+ parentSession
175
+ ? derived([parentSession, sessionMode], ([$parent, $mode]) =>
176
+ $mode === "guest" ? { ...$parent, user: null } : $mode === "user" ? { ...$parent, user: $parent?.user ?? FAKE_USER } : $parent,
177
+ )
178
+ : readable(undefined),
179
+ );
180
+
181
+ $effect.pre(() => {
182
+ sessionMode.set(data.sample?.session ?? null);
183
+ });
184
+
185
+ const View = $derived(data.View);
186
+
187
+ const propEntries = $derived(
188
+ Object.entries(data.row.props ?? {}).map(([name, spec]) => [
189
+ name,
190
+ typeof spec === "string"
191
+ ? { required: false, text: spec }
192
+ : { required: spec?.required === true, text: `${spec?.type ?? "any"}${spec?.required ? "" : " (optional)"}` },
193
+ ]),
194
+ );
195
+
196
+ const controllerNames = $derived(
197
+ [...new Set([...Object.keys(data.sample?.controllers ?? {}), ...data.row.controllers])].sort(),
198
+ );
199
+
200
+ // Recorded calls: read from the sample controllers while the stage is up.
201
+ let calls = $state([]);
202
+
203
+ onMount(() => {
204
+ const read = () => {
205
+ const names = new Set([...controllerNames, ...list().filter((c) => c.name.startsWith(`${data.row.ns}/`)).map((c) => c.name)]);
206
+ const out = [];
207
+ for (const name of names) {
208
+ for (const call of use(name)?.calls ?? []) out.push({ controller: name, name: call.name, args: call.args ?? [] });
209
+ }
210
+ if (out.length !== calls.length) calls = out;
211
+ };
212
+ const timer = setInterval(read, 400);
213
+ read();
214
+
215
+ return () => clearInterval(timer);
216
+ });
217
+ </script>
218
+
219
+ <style>
220
+ .stage-page {
221
+ font-family: system-ui, sans-serif;
222
+ color: var(--bs-body-color, #1c1c1c);
223
+ }
224
+ .bar {
225
+ display: flex;
226
+ flex-wrap: wrap;
227
+ gap: 1rem 2rem;
228
+ justify-content: space-between;
229
+ align-items: start;
230
+ padding: 0.75rem 0;
231
+ border-bottom: 1px solid rgba(128, 128, 128, 0.3);
232
+ }
233
+ h1 {
234
+ display: inline;
235
+ font-size: 1.25rem;
236
+ margin: 0 0.5rem;
237
+ }
238
+ .back {
239
+ font-size: 0.85rem;
240
+ }
241
+ .muted {
242
+ opacity: 0.7;
243
+ }
244
+ .small {
245
+ font-size: 0.8rem;
246
+ }
247
+ .switches {
248
+ display: grid;
249
+ gap: 0.35rem;
250
+ }
251
+ .label {
252
+ display: inline-block;
253
+ min-width: 4.5rem;
254
+ font-size: 0.75rem;
255
+ text-transform: uppercase;
256
+ opacity: 0.7;
257
+ }
258
+ .chip,
259
+ .status {
260
+ display: inline-block;
261
+ padding: 0.05rem 0.5rem;
262
+ margin-right: 0.25rem;
263
+ border-radius: 999px;
264
+ border: 1px solid rgba(128, 128, 128, 0.5);
265
+ font-size: 0.75rem;
266
+ text-decoration: none;
267
+ }
268
+ .chip.on {
269
+ background: rgba(128, 128, 128, 0.25);
270
+ font-weight: 600;
271
+ }
272
+ .status[data-status="overridden"] {
273
+ border-color: #2c8a4b;
274
+ color: #2c8a4b;
275
+ }
276
+ .status[data-status="override-outdated"] {
277
+ border-color: #c0392b;
278
+ color: #c0392b;
279
+ }
280
+ .layout {
281
+ display: grid;
282
+ grid-template-columns: minmax(0, 1fr) 22rem;
283
+ gap: 1.5rem;
284
+ margin-top: 1rem;
285
+ }
286
+ .bare .layout {
287
+ display: block;
288
+ margin: 0;
289
+ }
290
+ .canvas {
291
+ min-width: 0;
292
+ padding: 1rem;
293
+ border: 1px dashed rgba(128, 128, 128, 0.5);
294
+ background: var(--bs-body-bg, transparent);
295
+ color: var(--bs-body-color, inherit);
296
+ }
297
+ .bare .canvas {
298
+ border: 0;
299
+ padding: 0;
300
+ }
301
+ .slot-note {
302
+ margin: 0;
303
+ padding: 0.5rem;
304
+ border: 1px dotted rgba(128, 128, 128, 0.5);
305
+ font-size: 0.8rem;
306
+ opacity: 0.7;
307
+ }
308
+ .note {
309
+ margin: 0;
310
+ }
311
+ .panel {
312
+ font-size: 0.85rem;
313
+ min-width: 0;
314
+ }
315
+ .panel h2 {
316
+ font-size: 0.85rem;
317
+ text-transform: uppercase;
318
+ letter-spacing: 0.04em;
319
+ margin: 1rem 0 0.4rem;
320
+ }
321
+ .warn {
322
+ border-left: 3px solid #c0392b;
323
+ padding-left: 0.6rem;
324
+ }
325
+ dl {
326
+ margin: 0;
327
+ }
328
+ dt {
329
+ font-weight: 600;
330
+ font-family: monospace;
331
+ }
332
+ dd {
333
+ margin: 0 0 0.4rem;
334
+ opacity: 0.8;
335
+ }
336
+ .command,
337
+ .source {
338
+ margin: 0;
339
+ padding: 0.5rem;
340
+ background: rgba(128, 128, 128, 0.15);
341
+ overflow: auto;
342
+ max-height: 24rem;
343
+ font-size: 0.75rem;
344
+ }
345
+ .controller,
346
+ .call {
347
+ margin-bottom: 0.25rem;
348
+ word-break: break-word;
349
+ }
350
+ @media (max-width: 900px) {
351
+ .layout {
352
+ grid-template-columns: minmax(0, 1fr);
353
+ }
354
+ }
355
+ </style>