efficient-shell 4.175.0 → 4.177.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 (40) hide show
  1. package/README.md +46 -1
  2. package/dist/{Browser-PZIVSYLM.js → Browser-MFFTBGEB.js} +14 -14
  3. package/dist/{Calculator-6BJVESFN.js → Calculator-AGQQYMMZ.js} +18 -18
  4. package/dist/{CurrencyConverter-4RZZ5STO.js → CurrencyConverter-KZPE7ZCC.js} +4 -4
  5. package/dist/{Documents-ERSFDOCV.js → Documents-ZD227WZC.js} +11 -11
  6. package/dist/{Files-3J2DW6ET.js → Files-BLGT4RLF.js} +27 -27
  7. package/dist/{Notepad-MVMFJE2F.js → Notepad-LUK2IFHD.js} +9 -9
  8. package/dist/{PomodoroTimer-D6VQJICB.js → PomodoroTimer-LHPV6QXG.js} +25 -25
  9. package/dist/{Preview-VIHMVC7B.js → Preview-5CALO6PW.js} +12 -12
  10. package/dist/{Sidebar-2BZJ2MEI.js → Sidebar-4GIZSTD5.js} +25 -25
  11. package/dist/{Spreadsheet-KTB6JLBV.js → Spreadsheet-F3VBCPHF.js} +14 -14
  12. package/dist/{Stock-KRPM6NSB.js → Stock-XSDFN7U2.js} +1 -1
  13. package/dist/{Weather-HRH4JHTF.js → Weather-7YDUDMCO.js} +11 -11
  14. package/dist/{WorldClock-OUSV52XM.js → WorldClock-Q2JHBKLS.js} +4 -4
  15. package/dist/apps/index.js +1 -1
  16. package/dist/bin/ui-check.js +1 -1
  17. package/dist/{chunk-VRLHUZSC.js → chunk-4PCIZFDR.js} +1 -1
  18. package/dist/chunk-7H6Q5TNN.js +27 -0
  19. package/dist/{chunk-PGVUO7GB.js → chunk-AA4TMQOS.js} +3 -3
  20. package/dist/{chunk-TMQEH7WA.js → chunk-AI6HQ55O.js} +1 -1
  21. package/dist/{chunk-6BZCJQCT.js → chunk-AZO5NPB4.js} +125 -125
  22. package/dist/chunk-MFXG5BWL.js +1 -0
  23. package/dist/{chunk-D3UQLWIZ.js → chunk-N6BJG6AL.js} +8 -8
  24. package/dist/{chunk-EXXHI5DO.js → chunk-OGXU7QFW.js} +2 -2
  25. package/dist/{chunk-JOOXVX4A.js → chunk-PE6MTNFO.js} +1 -1
  26. package/dist/{chunk-KG4NRNFS.js → chunk-Q7UGGJ5X.js} +1 -1
  27. package/dist/{chunk-GCO3A63X.js → chunk-TZ2BPFCT.js} +52 -52
  28. package/dist/i18n/index.d.ts +78 -0
  29. package/dist/i18n/index.js +2 -0
  30. package/dist/{index-DIaav9a1.d.ts → index-BS_HzJCc.d.ts} +27 -927
  31. package/dist/index.d.ts +3 -2
  32. package/dist/index.js +89 -89
  33. package/dist/map/index.js +3 -3
  34. package/dist/page-tabs/index.js +5 -5
  35. package/dist/strings-C3kt6WTH.d.ts +924 -0
  36. package/dist/ui/index.d.ts +2 -1
  37. package/dist/ui/index.js +1 -1
  38. package/package.json +16 -1
  39. package/dist/chunk-7LAPNAKS.js +0 -1
  40. package/dist/chunk-FEK5ELXS.js +0 -27
@@ -0,0 +1,78 @@
1
+ import { ResourceLanguage, i18n, TFunction } from 'i18next';
2
+ import { S as ShellStringsOverride } from '../strings-C3kt6WTH.js';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
5
+
6
+ /**
7
+ * efficient-shell/i18n — a host's own copy, in the language the shell is in.
8
+ *
9
+ * The shell's strings live in its typed catalog (`strings.tsx`) and the shell
10
+ * decides which language is active (`language.tsx`). Neither holds a HOST's
11
+ * copy: its column headings, its page titles, its toasts. That copy goes
12
+ * through i18next, and this entry is the one place it is set up, so every
13
+ * portal initialises it the same way and one language drives both halves.
14
+ *
15
+ * `i18next` and `react-i18next` are optional peers of this entry alone. A host
16
+ * that offers one language never installs them, and nothing reachable from
17
+ * `efficient-shell` or `efficient-shell/ui` imports them
18
+ * (`scripts/verify-dist.mjs`).
19
+ *
20
+ * ── The order a host boots in ──
21
+ * A language is fixed for the life of a page (see `language.tsx`), so:
22
+ *
23
+ * 1. `createShellI18n({ copy, load })` at module scope. It initialises
24
+ * SYNCHRONOUSLY with the source-language copy, so `t` already answers in
25
+ * English: a unit test that imports a column set gets English with no
26
+ * setup at all.
27
+ * 2. Before the app is imported, `await activate(resolveShellLanguage(…))`.
28
+ * It loads that language's copy and the shell's catalog for it together
29
+ * and switches `t` over.
30
+ * 3. Only then import the app, and hand `activation.strings` to
31
+ * `ShellLanguageProvider`.
32
+ *
33
+ * The order matters because a host's column sets, navigation and status
34
+ * buckets are module-level constants: they call `t` when they are IMPORTED and
35
+ * keep what it said. Copy read before step 2 stays in the source language for
36
+ * the life of the page, silently. `activate` says so out loud when it happens.
37
+ */
38
+
39
+ interface CreateShellI18nOptions {
40
+ /** The source language's copy, bundled with the app: namespace → messages. */
41
+ copy: ResourceLanguage;
42
+ /** Another language's copy, in the same shape. Usually a dynamic import per
43
+ * language, so a reader downloads only their own. */
44
+ load: (language: string) => Promise<ResourceLanguage>;
45
+ /** The shell's own catalog for a language — `efficient-shell/locales/<tag>`.
46
+ * Omitted, or resolving to `undefined`, the shell's own words stay in the
47
+ * source language. */
48
+ loadShellStrings?: (language: string) => Promise<ShellStringsOverride | undefined>;
49
+ /** The language `copy` is written in. Defaults to `en`. */
50
+ source?: string;
51
+ /** The namespace `t('key')` reads when it names none. Defaults to `common`. */
52
+ defaultNamespace?: string;
53
+ }
54
+ interface ShellI18nActivation {
55
+ /** The language actually in force: the one asked for, or the source
56
+ * language when its copy could not be loaded. */
57
+ language: string;
58
+ /** The shell's catalog for it, for `ShellLanguageProvider`'s `strings`. */
59
+ strings?: ShellStringsOverride;
60
+ /** The requested language's copy could not be loaded, and the page is in the
61
+ * source language instead. */
62
+ failed: boolean;
63
+ }
64
+ interface ShellI18n {
65
+ /** The i18next instance, for anything this entry does not wrap. It is also
66
+ * the instance `react-i18next`'s `useTranslation` reads. */
67
+ i18n: i18n;
68
+ /** Read copy by key, anywhere: a module-level constant, a utility, a
69
+ * component. Typed by the host's `CustomTypeOptions`, like i18next's own. */
70
+ t: TFunction;
71
+ /** Load a language's copy and switch to it. Call once, before the app is
72
+ * imported. Never rejects: a language that cannot be loaded leaves the
73
+ * page in the source language, with `failed` set. */
74
+ activate: (language: string) => Promise<ShellI18nActivation>;
75
+ }
76
+ declare function createShellI18n({ copy, load, loadShellStrings, source, defaultNamespace, }: CreateShellI18nOptions): ShellI18n;
77
+
78
+ export { type CreateShellI18nOptions, type ShellI18n, type ShellI18nActivation, createShellI18n };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import e from"i18next";import{initReactI18next as t}from"react-i18next";function a({copy:a,load:n,loadShellStrings:o,source:r="en",defaultNamespace:i="common"}){const s=e.createInstance();s.use(t).init({lng:r,fallbackLng:r,resources:{[r]:a},ns:Object.keys(a),defaultNS:i,initAsync:!1,interpolation:{escapeValue:!1}});let l=!1,c=!1;return{i18n:s,t:(...e)=>(c||(l=!0),s.t(...e)),activate:async e=>{if(c=!0,e===r)return{language:r,failed:!1};l&&console.error(`[efficient-shell/i18n] copy was read before activate("${e}") ran, so those strings stay in "${r}" for the life of this page. Import the app only after activate() resolves.`);try{const[t,a]=await Promise.all([n(e),o?.(e)]);for(const[a,n]of Object.entries(t))s.addResourceBundle(e,a,n,!0,!0);return await s.changeLanguage(e),{language:e,strings:a,failed:!1}}catch(t){return console.error(`[efficient-shell/i18n] could not load "${e}"; staying in "${r}".`,t),{language:r,failed:!0}}}}}export{a as createShellI18n};