@objectstack/core 3.2.5 → 3.2.6

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/core@3.2.5 build /home/runner/work/spec/spec/packages/core
2
+ > @objectstack/core@3.2.6 build /home/runner/work/spec/spec/packages/core
3
3
  > tsup --config ../../tsup.config.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.js 147.91 KB
14
- ESM dist/index.js.map 312.55 KB
15
- ESM ⚡️ Build success in 102ms
16
- CJS dist/index.cjs 150.95 KB
17
- CJS dist/index.cjs.map 314.18 KB
18
- CJS ⚡️ Build success in 103ms
13
+ ESM dist/index.js 150.14 KB
14
+ ESM dist/index.js.map 318.23 KB
15
+ ESM ⚡️ Build success in 120ms
16
+ CJS dist/index.cjs 153.26 KB
17
+ CJS dist/index.cjs.map 319.87 KB
18
+ CJS ⚡️ Build success in 120ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 3372ms
21
- DTS dist/index.d.ts 61.79 KB
22
- DTS dist/index.d.cts 61.79 KB
20
+ DTS ⚡️ Build success in 4487ms
21
+ DTS dist/index.d.ts 63.12 KB
22
+ DTS dist/index.d.cts 63.12 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @objectstack/core
2
2
 
3
+ ## 3.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - @objectstack/spec@3.2.6
8
+
3
9
  ## 3.2.5
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -55,6 +55,7 @@ __export(index_exports, {
55
55
  createApiRegistryPlugin: () => createApiRegistryPlugin,
56
56
  createLogger: () => createLogger,
57
57
  createMemoryCache: () => createMemoryCache,
58
+ createMemoryI18n: () => createMemoryI18n,
58
59
  createMemoryJob: () => createMemoryJob,
59
60
  createMemoryQueue: () => createMemoryQueue,
60
61
  createPluginConfigValidator: () => createPluginConfigValidator,
@@ -62,6 +63,7 @@ __export(index_exports, {
62
63
  getEnv: () => getEnv,
63
64
  getMemoryUsage: () => getMemoryUsage,
64
65
  isNode: () => isNode,
66
+ resolveLocale: () => resolveLocale,
65
67
  safeExit: () => safeExit
66
68
  });
67
69
  module.exports = __toCommonJS(index_exports);
@@ -1093,11 +1095,73 @@ function createMemoryJob() {
1093
1095
  };
1094
1096
  }
1095
1097
 
1098
+ // src/fallbacks/memory-i18n.ts
1099
+ function resolveLocale(requestedLocale, availableLocales) {
1100
+ if (availableLocales.length === 0) return void 0;
1101
+ if (availableLocales.includes(requestedLocale)) return requestedLocale;
1102
+ const lower = requestedLocale.toLowerCase();
1103
+ const caseMatch = availableLocales.find((l) => l.toLowerCase() === lower);
1104
+ if (caseMatch) return caseMatch;
1105
+ const baseLang = requestedLocale.split("-")[0].toLowerCase();
1106
+ const baseMatch = availableLocales.find((l) => l.toLowerCase() === baseLang);
1107
+ if (baseMatch) return baseMatch;
1108
+ const variantMatch = availableLocales.find((l) => l.split("-")[0].toLowerCase() === baseLang);
1109
+ if (variantMatch) return variantMatch;
1110
+ return void 0;
1111
+ }
1112
+ function createMemoryI18n() {
1113
+ const translations = /* @__PURE__ */ new Map();
1114
+ let defaultLocale = "en";
1115
+ function resolveKey(data, key) {
1116
+ const parts = key.split(".");
1117
+ let current = data;
1118
+ for (const part of parts) {
1119
+ if (current == null || typeof current !== "object") return void 0;
1120
+ current = current[part];
1121
+ }
1122
+ return typeof current === "string" ? current : void 0;
1123
+ }
1124
+ function resolveTranslations(locale) {
1125
+ if (translations.has(locale)) return translations.get(locale);
1126
+ const resolved = resolveLocale(locale, [...translations.keys()]);
1127
+ if (resolved) return translations.get(resolved);
1128
+ return void 0;
1129
+ }
1130
+ return {
1131
+ _fallback: true,
1132
+ _serviceName: "i18n",
1133
+ t(key, locale, params) {
1134
+ const data = resolveTranslations(locale) ?? translations.get(defaultLocale);
1135
+ const value = data ? resolveKey(data, key) : void 0;
1136
+ if (value == null) return key;
1137
+ if (!params) return value;
1138
+ return value.replace(/\{\{(\w+)\}\}/g, (_, name) => String(params[name] ?? `{{${name}}}`));
1139
+ },
1140
+ getTranslations(locale) {
1141
+ return resolveTranslations(locale) ?? {};
1142
+ },
1143
+ loadTranslations(locale, data) {
1144
+ const existing = translations.get(locale) ?? {};
1145
+ translations.set(locale, { ...existing, ...data });
1146
+ },
1147
+ getLocales() {
1148
+ return [...translations.keys()];
1149
+ },
1150
+ getDefaultLocale() {
1151
+ return defaultLocale;
1152
+ },
1153
+ setDefaultLocale(locale) {
1154
+ defaultLocale = locale;
1155
+ }
1156
+ };
1157
+ }
1158
+
1096
1159
  // src/fallbacks/index.ts
1097
1160
  var CORE_FALLBACK_FACTORIES = {
1098
1161
  cache: createMemoryCache,
1099
1162
  queue: createMemoryQueue,
1100
- job: createMemoryJob
1163
+ job: createMemoryJob,
1164
+ i18n: createMemoryI18n
1101
1165
  };
1102
1166
 
1103
1167
  // src/kernel.ts
@@ -4920,6 +4984,7 @@ var PackageManager = class {
4920
4984
  createApiRegistryPlugin,
4921
4985
  createLogger,
4922
4986
  createMemoryCache,
4987
+ createMemoryI18n,
4923
4988
  createMemoryJob,
4924
4989
  createMemoryQueue,
4925
4990
  createPluginConfigValidator,
@@ -4927,6 +4992,7 @@ var PackageManager = class {
4927
4992
  getEnv,
4928
4993
  getMemoryUsage,
4929
4994
  isNode,
4995
+ resolveLocale,
4930
4996
  safeExit
4931
4997
  });
4932
4998
  //# sourceMappingURL=index.cjs.map