waybetter 0.1.1 → 0.6.0

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 (515) hide show
  1. package/README.md +140 -6
  2. package/bin/waybetter.mjs +46 -0
  3. package/build/runtime.mjs +105 -0
  4. package/cli/buildenv.mjs +130 -0
  5. package/cli/dev.mjs +97 -0
  6. package/cli/i18n.mjs +382 -0
  7. package/cli/manifests.mjs +383 -0
  8. package/cli/privacy.mjs +768 -0
  9. package/cli/release.mjs +444 -0
  10. package/cli/remote.mjs +260 -0
  11. package/cli/store.mjs +326 -0
  12. package/cli/strings.mjs +121 -0
  13. package/dist/runtime/column.d.ts +93 -0
  14. package/dist/runtime/column.js +451 -0
  15. package/dist/runtime/column.js.map +1 -0
  16. package/dist/runtime/commandReport.d.ts +19 -0
  17. package/dist/runtime/commandReport.js +47 -0
  18. package/dist/runtime/commandReport.js.map +1 -0
  19. package/dist/runtime/commands.d.ts +72 -0
  20. package/dist/runtime/commands.js +214 -0
  21. package/dist/runtime/commands.js.map +1 -0
  22. package/dist/runtime/devErrors.d.ts +16 -0
  23. package/dist/runtime/devErrors.js +30 -0
  24. package/dist/runtime/devErrors.js.map +1 -0
  25. package/dist/runtime/domHub.d.ts +21 -0
  26. package/dist/runtime/domHub.js +139 -4
  27. package/dist/runtime/domHub.js.map +1 -1
  28. package/dist/runtime/featureModules.d.ts +157 -0
  29. package/dist/runtime/featureModules.js +484 -0
  30. package/dist/runtime/featureModules.js.map +1 -0
  31. package/dist/runtime/featureTable.d.ts +144 -0
  32. package/dist/runtime/featureTable.js +223 -0
  33. package/dist/runtime/featureTable.js.map +1 -0
  34. package/dist/runtime/fonts.d.ts +22 -0
  35. package/dist/runtime/fonts.js +72 -0
  36. package/dist/runtime/fonts.js.map +1 -0
  37. package/dist/runtime/i18n.d.ts +138 -0
  38. package/dist/runtime/i18n.js +614 -0
  39. package/dist/runtime/i18n.js.map +1 -0
  40. package/dist/runtime/i18nCheck.d.ts +30 -0
  41. package/dist/runtime/i18nCheck.js +224 -0
  42. package/dist/runtime/i18nCheck.js.map +1 -0
  43. package/dist/runtime/pageLang.d.ts +8 -0
  44. package/dist/runtime/pageLang.js +64 -0
  45. package/dist/runtime/pageLang.js.map +1 -0
  46. package/dist/runtime/pageStrings.d.ts +35 -0
  47. package/dist/runtime/pageStrings.js +76 -0
  48. package/dist/runtime/pageStrings.js.map +1 -0
  49. package/dist/runtime/panelButton.d.ts +33 -0
  50. package/dist/runtime/panelButton.js +83 -0
  51. package/dist/runtime/panelButton.js.map +1 -0
  52. package/dist/runtime/permissions.d.ts +47 -0
  53. package/dist/runtime/permissions.js +141 -0
  54. package/dist/runtime/permissions.js.map +1 -0
  55. package/dist/runtime/pluginApi.d.ts +51 -2
  56. package/dist/runtime/pluginApi.js +137 -22
  57. package/dist/runtime/pluginApi.js.map +1 -1
  58. package/dist/runtime/pluginI18n.d.ts +29 -0
  59. package/dist/runtime/pluginI18n.js +119 -0
  60. package/dist/runtime/pluginI18n.js.map +1 -0
  61. package/dist/runtime/settingsForm.d.ts +66 -0
  62. package/dist/runtime/settingsForm.js +114 -0
  63. package/dist/runtime/settingsForm.js.map +1 -0
  64. package/dist/runtime/site.d.ts +5 -0
  65. package/dist/runtime/site.js +1 -1
  66. package/dist/runtime/site.js.map +1 -1
  67. package/dist/runtime/siteRuntime.d.ts +144 -0
  68. package/dist/runtime/siteRuntime.js +175 -0
  69. package/dist/runtime/siteRuntime.js.map +1 -0
  70. package/dist/runtime/stringPackHook.d.ts +84 -0
  71. package/dist/runtime/stringPackHook.js +220 -0
  72. package/dist/runtime/stringPackHook.js.map +1 -0
  73. package/dist/runtime/stringPackTranslate.d.ts +59 -0
  74. package/dist/runtime/stringPackTranslate.js +264 -0
  75. package/dist/runtime/stringPackTranslate.js.map +1 -0
  76. package/dist/runtime/stringPacks.d.ts +200 -0
  77. package/dist/runtime/stringPacks.js +474 -0
  78. package/dist/runtime/stringPacks.js.map +1 -0
  79. package/dist/runtime/styles.d.ts +15 -0
  80. package/dist/runtime/styles.js +81 -0
  81. package/dist/runtime/styles.js.map +1 -0
  82. package/dist/runtime/textNet.d.ts +15 -0
  83. package/dist/runtime/textNet.js +131 -0
  84. package/dist/runtime/textNet.js.map +1 -0
  85. package/dist/runtime/themeApi.d.ts +121 -0
  86. package/dist/runtime/themeApi.js +220 -0
  87. package/dist/runtime/themeApi.js.map +1 -0
  88. package/dist/runtime/themeChoice.d.ts +52 -0
  89. package/dist/runtime/themeChoice.js +69 -0
  90. package/dist/runtime/themeChoice.js.map +1 -0
  91. package/dist/runtime/themeComponents.d.ts +435 -0
  92. package/dist/runtime/themeComponents.js +463 -0
  93. package/dist/runtime/themeComponents.js.map +1 -0
  94. package/dist/runtime/themeDecor.d.ts +73 -0
  95. package/dist/runtime/themeDecor.js +131 -0
  96. package/dist/runtime/themeDecor.js.map +1 -0
  97. package/dist/runtime/themeDoctor.d.ts +11 -0
  98. package/dist/runtime/themeDoctor.js +51 -0
  99. package/dist/runtime/themeDoctor.js.map +1 -0
  100. package/dist/runtime/themeIcons.d.ts +130 -0
  101. package/dist/runtime/themeIcons.js +263 -0
  102. package/dist/runtime/themeIcons.js.map +1 -0
  103. package/dist/runtime/themeRuntime.d.ts +100 -0
  104. package/dist/runtime/themeRuntime.js +497 -0
  105. package/dist/runtime/themeRuntime.js.map +1 -0
  106. package/dist/runtime/themeSchema.d.ts +10 -0
  107. package/dist/runtime/themeSchema.js +150 -0
  108. package/dist/runtime/themeSchema.js.map +1 -0
  109. package/dist/runtime/themeSpec.d.ts +259 -0
  110. package/dist/runtime/themeSpec.js +439 -0
  111. package/dist/runtime/themeSpec.js.map +1 -0
  112. package/dist/runtime/themeTokens.d.ts +12 -0
  113. package/dist/runtime/themeTokens.js +14 -6
  114. package/dist/runtime/themeTokens.js.map +1 -1
  115. package/dist/runtime/themeVariants.d.ts +30 -0
  116. package/dist/runtime/themeVariants.js +53 -0
  117. package/dist/runtime/themeVariants.js.map +1 -0
  118. package/dist/runtime/ui.d.ts +192 -0
  119. package/dist/runtime/ui.js +926 -0
  120. package/dist/runtime/ui.js.map +1 -0
  121. package/dist/shell/InstallDialog.d.ts +40 -0
  122. package/dist/shell/InstallDialog.js +170 -0
  123. package/dist/shell/InstallDialog.js.map +1 -0
  124. package/dist/shell/StoreView.d.ts +66 -0
  125. package/dist/shell/StoreView.js +103 -0
  126. package/dist/shell/StoreView.js.map +1 -0
  127. package/dist/shell/addressModel.js.map +1 -1
  128. package/dist/shell/chrome.js.map +1 -1
  129. package/dist/shell/deckModel.d.ts +117 -0
  130. package/dist/shell/deckModel.js +267 -0
  131. package/dist/shell/deckModel.js.map +1 -0
  132. package/dist/shell/frame/AccountSwitcher.d.ts +42 -0
  133. package/dist/shell/frame/AccountSwitcher.js +243 -0
  134. package/dist/shell/frame/AccountSwitcher.js.map +1 -0
  135. package/dist/shell/frame/AddColumnDialog.d.ts +8 -0
  136. package/dist/shell/frame/AddColumnDialog.js +81 -0
  137. package/dist/shell/frame/AddColumnDialog.js.map +1 -0
  138. package/dist/shell/frame/AppMenu.d.ts +21 -0
  139. package/dist/shell/frame/AppMenu.js +642 -0
  140. package/dist/shell/frame/AppMenu.js.map +1 -0
  141. package/dist/shell/frame/CommandPalette.d.ts +7 -0
  142. package/dist/shell/frame/CommandPalette.js +118 -0
  143. package/dist/shell/frame/CommandPalette.js.map +1 -0
  144. package/dist/shell/frame/DeckView.d.ts +13 -0
  145. package/dist/shell/frame/DeckView.js +287 -0
  146. package/dist/shell/frame/DeckView.js.map +1 -0
  147. package/dist/shell/frame/FindBar.d.ts +10 -0
  148. package/dist/shell/frame/FindBar.js +108 -0
  149. package/dist/shell/frame/FindBar.js.map +1 -0
  150. package/dist/shell/frame/MediaPanel.d.ts +8 -0
  151. package/dist/shell/frame/MediaPanel.js +76 -0
  152. package/dist/shell/frame/MediaPanel.js.map +1 -0
  153. package/dist/shell/frame/NewTabPage.d.ts +9 -0
  154. package/dist/shell/frame/NewTabPage.js +71 -0
  155. package/dist/shell/frame/NewTabPage.js.map +1 -0
  156. package/dist/shell/frame/PaneTheme.d.ts +16 -0
  157. package/dist/shell/frame/PaneTheme.js +67 -0
  158. package/dist/shell/frame/PaneTheme.js.map +1 -0
  159. package/dist/shell/frame/ReportDialog.d.ts +3 -0
  160. package/dist/shell/frame/ReportDialog.js +95 -0
  161. package/dist/shell/frame/ReportDialog.js.map +1 -0
  162. package/dist/shell/frame/Shell.d.ts +8 -0
  163. package/dist/shell/frame/Shell.js +1131 -0
  164. package/dist/shell/frame/Shell.js.map +1 -0
  165. package/dist/shell/frame/Titlebar.d.ts +16 -0
  166. package/dist/shell/frame/Titlebar.js +77 -0
  167. package/dist/shell/frame/Titlebar.js.map +1 -0
  168. package/dist/shell/frame/TitlebarExtras.d.ts +4 -0
  169. package/dist/shell/frame/TitlebarExtras.js +202 -0
  170. package/dist/shell/frame/TitlebarExtras.js.map +1 -0
  171. package/dist/shell/frame/WebPanel.d.ts +4 -0
  172. package/dist/shell/frame/WebPanel.js +182 -0
  173. package/dist/shell/frame/WebPanel.js.map +1 -0
  174. package/dist/shell/frame/accountModel.d.ts +49 -0
  175. package/dist/shell/frame/accountModel.js +67 -0
  176. package/dist/shell/frame/accountModel.js.map +1 -0
  177. package/dist/shell/frame/accountSwitcher.css +91 -0
  178. package/dist/shell/frame/appI18n.d.ts +44 -0
  179. package/dist/shell/frame/appI18n.js +64 -0
  180. package/dist/shell/frame/appI18n.js.map +1 -0
  181. package/dist/shell/frame/appMenu.css +121 -0
  182. package/dist/shell/frame/backupModel.d.ts +38 -0
  183. package/dist/shell/frame/backupModel.js +192 -0
  184. package/dist/shell/frame/backupModel.js.map +1 -0
  185. package/dist/shell/frame/boot.d.ts +8 -0
  186. package/dist/shell/frame/boot.js +35 -0
  187. package/dist/shell/frame/boot.js.map +1 -0
  188. package/dist/shell/frame/brand.d.ts +1 -0
  189. package/dist/shell/frame/brand.js +4 -0
  190. package/dist/shell/frame/brand.js.map +1 -0
  191. package/dist/shell/frame/bridge.d.ts +35 -0
  192. package/dist/shell/frame/bridge.js +70 -0
  193. package/dist/shell/frame/bridge.js.map +1 -0
  194. package/dist/shell/frame/chromeTheme.d.ts +29 -0
  195. package/dist/shell/frame/chromeTheme.js +81 -0
  196. package/dist/shell/frame/chromeTheme.js.map +1 -0
  197. package/dist/shell/frame/deck.css +209 -0
  198. package/dist/shell/frame/deckStore.d.ts +89 -0
  199. package/dist/shell/frame/deckStore.js +239 -0
  200. package/dist/shell/frame/deckStore.js.map +1 -0
  201. package/dist/shell/frame/devHost.d.ts +35 -0
  202. package/dist/shell/frame/devHost.js +80 -0
  203. package/dist/shell/frame/devHost.js.map +1 -0
  204. package/dist/shell/frame/devModel.d.ts +7 -0
  205. package/dist/shell/frame/devModel.js +17 -0
  206. package/dist/shell/frame/devModel.js.map +1 -0
  207. package/dist/shell/frame/diag.d.ts +7 -0
  208. package/dist/shell/frame/diag.js +39 -0
  209. package/dist/shell/frame/diag.js.map +1 -0
  210. package/dist/shell/frame/findBar.css +14 -0
  211. package/dist/shell/frame/frameMessages.d.ts +248 -0
  212. package/dist/shell/frame/frameMessages.js +252 -0
  213. package/dist/shell/frame/frameMessages.js.map +1 -0
  214. package/dist/shell/frame/hooks.d.ts +39 -0
  215. package/dist/shell/frame/hooks.js +97 -0
  216. package/dist/shell/frame/hooks.js.map +1 -0
  217. package/dist/shell/frame/i18n.d.ts +27 -0
  218. package/dist/shell/frame/i18n.js +66 -0
  219. package/dist/shell/frame/i18n.js.map +1 -0
  220. package/dist/shell/frame/iconPack.d.ts +11 -0
  221. package/dist/shell/frame/iconPack.js +45 -0
  222. package/dist/shell/frame/iconPack.js.map +1 -0
  223. package/dist/shell/frame/icons.d.ts +71 -0
  224. package/dist/shell/frame/icons.js +75 -0
  225. package/dist/shell/frame/icons.js.map +1 -0
  226. package/dist/shell/frame/index.d.ts +34 -0
  227. package/dist/shell/frame/index.js +43 -0
  228. package/dist/shell/frame/index.js.map +1 -0
  229. package/dist/shell/frame/language.d.ts +58 -0
  230. package/dist/shell/frame/language.js +165 -0
  231. package/dist/shell/frame/language.js.map +1 -0
  232. package/dist/shell/frame/mediaModel.d.ts +34 -0
  233. package/dist/shell/frame/mediaModel.js +53 -0
  234. package/dist/shell/frame/mediaModel.js.map +1 -0
  235. package/dist/shell/frame/menuMessages.en.json +54 -0
  236. package/dist/shell/frame/menuModel.d.ts +277 -0
  237. package/dist/shell/frame/menuModel.js +293 -0
  238. package/dist/shell/frame/menuModel.js.map +1 -0
  239. package/dist/shell/frame/paletteModel.d.ts +139 -0
  240. package/dist/shell/frame/paletteModel.js +112 -0
  241. package/dist/shell/frame/paletteModel.js.map +1 -0
  242. package/dist/shell/frame/paneTheme.css +9 -0
  243. package/dist/shell/frame/pluginCommandStore.d.ts +23 -0
  244. package/dist/shell/frame/pluginCommandStore.js +70 -0
  245. package/dist/shell/frame/pluginCommandStore.js.map +1 -0
  246. package/dist/shell/frame/reportModel.d.ts +52 -0
  247. package/dist/shell/frame/reportModel.js +105 -0
  248. package/dist/shell/frame/reportModel.js.map +1 -0
  249. package/dist/shell/frame/safeStore.d.ts +7 -0
  250. package/dist/shell/frame/safeStore.js +40 -0
  251. package/dist/shell/frame/safeStore.js.map +1 -0
  252. package/dist/shell/frame/searchInput.d.ts +2 -0
  253. package/dist/shell/frame/searchInput.js +11 -0
  254. package/dist/shell/frame/searchInput.js.map +1 -0
  255. package/dist/shell/frame/shell.css +629 -0
  256. package/dist/shell/frame/site.d.ts +206 -0
  257. package/dist/shell/frame/site.js +22 -0
  258. package/dist/shell/frame/site.js.map +1 -0
  259. package/dist/shell/frame/state.d.ts +99 -0
  260. package/dist/shell/frame/state.js +284 -0
  261. package/dist/shell/frame/state.js.map +1 -0
  262. package/dist/shell/frame/syncGate.d.ts +10 -0
  263. package/dist/shell/frame/syncGate.js +36 -0
  264. package/dist/shell/frame/syncGate.js.map +1 -0
  265. package/dist/shell/frame/syncHost.d.ts +35 -0
  266. package/dist/shell/frame/syncHost.js +85 -0
  267. package/dist/shell/frame/syncHost.js.map +1 -0
  268. package/dist/shell/frame/tabStill.d.ts +2 -0
  269. package/dist/shell/frame/tabStill.js +62 -0
  270. package/dist/shell/frame/tabStill.js.map +1 -0
  271. package/dist/shell/frame/themeScopes.d.ts +29 -0
  272. package/dist/shell/frame/themeScopes.js +61 -0
  273. package/dist/shell/frame/themeScopes.js.map +1 -0
  274. package/dist/shell/frame/themeStore.d.ts +99 -0
  275. package/dist/shell/frame/themeStore.js +252 -0
  276. package/dist/shell/frame/themeStore.js.map +1 -0
  277. package/dist/shell/frame/windowBinding.d.ts +2 -0
  278. package/dist/shell/frame/windowBinding.js +7 -0
  279. package/dist/shell/frame/windowBinding.js.map +1 -0
  280. package/dist/shell/frame/workspaceModel.d.ts +82 -0
  281. package/dist/shell/frame/workspaceModel.js +250 -0
  282. package/dist/shell/frame/workspaceModel.js.map +1 -0
  283. package/dist/shell/frame/workspaces.css +84 -0
  284. package/dist/shell/frame/workspaces.d.ts +22 -0
  285. package/dist/shell/frame/workspaces.js +125 -0
  286. package/dist/shell/frame/workspaces.js.map +1 -0
  287. package/dist/shell/frame/zoomStore.d.ts +10 -0
  288. package/dist/shell/frame/zoomStore.js +65 -0
  289. package/dist/shell/frame/zoomStore.js.map +1 -0
  290. package/dist/shell/installController.d.ts +122 -0
  291. package/dist/shell/installController.js +146 -0
  292. package/dist/shell/installController.js.map +1 -0
  293. package/dist/shell/installerMessages.d.ts +30 -0
  294. package/dist/shell/installerMessages.js +36 -0
  295. package/dist/shell/installerMessages.js.map +1 -0
  296. package/dist/shell/linkDrop.js.map +1 -1
  297. package/dist/shell/messages.d.ts +16 -0
  298. package/dist/shell/messages.js +27 -0
  299. package/dist/shell/messages.js.map +1 -0
  300. package/dist/shell/palette.js.map +1 -1
  301. package/dist/shell/paneModel.d.ts +22 -0
  302. package/dist/shell/paneModel.js +24 -1
  303. package/dist/shell/paneModel.js.map +1 -1
  304. package/dist/shell/panel/Appearance.d.ts +8 -0
  305. package/dist/shell/panel/Appearance.js +256 -0
  306. package/dist/shell/panel/Appearance.js.map +1 -0
  307. package/dist/shell/panel/BackupPanel.d.ts +5 -0
  308. package/dist/shell/panel/BackupPanel.js +198 -0
  309. package/dist/shell/panel/BackupPanel.js.map +1 -0
  310. package/dist/shell/panel/DeveloperPanel.d.ts +4 -0
  311. package/dist/shell/panel/DeveloperPanel.js +51 -0
  312. package/dist/shell/panel/DeveloperPanel.js.map +1 -0
  313. package/dist/shell/panel/FeatureToggles.d.ts +13 -0
  314. package/dist/shell/panel/FeatureToggles.js +42 -0
  315. package/dist/shell/panel/FeatureToggles.js.map +1 -0
  316. package/dist/shell/panel/Home.d.ts +3 -0
  317. package/dist/shell/panel/Home.js +23 -0
  318. package/dist/shell/panel/Home.js.map +1 -0
  319. package/dist/shell/panel/IconPackInstall.d.ts +15 -0
  320. package/dist/shell/panel/IconPackInstall.js +41 -0
  321. package/dist/shell/panel/IconPackInstall.js.map +1 -0
  322. package/dist/shell/panel/LanguageSettings.d.ts +1 -0
  323. package/dist/shell/panel/LanguageSettings.js +54 -0
  324. package/dist/shell/panel/LanguageSettings.js.map +1 -0
  325. package/dist/shell/panel/MakePanel.d.ts +3 -0
  326. package/dist/shell/panel/MakePanel.js +237 -0
  327. package/dist/shell/panel/MakePanel.js.map +1 -0
  328. package/dist/shell/panel/MarkdownDoc.d.ts +6 -0
  329. package/dist/shell/panel/MarkdownDoc.js +35 -0
  330. package/dist/shell/panel/MarkdownDoc.js.map +1 -0
  331. package/dist/shell/panel/Modes.d.ts +40 -0
  332. package/dist/shell/panel/Modes.js +270 -0
  333. package/dist/shell/panel/Modes.js.map +1 -0
  334. package/dist/shell/panel/NavIcon.d.ts +4 -0
  335. package/dist/shell/panel/NavIcon.js +6 -0
  336. package/dist/shell/panel/NavIcon.js.map +1 -0
  337. package/dist/shell/panel/Panel.d.ts +7 -0
  338. package/dist/shell/panel/Panel.js +139 -0
  339. package/dist/shell/panel/Panel.js.map +1 -0
  340. package/dist/shell/panel/PluginFeatures.d.ts +24 -0
  341. package/dist/shell/panel/PluginFeatures.js +165 -0
  342. package/dist/shell/panel/PluginFeatures.js.map +1 -0
  343. package/dist/shell/panel/Plugins.d.ts +33 -0
  344. package/dist/shell/panel/Plugins.js +112 -0
  345. package/dist/shell/panel/Plugins.js.map +1 -0
  346. package/dist/shell/panel/PowerSettings.d.ts +4 -0
  347. package/dist/shell/panel/PowerSettings.js +52 -0
  348. package/dist/shell/panel/PowerSettings.js.map +1 -0
  349. package/dist/shell/panel/Settings.d.ts +23 -0
  350. package/dist/shell/panel/Settings.js +116 -0
  351. package/dist/shell/panel/Settings.js.map +1 -0
  352. package/dist/shell/panel/ShareSetup.d.ts +8 -0
  353. package/dist/shell/panel/ShareSetup.js +130 -0
  354. package/dist/shell/panel/ShareSetup.js.map +1 -0
  355. package/dist/shell/panel/StoreSection.d.ts +6 -0
  356. package/dist/shell/panel/StoreSection.js +48 -0
  357. package/dist/shell/panel/StoreSection.js.map +1 -0
  358. package/dist/shell/panel/StringPacks.d.ts +11 -0
  359. package/dist/shell/panel/StringPacks.js +106 -0
  360. package/dist/shell/panel/StringPacks.js.map +1 -0
  361. package/dist/shell/panel/ThemeBuilder.d.ts +5 -0
  362. package/dist/shell/panel/ThemeBuilder.js +205 -0
  363. package/dist/shell/panel/ThemeBuilder.js.map +1 -0
  364. package/dist/shell/panel/backup.css +34 -0
  365. package/dist/shell/panel/builder.css +232 -0
  366. package/dist/shell/panel/builderModel.d.ts +55 -0
  367. package/dist/shell/panel/builderModel.js +95 -0
  368. package/dist/shell/panel/builderModel.js.map +1 -0
  369. package/dist/shell/panel/compare.d.ts +10 -0
  370. package/dist/shell/panel/compare.js +51 -0
  371. package/dist/shell/panel/compare.js.map +1 -0
  372. package/dist/shell/panel/controls.d.ts +135 -0
  373. package/dist/shell/panel/controls.js +213 -0
  374. package/dist/shell/panel/controls.js.map +1 -0
  375. package/dist/shell/panel/featureModel.d.ts +69 -0
  376. package/dist/shell/panel/featureModel.js +79 -0
  377. package/dist/shell/panel/featureModel.js.map +1 -0
  378. package/dist/shell/panel/fonts/FontBrowser.d.ts +10 -0
  379. package/dist/shell/panel/fonts/FontBrowser.js +189 -0
  380. package/dist/shell/panel/fonts/FontBrowser.js.map +1 -0
  381. package/dist/shell/panel/fonts/FontRoles.d.ts +20 -0
  382. package/dist/shell/panel/fonts/FontRoles.js +77 -0
  383. package/dist/shell/panel/fonts/FontRoles.js.map +1 -0
  384. package/dist/shell/panel/fonts/catalog.d.ts +37 -0
  385. package/dist/shell/panel/fonts/catalog.js +68 -0
  386. package/dist/shell/panel/fonts/catalog.js.map +1 -0
  387. package/dist/shell/panel/fonts/googleFontsCatalog.json +1 -0
  388. package/dist/shell/panel/index.d.ts +20 -0
  389. package/dist/shell/panel/index.js +34 -0
  390. package/dist/shell/panel/index.js.map +1 -0
  391. package/dist/shell/panel/languageModel.d.ts +5 -0
  392. package/dist/shell/panel/languageModel.js +7 -0
  393. package/dist/shell/panel/languageModel.js.map +1 -0
  394. package/dist/shell/panel/make.css +72 -0
  395. package/dist/shell/panel/makeModel.d.ts +32 -0
  396. package/dist/shell/panel/makeModel.js +84 -0
  397. package/dist/shell/panel/makeModel.js.map +1 -0
  398. package/dist/shell/panel/markdown.d.ts +46 -0
  399. package/dist/shell/panel/markdown.js +100 -0
  400. package/dist/shell/panel/markdown.js.map +1 -0
  401. package/dist/shell/panel/nav.d.ts +12 -0
  402. package/dist/shell/panel/nav.js +50 -0
  403. package/dist/shell/panel/nav.js.map +1 -0
  404. package/dist/shell/panel/panel.css +401 -0
  405. package/dist/shell/panel/panelMessages.d.ts +763 -0
  406. package/dist/shell/panel/panelMessages.js +767 -0
  407. package/dist/shell/panel/panelMessages.js.map +1 -0
  408. package/dist/shell/panel/plugins.css +59 -0
  409. package/dist/shell/panel/setupModel.d.ts +87 -0
  410. package/dist/shell/panel/setupModel.js +152 -0
  411. package/dist/shell/panel/setupModel.js.map +1 -0
  412. package/dist/shell/panel/site.d.ts +259 -0
  413. package/dist/shell/panel/site.js +25 -0
  414. package/dist/shell/panel/site.js.map +1 -0
  415. package/dist/shell/panel/strings.css +7 -0
  416. package/dist/shell/panel/themes.d.ts +10 -0
  417. package/dist/shell/panel/themes.js +8 -0
  418. package/dist/shell/panel/themes.js.map +1 -0
  419. package/dist/shell/profileModel.d.ts +3 -2
  420. package/dist/shell/profileModel.js +7 -5
  421. package/dist/shell/profileModel.js.map +1 -1
  422. package/dist/shell/store.css +230 -0
  423. package/dist/shell/storeMessages.d.ts +169 -0
  424. package/dist/shell/storeMessages.js +172 -0
  425. package/dist/shell/storeMessages.js.map +1 -0
  426. package/dist/shell/storeModel.d.ts +181 -0
  427. package/dist/shell/storeModel.js +133 -0
  428. package/dist/shell/storeModel.js.map +1 -0
  429. package/dist/shell/stringPacksModel.d.ts +44 -0
  430. package/dist/shell/stringPacksModel.js +94 -0
  431. package/dist/shell/stringPacksModel.js.map +1 -0
  432. package/dist/shell/updateModel.d.ts +2 -1
  433. package/dist/shell/updateModel.js +5 -4
  434. package/dist/shell/updateModel.js.map +1 -1
  435. package/dist/shell/windowControls.d.ts +4 -0
  436. package/dist/shell/windowControls.js +5 -0
  437. package/dist/shell/windowControls.js.map +1 -1
  438. package/i18n-config.schema.json +29 -0
  439. package/i18n-meta.schema.json +26 -0
  440. package/i18n.schema.json +42 -0
  441. package/icons.schema.json +646 -0
  442. package/languages.schema.json +23 -0
  443. package/locales/ar-x-fm.json +11 -0
  444. package/locales/ar.json +1281 -0
  445. package/locales/bg.json +1280 -0
  446. package/locales/bn.json +1280 -0
  447. package/locales/ca.json +1280 -0
  448. package/locales/cs.json +1280 -0
  449. package/locales/da.json +1280 -0
  450. package/locales/de.json +1280 -0
  451. package/locales/el.json +1280 -0
  452. package/locales/en-GB.json +27 -0
  453. package/locales/en.json +1280 -0
  454. package/locales/en.meta.json +51 -0
  455. package/locales/es.json +1280 -0
  456. package/locales/eu.json +1280 -0
  457. package/locales/fa.json +1281 -0
  458. package/locales/fi.json +1280 -0
  459. package/locales/fil.json +1280 -0
  460. package/locales/fr.json +1280 -0
  461. package/locales/ga.json +1280 -0
  462. package/locales/gl.json +1280 -0
  463. package/locales/gu.json +1280 -0
  464. package/locales/ha.json +1280 -0
  465. package/locales/he.json +1281 -0
  466. package/locales/hi.json +1280 -0
  467. package/locales/hr.json +1280 -0
  468. package/locales/hu.json +1279 -0
  469. package/locales/id.json +1280 -0
  470. package/locales/ig.json +1280 -0
  471. package/locales/it.json +1280 -0
  472. package/locales/ja.json +1280 -0
  473. package/locales/kn.json +1280 -0
  474. package/locales/ko.json +1280 -0
  475. package/locales/mr.json +1280 -0
  476. package/locales/ms.json +1280 -0
  477. package/locales/nb.json +1280 -0
  478. package/locales/nl.json +1280 -0
  479. package/locales/pl.json +1280 -0
  480. package/locales/pt.json +1280 -0
  481. package/locales/ro.json +1280 -0
  482. package/locales/ru.json +1280 -0
  483. package/locales/sk.json +1280 -0
  484. package/locales/sr.json +1280 -0
  485. package/locales/sv.json +1280 -0
  486. package/locales/ta.json +1280 -0
  487. package/locales/th.json +1280 -0
  488. package/locales/tr.json +1280 -0
  489. package/locales/uk.json +1280 -0
  490. package/locales/ur.json +1281 -0
  491. package/locales/vi.json +1280 -0
  492. package/locales/yo.json +1280 -0
  493. package/locales/zh-Hans.json +1280 -0
  494. package/locales/zh-Hant.json +1280 -0
  495. package/package.json +139 -5
  496. package/store-catalog.schema.json +65 -0
  497. package/theme.schema.json +4659 -0
  498. package/windows/installer.nsi +926 -0
  499. package/windows/languages/Basque.nsh +28 -0
  500. package/windows/languages/Catalan.nsh +28 -0
  501. package/windows/languages/Croatian.nsh +28 -0
  502. package/windows/languages/Czech.nsh +28 -0
  503. package/windows/languages/Danish.nsh +28 -0
  504. package/windows/languages/Finnish.nsh +28 -0
  505. package/windows/languages/Galician.nsh +28 -0
  506. package/windows/languages/Greek.nsh +28 -0
  507. package/windows/languages/Hungarian.nsh +28 -0
  508. package/windows/languages/Indonesian.nsh +28 -0
  509. package/windows/languages/Irish.nsh +28 -0
  510. package/windows/languages/Malay.nsh +28 -0
  511. package/windows/languages/Polish.nsh +28 -0
  512. package/windows/languages/Romanian.nsh +28 -0
  513. package/windows/languages/Serbian.nsh +28 -0
  514. package/windows/languages/Slovak.nsh +28 -0
  515. package/windows/languages/Thai.nsh +28 -0
@@ -0,0 +1,614 @@
1
+ // wayBetter i18n: a small, dependency-free message runtime for the shell, the panel, the page
2
+ // runtime and plugins (published as `waybetter/i18n`).
3
+ //
4
+ // Messages are plain strings in an ICU MessageFormat subset ("ICU-lite"):
5
+ // Hello, {name}! placeholder (inserted as text, never HTML)
6
+ // {count, plural, =0 {No drafts} one {# draft} other {# drafts}} plural (Intl.PluralRules)
7
+ // {n, selectordinal, one {#st} two {#nd} few {#rd} other {#th}} ordinal
8
+ // {kind, select, post {Post} reply {Reply} other {Item}} select
9
+ // {n, number} {n, number, percent} {d, date, short} {d, time} Intl number/date formats
10
+ // '{literal}' '#' and '' (an apostrophe) ICU quoting
11
+ // An apostrophe quotes only when it comes right before { } # or another apostrophe, so ordinary
12
+ // English ("don't", "the developer's") needs no escaping.
13
+ // `#` inside a plural is the (locale-formatted) number. Numbers, dates, relative times and lists
14
+ // go through `Intl` in the active locale.
15
+ //
16
+ // Catalogs are data only: one JSON file per locale (`locales/<bcp47>.json`), English is the
17
+ // source. Lookups fall back along a chain (pt-BR -> pt -> en). Missing keys are reported once per
18
+ // key and locale through `onMissing` (development), never thrown.
19
+ // -------------------------------------------------------------------------------------------
20
+ // Locales
21
+ /** Scripts written right to left, by primary language subtag. */
22
+ const RTL = new Set(['ar', 'arc', 'ckb', 'dv', 'fa', 'he', 'iw', 'ks', 'ku-arab', 'ps', 'sd', 'syr', 'ug', 'ur', 'yi']);
23
+ /**
24
+ * Site and legacy codes mapped to BCP 47: X's own settings use `msa`, `zh-cn`, `zh-tw`, `no` and
25
+ * `en-gb`; old platforms say `iw`, `in`, `tl`.
26
+ */
27
+ const ALIASES = {
28
+ msa: 'ms',
29
+ 'zh-cn': 'zh-Hans',
30
+ 'zh-sg': 'zh-Hans',
31
+ zh: 'zh-Hans',
32
+ 'zh-tw': 'zh-Hant',
33
+ 'zh-hk': 'zh-Hant',
34
+ 'zh-mo': 'zh-Hant',
35
+ no: 'nb',
36
+ nn: 'nb',
37
+ iw: 'he',
38
+ in: 'id',
39
+ tl: 'fil',
40
+ ji: 'yi',
41
+ };
42
+ const TAG = /^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8}){0,4}$/;
43
+ /**
44
+ * A tag in canonical BCP 47 form (`en_gb` -> `en-GB`, `zh-cn` -> `zh-Hans`, `msa` -> `ms`), or null
45
+ * when it is not a language tag at all. Private-use subtags survive (`ar-x-fm`).
46
+ */
47
+ export function normalizeLocale(input) {
48
+ if (typeof input !== 'string')
49
+ return null;
50
+ const raw = input.trim().replace(/_/g, '-');
51
+ if (!raw || raw.length > 35 || !TAG.test(raw))
52
+ return null;
53
+ const lower = raw.toLowerCase();
54
+ if (ALIASES[lower])
55
+ return ALIASES[lower];
56
+ // `zh-Hans-CN` / `zh-Hant-TW`: the script decides; the region is noise for our catalogs.
57
+ const parts = lower.split('-');
58
+ if (parts[0] === 'zh') {
59
+ if (parts.includes('hant') || ['tw', 'hk', 'mo'].includes(parts[1] ?? ''))
60
+ return 'zh-Hant';
61
+ return 'zh-Hans';
62
+ }
63
+ const privateUse = lower.indexOf('-x-');
64
+ if (privateUse > 0) {
65
+ const base = normalizeLocale(raw.slice(0, privateUse));
66
+ return base ? `${base}-x-${lower.slice(privateUse + 3)}` : null;
67
+ }
68
+ const alias = ALIASES[parts[0]];
69
+ const head = alias && !alias.includes('-') ? [alias, ...parts.slice(1)].join('-') : raw;
70
+ try {
71
+ return Intl.getCanonicalLocales(head)[0] ?? null;
72
+ }
73
+ catch {
74
+ return null;
75
+ }
76
+ }
77
+ /** The primary language subtag (`pt-BR` -> `pt`). */
78
+ export function languageOf(locale) {
79
+ return locale.split('-')[0].toLowerCase();
80
+ }
81
+ /** Writing direction of a locale. */
82
+ export function direction(locale) {
83
+ const lower = locale.toLowerCase();
84
+ if (lower.startsWith('ku-arab'))
85
+ return 'rtl';
86
+ return RTL.has(languageOf(lower)) ? 'rtl' : 'ltr';
87
+ }
88
+ /**
89
+ * Where lookups go, most specific first, ending with the source locale: `pt-BR` -> [pt-BR, pt, en].
90
+ * `fallbacks` maps a locale to the one it inherits from (a catalog's `fallback`, e.g. ar-x-fm -> ar).
91
+ * Script variants never fall back to another script: `zh-Hant` does not use `zh-Hans`.
92
+ */
93
+ export function fallbackChain(locale, source = 'en', fallbacks = {}) {
94
+ const out = [];
95
+ const push = (tag) => {
96
+ if (tag && !out.includes(tag))
97
+ out.push(tag);
98
+ };
99
+ let current = normalizeLocale(locale);
100
+ for (let guard = 0; current && guard < 8; guard += 1) {
101
+ push(current);
102
+ const explicit = fallbacks[current];
103
+ if (explicit) {
104
+ current = normalizeLocale(explicit);
105
+ continue;
106
+ }
107
+ const privateUse = current.indexOf('-x-');
108
+ if (privateUse > 0) {
109
+ current = current.slice(0, privateUse);
110
+ continue;
111
+ }
112
+ const parts = current.split('-');
113
+ if (parts.length <= 1)
114
+ break;
115
+ // zh-Hans / zh-Hant, sr-Latn: a script subtag is its own catalog.
116
+ if (parts.length === 2 && /^[A-Z][a-z]{3}$/.test(parts[1]))
117
+ break;
118
+ current = parts.slice(0, -1).join('-');
119
+ }
120
+ push(source);
121
+ return out;
122
+ }
123
+ /**
124
+ * Picks the best available locale for a list of preferences (most wanted first), by fallback chain:
125
+ * `['pt-PT', 'en']` with `pt` available -> `pt`. Returns `fallback` when nothing matches.
126
+ */
127
+ export function matchLocale(preferred, available, fallback = 'en') {
128
+ const set = new Set(available);
129
+ for (const wanted of preferred) {
130
+ const tag = normalizeLocale(wanted);
131
+ if (!tag)
132
+ continue;
133
+ for (const candidate of fallbackChain(tag, '')) {
134
+ if (candidate && set.has(candidate))
135
+ return candidate;
136
+ }
137
+ }
138
+ return fallback;
139
+ }
140
+ export class MessageSyntaxError extends Error {
141
+ source;
142
+ index;
143
+ constructor(message, source, index) {
144
+ super(`${message} at ${index} in ${JSON.stringify(source.length > 80 ? `${source.slice(0, 80)}…` : source)}`);
145
+ this.name = 'MessageSyntaxError';
146
+ this.source = source;
147
+ this.index = index;
148
+ }
149
+ }
150
+ const NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
151
+ /** Parses a message into parts; throws `MessageSyntaxError` on malformed ICU. */
152
+ export function parseMessage(source) {
153
+ let i = 0;
154
+ const parseParts = (inPlural, depth) => {
155
+ const parts = [];
156
+ let text = '';
157
+ const flush = () => {
158
+ if (text)
159
+ parts.push(text);
160
+ text = '';
161
+ };
162
+ while (i < source.length) {
163
+ const ch = source[i];
164
+ if (ch === "'") {
165
+ const next = source[i + 1];
166
+ if (next === "'") {
167
+ text += "'";
168
+ i += 2;
169
+ continue;
170
+ }
171
+ // An apostrophe only quotes before { } # (or another apostrophe); "don't" stays literal.
172
+ if (next === '{' || next === '}' || next === '#') {
173
+ // Quoted literal up to the next lone apostrophe.
174
+ i += 1;
175
+ while (i < source.length) {
176
+ if (source[i] === "'") {
177
+ if (source[i + 1] === "'") {
178
+ text += "'";
179
+ i += 2;
180
+ continue;
181
+ }
182
+ i += 1;
183
+ break;
184
+ }
185
+ text += source[i];
186
+ i += 1;
187
+ }
188
+ continue;
189
+ }
190
+ text += ch;
191
+ i += 1;
192
+ continue;
193
+ }
194
+ if (ch === '}') {
195
+ if (depth > 0)
196
+ break;
197
+ throw new MessageSyntaxError('unexpected }', source, i);
198
+ }
199
+ if (ch === '#' && inPlural) {
200
+ flush();
201
+ parts.push({ kind: 'pound' });
202
+ i += 1;
203
+ continue;
204
+ }
205
+ if (ch === '{') {
206
+ flush();
207
+ parts.push(parseArgument(depth));
208
+ continue;
209
+ }
210
+ text += ch;
211
+ i += 1;
212
+ }
213
+ flush();
214
+ return parts;
215
+ };
216
+ const skipSpace = () => { while (i < source.length && /\s/.test(source[i]))
217
+ i += 1; };
218
+ const readWord = () => {
219
+ const start = i;
220
+ while (i < source.length && /[^\s,{}]/.test(source[i]))
221
+ i += 1;
222
+ return source.slice(start, i);
223
+ };
224
+ const expect = (ch) => {
225
+ if (source[i] !== ch)
226
+ throw new MessageSyntaxError(`expected ${ch}`, source, i);
227
+ i += 1;
228
+ };
229
+ const parseOptions = (inPlural, depth) => {
230
+ const options = {};
231
+ for (;;) {
232
+ skipSpace();
233
+ if (source[i] === '}')
234
+ break;
235
+ const selector = readWord();
236
+ if (!selector)
237
+ throw new MessageSyntaxError('expected a selector', source, i);
238
+ skipSpace();
239
+ expect('{');
240
+ options[selector] = parseParts(inPlural, depth + 1);
241
+ expect('}');
242
+ }
243
+ if (!('other' in options))
244
+ throw new MessageSyntaxError('a plural or select needs an "other" option', source, i);
245
+ return options;
246
+ };
247
+ const parseArgument = (depth) => {
248
+ expect('{');
249
+ skipSpace();
250
+ const name = readWord();
251
+ if (!NAME.test(name))
252
+ throw new MessageSyntaxError(`invalid placeholder name ${JSON.stringify(name)}`, source, i);
253
+ skipSpace();
254
+ if (source[i] === '}') {
255
+ i += 1;
256
+ return { kind: 'arg', name };
257
+ }
258
+ expect(',');
259
+ skipSpace();
260
+ const type = readWord();
261
+ skipSpace();
262
+ if (type === 'plural' || type === 'selectordinal') {
263
+ expect(',');
264
+ skipSpace();
265
+ let offset = 0;
266
+ const offsetMatch = /^offset:(\d+)/.exec(source.slice(i));
267
+ if (offsetMatch) {
268
+ offset = Number(offsetMatch[1]);
269
+ i += offsetMatch[0].length;
270
+ }
271
+ const options = parseOptions(true, depth);
272
+ expect('}');
273
+ return { kind: 'plural', name, ordinal: type === 'selectordinal', offset, options };
274
+ }
275
+ if (type === 'select') {
276
+ expect(',');
277
+ const options = parseOptions(false, depth);
278
+ expect('}');
279
+ return { kind: 'select', name, options };
280
+ }
281
+ if (type === 'number' || type === 'date' || type === 'time') {
282
+ let style;
283
+ if (source[i] === ',') {
284
+ i += 1;
285
+ skipSpace();
286
+ style = readWord();
287
+ skipSpace();
288
+ }
289
+ expect('}');
290
+ return { kind: 'arg', name, format: type, style };
291
+ }
292
+ throw new MessageSyntaxError(`unknown argument type ${JSON.stringify(type)}`, source, i);
293
+ };
294
+ const parts = parseParts(false, 0);
295
+ if (i < source.length)
296
+ throw new MessageSyntaxError('unexpected }', source, i);
297
+ return parts;
298
+ }
299
+ /** Placeholder names a message uses (plural/select arguments included), sorted. */
300
+ export function placeholders(source) {
301
+ const names = new Set();
302
+ const walk = (parts) => {
303
+ for (const part of parts) {
304
+ if (typeof part === 'string' || part.kind === 'pound')
305
+ continue;
306
+ names.add(part.name);
307
+ if (part.kind === 'plural' || part.kind === 'select')
308
+ for (const option of Object.values(part.options))
309
+ walk(option);
310
+ }
311
+ };
312
+ walk(parseMessage(source));
313
+ return [...names].sort();
314
+ }
315
+ /** Plural/select structure of a message: `{ count: { kind: 'plural', options: ['one', 'other'] } }`. */
316
+ export function argumentShapes(source) {
317
+ const out = {};
318
+ const walk = (parts) => {
319
+ for (const part of parts) {
320
+ if (typeof part === 'string' || part.kind === 'pound' || part.kind === 'arg')
321
+ continue;
322
+ const kind = part.kind === 'select' ? 'select' : part.ordinal ? 'selectordinal' : 'plural';
323
+ const entry = (out[part.name] ??= { kind, options: [] });
324
+ for (const [selector, option] of Object.entries(part.options)) {
325
+ if (!entry.options.includes(selector))
326
+ entry.options.push(selector);
327
+ walk(option);
328
+ }
329
+ }
330
+ };
331
+ walk(parseMessage(source));
332
+ return out;
333
+ }
334
+ const formatterCache = new Map();
335
+ function cached(key, make) {
336
+ let value = formatterCache.get(key);
337
+ if (!value) {
338
+ value = make();
339
+ if (formatterCache.size > 256)
340
+ formatterCache.clear();
341
+ formatterCache.set(key, value);
342
+ }
343
+ return value;
344
+ }
345
+ function safeLocale(locale) {
346
+ // Private-use tags (ar-x-fm) are valid BCP 47 but Intl may not know them: format as the base.
347
+ const base = locale.split('-x-')[0];
348
+ try {
349
+ return Intl.getCanonicalLocales(base)[0] ?? 'en';
350
+ }
351
+ catch {
352
+ return 'en';
353
+ }
354
+ }
355
+ export function numberFormat(locale, options) {
356
+ const tag = safeLocale(locale);
357
+ return cached(`n|${tag}|${JSON.stringify(options ?? {})}`, () => new Intl.NumberFormat(tag, options));
358
+ }
359
+ export function dateFormat(locale, options) {
360
+ const tag = safeLocale(locale);
361
+ return cached(`d|${tag}|${JSON.stringify(options ?? {})}`, () => new Intl.DateTimeFormat(tag, options));
362
+ }
363
+ export function pluralRules(locale, ordinal = false) {
364
+ const tag = safeLocale(locale);
365
+ return cached(`p|${tag}|${ordinal}`, () => new Intl.PluralRules(tag, { type: ordinal ? 'ordinal' : 'cardinal' }));
366
+ }
367
+ /** CLDR plural categories a locale uses (`tr`: one, other; `ar`: zero, one, two, few, many, other). */
368
+ export function pluralCategories(locale, ordinal = false) {
369
+ return [...pluralRules(locale, ordinal).resolvedOptions().pluralCategories];
370
+ }
371
+ const NUMBER_STYLES = {
372
+ integer: { maximumFractionDigits: 0 },
373
+ percent: { style: 'percent' },
374
+ compact: { notation: 'compact' },
375
+ };
376
+ const DATE_STYLES = {
377
+ short: { dateStyle: 'short' },
378
+ medium: { dateStyle: 'medium' },
379
+ long: { dateStyle: 'long' },
380
+ full: { dateStyle: 'full' },
381
+ };
382
+ const TIME_STYLES = {
383
+ short: { timeStyle: 'short' },
384
+ medium: { timeStyle: 'medium' },
385
+ long: { timeStyle: 'long' },
386
+ full: { timeStyle: 'full' },
387
+ };
388
+ function toDate(value) {
389
+ const date = value instanceof Date ? value : typeof value === 'number' || typeof value === 'string' ? new Date(value) : null;
390
+ return date && Number.isFinite(date.getTime()) ? date : null;
391
+ }
392
+ function render(parts, params, locale, pound, onMissingParam) {
393
+ let out = '';
394
+ for (const part of parts) {
395
+ if (typeof part === 'string') {
396
+ out += part;
397
+ continue;
398
+ }
399
+ if (part.kind === 'pound') {
400
+ out += pound === null ? '#' : numberFormat(locale).format(pound);
401
+ continue;
402
+ }
403
+ const has = Object.prototype.hasOwnProperty.call(params, part.name);
404
+ const value = has ? params[part.name] : undefined;
405
+ if (!has || value === undefined || value === null) {
406
+ onMissingParam?.(part.name);
407
+ out += `{${part.name}}`;
408
+ continue;
409
+ }
410
+ if (part.kind === 'arg') {
411
+ if (part.format === 'number' && typeof value === 'number') {
412
+ out += numberFormat(locale, NUMBER_STYLES[part.style ?? ''] ?? undefined).format(value);
413
+ }
414
+ else if ((part.format === 'date' || part.format === 'time') && toDate(value)) {
415
+ const styles = part.format === 'date' ? DATE_STYLES : TIME_STYLES;
416
+ out += dateFormat(locale, styles[part.style ?? 'medium'] ?? styles.medium).format(toDate(value));
417
+ }
418
+ else if (typeof value === 'number') {
419
+ out += numberFormat(locale).format(value);
420
+ }
421
+ else {
422
+ out += String(value);
423
+ }
424
+ continue;
425
+ }
426
+ if (part.kind === 'select') {
427
+ const key = String(value);
428
+ out += render(part.options[key] ?? part.options.other, params, locale, pound, onMissingParam);
429
+ continue;
430
+ }
431
+ const n = typeof value === 'number' ? value : Number(value);
432
+ if (!Number.isFinite(n)) {
433
+ out += String(value);
434
+ continue;
435
+ }
436
+ const exact = part.options[`=${n}`];
437
+ const shifted = n - part.offset;
438
+ const option = exact ?? part.options[pluralRules(locale, part.ordinal).select(shifted)] ?? part.options.other;
439
+ out += render(option, params, locale, shifted, onMissingParam);
440
+ }
441
+ return out;
442
+ }
443
+ const compiled = new Map();
444
+ /**
445
+ * Formats one message. Placeholder values are inserted as plain text; a malformed message renders
446
+ * as its raw text (and `onError` hears about it) rather than throwing in the UI.
447
+ */
448
+ export function formatMessage(source, params = {}, locale = 'en', hooks = {}) {
449
+ if (!source.includes('{') && !source.includes("'"))
450
+ return source;
451
+ let parts = compiled.get(source);
452
+ if (!parts) {
453
+ try {
454
+ parts = parseMessage(source);
455
+ }
456
+ catch (error) {
457
+ parts = error instanceof Error ? error : new Error(String(error));
458
+ }
459
+ if (compiled.size > 4096)
460
+ compiled.clear();
461
+ compiled.set(source, parts);
462
+ }
463
+ if (parts instanceof Error) {
464
+ hooks.onError?.(parts);
465
+ return source;
466
+ }
467
+ return render(parts, params, locale, null, hooks.onMissingParam);
468
+ }
469
+ export function createI18n(options) {
470
+ const source = options.sourceLocale ?? 'en';
471
+ const available = Object.freeze([...new Set([source, ...options.available])]);
472
+ const tables = new Map();
473
+ tables.set(source, { ...options.source });
474
+ const loaded = new Set([source]);
475
+ const listeners = new Set();
476
+ const reported = new Set();
477
+ let locale = source;
478
+ let chain = [source];
479
+ const report = (key, where, reason) => {
480
+ const id = `${reason}|${where}|${key}`;
481
+ if (reported.has(id) || !options.onMissing)
482
+ return;
483
+ if (reported.size > 2048)
484
+ reported.clear();
485
+ reported.add(id);
486
+ try {
487
+ options.onMissing(key, where, reason);
488
+ }
489
+ catch { /* a reporter must not break the UI */ }
490
+ };
491
+ const chainFor = (tag) => fallbackChain(tag, source, options.fallbacks).filter(entry => available.includes(entry));
492
+ const lookup = (key) => {
493
+ for (const entry of chain) {
494
+ const value = tables.get(entry)?.[key];
495
+ if (typeof value === 'string') {
496
+ if (entry !== locale && locale !== source && entry === source)
497
+ report(key, locale, 'key');
498
+ return value;
499
+ }
500
+ }
501
+ return undefined;
502
+ };
503
+ const format = (key, message, params) => formatMessage(message, params ?? {}, locale, {
504
+ onError: () => report(key, locale, 'syntax'),
505
+ onMissingParam: () => report(key, locale, 'param'),
506
+ });
507
+ const i18n = {
508
+ get locale() { return locale; },
509
+ get dir() { return direction(locale); },
510
+ get chain() { return chain; },
511
+ available,
512
+ t(key, params) {
513
+ const message = lookup(key);
514
+ if (message === undefined) {
515
+ report(key, locale, 'key');
516
+ return key;
517
+ }
518
+ return format(key, message, params);
519
+ },
520
+ tx(key, params, fallback) {
521
+ const message = lookup(key);
522
+ if (message === undefined)
523
+ return fallback ?? key;
524
+ return format(key, message, params);
525
+ },
526
+ has: key => lookup(key) !== undefined,
527
+ async setLocale(requested) {
528
+ const target = matchLocale([requested], available, source);
529
+ const nextChain = chainFor(target);
530
+ if (options.load) {
531
+ await Promise.all(nextChain.filter(tag => !loaded.has(tag)).map(async (tag) => {
532
+ try {
533
+ const messages = await options.load(tag);
534
+ if (messages)
535
+ tables.set(tag, { ...messages, ...tables.get(tag) });
536
+ }
537
+ catch (error) {
538
+ report(`<catalog ${tag}: ${error instanceof Error ? error.message : String(error)}>`, tag, 'key');
539
+ }
540
+ loaded.add(tag);
541
+ }));
542
+ }
543
+ const changed = target !== locale;
544
+ locale = target;
545
+ chain = nextChain;
546
+ if (changed)
547
+ for (const listener of [...listeners]) {
548
+ try {
549
+ listener(locale);
550
+ }
551
+ catch { /* listeners must not break each other */ }
552
+ }
553
+ return locale;
554
+ },
555
+ add(tag, messages) {
556
+ const key = normalizeLocale(tag) ?? tag;
557
+ tables.set(key, { ...tables.get(key), ...messages });
558
+ },
559
+ onChange(listener) {
560
+ listeners.add(listener);
561
+ return () => listeners.delete(listener);
562
+ },
563
+ resolved(prefixes) {
564
+ const out = {};
565
+ for (const entry of [...chain].reverse()) {
566
+ for (const [key, value] of Object.entries(tables.get(entry) ?? {})) {
567
+ if (!prefixes || prefixes.some(prefix => key.startsWith(prefix)))
568
+ out[key] = value;
569
+ }
570
+ }
571
+ return out;
572
+ },
573
+ number: (value, opts) => numberFormat(locale, opts).format(value),
574
+ date: (value, opts) => {
575
+ const date = toDate(value);
576
+ return date ? dateFormat(locale, opts).format(date) : '';
577
+ },
578
+ relative: (value, unit, opts) => {
579
+ try {
580
+ return new Intl.RelativeTimeFormat(safeLocale(locale), { numeric: 'auto', ...opts }).format(value, unit);
581
+ }
582
+ catch {
583
+ return `${value} ${unit}`;
584
+ }
585
+ },
586
+ list: (items, opts) => {
587
+ try {
588
+ return new Intl.ListFormat(safeLocale(locale), { type: opts?.type ?? 'conjunction', style: opts?.style ?? 'long' }).format(items);
589
+ }
590
+ catch {
591
+ return items.join(', ');
592
+ }
593
+ },
594
+ plural: (count, ordinal = false) => pluralRules(locale, ordinal).select(count),
595
+ };
596
+ return i18n;
597
+ }
598
+ /** Picks a relative-time unit for a timestamp: "just now" granularity down to seconds. */
599
+ export function relativeParts(then, now = Date.now()) {
600
+ const seconds = Math.round((then - now) / 1000);
601
+ const abs = Math.abs(seconds);
602
+ if (abs < 60)
603
+ return { value: seconds, unit: 'second' };
604
+ if (abs < 3600)
605
+ return { value: Math.round(seconds / 60), unit: 'minute' };
606
+ if (abs < 86400)
607
+ return { value: Math.round(seconds / 3600), unit: 'hour' };
608
+ if (abs < 86400 * 30)
609
+ return { value: Math.round(seconds / 86400), unit: 'day' };
610
+ if (abs < 86400 * 365)
611
+ return { value: Math.round(seconds / (86400 * 30)), unit: 'month' };
612
+ return { value: Math.round(seconds / (86400 * 365)), unit: 'year' };
613
+ }
614
+ //# sourceMappingURL=i18n.js.map