gemi 0.53.0 → 0.54.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/dist/app/index.js +2 -2
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gemi.js +1456 -5
- package/dist/bin/gemi.js.map +9 -5
- package/dist/broadcasting/index.js +1 -1
- package/dist/bun/plugin.js +2 -2
- package/dist/bun/plugin.js.map +1 -1
- package/dist/bun/preload.js +2 -2
- package/dist/bun/preload.js.map +1 -1
- package/dist/{chunk-msz8rngs.js → chunk-004bcmsa.js} +2 -2
- package/dist/chunk-004bcmsa.js.map +10 -0
- package/dist/chunk-07t0dmdg.js +4 -0
- package/dist/{chunk-faa987e4.js.map → chunk-07t0dmdg.js.map} +2 -2
- package/dist/{chunk-cg53h5ht.js → chunk-0weeq0ke.js} +2 -2
- package/dist/{chunk-cg53h5ht.js.map → chunk-0weeq0ke.js.map} +1 -1
- package/dist/chunk-113khwbw.js +5 -0
- package/dist/{chunk-2qn472j4.js.map → chunk-113khwbw.js.map} +1 -1
- package/dist/{chunk-tmk4zfz9.js → chunk-1sh6kqjn.js} +3 -3
- package/dist/{chunk-tmk4zfz9.js.map → chunk-1sh6kqjn.js.map} +1 -1
- package/dist/{chunk-2gw6cyyj.js → chunk-1snh7yc4.js} +2 -2
- package/dist/{chunk-2gw6cyyj.js.map → chunk-1snh7yc4.js.map} +1 -1
- package/dist/chunk-26r8dcxd.js +6 -0
- package/dist/{chunk-ffre1z8s.js.map → chunk-26r8dcxd.js.map} +2 -2
- package/dist/{chunk-ebcgdv00.js → chunk-2pt6kyn9.js} +3 -3
- package/dist/{chunk-ebcgdv00.js.map → chunk-2pt6kyn9.js.map} +1 -1
- package/dist/{chunk-1pqfmw5h.js → chunk-2zmz3pjk.js} +3 -3
- package/dist/{chunk-1pqfmw5h.js.map → chunk-2zmz3pjk.js.map} +1 -1
- package/dist/{chunk-zhsaz9cr.js → chunk-3bw1jk21.js} +1 -1
- package/dist/chunk-4qkzdyj7.js +4 -0
- package/dist/{chunk-0h3jr9d9.js.map → chunk-4qkzdyj7.js.map} +1 -1
- package/dist/{chunk-d1ahbza9.js → chunk-50vm7x98.js} +3 -3
- package/dist/{chunk-d1ahbza9.js.map → chunk-50vm7x98.js.map} +1 -1
- package/dist/{chunk-qyaqg07q.js → chunk-6j1z2cqt.js} +2 -2
- package/dist/{chunk-qyaqg07q.js.map → chunk-6j1z2cqt.js.map} +1 -1
- package/dist/chunk-6rhebm18.js +5 -0
- package/dist/chunk-6rhebm18.js.map +10 -0
- package/dist/{chunk-rq770c71.js → chunk-71m47kad.js} +2 -2
- package/dist/{chunk-rq770c71.js.map → chunk-71m47kad.js.map} +1 -1
- package/dist/{chunk-0h3jr9d9.js → chunk-7f5ad759.js} +2 -2
- package/dist/{chunk-4e61qbp4.js.map → chunk-7f5ad759.js.map} +1 -1
- package/dist/chunk-85av4ncy.js +4 -0
- package/dist/{chunk-3d3nmr5g.js.map → chunk-85av4ncy.js.map} +2 -2
- package/dist/{chunk-23g7qdpg.js → chunk-9taz1h3t.js} +3 -3
- package/dist/{chunk-23g7qdpg.js.map → chunk-9taz1h3t.js.map} +1 -1
- package/dist/{chunk-ppt296ye.js → chunk-agabw2w1.js} +2 -2
- package/dist/{chunk-ppt296ye.js.map → chunk-agabw2w1.js.map} +1 -1
- package/dist/{chunk-092pj2j2.js → chunk-bb3zvxsf.js} +3 -3
- package/dist/{chunk-092pj2j2.js.map → chunk-bb3zvxsf.js.map} +1 -1
- package/dist/{chunk-h7jv3ame.js → chunk-br8ten26.js} +2 -2
- package/dist/{chunk-h7jv3ame.js.map → chunk-br8ten26.js.map} +1 -1
- package/dist/{chunk-4e61qbp4.js → chunk-bzhtymvv.js} +2 -2
- package/dist/{chunk-8p6rqegw.js.map → chunk-bzhtymvv.js.map} +1 -1
- package/dist/{chunk-68w225rv.js → chunk-c0wcsmpj.js} +2 -2
- package/dist/{chunk-68w225rv.js.map → chunk-c0wcsmpj.js.map} +1 -1
- package/dist/{chunk-xsmt86n3.js → chunk-c22vcxty.js} +2 -2
- package/dist/{chunk-xsmt86n3.js.map → chunk-c22vcxty.js.map} +1 -1
- package/dist/{chunk-07jtzbf0.js → chunk-c2pv3ah8.js} +2 -2
- package/dist/{chunk-07jtzbf0.js.map → chunk-c2pv3ah8.js.map} +2 -2
- package/dist/{chunk-q09mmr05.js → chunk-cz3szqhq.js} +2 -2
- package/dist/{chunk-q09mmr05.js.map → chunk-cz3szqhq.js.map} +1 -1
- package/dist/{chunk-69w4egkg.js → chunk-dwx2y7br.js} +4 -4
- package/dist/{chunk-69w4egkg.js.map → chunk-dwx2y7br.js.map} +1 -1
- package/dist/{chunk-2sfz64xh.js → chunk-dxw8k6f1.js} +2 -2
- package/dist/{chunk-2sfz64xh.js.map → chunk-dxw8k6f1.js.map} +1 -1
- package/dist/chunk-e3mggavt.js +5 -0
- package/dist/chunk-e3mggavt.js.map +11 -0
- package/dist/{chunk-j1knf8gv.js → chunk-efsk1wy0.js} +3 -3
- package/dist/{chunk-j1knf8gv.js.map → chunk-efsk1wy0.js.map} +1 -1
- package/dist/{chunk-t4n25km9.js → chunk-f13f68c0.js} +2 -2
- package/dist/{chunk-t4n25km9.js.map → chunk-f13f68c0.js.map} +1 -1
- package/dist/{chunk-vv72kw74.js → chunk-f418jh9k.js} +2 -2
- package/dist/{chunk-vv72kw74.js.map → chunk-f418jh9k.js.map} +1 -1
- package/dist/chunk-f4e7fh95.js +17 -0
- package/dist/chunk-f4e7fh95.js.map +14 -0
- package/dist/{chunk-ewgv1j8q.js → chunk-fcqc3e3r.js} +2 -2
- package/dist/{chunk-ewgv1j8q.js.map → chunk-fcqc3e3r.js.map} +1 -1
- package/dist/{chunk-3y9nf09k.js → chunk-g5tj10p8.js} +2 -2
- package/dist/{chunk-3y9nf09k.js.map → chunk-g5tj10p8.js.map} +1 -1
- package/dist/chunk-gn9zjgep.js +5 -0
- package/dist/chunk-gn9zjgep.js.map +10 -0
- package/dist/{chunk-5s45prj5.js → chunk-h7mcwfg5.js} +4 -4
- package/dist/{chunk-5s45prj5.js.map → chunk-h7mcwfg5.js.map} +1 -1
- package/dist/chunk-hk067634.js +4 -0
- package/dist/{chunk-vnjvd82s.js.map → chunk-hk067634.js.map} +2 -2
- package/dist/{chunk-qx6sahe0.js → chunk-hrrmxreg.js} +2 -2
- package/dist/{chunk-qx6sahe0.js.map → chunk-hrrmxreg.js.map} +1 -1
- package/dist/{chunk-p22rkf1g.js → chunk-jb022m7n.js} +2 -2
- package/dist/{chunk-p22rkf1g.js.map → chunk-jb022m7n.js.map} +1 -1
- package/dist/chunk-jb2nst6v.js +4 -0
- package/dist/{chunk-6scjrbw7.js.map → chunk-jb2nst6v.js.map} +2 -2
- package/dist/{chunk-kxzwem3g.js → chunk-jdgvdddd.js} +2 -2
- package/dist/{chunk-kxzwem3g.js.map → chunk-jdgvdddd.js.map} +1 -1
- package/dist/{chunk-2yth3kk2.js → chunk-jp4pf3yt.js} +4 -4
- package/dist/{chunk-2yth3kk2.js.map → chunk-jp4pf3yt.js.map} +1 -1
- package/dist/chunk-k14dmqwh.js +5 -0
- package/dist/{chunk-92793zh4.js.map → chunk-k14dmqwh.js.map} +4 -3
- package/dist/{chunk-tkv6cw94.js → chunk-k8endm5j.js} +3 -3
- package/dist/{chunk-tkv6cw94.js.map → chunk-k8endm5j.js.map} +1 -1
- package/dist/chunk-kkkqyvwv.js +81 -0
- package/dist/{chunk-ear03axe.js.map → chunk-kkkqyvwv.js.map} +7 -5
- package/dist/{chunk-cmq5t8p9.js → chunk-kv2ep453.js} +3 -3
- package/dist/{chunk-cmq5t8p9.js.map → chunk-kv2ep453.js.map} +1 -1
- package/dist/{chunk-z4q1ty6w.js → chunk-kz39hphm.js} +3 -3
- package/dist/{chunk-z4q1ty6w.js.map → chunk-kz39hphm.js.map} +1 -1
- package/dist/{chunk-kaxvw75w.js → chunk-ms8qd7da.js} +3 -3
- package/dist/{chunk-kaxvw75w.js.map → chunk-ms8qd7da.js.map} +1 -1
- package/dist/{chunk-ttzkn1qd.js → chunk-n1tkn8gv.js} +2 -2
- package/dist/{chunk-ttzkn1qd.js.map → chunk-n1tkn8gv.js.map} +1 -1
- package/dist/chunk-nncwsdzz.js +5 -0
- package/dist/chunk-nncwsdzz.js.map +10 -0
- package/dist/{chunk-7s1g3v1y.js → chunk-pgjk5ft3.js} +3 -3
- package/dist/{chunk-7s1g3v1y.js.map → chunk-pgjk5ft3.js.map} +1 -1
- package/dist/{chunk-tztqkat2.js → chunk-r06rxn19.js} +2 -2
- package/dist/{chunk-tztqkat2.js.map → chunk-r06rxn19.js.map} +1 -1
- package/dist/chunk-r9z5rrk0.js +4 -0
- package/dist/{chunk-1ab1ptq5.js.map → chunk-r9z5rrk0.js.map} +2 -2
- package/dist/{chunk-h5g05qwb.js → chunk-s6e7cvek.js} +2 -2
- package/dist/{chunk-h5g05qwb.js.map → chunk-s6e7cvek.js.map} +1 -1
- package/dist/{chunk-qjnv2rkh.js → chunk-sqp7kn7h.js} +3 -3
- package/dist/{chunk-qjnv2rkh.js.map → chunk-sqp7kn7h.js.map} +1 -1
- package/dist/{chunk-mt2755rs.js → chunk-w6gb9gc5.js} +3 -3
- package/dist/{chunk-mt2755rs.js.map → chunk-w6gb9gc5.js.map} +1 -1
- package/dist/{chunk-ha7n1c94.js → chunk-xxw0gz4q.js} +2 -2
- package/dist/{chunk-ha7n1c94.js.map → chunk-xxw0gz4q.js.map} +1 -1
- package/dist/chunk-ywr2vd5r.js +5 -0
- package/dist/{chunk-9279y4af.js.map → chunk-ywr2vd5r.js.map} +2 -2
- package/dist/{chunk-fbp5vapa.js → chunk-zckj6bs6.js} +3 -3
- package/dist/{chunk-fbp5vapa.js.map → chunk-zckj6bs6.js.map} +2 -2
- package/dist/chunks/{ThemeProvider-CTX9LOFC.js → ThemeProvider-Bk1eZymb.js} +186 -3
- package/dist/chunks/ThemeProvider-Bk1eZymb.js.map +1 -0
- package/dist/client/ComponentContext.d.ts.map +1 -1
- package/dist/client/DictionarySinkContext.d.ts +10 -0
- package/dist/client/DictionarySinkContext.d.ts.map +1 -0
- package/dist/client/createRoot.d.ts.map +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +187 -8
- package/dist/client/index.js.map +1 -1
- package/dist/client/useDictionary.d.ts +34 -0
- package/dist/client/useDictionary.d.ts.map +1 -0
- package/dist/client/useDictionary.test-d.d.ts +2 -0
- package/dist/client/useDictionary.test-d.d.ts.map +1 -0
- package/dist/client/useTranslator.d.ts +8 -0
- package/dist/client/useTranslator.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Lang.d.ts.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/Dictionary.d.ts +7 -0
- package/dist/i18n/Dictionary.d.ts.map +1 -1
- package/dist/i18n/Translator.d.ts +12 -0
- package/dist/i18n/Translator.d.ts.map +1 -1
- package/dist/i18n/config.d.ts +6 -0
- package/dist/i18n/config.d.ts.map +1 -1
- package/dist/i18n/defineDictionary.d.ts +65 -0
- package/dist/i18n/defineDictionary.d.ts.map +1 -0
- package/dist/i18n/dictionaryRegistry.d.ts +85 -0
- package/dist/i18n/dictionaryRegistry.d.ts.map +1 -0
- package/dist/i18n/dictionaryRuntime.d.ts +16 -0
- package/dist/i18n/dictionaryRuntime.d.ts.map +1 -0
- package/dist/i18n/dictionaryRuntime.js +4 -0
- package/dist/i18n/dictionaryRuntime.js.map +9 -0
- package/dist/i18n/dictionaryShape.d.ts +66 -0
- package/dist/i18n/dictionaryShape.d.ts.map +1 -0
- package/dist/i18n/dictionarySink.d.ts +31 -0
- package/dist/i18n/dictionarySink.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +5 -4
- package/dist/i18n/translate.d.ts +21 -0
- package/dist/i18n/translate.d.ts.map +1 -0
- package/dist/internal/gemiExternals.d.ts +1 -1
- package/dist/internal/gemiExternals.d.ts.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +2 -2
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.js +4 -4
- package/dist/services/index.js.map +2 -2
- package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/streamQueryInjection.d.ts +9 -1
- package/dist/services/router/streamQueryInjection.d.ts.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/vite/__vite-browser-external-S5EYS4bz.mjs +7 -0
- package/dist/vite/api_vite-DSBC5Nzy.mjs +5 -0
- package/dist/vite/browser-DFEUWTkA.mjs +6086 -0
- package/dist/vite/build-C0lmnz6d.mjs +5326 -0
- package/dist/vite/index.mjs +1349 -1
- package/dist/vite/lib-TT6NqN6b.mjs +363 -0
- package/dist/vite/lib-U4DF62jt.mjs +48846 -0
- package/dist/vite/main-Drp2rSLR.mjs +2123 -0
- package/dist/vite/node-BgyIm-M7.mjs +17799 -0
- package/dist/vite/node-yGkKTK1d.mjs +789 -0
- package/dist/vite/postcss-hCXrlC4m.mjs +3515 -0
- package/dist/vite/postcss-import-rYEe0OKc.mjs +448 -0
- package/dist/vite/prompt--dNycKSZ-BmZ8jzP_.mjs +889 -0
- package/dist/vite/rolldown-runtime-B4lejLz5.mjs +37 -0
- package/package.json +3 -1
- package/dist/chunk-1ab1ptq5.js +0 -4
- package/dist/chunk-2qn472j4.js +0 -5
- package/dist/chunk-3d3nmr5g.js +0 -4
- package/dist/chunk-6scjrbw7.js +0 -4
- package/dist/chunk-88pq4gmf.js +0 -5
- package/dist/chunk-88pq4gmf.js.map +0 -10
- package/dist/chunk-8p6rqegw.js +0 -4
- package/dist/chunk-92793zh4.js +0 -5
- package/dist/chunk-9279y4af.js +0 -5
- package/dist/chunk-bq4w14a6.js +0 -5
- package/dist/chunk-bq4w14a6.js.map +0 -10
- package/dist/chunk-ear03axe.js +0 -81
- package/dist/chunk-faa987e4.js +0 -4
- package/dist/chunk-ffre1z8s.js +0 -6
- package/dist/chunk-msz8rngs.js.map +0 -10
- package/dist/chunk-vnjvd82s.js +0 -4
- package/dist/chunk-xw44bwnh.js +0 -5
- package/dist/chunk-xw44bwnh.js.map +0 -11
- package/dist/chunk-y4djde42.js +0 -5
- package/dist/chunk-y4djde42.js.map +0 -11
- package/dist/chunks/ThemeProvider-CTX9LOFC.js.map +0 -1
- /package/dist/{chunk-zhsaz9cr.js.map → chunk-3bw1jk21.js.map} +0 -0
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fragment, StrictMode, Suspense, createContext, createElement, isValidElement, memo, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
|
|
1
|
+
import { B as QueryError, C as I18nContext, D as useLocation, E as ServerDataProvider, F as applyParams$1, I as QueryConfigContext, L as QueryManagerContext, M as RouteStateContext, N as RouteStateProvider, P as toVariantKey, R as QueryManagerProvider, S as useNavigate, T as ServerDataContext, V as Subject, _ as setActiveLocale, a as m, b as useRoute, c as ClientRouterContext, d as ComponentsProvider, f as loadViewModule, g as registerDictionary, h as loadDictionaryForRender, i as WebSocketContextProvider, j as useParams, k as Action, l as ClientRouterProvider, m as loadDictionary, n as useTheme, o as RouteTransitionProvider, p as subscribeViewModules, r as WebSocketContext, s as useRouteTransition, t as ThemeProvider, u as ComponentsContext, v as readRoutePayload, w as I18nProvider, x as useSearchParams, y as routeDataUrl, z as DEFAULT_STALE_TIME } from "../chunks/ThemeProvider-Bk1eZymb.js";
|
|
2
|
+
import { Fragment, StrictMode, Suspense, createContext, createElement, isValidElement, memo, use, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
|
|
3
3
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { createRoot as createRoot$1, hydrateRoot } from "react-dom/client";
|
|
5
5
|
//#region client/ServerQueryContext.tsx
|
|
@@ -1332,17 +1332,30 @@ function create(RootLayout, { componentTree, loaders, routeManifest, router, i18
|
|
|
1332
1332
|
}) }));
|
|
1333
1333
|
}
|
|
1334
1334
|
//#endregion
|
|
1335
|
+
//#region client/DictionarySinkContext.ts
|
|
1336
|
+
/**
|
|
1337
|
+
* The SSR-only collector `useDictionary` reports into. `null` in the browser,
|
|
1338
|
+
* where nothing needs collecting — the strings are already there.
|
|
1339
|
+
*
|
|
1340
|
+
* Mirrors `ServerQueryContext`: a server-supplied per-request object handed to
|
|
1341
|
+
* the tree by `createRoot`.
|
|
1342
|
+
*/
|
|
1343
|
+
var DictionarySinkContext = createContext(null);
|
|
1344
|
+
//#endregion
|
|
1335
1345
|
//#region client/createRoot.tsx
|
|
1336
1346
|
function createRoot(RootLayout, options = {}) {
|
|
1337
1347
|
return (props) => /* @__PURE__ */ jsx(ServerDataProvider, {
|
|
1338
1348
|
value: props.data,
|
|
1339
1349
|
children: /* @__PURE__ */ jsx(ServerQueryContext.Provider, {
|
|
1340
1350
|
value: props.serverQueries ?? null,
|
|
1341
|
-
children: /* @__PURE__ */ jsx(
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1351
|
+
children: /* @__PURE__ */ jsx(DictionarySinkContext.Provider, {
|
|
1352
|
+
value: props.dictionarySink ?? null,
|
|
1353
|
+
children: /* @__PURE__ */ jsx(ClientRouter, {
|
|
1354
|
+
RootLayout,
|
|
1355
|
+
viewImportMap: props.viewImportMap,
|
|
1356
|
+
viewModules: props.viewModules,
|
|
1357
|
+
queryConfig: options.queryConfig
|
|
1358
|
+
})
|
|
1346
1359
|
})
|
|
1347
1360
|
})
|
|
1348
1361
|
});
|
|
@@ -1501,6 +1514,14 @@ function parseTranslation(template, params) {
|
|
|
1501
1514
|
}
|
|
1502
1515
|
//#endregion
|
|
1503
1516
|
//#region client/useTranslator.ts
|
|
1517
|
+
/**
|
|
1518
|
+
* @deprecated Use `useDictionary(dict)` with a `defineDictionary` dictionary
|
|
1519
|
+
* declared next to the component. This resolves a dictionary by name through
|
|
1520
|
+
* the global `I18nDictionary` interface, which needs a `gemi.d.ts`
|
|
1521
|
+
* declaration, a central `app/i18n/index.ts`, and a hand-maintained `prefetch`
|
|
1522
|
+
* map naming every route's dictionaries — and it ships whatever that map says
|
|
1523
|
+
* whether the page reads it or not. Still supported; see `docs/i18n.md`.
|
|
1524
|
+
*/
|
|
1504
1525
|
function useTranslator(component) {
|
|
1505
1526
|
const { i18n } = useRouteData();
|
|
1506
1527
|
function parse(key, ...args) {
|
|
@@ -1519,6 +1540,164 @@ function useTranslator(component) {
|
|
|
1519
1540
|
return parse;
|
|
1520
1541
|
}
|
|
1521
1542
|
//#endregion
|
|
1543
|
+
//#region client/useDictionary.ts
|
|
1544
|
+
/**
|
|
1545
|
+
* Read a dictionary declared with `defineDictionary`, next to the component
|
|
1546
|
+
* that uses it.
|
|
1547
|
+
*
|
|
1548
|
+
* ```tsx
|
|
1549
|
+
* const t = useDictionary(homeDict);
|
|
1550
|
+
* t("title", { name });
|
|
1551
|
+
* ```
|
|
1552
|
+
*
|
|
1553
|
+
* Keys and interpolation params come straight from the literal — there is no
|
|
1554
|
+
* name string to keep in sync and no `gemi.d.ts` augmentation.
|
|
1555
|
+
*
|
|
1556
|
+
* Normally this resolves without suspending: the server seeds the strings it
|
|
1557
|
+
* rendered with into the hydration payload, and the router warms a view's
|
|
1558
|
+
* dictionaries while it is already loading that view's chunks. It falls back to
|
|
1559
|
+
* suspending on the locale's chunk when neither happened — a dictionary inside
|
|
1560
|
+
* a `lazy()` subtree, or the first render after a locale switch.
|
|
1561
|
+
*
|
|
1562
|
+
* Replaces `useTranslator`, which is deprecated.
|
|
1563
|
+
*/
|
|
1564
|
+
function useDictionary(dictionary) {
|
|
1565
|
+
const { i18n } = useRouteData();
|
|
1566
|
+
const sink = useContext(DictionarySinkContext);
|
|
1567
|
+
const locale = i18n?.currentLocale ?? dictionary.locales[0];
|
|
1568
|
+
setActiveLocale(locale);
|
|
1569
|
+
const pending = dictionary.loadForRender(locale);
|
|
1570
|
+
const strings = pending instanceof Promise ? use(pending) : pending;
|
|
1571
|
+
sink?.use(dictionary.id, locale, strings);
|
|
1572
|
+
function parse(key, ...args) {
|
|
1573
|
+
const template = strings[key];
|
|
1574
|
+
if (typeof template !== "string") {
|
|
1575
|
+
console.error(`Unresolved translation key:${key} locale:${locale} dictionary:${dictionary.id}`);
|
|
1576
|
+
return key;
|
|
1577
|
+
}
|
|
1578
|
+
const [params = {}] = args;
|
|
1579
|
+
return parseTranslation(template, params);
|
|
1580
|
+
}
|
|
1581
|
+
parse.jsx = (key, ...args) => {
|
|
1582
|
+
return parse(key, ...args);
|
|
1583
|
+
};
|
|
1584
|
+
return parse;
|
|
1585
|
+
}
|
|
1586
|
+
//#endregion
|
|
1587
|
+
//#region i18n/dictionaryShape.ts
|
|
1588
|
+
/**
|
|
1589
|
+
* Locales the dictionary declares, source language first.
|
|
1590
|
+
*
|
|
1591
|
+
* The order is meaningful: the first locale is the source language, and a key
|
|
1592
|
+
* missing from some other locale falls back along this list.
|
|
1593
|
+
*
|
|
1594
|
+
* `sourceLocale` pins that choice. Without it the source language is whichever
|
|
1595
|
+
* locale is seen first while walking the literal, which makes it an emergent
|
|
1596
|
+
* property of key order — adding a key at the top of a dictionary whose other
|
|
1597
|
+
* keys happen to lack `en-US` would silently re-point every fallback in it. Any
|
|
1598
|
+
* dictionary that is not uniformly translated should say which locale it is
|
|
1599
|
+
* authored in.
|
|
1600
|
+
*/
|
|
1601
|
+
function dictionaryLocales(translations, sourceLocale) {
|
|
1602
|
+
const locales = [];
|
|
1603
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1604
|
+
if (sourceLocale) {
|
|
1605
|
+
seen.add(sourceLocale);
|
|
1606
|
+
locales.push(sourceLocale);
|
|
1607
|
+
}
|
|
1608
|
+
for (const byLocale of Object.values(translations)) for (const locale of Object.keys(byLocale)) if (!seen.has(locale)) {
|
|
1609
|
+
seen.add(locale);
|
|
1610
|
+
locales.push(locale);
|
|
1611
|
+
}
|
|
1612
|
+
return locales;
|
|
1613
|
+
}
|
|
1614
|
+
/**
|
|
1615
|
+
* Flatten one locale out of a dictionary.
|
|
1616
|
+
*
|
|
1617
|
+
* A key with no string for `locale` falls back along the declared locale order
|
|
1618
|
+
* rather than vanishing, so a half-translated dictionary degrades one string at
|
|
1619
|
+
* a time instead of rendering the whole component as raw keys.
|
|
1620
|
+
*/
|
|
1621
|
+
function localeStrings(translations, locale, fallbackOrder = dictionaryLocales(translations)) {
|
|
1622
|
+
const out = {};
|
|
1623
|
+
for (const [key, byLocale] of Object.entries(translations)) {
|
|
1624
|
+
let value = byLocale?.[locale];
|
|
1625
|
+
if (typeof value !== "string") for (const candidate of fallbackOrder) {
|
|
1626
|
+
const fallback = byLocale?.[candidate];
|
|
1627
|
+
if (typeof fallback === "string") {
|
|
1628
|
+
value = fallback;
|
|
1629
|
+
break;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
if (typeof value === "string") out[key] = value;
|
|
1633
|
+
}
|
|
1634
|
+
return out;
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Canonical serialization — key order in the source file must not change the
|
|
1638
|
+
* id, or an innocuous reordering would break the payload/registry match.
|
|
1639
|
+
*/
|
|
1640
|
+
function canonicalizeDictionary(translations) {
|
|
1641
|
+
return `{${Object.keys(translations).sort().map((key) => {
|
|
1642
|
+
const byLocale = translations[key] ?? {};
|
|
1643
|
+
const inner = Object.keys(byLocale).sort().map((l) => JSON.stringify([l, byLocale[l]])).join(",");
|
|
1644
|
+
return `${JSON.stringify(key)}:[${inner}]`;
|
|
1645
|
+
}).join(",")}}`;
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1648
|
+
* FNV-1a, run twice with different offsets for a 64-bit-wide id. No crypto
|
|
1649
|
+
* import, and it has to work identically in the browser bundle, under Bun on
|
|
1650
|
+
* the server, and inside the Vite plugin.
|
|
1651
|
+
*/
|
|
1652
|
+
function dictionaryId(translations) {
|
|
1653
|
+
const input = canonicalizeDictionary(translations);
|
|
1654
|
+
let a = 2166136261;
|
|
1655
|
+
let b = 16777619;
|
|
1656
|
+
for (let i = 0; i < input.length; i++) {
|
|
1657
|
+
const c = input.charCodeAt(i);
|
|
1658
|
+
a = Math.imul(a ^ c, 16777619);
|
|
1659
|
+
b = Math.imul(b ^ c, 2166136261);
|
|
1660
|
+
}
|
|
1661
|
+
const hex = (n) => (n >>> 0).toString(16).padStart(8, "0");
|
|
1662
|
+
return `d_${hex(a)}${hex(b)}`;
|
|
1663
|
+
}
|
|
1664
|
+
//#endregion
|
|
1665
|
+
//#region i18n/defineDictionary.ts
|
|
1666
|
+
function defineDictionary(translations, options = {}) {
|
|
1667
|
+
const locales = dictionaryLocales(translations, options.sourceLocale);
|
|
1668
|
+
return createHandle(dictionaryId(translations), locales, (locale) => localeStrings(translations, locale, locales));
|
|
1669
|
+
}
|
|
1670
|
+
function createHandle(id, locales, load) {
|
|
1671
|
+
const entry = {
|
|
1672
|
+
id,
|
|
1673
|
+
locales,
|
|
1674
|
+
load
|
|
1675
|
+
};
|
|
1676
|
+
registerDictionary(entry);
|
|
1677
|
+
const ensure = () => registerDictionary(entry);
|
|
1678
|
+
return {
|
|
1679
|
+
id,
|
|
1680
|
+
locales,
|
|
1681
|
+
load: (locale) => {
|
|
1682
|
+
ensure();
|
|
1683
|
+
return loadDictionary(id, locale);
|
|
1684
|
+
},
|
|
1685
|
+
loadForRender: (locale) => {
|
|
1686
|
+
ensure();
|
|
1687
|
+
return loadDictionaryForRender(id, locale);
|
|
1688
|
+
},
|
|
1689
|
+
get: (locale) => {
|
|
1690
|
+
ensure();
|
|
1691
|
+
const strings = loadDictionary(id, locale);
|
|
1692
|
+
if (strings instanceof Promise) {
|
|
1693
|
+
strings.catch(() => {});
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
return strings;
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
//#endregion
|
|
1522
1701
|
//#region client/useLocale.ts
|
|
1523
1702
|
var setCookie = async (locale) => {
|
|
1524
1703
|
try {
|
|
@@ -1587,6 +1766,6 @@ function useAppIdMissmatch() {
|
|
|
1587
1766
|
return current !== next;
|
|
1588
1767
|
}
|
|
1589
1768
|
//#endregion
|
|
1590
|
-
export { Form, FormError, FormFieldContainer, Head, Image, Link, OpenGraphImage, QueryError, QueryManagerProvider, Redirect, ValidationErrors, create, createRoot, init, useAppIdMissmatch, useBreadcrumbs, useBroadcast, useDelete, useForgotPassword, useFormData, useFormStatus, useIsNavigationPending, useLocale, useLocation, useMutate, useMutation, useMutationStatus, useNavigate, useNavigationProgress, useParams, usePatch, usePost, usePrefetch, usePut, useQuery, useResetPassword, useRoute, useRouteTransition, useSearchParams, useSignIn, useSignOut, useSignUp, useSubscription, useTheme, useTranslator, useUpload, useUser };
|
|
1769
|
+
export { Form, FormError, FormFieldContainer, Head, Image, Link, OpenGraphImage, QueryError, QueryManagerProvider, Redirect, ValidationErrors, create, createRoot, defineDictionary, init, useAppIdMissmatch, useBreadcrumbs, useBroadcast, useDelete, useDictionary, useForgotPassword, useFormData, useFormStatus, useIsNavigationPending, useLocale, useLocation, useMutate, useMutation, useMutationStatus, useNavigate, useNavigationProgress, useParams, usePatch, usePost, usePrefetch, usePut, useQuery, useResetPassword, useRoute, useRouteTransition, useSearchParams, useSignIn, useSignOut, useSignUp, useSubscription, useTheme, useTranslator, useUpload, useUser };
|
|
1591
1770
|
|
|
1592
1771
|
//# sourceMappingURL=index.js.map
|