hazo_core 2.3.0 → 2.4.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/i18n/client.d.ts +8 -0
- package/dist/i18n/client.d.ts.map +1 -0
- package/dist/i18n/client.js +8 -0
- package/dist/i18n/client.js.map +1 -0
- package/dist/i18n/index.d.ts +104 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +196 -0
- package/dist/i18n/index.js.map +1 -0
- package/package.json +9 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hazo_core/i18n/client — browser-safe re-export.
|
|
3
|
+
*
|
|
4
|
+
* Safe because `./index.ts` has zero Node.js-only imports (only
|
|
5
|
+
* `optional_import`, already used from hazo_core's own `index.client.ts`).
|
|
6
|
+
*/
|
|
7
|
+
export * from './index.js';
|
|
8
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/i18n/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hazo_core/i18n/client — browser-safe re-export.
|
|
3
|
+
*
|
|
4
|
+
* Safe because `./index.ts` has zero Node.js-only imports (only
|
|
5
|
+
* `optional_import`, already used from hazo_core's own `index.client.ts`).
|
|
6
|
+
*/
|
|
7
|
+
export * from './index.js';
|
|
8
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/i18n/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hazo_core/i18n — canonical i18n bridge for hazo_* packages' own baked-in
|
|
3
|
+
* strings.
|
|
4
|
+
*
|
|
5
|
+
* 17+ packages each maintain a ~120-line local copy of this pattern (see
|
|
6
|
+
* hazo_auth/src/lib/create_package_t.ts, the reference this module is
|
|
7
|
+
* modeled on). This is the canonical version so those local copies can
|
|
8
|
+
* eventually be deleted.
|
|
9
|
+
*
|
|
10
|
+
* `hazo_i18n` — the companion package that provides a FULL i18n runtime
|
|
11
|
+
* (ICU, request-scoped locales, DB-authored catalogs, LLM translation
|
|
12
|
+
* pipeline) — does NOT exist as a dependency or peer dependency of
|
|
13
|
+
* hazo_core. It is probed lazily and optionally, exactly like the
|
|
14
|
+
* `hazo_debug` probe in `../debug/index.ts`. This keeps the workspace's
|
|
15
|
+
* peer-dep graph acyclic (a guarded import is not a peer) and guarantees
|
|
16
|
+
* that `createPackageT`'s `t()` NEVER blocks on, awaits, or becomes
|
|
17
|
+
* "aware" of hazo_i18n at read time — it always reads the bundled flat
|
|
18
|
+
* fallback catalog directly. The optional hazo_i18n probe exists purely as
|
|
19
|
+
* a fire-and-forget SIDE EFFECT: if hazo_i18n happens to be installed in
|
|
20
|
+
* the consuming app, we register this package's catalog into hazo_i18n's
|
|
21
|
+
* cross-package registry so the strings show up in its admin panel / LLM
|
|
22
|
+
* translation pipeline / compiled artifacts. That registration can never
|
|
23
|
+
* change what `t()`, `t.has()`, or `t.raw()` return.
|
|
24
|
+
*
|
|
25
|
+
* hazo_i18n has no synchronous "get current locale" function anywhere in
|
|
26
|
+
* its public API — only async, request-scoped `getLocale()`/
|
|
27
|
+
* `getTranslations()` gated behind a runtime object that may not exist.
|
|
28
|
+
* That's a deliberate design decision on hazo_i18n's side (a long-lived
|
|
29
|
+
* process serves many concurrent requests in different locales, so there
|
|
30
|
+
* is nothing safe to peek at synchronously) — not a gap for this module to
|
|
31
|
+
* work around. See `resolvePackageLocale` below.
|
|
32
|
+
*/
|
|
33
|
+
export type TFunc = ((key: string, vars?: Record<string, string | number>) => string) & {
|
|
34
|
+
/** True iff `fallbackCatalog[key]` is a string. */
|
|
35
|
+
has(key: string): boolean;
|
|
36
|
+
/** Raw (non-interpolated) template for `key`, or `undefined` if absent. */
|
|
37
|
+
raw(key: string): string | undefined;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Minimal shape we rely on from `hazo_i18n` when it is present. This is a
|
|
41
|
+
* defensive, best-effort probe — hazo_core never imports hazo_i18n's types
|
|
42
|
+
* statically, and treats its module shape as unknown, checked at runtime.
|
|
43
|
+
*/
|
|
44
|
+
interface HazoI18nModuleShape {
|
|
45
|
+
registerCatalog?: (pkg: string, catalogs: Record<string, Record<string, unknown>>, owner?: string) => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a namespaced translator for a hazo_* package's own baked-in
|
|
49
|
+
* strings.
|
|
50
|
+
*
|
|
51
|
+
* `t()` does a direct flat lookup on `fallbackCatalog` (catalogs are flat
|
|
52
|
+
* objects with literal-dotted string keys, e.g. `{ "login.submit": "Sign
|
|
53
|
+
* in" }` — NOT nested trees), then `{{var}}` interpolation. A missing key
|
|
54
|
+
* returns the bare key unchanged; a placeholder whose variable is missing
|
|
55
|
+
* from `vars` is left literal in the output.
|
|
56
|
+
*
|
|
57
|
+
* Side effect: on every call, kicks off (or reuses) the shared, once-per-
|
|
58
|
+
* process `optional_import('hazo_i18n')` probe. When it resolves and the
|
|
59
|
+
* module exposes `registerCatalog`, this package's fallback catalog is
|
|
60
|
+
* registered under `{ en: fallbackCatalog }` for cross-package visibility
|
|
61
|
+
* (hazo_i18n's admin panel / LLM export / compiled artifacts). This is
|
|
62
|
+
* pure side effect — idempotent on hazo_i18n's side (same-owner
|
|
63
|
+
* re-registrations merge without warning) — and never affects what `t()`/
|
|
64
|
+
* `t.has()`/`t.raw()` return; those always read `fallbackCatalog` directly.
|
|
65
|
+
*
|
|
66
|
+
* @param namespace - Package namespace, e.g. `"hazo_ui"`. Used only when
|
|
67
|
+
* registering into hazo_i18n's cross-package registry.
|
|
68
|
+
* @param fallbackCatalog - Flat `{ key: "English text" }` map bundled with
|
|
69
|
+
* the package.
|
|
70
|
+
*/
|
|
71
|
+
export declare function createPackageT(namespace: string, fallbackCatalog: Record<string, string>): TFunc;
|
|
72
|
+
/**
|
|
73
|
+
* Registers additional locale catalogs into hazo_i18n's cross-package
|
|
74
|
+
* registry, for packages that ship non-English locale files beyond their
|
|
75
|
+
* own `createPackageT` default catalog.
|
|
76
|
+
*
|
|
77
|
+
* Uses the same shared, once-per-process hazo_i18n probe as
|
|
78
|
+
* `createPackageT`. If hazo_i18n isn't installed or hasn't resolved yet,
|
|
79
|
+
* this is a documented no-op — there is nothing else to register into, and
|
|
80
|
+
* throwing would defeat the point of an optional peer.
|
|
81
|
+
*/
|
|
82
|
+
export declare function registerCatalog(pkg: string, catalogs: Record<string, Record<string, string>>, owner?: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Always returns `defaultLocale` unchanged.
|
|
85
|
+
*
|
|
86
|
+
* hazo_i18n has no synchronous locale getter by design — a long-lived
|
|
87
|
+
* process serves many concurrent requests in different locales, so there
|
|
88
|
+
* is nothing safe to peek at synchronously (see hazo_i18n's
|
|
89
|
+
* `src/lib/package_t.ts` header for the fuller rationale). This function
|
|
90
|
+
* exists as a stable extension point for the day hazo_i18n (or another
|
|
91
|
+
* provider) exposes one, not because it does anything today.
|
|
92
|
+
*/
|
|
93
|
+
export declare function resolvePackageLocale(defaultLocale: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Test-only escape hatch: lets tests simulate hazo_i18n being installed
|
|
96
|
+
* without actually installing it. Also marks the shared probe as
|
|
97
|
+
* "resolved" so `createPackageT`/`registerCatalog` don't kick off (or wait
|
|
98
|
+
* on) a real dynamic import during tests. Not exported from the package's
|
|
99
|
+
* public entry points (`src/index.ts` / `src/index.client.ts`) — import
|
|
100
|
+
* directly from `hazo_core/i18n`'s source in tests only.
|
|
101
|
+
*/
|
|
102
|
+
export declare function __setHazoI18nModuleForTests(mod: HazoI18nModuleShape | null): void;
|
|
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AAE,mBAAmB,GAAG,IAAI,GAAG,IAAI,CAGjF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hazo_core/i18n — canonical i18n bridge for hazo_* packages' own baked-in
|
|
3
|
+
* strings.
|
|
4
|
+
*
|
|
5
|
+
* 17+ packages each maintain a ~120-line local copy of this pattern (see
|
|
6
|
+
* hazo_auth/src/lib/create_package_t.ts, the reference this module is
|
|
7
|
+
* modeled on). This is the canonical version so those local copies can
|
|
8
|
+
* eventually be deleted.
|
|
9
|
+
*
|
|
10
|
+
* `hazo_i18n` — the companion package that provides a FULL i18n runtime
|
|
11
|
+
* (ICU, request-scoped locales, DB-authored catalogs, LLM translation
|
|
12
|
+
* pipeline) — does NOT exist as a dependency or peer dependency of
|
|
13
|
+
* hazo_core. It is probed lazily and optionally, exactly like the
|
|
14
|
+
* `hazo_debug` probe in `../debug/index.ts`. This keeps the workspace's
|
|
15
|
+
* peer-dep graph acyclic (a guarded import is not a peer) and guarantees
|
|
16
|
+
* that `createPackageT`'s `t()` NEVER blocks on, awaits, or becomes
|
|
17
|
+
* "aware" of hazo_i18n at read time — it always reads the bundled flat
|
|
18
|
+
* fallback catalog directly. The optional hazo_i18n probe exists purely as
|
|
19
|
+
* a fire-and-forget SIDE EFFECT: if hazo_i18n happens to be installed in
|
|
20
|
+
* the consuming app, we register this package's catalog into hazo_i18n's
|
|
21
|
+
* cross-package registry so the strings show up in its admin panel / LLM
|
|
22
|
+
* translation pipeline / compiled artifacts. That registration can never
|
|
23
|
+
* change what `t()`, `t.has()`, or `t.raw()` return.
|
|
24
|
+
*
|
|
25
|
+
* hazo_i18n has no synchronous "get current locale" function anywhere in
|
|
26
|
+
* its public API — only async, request-scoped `getLocale()`/
|
|
27
|
+
* `getTranslations()` gated behind a runtime object that may not exist.
|
|
28
|
+
* That's a deliberate design decision on hazo_i18n's side (a long-lived
|
|
29
|
+
* process serves many concurrent requests in different locales, so there
|
|
30
|
+
* is nothing safe to peek at synchronously) — not a gap for this module to
|
|
31
|
+
* work around. See `resolvePackageLocale` below.
|
|
32
|
+
*/
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Shared, process-wide probe for the optional hazo_i18n peer
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
let hazoI18nModule = null;
|
|
37
|
+
// Fire-and-forget: populates hazoI18nModule as soon as the microtask queue
|
|
38
|
+
// runs. Using dynamic import() with bundler-ignore hints so Turbopack/
|
|
39
|
+
// webpack/Vite never try to statically resolve this optional peer dep and
|
|
40
|
+
// emit "Module not found" errors/warnings.
|
|
41
|
+
//
|
|
42
|
+
// The specifier MUST be a variable, not a string literal. Vite's
|
|
43
|
+
// import-analysis (which Vitest also runs through) only honours
|
|
44
|
+
// `@vite-ignore` when it can't statically determine the specifier —
|
|
45
|
+
// es-module-lexer resolves a literal `import('hazo_i18n')` to a concrete
|
|
46
|
+
// specifier regardless of any ignore comment, so Vite still tries to
|
|
47
|
+
// resolve it and hard-fails the whole module graph when the package isn't
|
|
48
|
+
// installed, bypassing this try/catch entirely. Routing the name through
|
|
49
|
+
// `hazoI18nPkg` makes the specifier unanalyzable, which is what actually
|
|
50
|
+
// makes Vite skip resolution (the `@vite-ignore` here only suppresses its
|
|
51
|
+
// "cannot analyze" warning). Mirrors `../debug/index.ts`'s `hazoDebugPkg`
|
|
52
|
+
// probe exactly.
|
|
53
|
+
//
|
|
54
|
+
// This probe runs ONCE per process — every `createPackageT()` call shares
|
|
55
|
+
// this same cached promise/module reference, it is not re-triggered per
|
|
56
|
+
// call.
|
|
57
|
+
const hazoI18nPkg = 'hazo_i18n';
|
|
58
|
+
let hazoI18nProbe = null;
|
|
59
|
+
function ensureHazoI18nProbe() {
|
|
60
|
+
if (!hazoI18nProbe) {
|
|
61
|
+
hazoI18nProbe = (async () => {
|
|
62
|
+
try {
|
|
63
|
+
hazoI18nModule = (await import(
|
|
64
|
+
/* turbopackIgnore: true */ /* webpackIgnore: true */ /* @vite-ignore */ hazoI18nPkg));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// hazo_i18n not installed — nothing to register into.
|
|
68
|
+
hazoI18nModule = null;
|
|
69
|
+
}
|
|
70
|
+
})();
|
|
71
|
+
}
|
|
72
|
+
return hazoI18nProbe;
|
|
73
|
+
}
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Interpolation
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
/**
|
|
78
|
+
* Simple `{{var}}` mustache-style interpolation — intentionally not ICU.
|
|
79
|
+
* Unknown placeholders are left as-is rather than dropped, so a missing var
|
|
80
|
+
* is obvious in the rendered string instead of silently disappearing.
|
|
81
|
+
*/
|
|
82
|
+
function interpolate(template, vars) {
|
|
83
|
+
if (!vars)
|
|
84
|
+
return template;
|
|
85
|
+
return template.replace(/\{\{\s*(\w+)\s*\}\}/g, (whole, name) => Object.prototype.hasOwnProperty.call(vars, name) ? String(vars[name]) : whole);
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// createPackageT
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
/**
|
|
91
|
+
* Creates a namespaced translator for a hazo_* package's own baked-in
|
|
92
|
+
* strings.
|
|
93
|
+
*
|
|
94
|
+
* `t()` does a direct flat lookup on `fallbackCatalog` (catalogs are flat
|
|
95
|
+
* objects with literal-dotted string keys, e.g. `{ "login.submit": "Sign
|
|
96
|
+
* in" }` — NOT nested trees), then `{{var}}` interpolation. A missing key
|
|
97
|
+
* returns the bare key unchanged; a placeholder whose variable is missing
|
|
98
|
+
* from `vars` is left literal in the output.
|
|
99
|
+
*
|
|
100
|
+
* Side effect: on every call, kicks off (or reuses) the shared, once-per-
|
|
101
|
+
* process `optional_import('hazo_i18n')` probe. When it resolves and the
|
|
102
|
+
* module exposes `registerCatalog`, this package's fallback catalog is
|
|
103
|
+
* registered under `{ en: fallbackCatalog }` for cross-package visibility
|
|
104
|
+
* (hazo_i18n's admin panel / LLM export / compiled artifacts). This is
|
|
105
|
+
* pure side effect — idempotent on hazo_i18n's side (same-owner
|
|
106
|
+
* re-registrations merge without warning) — and never affects what `t()`/
|
|
107
|
+
* `t.has()`/`t.raw()` return; those always read `fallbackCatalog` directly.
|
|
108
|
+
*
|
|
109
|
+
* @param namespace - Package namespace, e.g. `"hazo_ui"`. Used only when
|
|
110
|
+
* registering into hazo_i18n's cross-package registry.
|
|
111
|
+
* @param fallbackCatalog - Flat `{ key: "English text" }` map bundled with
|
|
112
|
+
* the package.
|
|
113
|
+
*/
|
|
114
|
+
export function createPackageT(namespace, fallbackCatalog) {
|
|
115
|
+
void ensureHazoI18nProbe().then(() => {
|
|
116
|
+
const mod = hazoI18nModule;
|
|
117
|
+
if (mod && typeof mod.registerCatalog === 'function') {
|
|
118
|
+
try {
|
|
119
|
+
mod.registerCatalog(namespace, { en: fallbackCatalog });
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// hazo_i18n present but errored on registration — never let this
|
|
123
|
+
// affect the fallback-catalog read path.
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
const t = ((key, vars) => {
|
|
128
|
+
const template = fallbackCatalog[key];
|
|
129
|
+
if (template === undefined)
|
|
130
|
+
return key;
|
|
131
|
+
return interpolate(template, vars);
|
|
132
|
+
});
|
|
133
|
+
t.has = (key) => typeof fallbackCatalog[key] === 'string';
|
|
134
|
+
t.raw = (key) => fallbackCatalog[key];
|
|
135
|
+
return t;
|
|
136
|
+
}
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// registerCatalog (standalone)
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
/**
|
|
141
|
+
* Registers additional locale catalogs into hazo_i18n's cross-package
|
|
142
|
+
* registry, for packages that ship non-English locale files beyond their
|
|
143
|
+
* own `createPackageT` default catalog.
|
|
144
|
+
*
|
|
145
|
+
* Uses the same shared, once-per-process hazo_i18n probe as
|
|
146
|
+
* `createPackageT`. If hazo_i18n isn't installed or hasn't resolved yet,
|
|
147
|
+
* this is a documented no-op — there is nothing else to register into, and
|
|
148
|
+
* throwing would defeat the point of an optional peer.
|
|
149
|
+
*/
|
|
150
|
+
export function registerCatalog(pkg, catalogs, owner) {
|
|
151
|
+
void ensureHazoI18nProbe().then(() => {
|
|
152
|
+
const mod = hazoI18nModule;
|
|
153
|
+
if (mod && typeof mod.registerCatalog === 'function') {
|
|
154
|
+
try {
|
|
155
|
+
mod.registerCatalog(pkg, catalogs, owner);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// hazo_i18n present but errored on registration — swallow, same as
|
|
159
|
+
// createPackageT's side-effect registration.
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// else: hazo_i18n absent/unresolved — no-op by design.
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
// resolvePackageLocale
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
/**
|
|
169
|
+
* Always returns `defaultLocale` unchanged.
|
|
170
|
+
*
|
|
171
|
+
* hazo_i18n has no synchronous locale getter by design — a long-lived
|
|
172
|
+
* process serves many concurrent requests in different locales, so there
|
|
173
|
+
* is nothing safe to peek at synchronously (see hazo_i18n's
|
|
174
|
+
* `src/lib/package_t.ts` header for the fuller rationale). This function
|
|
175
|
+
* exists as a stable extension point for the day hazo_i18n (or another
|
|
176
|
+
* provider) exposes one, not because it does anything today.
|
|
177
|
+
*/
|
|
178
|
+
export function resolvePackageLocale(defaultLocale) {
|
|
179
|
+
return defaultLocale;
|
|
180
|
+
}
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
// Test-only escape hatch
|
|
183
|
+
// ---------------------------------------------------------------------------
|
|
184
|
+
/**
|
|
185
|
+
* Test-only escape hatch: lets tests simulate hazo_i18n being installed
|
|
186
|
+
* without actually installing it. Also marks the shared probe as
|
|
187
|
+
* "resolved" so `createPackageT`/`registerCatalog` don't kick off (or wait
|
|
188
|
+
* on) a real dynamic import during tests. Not exported from the package's
|
|
189
|
+
* public entry points (`src/index.ts` / `src/index.client.ts`) — import
|
|
190
|
+
* directly from `hazo_core/i18n`'s source in tests only.
|
|
191
|
+
*/
|
|
192
|
+
export function __setHazoI18nModuleForTests(mod) {
|
|
193
|
+
hazoI18nModule = mod;
|
|
194
|
+
hazoI18nProbe = Promise.resolve();
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AA4BH,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAE9E,IAAI,cAAc,GAA+B,IAAI,CAAC;AAEtD,2EAA2E;AAC3E,uEAAuE;AACvE,0EAA0E;AAC1E,2CAA2C;AAC3C,EAAE;AACF,iEAAiE;AACjE,gEAAgE;AAChE,oEAAoE;AACpE,yEAAyE;AACzE,qEAAqE;AACrE,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,iBAAiB;AACjB,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,QAAQ;AACR,MAAM,WAAW,GAAG,WAAW,CAAC;AAChC,IAAI,aAAa,GAAyB,IAAI,CAAC;AAE/C,SAAS,mBAAmB;IAC1B,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YAC1B,IAAI,CAAC;gBACH,cAAc,GAAG,CAAC,MAAM,MAAM;gBAC5B,2BAA2B,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,WAAW,CACrF,CAAwB,CAAC;YAC5B,CAAC;YAAC,MAAM,CAAC;gBACP,sDAAsD;gBACtD,cAAc,GAAG,IAAI,CAAC;YAC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
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Foundation package for all hazo_* packages — errors, correlation ID, config, logger, debug, singletons, utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
"./context": {
|
|
23
23
|
"types": "./dist/context/index.d.ts",
|
|
24
24
|
"import": "./dist/context/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./i18n": {
|
|
27
|
+
"types": "./dist/i18n/index.d.ts",
|
|
28
|
+
"import": "./dist/i18n/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./i18n/client": {
|
|
31
|
+
"types": "./dist/i18n/client.d.ts",
|
|
32
|
+
"import": "./dist/i18n/client.js"
|
|
25
33
|
}
|
|
26
34
|
},
|
|
27
35
|
"files": [
|