efficient-shell 4.175.0 → 4.179.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.
- package/README.md +426 -6
- package/dist/{Browser-PZIVSYLM.js → Browser-LZMLL4CZ.js} +14 -14
- package/dist/Calculator-R5OEHQ67.js +29 -0
- package/dist/ConfirmDialog-CMNQZQA3.js +1 -0
- package/dist/{CurrencyConverter-4RZZ5STO.js → CurrencyConverter-AMXUOQR2.js} +7 -7
- package/dist/{Documents-ERSFDOCV.js → Documents-M4HKZAPJ.js} +12 -12
- package/dist/{Files-3J2DW6ET.js → Files-OY5GKCXA.js} +24 -24
- package/dist/Notepad-JLDNTMVB.js +25 -0
- package/dist/PdfViewer-3SC3LE4U.js +1 -0
- package/dist/{PomodoroTimer-D6VQJICB.js → PomodoroTimer-LE6J2KUU.js} +24 -24
- package/dist/Preview-2KHLL6NP.js +188 -0
- package/dist/{Sidebar-2BZJ2MEI.js → Sidebar-BQ4P5LBI.js} +25 -25
- package/dist/Spreadsheet-B5Z5MSX4.js +37 -0
- package/dist/{Stock-KRPM6NSB.js → Stock-GWVG2INU.js} +4 -4
- package/dist/{Weather-HRH4JHTF.js → Weather-APBCG4TO.js} +13 -13
- package/dist/{WorldClock-OUSV52XM.js → WorldClock-2LMZYKWR.js} +7 -7
- package/dist/apps/index.d.ts +4 -2
- package/dist/apps/index.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/{chunk-L3U2R7DH.js → chunk-3DGTIWZP.js} +1 -1
- package/dist/{chunk-6BZCJQCT.js → chunk-47VJNVB6.js} +643 -643
- package/dist/{chunk-KS7OSQ3Y.js → chunk-5ZDM6WIC.js} +11 -11
- package/dist/{chunk-E2D54MVV.js → chunk-6CFBF543.js} +2 -2
- package/dist/{chunk-LCTSBQBJ.js → chunk-7WZEFHPS.js} +1 -1
- package/dist/{chunk-PGVUO7GB.js → chunk-AA4TMQOS.js} +3 -3
- package/dist/chunk-AZURXTRB.js +1 -0
- package/dist/chunk-C3QOHMR6.js +1 -0
- package/dist/{chunk-YJRC6IKD.js → chunk-CIXQKCFA.js} +4 -4
- package/dist/chunk-CZK2VKIO.js +9 -0
- package/dist/{chunk-KG4NRNFS.js → chunk-FORN7LG7.js} +1 -1
- package/dist/chunk-J3LIIIHJ.js +1 -0
- package/dist/chunk-KDRAU4XQ.js +27 -0
- package/dist/{chunk-ZOPYAOUP.js → chunk-KVOFUFPP.js} +1 -1
- package/dist/{chunk-KDHXRJIX.js → chunk-LK7V32MR.js} +1 -1
- package/dist/{chunk-GCO3A63X.js → chunk-N6STBYXR.js} +111 -111
- package/dist/{chunk-54OP3M3K.js → chunk-NHIGOEZF.js} +1 -1
- package/dist/{chunk-EXXHI5DO.js → chunk-OGXU7QFW.js} +2 -2
- package/dist/{chunk-JOOXVX4A.js → chunk-PE4F4MJE.js} +4 -4
- package/dist/chunk-R7EBJKN2.js +69 -0
- package/dist/{chunk-TMQEH7WA.js → chunk-SVO3ES2E.js} +1 -1
- package/dist/{chunk-RKR5V4QR.js → chunk-T4CFSGSL.js} +6 -6
- package/dist/{chunk-D3UQLWIZ.js → chunk-UAIVAA5X.js} +11 -11
- package/dist/{chunk-REXHKIIJ.js → chunk-WNEO7TSP.js} +1 -1
- package/dist/{chunk-XJYXKO7K.js → chunk-ZAE6ROV7.js} +15 -15
- package/dist/file-intake/index.js +1 -1
- package/dist/i18n/index.d.ts +79 -0
- package/dist/i18n/index.js +2 -0
- package/dist/{index-DIaav9a1.d.ts → index-DcUj0nXY.d.ts} +39 -927
- package/dist/index.d.ts +3 -2
- package/dist/index.js +656 -656
- package/dist/locales/zh-Hans.d.ts +59 -0
- package/dist/locales/zh-Hans.js +1 -0
- package/dist/map/index.js +3 -3
- package/dist/page-tabs/index.js +5 -5
- package/dist/pdf/index.js +1 -1
- package/dist/strings-ZbotP_I6.d.ts +1292 -0
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.js +1 -1
- package/package.json +21 -1
- package/dist/Calculator-6BJVESFN.js +0 -29
- package/dist/ConfirmDialog-6PVUVYXZ.js +0 -1
- package/dist/Notepad-MVMFJE2F.js +0 -25
- package/dist/PdfViewer-RKRGO7Q2.js +0 -1
- package/dist/Preview-VIHMVC7B.js +0 -187
- package/dist/Spreadsheet-KTB6JLBV.js +0 -37
- package/dist/chunk-3YTHR7IC.js +0 -1
- package/dist/chunk-7LAPNAKS.js +0 -1
- package/dist/chunk-FEK5ELXS.js +0 -27
- package/dist/chunk-VIIBZ6DE.js +0 -69
- package/dist/chunk-VRLHUZSC.js +0 -9
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ResourceLanguage, i18n, TFunction } from 'i18next';
|
|
2
|
+
import { S as ShellStringsOverride } from '../strings-ZbotP_I6.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, the shell loads the catalogue it ships for that language, if it
|
|
47
|
+
* ships one. Resolving to `undefined`, the shell's own words stay in the
|
|
48
|
+
* source language. */
|
|
49
|
+
loadShellStrings?: (language: string) => Promise<ShellStringsOverride | undefined>;
|
|
50
|
+
/** The language `copy` is written in. Defaults to `en`. */
|
|
51
|
+
source?: string;
|
|
52
|
+
/** The namespace `t('key')` reads when it names none. Defaults to `common`. */
|
|
53
|
+
defaultNamespace?: string;
|
|
54
|
+
}
|
|
55
|
+
interface ShellI18nActivation {
|
|
56
|
+
/** The language actually in force: the one asked for, or the source
|
|
57
|
+
* language when its copy could not be loaded. */
|
|
58
|
+
language: string;
|
|
59
|
+
/** The shell's catalog for it, for `ShellLanguageProvider`'s `strings`. */
|
|
60
|
+
strings?: ShellStringsOverride;
|
|
61
|
+
/** The requested language's copy could not be loaded, and the page is in the
|
|
62
|
+
* source language instead. */
|
|
63
|
+
failed: boolean;
|
|
64
|
+
}
|
|
65
|
+
interface ShellI18n {
|
|
66
|
+
/** The i18next instance, for anything this entry does not wrap. It is also
|
|
67
|
+
* the instance `react-i18next`'s `useTranslation` reads. */
|
|
68
|
+
i18n: i18n;
|
|
69
|
+
/** Read copy by key, anywhere: a module-level constant, a utility, a
|
|
70
|
+
* component. Typed by the host's `CustomTypeOptions`, like i18next's own. */
|
|
71
|
+
t: TFunction;
|
|
72
|
+
/** Load a language's copy and switch to it. Call once, before the app is
|
|
73
|
+
* imported. Never rejects: a language that cannot be loaded leaves the
|
|
74
|
+
* page in the source language, with `failed` set. */
|
|
75
|
+
activate: (language: string) => Promise<ShellI18nActivation>;
|
|
76
|
+
}
|
|
77
|
+
declare function createShellI18n({ copy, load, loadShellStrings, source, defaultNamespace, }: CreateShellI18nOptions): ShellI18n;
|
|
78
|
+
|
|
79
|
+
export { type CreateShellI18nOptions, type ShellI18n, type ShellI18nActivation, createShellI18n };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from"i18next";import{initReactI18next as a}from"react-i18next";var t=/* @__PURE__ */new Map([["zh-Hans",()=>import("../locales/zh-Hans.js").then(e=>e.zhHansStrings())]]),n=async e=>t.get(e)?.();function r({copy:t,load:r,loadShellStrings:o=n,source:s="en",defaultNamespace:i="common"}){const l=e.createInstance();l.use(a).init({lng:s,fallbackLng:s,resources:{[s]:t},ns:Object.keys(t),defaultNS:i,initAsync:!1,interpolation:{escapeValue:!1}});let c=!1,f=!1;return{i18n:l,t:(...e)=>(f||(c=!0),l.t(...e)),activate:async e=>{if(f=!0,e===s)return{language:s,failed:!1};c&&console.error(`[efficient-shell/i18n] copy was read before activate("${e}") ran, so those strings stay in "${s}" for the life of this page. Import the app only after activate() resolves.`);try{const[a,t]=await Promise.all([r(e),o(e)]);for(const[t,n]of Object.entries(a))l.addResourceBundle(e,t,n,!0,!0);return await l.changeLanguage(e),{language:e,strings:t,failed:!1}}catch(a){return console.error(`[efficient-shell/i18n] could not load "${e}"; staying in "${s}".`,a),{language:s,failed:!0}}}}}export{r as createShellI18n};
|