@burdenoff/fe-libs 2026.1115.12 → 2026.1115.13

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.
@@ -3,13 +3,13 @@ import { DEFAULT_LOCALE_STORAGE_KEY as t, I18nProvider as n, resolveInitialLocal
3
3
  import { graphqlFetch as a } from "../../graphql/fetch.js";
4
4
  import { DEFAULT_PLATFORM_I18N_PRODUCT_ID as o, createLayeredTranslationLoader as s, effectivePlatformId as c, translationCacheScope as l } from "./translationLayers.js";
5
5
  import { getDefaultTranslationPersistence as u } from "./translationStore.js";
6
+ import { createExportedDictionaryLoader as d } from "./exportedDictionary.js";
6
7
  import "../../../shared-graphql.js";
7
- import { BrandedSplash as d } from "../../../ui/branded-splash.js";
8
- import { useCallback as f, useMemo as p } from "react";
9
- import { jsx as m } from "react/jsx-runtime";
10
- import { DirectionProvider as h } from "@radix-ui/react-direction";
11
- // src/shared/providers/shell/ProfileI18nBridge.tsx
12
- var g = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n url\n }\n }\n", _ = 2e3, v = {
8
+ import { BrandedSplash as f } from "../../../ui/branded-splash.js";
9
+ import { useCallback as p, useMemo as m } from "react";
10
+ import { jsx as h } from "react/jsx-runtime";
11
+ import { DirectionProvider as g } from "@radix-ui/react-direction";
12
+ var _ = 2e3, v = {
13
13
  en: "Loading…",
14
14
  es: "Cargando…",
15
15
  fr: "Chargement…",
@@ -23,44 +23,39 @@ var g = "\n query ExportTranslations($productId: String!, $languageCode: String
23
23
  function y(e) {
24
24
  return v[e.toLowerCase().split(/[-_]/)[0] ?? "en"] ?? v.en;
25
25
  }
26
- async function b(e, t) {
27
- let n = await a({
28
- gateway: "global",
29
- query: g,
30
- operationName: "ExportTranslations",
31
- batch: !1,
32
- variables: {
33
- productId: e,
34
- languageCode: t,
35
- format: "JSON"
36
- },
37
- extraHeaders: {
38
- "x-actor-id": "system-i18n",
39
- "x-actor-type": "service"
40
- }
41
- });
42
- if (n.errors?.length || !n.data?.exportTranslations?.url) return null;
43
- let r = n.data.exportTranslations.url, i = decodeURIComponent(r.replace("data:application/json;charset=utf-8,", ""));
44
- return JSON.parse(i);
45
- }
26
+ var b = (e) => a({
27
+ gateway: "global",
28
+ query: e.query,
29
+ operationName: e.operationName,
30
+ batch: !1,
31
+ variables: e.variables,
32
+ extraHeaders: {
33
+ "x-actor-id": "system-i18n",
34
+ "x-actor-type": "service"
35
+ }
36
+ });
46
37
  function x({ children: e }) {
47
38
  let { dir: t } = i();
48
- return /* @__PURE__ */ m(h, {
39
+ return /* @__PURE__ */ h(g, {
49
40
  dir: t,
50
41
  children: e
51
42
  });
52
43
  }
53
- function S({ children: i, i18nProductId: a, platformI18nProductId: h = o, defaultLocale: g = "en", fallbackTranslations: v, disableDynamicFetch: S = !1, persistTranslations: C = !0, directionMode: w = "off" }) {
54
- let { user: T } = e(), E = T?.id ?? null, D = !S, O = c(a, h), k = f((e) => v?.[e] ?? {}, [v]), A = p(() => s({
44
+ function S({ children: i, i18nProductId: a, platformI18nProductId: g = o, defaultLocale: v = "en", fallbackTranslations: S, disableDynamicFetch: C = !1, persistTranslations: w = !0, directionMode: T = "off" }) {
45
+ let { user: E } = e(), D = E?.id ?? null, O = !C, k = c(a, g), A = p((e) => S?.[e] ?? {}, [S]), j = m(() => O && w ? u() : null, [w, O]), M = m(() => s({
55
46
  productId: a,
56
- platformId: O,
57
- fallback: k,
58
- fetchDictionary: b
47
+ platformId: k,
48
+ fallback: A,
49
+ fetchDictionary: d({
50
+ query: b,
51
+ persistence: j
52
+ })
59
53
  }), [
60
- k,
54
+ A,
61
55
  a,
62
- O
63
- ]), j = p(() => D && C ? u() : null, [C, D]), M = p(() => /* @__PURE__ */ m(d, { label: y(r(E, t, g)) }), [g, E]), N = p(() => v ?? {
56
+ k,
57
+ j
58
+ ]), N = m(() => /* @__PURE__ */ h(f, { label: y(r(D, t, v)) }), [v, D]), P = m(() => S ?? {
64
59
  en: {},
65
60
  es: {},
66
61
  fr: {},
@@ -70,20 +65,20 @@ function S({ children: i, i18nProductId: a, platformI18nProductId: h = o, defaul
70
65
  ta: {},
71
66
  hi: {},
72
67
  ar: {}
73
- }, [v]);
74
- return /* @__PURE__ */ m(n, {
75
- defaultLocale: g,
76
- translations: N,
77
- loadTranslations: D ? A : void 0,
78
- cacheScope: l(a, O),
68
+ }, [S]);
69
+ return /* @__PURE__ */ h(n, {
70
+ defaultLocale: v,
71
+ translations: P,
72
+ loadTranslations: O ? M : void 0,
73
+ cacheScope: l(a, k),
79
74
  persistence: j,
80
75
  firstPaintHoldMs: j ? 150 : 0,
81
76
  coldCacheHoldMs: j ? _ : 0,
82
- loadingComponent: M,
83
- directionMode: w,
84
- profileId: E,
77
+ loadingComponent: N,
78
+ directionMode: T,
79
+ profileId: D,
85
80
  showChildrenWhileLoading: !0,
86
- children: /* @__PURE__ */ m(x, { children: i })
81
+ children: /* @__PURE__ */ h(x, { children: i })
87
82
  });
88
83
  }
89
84
  export { _ as COLD_CACHE_HOLD_MS, S as ProfileI18nBridge, y as dictionaryLoadingLabel };
@@ -0,0 +1,35 @@
1
+ import { Locale, TranslationDictionary } from './I18nProvider';
2
+ import { TranslationPersistence } from './translationStore';
3
+ /** Result of one GraphQL request, as `graphqlFetch` returns it. */
4
+ export interface ExportGraphqlResult<T> {
5
+ data?: T | null;
6
+ errors?: ReadonlyArray<unknown> | null;
7
+ }
8
+ /** Sends one i18n export query. Injected so the logic is testable without a gateway. */
9
+ export type ExportQueryFn = <T>(request: {
10
+ operationName: string;
11
+ query: string;
12
+ variables: Record<string, unknown>;
13
+ }) => Promise<ExportGraphqlResult<T>>;
14
+ export declare const EXPORT_TRANSLATIONS_CONTENT_QUERY = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n version\n content\n }\n }\n";
15
+ export declare const TRANSLATIONS_EXPORT_VERSION_QUERY = "\n query TranslationsExportVersion($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n translationsExportVersion(productId: $productId, languageCode: $languageCode, format: $format)\n }\n";
16
+ /** The query servers without `content`/`version` answer (before BOFF-14823). */
17
+ export declare const EXPORT_TRANSLATIONS_URL_QUERY = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n url\n }\n }\n";
18
+ /** The persistent-cache scope of one layer's export. Never collides with a merged scope. */
19
+ export declare function exportCacheScope(productId: string): string;
20
+ /**
21
+ * Whether the server rejected the query because it does not know a field: a
22
+ * server from before BOFF-14823. Any other error is transient and is retried
23
+ * on the next load, as before.
24
+ */
25
+ export declare function isUnknownFieldError(errors: ReadonlyArray<unknown> | null | undefined): boolean;
26
+ export interface ExportedDictionaryLoaderOptions {
27
+ query: ExportQueryFn;
28
+ /** Per-layer cache; null when there is none (no IndexedDB, persistence off). */
29
+ persistence: TranslationPersistence | null;
30
+ }
31
+ /**
32
+ * A `FetchDictionaryFn` for the layered loader: the dictionary, or null when
33
+ * it could not be had (transient failure, nothing published).
34
+ */
35
+ export declare function createExportedDictionaryLoader(options: ExportedDictionaryLoaderOptions): (productId: string, locale: Locale) => Promise<TranslationDictionary | null>;
@@ -0,0 +1,68 @@
1
+ // src/shared/providers/shell/exportedDictionary.ts
2
+ var e = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n version\n content\n }\n }\n", t = "\n query TranslationsExportVersion($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n translationsExportVersion(productId: $productId, languageCode: $languageCode, format: $format)\n }\n", n = "\n query ExportTranslations($productId: String!, $languageCode: String!, $format: ImportJobFormat!) {\n exportTranslations(productId: $productId, languageCode: $languageCode, format: $format) {\n format\n url\n }\n }\n";
3
+ function r(e) {
4
+ return `export:${e}`;
5
+ }
6
+ function i(e) {
7
+ return (e ?? []).some((e) => {
8
+ if (typeof e != "object" || !e) return !1;
9
+ let { message: t, extensions: n } = e;
10
+ return (typeof n == "object" && n ? n.code : void 0) === "GRAPHQL_VALIDATION_FAILED" || typeof t == "string" && t.includes("Cannot query field");
11
+ });
12
+ }
13
+ function a(e) {
14
+ return typeof e == "object" && !!e && !Array.isArray(e);
15
+ }
16
+ function o(e) {
17
+ try {
18
+ let t = JSON.parse(e);
19
+ return a(t) ? t : null;
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+ function s(a) {
25
+ let { query: s, persistence: c } = a, l = async (e) => {
26
+ let t = await s({
27
+ operationName: "ExportTranslations",
28
+ query: n,
29
+ variables: e
30
+ }), r = t.data?.exportTranslations?.url;
31
+ return t.errors?.length || !r ? null : o(decodeURIComponent(r.replace("data:application/json;charset=utf-8,", "")));
32
+ };
33
+ return async (n, a) => {
34
+ let u = {
35
+ productId: n,
36
+ languageCode: a,
37
+ format: "JSON"
38
+ }, d = r(n), f = c ? await c.read(d, a) : null;
39
+ if (f) {
40
+ let e = await s({
41
+ operationName: "TranslationsExportVersion",
42
+ query: t,
43
+ variables: u
44
+ }).then((e) => e.errors?.length ? null : e.data?.translationsExportVersion ?? null, () => null);
45
+ if (e && e === f.hash) return f.translations;
46
+ }
47
+ let p;
48
+ try {
49
+ p = await s({
50
+ operationName: "ExportTranslations",
51
+ query: e,
52
+ variables: u
53
+ });
54
+ } catch (e) {
55
+ if (f) return f.translations;
56
+ throw e;
57
+ }
58
+ let m = p.data?.exportTranslations;
59
+ if (p.errors?.length || !m) return i(p.errors) ? l(u) : f?.translations ?? null;
60
+ if (!m.content) return null;
61
+ let h = o(m.content);
62
+ return h ? (c && m.version && c.write(d, a, {
63
+ translations: h,
64
+ hash: m.version
65
+ }), h) : null;
66
+ };
67
+ }
68
+ export { e as EXPORT_TRANSLATIONS_CONTENT_QUERY, n as EXPORT_TRANSLATIONS_URL_QUERY, t as TRANSLATIONS_EXPORT_VERSION_QUERY, s as createExportedDictionaryLoader, r as exportCacheScope, i as isUnknownFieldError };
@@ -95,10 +95,11 @@ var d = [
95
95
  ]), p = /* @__PURE__ */ new Set([
96
96
  "ExportTranslations",
97
97
  "exportTranslations",
98
+ "TranslationsExportVersion",
98
99
  "AdminEntityCounts",
99
100
  "GetTenants",
100
101
  "NodeManifest"
101
- ]), m = ["exportTranslations"], h = ["No translation keys found for the specified criteria"], g = [
102
+ ]), m = ["exportTranslations", "translationsExportVersion"], h = ["No translation keys found for the specified criteria"], g = [
102
103
  /failed to fetch/i,
103
104
  /networkerror when attempting to fetch/i,
104
105
  /network request failed/i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/fe-libs",
3
- "version": "2026.1115.12",
3
+ "version": "2026.1115.13",
4
4
  "description": "Burdenoff frontend primitives and domain libraries",
5
5
  "repository": {
6
6
  "type": "git",