@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,378 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Generates the machine-readable parts of skin-contract.json and the engine's view table
4
+ * (doc 01 §8, slice 7).
5
+ *
6
+ * For every entry of `views` it reads the DEFAULT source (a part under `src/lib/views/parts`, a
7
+ * page view under `src/lib/views`, or a component under `src/lib/components`) and fills
8
+ *
9
+ * source path of the default markup, relative to the package
10
+ * uses engine views the default (and its controller) imports - the registry preloads them
11
+ * hooks `<Hook name="...">` names
12
+ * slotProps `<slot>` name -> prop names, for the slots a theme must keep filling
13
+ *
14
+ * It also writes `src/lib/views/parts/engine-views.generated.js`, the table that is passed to
15
+ * `registerEngineViews()` (`{ [name]: { contract, component: thunk, uses, hooks } }`).
16
+ *
17
+ * The prop set is the one thing a human writes (`props`: name -> description). The generator
18
+ * compares it with the source and keeps a lock per entry: the prop set recorded when the
19
+ * `contract` number was last raised. Changing the set without raising `contract` is refused.
20
+ *
21
+ * node bin/generate-contract.js fill the generated fields, the lock and the table
22
+ * node bin/generate-contract.js --check change nothing; exit 1 listing every problem
23
+ *
24
+ * JavaScript only; no dependencies.
25
+ */
26
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
27
+ import { dirname, join } from "node:path";
28
+ import { fileURLToPath } from "node:url";
29
+
30
+ export const pkgDir = join(dirname(fileURLToPath(import.meta.url)), "..");
31
+
32
+ const CONTRACT_FILE = "skin-contract.json";
33
+ const TABLE_FILE = "src/lib/views/parts/engine-views.generated.js";
34
+
35
+ /** Directories of default sources, in lookup order, relative to the package. */
36
+ const SOURCE_DIRS = ["src/lib/views/parts", "src/lib/views", "src/lib/components"];
37
+ /** Directories where a controller (the component a theme imports today) may live. */
38
+ const CONTROLLER_DIRS = ["src/lib/components", "src/lib/components/modals"];
39
+
40
+ const read = (dir, rel) => readFileSync(join(dir, rel), "utf-8");
41
+
42
+ /** Strips HTML comments and string-free noise that would confuse the scans below. */
43
+ const stripComments = (source) => source.replace(/<!--[\s\S]*?-->/g, "");
44
+
45
+ /** @returns {{ script: string, markup: string }} instance script text and the rest of the file */
46
+ function splitSource(source) {
47
+ const clean = stripComments(source);
48
+ let script = "";
49
+ const markup = clean.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g, (_all, attrs, body) => {
50
+ if (!/context\s*=\s*["']module["']/.test(attrs)) script += `${body}\n`;
51
+ return "";
52
+ });
53
+ return { script, markup };
54
+ }
55
+
56
+ /** Names bound by a destructuring pattern `{ a, b = 1, c: d, ...rest }` (the prop names, i.e. the keys). */
57
+ function destructuredNames(pattern) {
58
+ const names = [];
59
+ let depth = 0;
60
+ let current = "";
61
+ const parts = [];
62
+ for (const ch of pattern) {
63
+ if (ch === "{" || ch === "[" || ch === "(") depth++;
64
+ if (ch === "}" || ch === "]" || ch === ")") depth--;
65
+ if (ch === "," && depth === 0) {
66
+ parts.push(current);
67
+ current = "";
68
+ } else current += ch;
69
+ }
70
+ if (current.trim()) parts.push(current);
71
+ for (const part of parts) {
72
+ const text = part.trim();
73
+ if (!text || text.startsWith("...")) continue;
74
+ const m = /^([A-Za-z_$][\w$]*)/.exec(text);
75
+ if (m) names.push(m[1]);
76
+ }
77
+ return names;
78
+ }
79
+
80
+ /** Prop names of a component: `export let a`, or `let { a, b } = $props()`. */
81
+ export function propNamesOf(source) {
82
+ const { script } = splitSource(source);
83
+ const names = new Set();
84
+ for (const m of script.matchAll(/export\s+let\s+/g)) {
85
+ // the declaration runs to the first `;` or line end outside brackets
86
+ let depth = 0;
87
+ let end = m.index + m[0].length;
88
+ for (; end < script.length; end++) {
89
+ const ch = script[end];
90
+ if ("{[(".includes(ch)) depth++;
91
+ else if ("}])".includes(ch)) depth--;
92
+ else if (depth <= 0 && (ch === ";" || ch === "\n")) break;
93
+ }
94
+ for (const decl of splitTopLevel(script.slice(m.index + m[0].length, end))) {
95
+ const id = /^\s*([A-Za-z_$][\w$]*)/.exec(decl);
96
+ if (id) names.add(id[1]);
97
+ }
98
+ }
99
+ for (const m of script.matchAll(/let\s*\{([\s\S]*?)\}\s*=\s*\$props\(\)/g)) {
100
+ for (const name of destructuredNames(m[1])) names.add(name);
101
+ }
102
+ return [...names].sort();
103
+ }
104
+
105
+ function splitTopLevel(text) {
106
+ const out = [];
107
+ let depth = 0;
108
+ let current = "";
109
+ for (const ch of text) {
110
+ if ("{[(".includes(ch)) depth++;
111
+ if ("}])".includes(ch)) depth--;
112
+ if (ch === "," && depth === 0) {
113
+ out.push(current);
114
+ current = "";
115
+ } else current += ch;
116
+ }
117
+ if (current.trim()) out.push(current);
118
+ return out;
119
+ }
120
+
121
+ /** `<Hook name="x" />` names, in order of first appearance. */
122
+ export function hooksOf(source) {
123
+ const { markup } = splitSource(source);
124
+ const names = [];
125
+ for (const m of markup.matchAll(/<Hook\b[^>]*?\bname\s*=\s*(?:"([^"]+)"|'([^']+)'|\{\s*["']([^"']+)["']\s*\})/g)) {
126
+ const name = m[1] ?? m[2] ?? m[3];
127
+ if (!names.includes(name)) names.push(name);
128
+ }
129
+ return names;
130
+ }
131
+
132
+ /** `<slot name="x" a={b} {c}>` -> { x: ["a", "c"] }; the unnamed slot is "default". */
133
+ export function slotPropsOf(source) {
134
+ const { markup } = splitSource(source);
135
+ /** @type {Record<string, string[]>} */
136
+ const out = {};
137
+ for (const m of markup.matchAll(/<slot\b([^>]*?)\/?>/g)) {
138
+ const attrs = m[1];
139
+ const named = /\bname\s*=\s*(?:"([^"]+)"|'([^']+)')/.exec(attrs);
140
+ const slot = named ? (named[1] ?? named[2]) : "default";
141
+ const props = new Set(out[slot] ?? []);
142
+ for (const a of attrs.matchAll(/(?:^|\s)(?:([A-Za-z_][\w-]*)\s*=|\{\s*([A-Za-z_$][\w$]*)\s*\})/g)) {
143
+ const name = a[1] ?? a[2];
144
+ if (name && name !== "name") props.add(name);
145
+ }
146
+ out[slot] = [...props].sort();
147
+ }
148
+ return Object.fromEntries(Object.entries(out).sort(([a], [b]) => a.localeCompare(b)));
149
+ }
150
+
151
+ /**
152
+ * The engine views a source renders: a component imported from `<Name>.svelte` that is placed as a
153
+ * tag (`<Name ...>`, `<svelte:component this={Name}>`), or imported in the module script (a default
154
+ * the file hands out, like the toast container's `DefaultToast`). An import that only reads a
155
+ * constant from a controller (`TicketStatuses`) is not a use.
156
+ * @returns {Set<string>} basenames
157
+ */
158
+ export function renderedComponents(source) {
159
+ const clean = stripComments(source);
160
+ const used = new Set();
161
+ const scripts = [...clean.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/g)].map((m) => ({
162
+ module: /context\s*=\s*["']module["']/.test(m[1]),
163
+ body: m[2],
164
+ }));
165
+ const markup = clean.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/g, "");
166
+ for (const { module, body } of scripts) {
167
+ for (const m of body.matchAll(/import\s+([A-Za-z_$][\w$]*)\s*(?:,\s*\{[^}]*\})?\s*from\s*["']([^"']+\.svelte)["']/g)) {
168
+ const [, local, path] = m;
169
+ const name = path.slice(path.lastIndexOf("/") + 1, -".svelte".length);
170
+ const placed = new RegExp(`<${local}[\\s/>]|this=\\{${local}\\}`).test(markup);
171
+ if (module || placed) used.add(name);
172
+ }
173
+ }
174
+ return used;
175
+ }
176
+
177
+ /** The default source of a view, relative to the package, or null. */
178
+ export function defaultSourceOf(name, dir = pkgDir) {
179
+ for (const base of SOURCE_DIRS) {
180
+ const rel = `${base}/${name}.svelte`;
181
+ if (existsSync(join(dir, rel))) return rel;
182
+ }
183
+ return null;
184
+ }
185
+
186
+ /** The controller file of a view when it differs from the default source (the thing themes import). */
187
+ function controllerOf(name, source, dir) {
188
+ for (const base of CONTROLLER_DIRS) {
189
+ const rel = `${base}/${name}.svelte`;
190
+ if (rel !== source && existsSync(join(dir, rel))) return rel;
191
+ }
192
+ return null;
193
+ }
194
+
195
+ /**
196
+ * What the sources say about every view of the contract.
197
+ * @param {{ views: Record<string, any> }} contract
198
+ * @param {string} [dir]
199
+ */
200
+ export function deriveAll(contract, dir = pkgDir) {
201
+ const names = Object.keys(contract.views);
202
+ /** @type {Record<string, { source: string|null, props: string[], hooks: string[], slotProps: Record<string,string[]>, uses: string[] }>} */
203
+ const out = {};
204
+ for (const name of names) {
205
+ const source = defaultSourceOf(name, dir);
206
+ if (!source) {
207
+ out[name] = { source: null, props: [], hooks: [], slotProps: {}, uses: [] };
208
+ continue;
209
+ }
210
+ const text = read(dir, source);
211
+ const controller = controllerOf(name, source, dir);
212
+ const imported = new Set(renderedComponents(text));
213
+ if (controller) for (const n of renderedComponents(read(dir, controller))) imported.add(n);
214
+ imported.delete(name);
215
+ out[name] = {
216
+ source,
217
+ props: propNamesOf(text),
218
+ hooks: hooksOf(text),
219
+ slotProps: slotPropsOf(text),
220
+ uses: names.filter((n) => imported.has(n)).sort(),
221
+ };
222
+ }
223
+ return out;
224
+ }
225
+
226
+ const sameSet = (a, b) => a.length === b.length && [...a].sort().every((v, i) => v === [...b].sort()[i]);
227
+
228
+ /**
229
+ * Applies the derived data to a contract object and checks the rules.
230
+ * @param {any} contract parsed skin-contract.json (not modified)
231
+ * @param {ReturnType<typeof deriveAll>} derived
232
+ * @returns {{ contract: any, problems: string[] }}
233
+ */
234
+ export function applyDerived(contract, derived) {
235
+ const problems = [];
236
+ const next = structuredClone(contract);
237
+ const views = {};
238
+
239
+ for (const [name, entry] of Object.entries(next.views)) {
240
+ const d = derived[name];
241
+ if (!d.source) {
242
+ problems.push(`${name}: no default source found (looked for ${name}.svelte in ${SOURCE_DIRS.join(", ")})`);
243
+ views[name] = entry;
244
+ continue;
245
+ }
246
+
247
+ const recorded = Object.keys(entry.props ?? {}).sort();
248
+ // Page views take their data through `$$props` in a few places; their listed props are the
249
+ // contract, so the source comparison applies to entries that declare their props.
250
+ if (!sameSet(recorded, d.props)) {
251
+ const missing = d.props.filter((p) => !recorded.includes(p));
252
+ const extra = recorded.filter((p) => !d.props.includes(p));
253
+ problems.push(
254
+ `${name}: the props of ${d.source} differ from skin-contract.json` +
255
+ (missing.length ? ` - not described: ${missing.join(", ")}` : "") +
256
+ (extra.length ? ` - not in the source: ${extra.join(", ")}` : "") +
257
+ `; edit "props" and raise "contract" (now ${entry.contract ?? 1})`,
258
+ );
259
+ }
260
+
261
+ const contractNumber = entry.contract ?? 1;
262
+ const lock = entry.locked;
263
+ let nextLock = lock;
264
+ if (!lock) {
265
+ nextLock = { contract: contractNumber, props: recorded };
266
+ } else if (!sameSet(lock.props, recorded)) {
267
+ if (contractNumber > lock.contract) nextLock = { contract: contractNumber, props: recorded };
268
+ else
269
+ problems.push(
270
+ `${name}: the prop set changed (${lock.props.join(", ")} -> ${recorded.join(", ")}) but "contract" is still ${contractNumber}; raise it to ${lock.contract + 1} (themes that override ${name} keep the default view until they accept the new contract)`,
271
+ );
272
+ } else if (contractNumber > lock.contract) {
273
+ nextLock = { contract: contractNumber, props: recorded };
274
+ } else if (contractNumber < lock.contract) {
275
+ problems.push(`${name}: "contract" went down (${lock.contract} -> ${contractNumber})`);
276
+ }
277
+
278
+ const { kind, contract: _c, source: _s, uses: _u, hooks: _h, slotProps: _sp, props, locked: _l, ...other } = entry;
279
+ views[name] = {
280
+ ...(kind ? { kind } : {}),
281
+ contract: contractNumber,
282
+ source: d.source,
283
+ uses: d.uses,
284
+ hooks: d.hooks,
285
+ slotProps: d.slotProps,
286
+ ...other,
287
+ props,
288
+ locked: nextLock,
289
+ };
290
+ }
291
+
292
+ next.views = views;
293
+ // Kept for `theme-core check` / `list-views`, which still read it: the component-kind views.
294
+ next.registry_components = Object.entries(views)
295
+ .filter(([, v]) => v.kind === "component")
296
+ .map(([name]) => name);
297
+ return { contract: next, problems };
298
+ }
299
+
300
+ /** The text of the generated engine table. */
301
+ export function engineTableSource(contract) {
302
+ const lines = [
303
+ "// Generated by bin/generate-contract.js from skin-contract.json - do not edit.",
304
+ "// The engine's own views for registerEngineViews() (doc 01 section 4): the default of a view",
305
+ "// is its markup file (a part when the view was split into controller + part).",
306
+ "",
307
+ "export const engineViews = {",
308
+ ];
309
+ for (const [name, entry] of Object.entries(contract.views)) {
310
+ const rel = entry.source.replace(/^src\/lib\//, "../../");
311
+ const path = rel.startsWith("../../views/parts/") ? `./${rel.slice("../../views/parts/".length)}` : rel.replace("../../views/", "../");
312
+ const fields = [`contract: ${entry.contract ?? 1}`, `component: () => import(${JSON.stringify(path)})`];
313
+ if (entry.uses?.length) fields.push(`uses: ${JSON.stringify(entry.uses)}`);
314
+ if (entry.hooks?.length) fields.push(`hooks: ${JSON.stringify(entry.hooks)}`);
315
+ lines.push(` ${JSON.stringify(name)}: { ${fields.join(", ")} },`);
316
+ }
317
+ lines.push("};", "");
318
+ return lines.join("\n");
319
+ }
320
+
321
+ /**
322
+ * JSON with a one-space indent (the file's existing style); arrays of plain values under
323
+ * `settings_tabs` and inside a view entry (`uses`, `hooks`, `slotProps`, `locked`) stay on one line.
324
+ */
325
+ export function stringify(contract) {
326
+ const flat = (v) => Array.isArray(v) && v.every((x) => x === null || typeof x !== "object");
327
+ const emit = (value, depth, compact) => {
328
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
329
+ const pad = " ".repeat(depth + 1);
330
+ const end = " ".repeat(depth);
331
+ if (Array.isArray(value)) {
332
+ if (value.length === 0) return "[]";
333
+ if (compact && flat(value)) return `[${value.map((x) => JSON.stringify(x)).join(", ")}]`;
334
+ return `[\n${value.map((x) => pad + emit(x, depth + 1, compact)).join(",\n")}\n${end}]`;
335
+ }
336
+ const keys = Object.keys(value);
337
+ if (keys.length === 0) return "{}";
338
+ return `{\n${keys.map((k) => `${pad}${JSON.stringify(k)}: ${emit(value[k], depth + 1, compact || k === "settings_tabs" || (depth === 2 && k !== "props"))}`).join(",\n")}\n${end}}`;
339
+ };
340
+ return `${emit(contract, 0, false)}\n`;
341
+ }
342
+
343
+ /**
344
+ * Runs the generator.
345
+ * @param {{ dir?: string, check?: boolean }} [options]
346
+ * @returns {{ problems: string[], changed: string[] }}
347
+ */
348
+ export function generate({ dir = pkgDir, check = false } = {}) {
349
+ const current = JSON.parse(read(dir, CONTRACT_FILE));
350
+ const derived = deriveAll(current, dir);
351
+ const { contract, problems } = applyDerived(current, derived);
352
+
353
+ /** @type {string[]} */
354
+ const changed = [];
355
+ const files = [
356
+ [CONTRACT_FILE, stringify(contract)],
357
+ [TABLE_FILE, engineTableSource(contract)],
358
+ ];
359
+ for (const [rel, text] of files) {
360
+ const existing = existsSync(join(dir, rel)) ? read(dir, rel) : null;
361
+ if (existing === text) continue;
362
+ changed.push(rel);
363
+ // Never write a contract that breaks a rule: the human edit comes first.
364
+ if (!check && problems.length === 0) writeFileSync(join(dir, rel), text);
365
+ }
366
+ return { problems, changed };
367
+ }
368
+
369
+ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
370
+ const check = process.argv.includes("--check");
371
+ const { problems, changed } = generate({ check });
372
+ for (const p of problems) console.error(`contract: ${p}`);
373
+ if (check && changed.length) {
374
+ for (const rel of changed) console.error(`contract: ${rel} is out of date; run: node bin/generate-contract.js`);
375
+ }
376
+ if (problems.length || (check && changed.length)) process.exit(1);
377
+ if (!check) console.log(changed.length ? `updated ${changed.join(", ")}` : "skin-contract.json is up to date");
378
+ }
@@ -1,6 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
2
2
  import { dirname, join } from "path";
3
3
  import { fileURLToPath } from "url";
4
+ import { createRequire } from "module";
4
5
 
5
6
  const __filename = fileURLToPath(import.meta.url);
6
7
  const __dirname = dirname(__filename);
@@ -44,6 +45,18 @@ function getLicenseText(packagePath) {
44
45
  return null;
45
46
  }
46
47
 
48
+ /**
49
+ * Folder of an installed dependency, found the way Node resolves it from the project (a hoisted workspace keeps
50
+ * it in a parent `node_modules`). A package whose `exports` hide its package.json falls back to the local folder.
51
+ */
52
+ function findPackageDir(root, name) {
53
+ try {
54
+ return dirname(createRequire(join(root, "package.json")).resolve(`${name}/package.json`));
55
+ } catch {
56
+ return join(root, "node_modules", name);
57
+ }
58
+ }
59
+
47
60
  export function collectLicenses(outputDir = null) {
48
61
  const packageJsonPath = join(projectRoot, "package.json");
49
62
  const packageJson = readPackageJson(packageJsonPath);
@@ -58,10 +71,9 @@ export function collectLicenses(outputDir = null) {
58
71
  };
59
72
 
60
73
  const licenses = [];
61
- const nodeModulesPath = join(projectRoot, "node_modules");
62
74
 
63
75
  for (const [packageName, version] of Object.entries(allDependencies)) {
64
- const packagePath = join(nodeModulesPath, packageName);
76
+ const packagePath = findPackageDir(projectRoot, packageName);
65
77
  const packageJsonPath = join(packagePath, "package.json");
66
78
 
67
79
  if (!existsSync(packageJsonPath)) {
@@ -43,6 +43,11 @@ const defaultExportSpecs = new Set([
43
43
  "@panomc/sdk/utils/tooltip",
44
44
  ]);
45
45
 
46
+ // Runtime specifiers whose SDK module is written by a later unit of the open
47
+ // front-end plan. Until the file exists their shim is emitted with no exports
48
+ // (and a warning) so the generator keeps working; it fills in on the next run.
49
+ const pendingSpecs = new Set(["@panomc/sdk/controllers"]);
50
+
46
51
  const identifierRe = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
47
52
 
48
53
  // Names that parse as IdentifierName but cannot be declared with `const` — they must
@@ -68,15 +73,28 @@ async function enumerateExports(spec) {
68
73
  }
69
74
  writeFileSync(entryPath, entrySource);
70
75
 
71
- const result = await Bun.build({
72
- entrypoints: [entryPath],
73
- target: "browser",
74
- format: "esm",
75
- splitting: false,
76
- minify: false,
77
- // The bundle is only scanned for its export list, never executed or shipped.
78
- outdir: undefined,
79
- });
76
+ let result;
77
+ try {
78
+ result = await Bun.build({
79
+ entrypoints: [entryPath],
80
+ target: "browser",
81
+ format: "esm",
82
+ splitting: false,
83
+ minify: false,
84
+ // The bundle is only scanned for its export list, never executed or shipped.
85
+ outdir: undefined,
86
+ });
87
+ } catch (error) {
88
+ // Newer Bun versions throw on a failed build instead of returning success: false.
89
+ result = { success: false, logs: [error] };
90
+ }
91
+
92
+ if (!result.success && pendingSpecs.has(spec)) {
93
+ console.warn(
94
+ `Warning: '${spec}' does not resolve yet; emitting its shim without exports.`,
95
+ );
96
+ return [];
97
+ }
80
98
 
81
99
  if (!result.success) {
82
100
  console.error(`Failed to bundle '${spec}' for export enumeration:`);
package/bin/new.js CHANGED
@@ -6,6 +6,9 @@
6
6
  * bunx @panomc/theme-core new my-theme npm-published core (default)
7
7
  * bunx @panomc/theme-core new my-theme --local file: links into a local theme-core
8
8
  * checkout (this workspace)
9
+ * bunx @panomc/theme-core new my-theme --bare a theme without Bootstrap and Font Awesome: provides is
10
+ * false, src/styles/tokens.css holds every --pano-* token
11
+ * (doc 03 sections 4.1, 4.5)
9
12
  *
10
13
  * The result runs immediately and looks like vanilla; the author's job starts
11
14
  * at src/styles/tokens.scss (Tier 1) and grows through eject-view (Tier 2).
@@ -38,6 +41,7 @@ const require = createRequire(import.meta.url);
38
41
  const args = process.argv.slice(2);
39
42
  const nameArg = args.find((a) => !a.startsWith("-"));
40
43
  const local = args.includes("--local") || corePkg.version === "0.0.0-development";
44
+ const bare = args.includes("--bare");
41
45
 
42
46
  const KEBAB = /^[a-z][a-z0-9-]*$/;
43
47
  const titleFrom = (name) =>
@@ -164,6 +168,49 @@ function collectTokens() {
164
168
  return lines.join("\n");
165
169
  }
166
170
 
171
+ // ---- bare theme: the tokens, light values ------------------------------------
172
+ // `pano-tokens.css` (generated by the engine) holds every `--pano-*` token per palette. A bare theme starts from the
173
+ // light values, written into its own `src/styles/tokens.css`, so the first render matches a light theme and the
174
+ // author edits values in place.
175
+ function collectLightTokens() {
176
+ try {
177
+ const sdkDir = dirname(require.resolve("@panomc/sdk/package.json"));
178
+ const css = readFileSync(join(sdkDir, "core", "css", "pano-tokens.css"), "utf-8");
179
+ const block = css.match(/:root,\s*\[data-bs-theme=['"]light['"]\]\s*\{([^}]*)\}/)?.[1] ?? "";
180
+
181
+ return [...block.matchAll(/(--pano-[\w-]+)\s*:\s*([^;]+);/g)].map(([, token, value]) => [token, value.trim()]);
182
+ } catch {
183
+ return [];
184
+ }
185
+ }
186
+
187
+ function bareTokensCss() {
188
+ const tokens = collectLightTokens();
189
+ const lines = [
190
+ `/* Design tokens of ${title}.`,
191
+ " *",
192
+ " * Every --pano-* variable the engine and the plugins read. The values below are the light palette; change them",
193
+ " * in place. A theme that honours the admin's theme colour adds one block per palette, for example",
194
+ " * [data-bs-theme='copper'] { --pano-color-primary: #b87333; }",
195
+ " * (palettes: light, dark, copper, emerald, midnight, crimson). Anything you do not set keeps the engine's value. */",
196
+ ":root {",
197
+ ...tokens.map(([token, value]) => ` ${token}: ${value};`),
198
+ "}",
199
+ "",
200
+ ];
201
+
202
+ if (tokens.length === 0) {
203
+ lines.splice(
204
+ 8,
205
+ 0,
206
+ " /* (token list unavailable at scaffold time: copy the :root block of",
207
+ " node_modules/@panomc/sdk/core/css/pano-tokens.css here) */",
208
+ );
209
+ }
210
+
211
+ return lines.join("\n");
212
+ }
213
+
167
214
  // ---- files ------------------------------------------------------------------
168
215
  const FILES = {
169
216
  "manifest.json": JSON.stringify(
@@ -204,7 +251,8 @@ export default {
204
251
  type: "module",
205
252
  scripts: {
206
253
  dev: "vite dev --host=0.0.0.0 --port 3000",
207
- "dev:ui": 'concurrently "bun run watch:ui" "bun run dev"',
254
+ "dev:ui":
255
+ 'bun node_modules/@panomc/theme-core/bin/theme-core.js dev-hint --port 3000 && concurrently "bun run watch:ui" "bun run dev"',
208
256
  "watch:ui":
209
257
  "sass src/styles/style.scss static/style.css --watch --load-path=. --load-path=node_modules --quiet-deps --silence-deprecation=import --no-source-map",
210
258
  "build:ui":
@@ -235,6 +283,9 @@ export default {
235
283
  "svelte-preprocess": corePkg.peerDependencies["svelte-preprocess"],
236
284
  vite: corePkg.peerDependencies["vite"],
237
285
  },
286
+ // --local: the engine asks for @panomc/sdk as a workspace package, which cannot resolve outside the workspace;
287
+ // the override points every request for it at the local sdk.
288
+ ...(local ? { overrides: { "@panomc/sdk": sdkDep } } : {}),
238
289
  trustedDependencies: ["@parcel/watcher", "es5-ext", "esbuild", "svelte-preprocess"],
239
290
  },
240
291
  null,
@@ -257,6 +308,12 @@ export default createViteConfig();
257
308
  + "VITE_COOKIE_PREFIX=pano_\n\n"
258
309
  + "VITE_UI_URL=/\nVITE_PANEL_URL=/panel\nVITE_SETUP_URL=/\n",
259
310
 
311
+ // --local: bun's default (isolated) linker copies a file: package only on the second install, so the first
312
+ // postinstall runs against an empty folder. The hoisted layout copies it at once.
313
+ ...(local
314
+ ? { "bunfig.toml": '[install]\n# the local engine is a file: package; the hoisted layout installs it in one pass\nlinker = "hoisted"\n' }
315
+ : {}),
316
+
260
317
  ".gitignore": `node_modules/
261
318
  build/
262
319
  .svelte-kit/
@@ -346,6 +403,46 @@ bun run build && bun run package
346
403
  `,
347
404
  };
348
405
 
406
+ // ---- bare variant -----------------------------------------------------------
407
+ // A theme that ships no Bootstrap and no Font Awesome of its own: `provides` tells the engine to give every default
408
+ // plugin view its scoped fallback sheet (doc 03 section 4), and the author's file is src/styles/tokens.css.
409
+ if (bare) {
410
+ delete FILES["src/styles/tokens.scss"];
411
+
412
+ FILES["src/styles/tokens.css"] = bareTokensCss();
413
+
414
+ FILES["theme.config.js"] = `/**
415
+ * ${title} — bare theme on @panomc/theme-core: no Bootstrap, no Font Awesome.
416
+ *
417
+ * \`provides\` tells the engine this theme ships neither, so every default plugin view gets its own small
418
+ * stylesheet, scoped to that view and bound to the --pano-* tokens in src/styles/tokens.css.
419
+ * Tier 1: edit src/styles/tokens.css. Tier 2: eject a view and register it here:
420
+ * bunx @panomc/theme-core eject-view LoginView
421
+ */
422
+ export default {
423
+ provides: { bootstrap: false, fontawesome: false },
424
+ views: {},
425
+ };
426
+ `;
427
+
428
+ FILES["src/styles/style.scss"] = `// The design tokens (--pano-*): everything the engine's default views and the plugins read.
429
+ @use "tokens";
430
+
431
+ // ${title}'s own styles go below. There is no Bootstrap here: write the markup of your views and
432
+ // the layout of the page yourself, and use the tokens (var(--pano-color-primary), var(--pano-radius), ...).
433
+ `;
434
+
435
+ const pkg = JSON.parse(FILES["package.json"]);
436
+
437
+ delete pkg.devDependencies.bootstrap;
438
+ delete pkg.devDependencies["animate.css"];
439
+ FILES["package.json"] = JSON.stringify(pkg, null, 2) + "\n";
440
+
441
+ FILES["README.md"] = FILES["README.md"]
442
+ .replace("- Tier 1: edit `src/styles/tokens.scss`.", "- Tier 1: edit `src/styles/tokens.css` (every `--pano-*` token, light values).")
443
+ .replace("A Pano theme", "A bare Pano theme (no Bootstrap, no Font Awesome)");
444
+ }
445
+
349
446
  // ---- scaffold ---------------------------------------------------------------
350
447
  function scaffold() {
351
448
  for (const [rel, content] of Object.entries(FILES)) {
@@ -410,7 +507,9 @@ if (interactive) {
410
507
  ` ${pc.cyan("bun run dev:ui")} ${pc.dim("# needs a Pano backend (VITE_API_URL in .env)")}`,
411
508
  "",
412
509
  pc.bold("Make it yours:"),
413
- ` ${pc.cyan("src/styles/tokens.scss")} ${pc.dim("colors / fonts / radius (Tier 1)")}`,
510
+ bare
511
+ ? ` ${pc.cyan("src/styles/tokens.css")} ${pc.dim("every --pano-* token (Tier 1)")}`
512
+ : ` ${pc.cyan("src/styles/tokens.scss")} ${pc.dim("colors / fonts / radius (Tier 1)")}`,
414
513
  ` ${pc.cyan("bunx @panomc/theme-core list-views")} ${pc.dim("what you can override")}`,
415
514
  ` ${pc.cyan("bunx @panomc/theme-core eject-view HomeView")} ${pc.dim("own a page's markup (Tier 2)")}`,
416
515
  ].join("\n"),
@@ -8,17 +8,31 @@
8
8
  * (The build itself is reproducible because the core svelte-config factory
9
9
  * pins kit.version.name; see docs/P0-SPIKE.md.)
10
10
  *
11
+ * `check.js --strict` runs first and a failure stops the packaging, so every published theme passes the
12
+ * same contract check.
13
+ *
11
14
  * Usage: theme-core package [outfile.zip] (default: <id>-<version>.zip)
12
15
  */
13
- import { execFileSync } from "node:child_process";
16
+ import { execFileSync, spawnSync } from "node:child_process";
14
17
  import { existsSync, readFileSync, rmSync, utimesSync, readdirSync, statSync } from "node:fs";
15
- import { join, resolve } from "node:path";
18
+ import { dirname, join, resolve } from "node:path";
19
+ import { fileURLToPath } from "node:url";
16
20
  import { pc } from "./ui.js";
17
21
 
18
22
  const ROOT = process.cwd();
19
23
 
20
24
  const BUILD = join(ROOT, "build");
21
25
 
26
+ const checked = spawnSync(process.execPath, [join(dirname(fileURLToPath(import.meta.url)), "check.js"), "--strict"], {
27
+ stdio: "inherit",
28
+ cwd: ROOT,
29
+ });
30
+
31
+ if (checked.status !== 0) {
32
+ console.error(`[theme-core] \`check --strict\` failed — nothing was packaged; fix the problems above and run \`theme-core package\` again`);
33
+ process.exit(checked.status ?? 1);
34
+ }
35
+
22
36
  if (!existsSync(join(BUILD, "manifest.json"))) {
23
37
  console.error("[theme-core] build/manifest.json missing — run `bun run build` first");
24
38
  process.exit(1);