@generaltranslation/react-core 1.8.17 → 1.8.19

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.
Files changed (194) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/errors.cjs.min.cjs +2 -2
  3. package/dist/errors.cjs.min.cjs.map +1 -1
  4. package/dist/errors.d.ts +3 -1
  5. package/dist/errors.d.ts.map +1 -1
  6. package/dist/errors.esm.min.mjs +2 -2
  7. package/dist/errors.esm.min.mjs.map +1 -1
  8. package/dist/index.cjs.min.cjs +2 -2
  9. package/dist/index.cjs.min.cjs.map +1 -1
  10. package/dist/index.d.ts +1384 -35
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.esm.min.mjs +2 -2
  13. package/dist/index.esm.min.mjs.map +1 -1
  14. package/dist/internal.cjs.min.cjs +2 -2
  15. package/dist/internal.cjs.min.cjs.map +1 -1
  16. package/dist/internal.d.ts +764 -31
  17. package/dist/internal.d.ts.map +1 -1
  18. package/dist/internal.esm.min.mjs +2 -2
  19. package/dist/internal.esm.min.mjs.map +1 -1
  20. package/dist/types.d.ts +357 -174
  21. package/dist/types.d.ts.map +1 -1
  22. package/package.json +8 -7
  23. package/dist/branches/Branch.d.ts +0 -34
  24. package/dist/branches/Branch.d.ts.map +0 -1
  25. package/dist/branches/plurals/Plural.d.ts +0 -38
  26. package/dist/branches/plurals/Plural.d.ts.map +0 -1
  27. package/dist/branches/plurals/getPluralBranch.d.ts +0 -9
  28. package/dist/branches/plurals/getPluralBranch.d.ts.map +0 -1
  29. package/dist/dictionaries/collectUntranslatedEntries.d.ts +0 -18
  30. package/dist/dictionaries/collectUntranslatedEntries.d.ts.map +0 -1
  31. package/dist/dictionaries/getDictionaryEntry.d.ts +0 -4
  32. package/dist/dictionaries/getDictionaryEntry.d.ts.map +0 -1
  33. package/dist/dictionaries/getEntryAndMetadata.d.ts +0 -6
  34. package/dist/dictionaries/getEntryAndMetadata.d.ts.map +0 -1
  35. package/dist/dictionaries/getSubtree.d.ts +0 -18
  36. package/dist/dictionaries/getSubtree.d.ts.map +0 -1
  37. package/dist/dictionaries/indexDict.d.ts +0 -15
  38. package/dist/dictionaries/indexDict.d.ts.map +0 -1
  39. package/dist/dictionaries/injectAndMerge.d.ts +0 -9
  40. package/dist/dictionaries/injectAndMerge.d.ts.map +0 -1
  41. package/dist/dictionaries/injectEntry.d.ts +0 -18
  42. package/dist/dictionaries/injectEntry.d.ts.map +0 -1
  43. package/dist/dictionaries/injectFallbacks.d.ts +0 -18
  44. package/dist/dictionaries/injectFallbacks.d.ts.map +0 -1
  45. package/dist/dictionaries/injectHashes.d.ts +0 -11
  46. package/dist/dictionaries/injectHashes.d.ts.map +0 -1
  47. package/dist/dictionaries/injectTranslations.d.ts +0 -21
  48. package/dist/dictionaries/injectTranslations.d.ts.map +0 -1
  49. package/dist/dictionaries/isDictionaryEntry.d.ts +0 -8
  50. package/dist/dictionaries/isDictionaryEntry.d.ts.map +0 -1
  51. package/dist/dictionaries/loadDictionaryHelper.d.ts +0 -3
  52. package/dist/dictionaries/loadDictionaryHelper.d.ts.map +0 -1
  53. package/dist/dictionaries/mergeDictionaries.d.ts +0 -3
  54. package/dist/dictionaries/mergeDictionaries.d.ts.map +0 -1
  55. package/dist/dictionaries/stripMetadataFromEntries.d.ts +0 -6
  56. package/dist/dictionaries/stripMetadataFromEntries.d.ts.map +0 -1
  57. package/dist/errors-dir/constants.d.ts +0 -2
  58. package/dist/errors-dir/constants.d.ts.map +0 -1
  59. package/dist/errors-dir/createErrors.d.ts +0 -36
  60. package/dist/errors-dir/createErrors.d.ts.map +0 -1
  61. package/dist/errors-dir/internalErrors.d.ts +0 -8
  62. package/dist/errors-dir/internalErrors.d.ts.map +0 -1
  63. package/dist/hooks/useDefaultLocale.d.ts +0 -13
  64. package/dist/hooks/useDefaultLocale.d.ts.map +0 -1
  65. package/dist/hooks/useGTClass.d.ts +0 -23
  66. package/dist/hooks/useGTClass.d.ts.map +0 -1
  67. package/dist/hooks/useLocale.d.ts +0 -11
  68. package/dist/hooks/useLocale.d.ts.map +0 -1
  69. package/dist/hooks/useLocaleDirection.d.ts +0 -14
  70. package/dist/hooks/useLocaleDirection.d.ts.map +0 -1
  71. package/dist/hooks/useLocaleSelector.d.ts +0 -19
  72. package/dist/hooks/useLocaleSelector.d.ts.map +0 -1
  73. package/dist/hooks/useLocales.d.ts +0 -11
  74. package/dist/hooks/useLocales.d.ts.map +0 -1
  75. package/dist/hooks/useRegion.d.ts +0 -20
  76. package/dist/hooks/useRegion.d.ts.map +0 -1
  77. package/dist/hooks/useRegionSelector.d.ts +0 -82
  78. package/dist/hooks/useRegionSelector.d.ts.map +0 -1
  79. package/dist/hooks/useSetLocale.d.ts +0 -12
  80. package/dist/hooks/useSetLocale.d.ts.map +0 -1
  81. package/dist/hooks/useVersionId.d.ts +0 -11
  82. package/dist/hooks/useVersionId.d.ts.map +0 -1
  83. package/dist/internal/addGTIdentifier.d.ts +0 -4
  84. package/dist/internal/addGTIdentifier.d.ts.map +0 -1
  85. package/dist/internal/flattenDictionary.d.ts +0 -11
  86. package/dist/internal/flattenDictionary.d.ts.map +0 -1
  87. package/dist/internal/removeInjectedT.d.ts +0 -11
  88. package/dist/internal/removeInjectedT.d.ts.map +0 -1
  89. package/dist/internal/writeChildrenAsObjects.d.ts +0 -10
  90. package/dist/internal/writeChildrenAsObjects.d.ts.map +0 -1
  91. package/dist/messages/messages.d.ts +0 -2
  92. package/dist/messages/messages.d.ts.map +0 -1
  93. package/dist/promises/dangerouslyUsable.d.ts +0 -37
  94. package/dist/promises/dangerouslyUsable.d.ts.map +0 -1
  95. package/dist/promises/reactHasUse.d.ts +0 -2
  96. package/dist/promises/reactHasUse.d.ts.map +0 -1
  97. package/dist/provider/GTContext.d.ts +0 -4
  98. package/dist/provider/GTContext.d.ts.map +0 -1
  99. package/dist/provider/GTProvider.d.ts +0 -3
  100. package/dist/provider/GTProvider.d.ts.map +0 -1
  101. package/dist/provider/config/defaultProps.d.ts +0 -4
  102. package/dist/provider/config/defaultProps.d.ts.map +0 -1
  103. package/dist/provider/helpers/isSSREnabled.d.ts +0 -5
  104. package/dist/provider/helpers/isSSREnabled.d.ts.map +0 -1
  105. package/dist/provider/helpers/validateString.d.ts +0 -6
  106. package/dist/provider/helpers/validateString.d.ts.map +0 -1
  107. package/dist/provider/hooks/locales/types.d.ts +0 -13
  108. package/dist/provider/hooks/locales/types.d.ts.map +0 -1
  109. package/dist/provider/hooks/locales/useDetermineLocale.d.ts +0 -6
  110. package/dist/provider/hooks/locales/useDetermineLocale.d.ts.map +0 -1
  111. package/dist/provider/hooks/locales/useLocaleState.d.ts +0 -20
  112. package/dist/provider/hooks/locales/useLocaleState.d.ts.map +0 -1
  113. package/dist/provider/hooks/translation/useCreateInternalUseGTFunction.d.ts +0 -19
  114. package/dist/provider/hooks/translation/useCreateInternalUseGTFunction.d.ts.map +0 -1
  115. package/dist/provider/hooks/translation/useCreateInternalUseTranslationsFunction.d.ts +0 -5
  116. package/dist/provider/hooks/translation/useCreateInternalUseTranslationsFunction.d.ts.map +0 -1
  117. package/dist/provider/hooks/translation/useCreateInternalUseTranslationsObjFunction.d.ts +0 -4
  118. package/dist/provider/hooks/translation/useCreateInternalUseTranslationsObjFunction.d.ts.map +0 -1
  119. package/dist/provider/hooks/types.d.ts +0 -19
  120. package/dist/provider/hooks/types.d.ts.map +0 -1
  121. package/dist/provider/hooks/useEnableI18n.d.ts +0 -3
  122. package/dist/provider/hooks/useEnableI18n.d.ts.map +0 -1
  123. package/dist/provider/hooks/useErrorChecks.d.ts +0 -10
  124. package/dist/provider/hooks/useErrorChecks.d.ts.map +0 -1
  125. package/dist/provider/hooks/useLoadDictionary.d.ts +0 -15
  126. package/dist/provider/hooks/useLoadDictionary.d.ts.map +0 -1
  127. package/dist/provider/hooks/useLoadTranslations.d.ts +0 -17
  128. package/dist/provider/hooks/useLoadTranslations.d.ts.map +0 -1
  129. package/dist/provider/hooks/useRegionState.d.ts +0 -6
  130. package/dist/provider/hooks/useRegionState.d.ts.map +0 -1
  131. package/dist/provider/hooks/useRuntimeTranslation.d.ts +0 -24
  132. package/dist/provider/hooks/useRuntimeTranslation.d.ts.map +0 -1
  133. package/dist/rendering/getDefaultRenderSettings.d.ts +0 -6
  134. package/dist/rendering/getDefaultRenderSettings.d.ts.map +0 -1
  135. package/dist/rendering/getGTTag.d.ts +0 -3
  136. package/dist/rendering/getGTTag.d.ts.map +0 -1
  137. package/dist/rendering/isVariableObject.d.ts +0 -3
  138. package/dist/rendering/isVariableObject.d.ts.map +0 -1
  139. package/dist/rendering/renderDefaultChildren.d.ts +0 -8
  140. package/dist/rendering/renderDefaultChildren.d.ts.map +0 -1
  141. package/dist/rendering/renderSkeleton.d.ts +0 -8
  142. package/dist/rendering/renderSkeleton.d.ts.map +0 -1
  143. package/dist/rendering/renderTranslatedChildren.d.ts +0 -9
  144. package/dist/rendering/renderTranslatedChildren.d.ts.map +0 -1
  145. package/dist/rendering/renderVariable.d.ts +0 -4
  146. package/dist/rendering/renderVariable.d.ts.map +0 -1
  147. package/dist/translation/T.d.ts +0 -42
  148. package/dist/translation/T.d.ts.map +0 -1
  149. package/dist/translation/hooks/useGT.d.ts +0 -21
  150. package/dist/translation/hooks/useGT.d.ts.map +0 -1
  151. package/dist/translation/hooks/useMessages.d.ts +0 -19
  152. package/dist/translation/hooks/useMessages.d.ts.map +0 -1
  153. package/dist/translation/hooks/useTranslations.d.ts +0 -17
  154. package/dist/translation/hooks/useTranslations.d.ts.map +0 -1
  155. package/dist/types-dir/config.d.ts +0 -69
  156. package/dist/types-dir/config.d.ts.map +0 -1
  157. package/dist/types-dir/context.d.ts +0 -31
  158. package/dist/types-dir/context.d.ts.map +0 -1
  159. package/dist/types-dir/runtime.d.ts +0 -22
  160. package/dist/types-dir/runtime.d.ts.map +0 -1
  161. package/dist/types-dir/types.d.ts +0 -90
  162. package/dist/types-dir/types.d.ts.map +0 -1
  163. package/dist/ui/LocaleSelector.d.ts +0 -7
  164. package/dist/ui/LocaleSelector.d.ts.map +0 -1
  165. package/dist/ui/RegionSelector.d.ts +0 -7
  166. package/dist/ui/RegionSelector.d.ts.map +0 -1
  167. package/dist/ui/types.d.ts +0 -18
  168. package/dist/ui/types.d.ts.map +0 -1
  169. package/dist/utils/cookies.d.ts +0 -14
  170. package/dist/utils/cookies.d.ts.map +0 -1
  171. package/dist/utils/fetchTranslations.d.ts +0 -9
  172. package/dist/utils/fetchTranslations.d.ts.map +0 -1
  173. package/dist/utils/types.d.ts +0 -9
  174. package/dist/utils/types.d.ts.map +0 -1
  175. package/dist/utils/use.d.ts +0 -4
  176. package/dist/utils/use.d.ts.map +0 -1
  177. package/dist/utils/utils.d.ts +0 -8
  178. package/dist/utils/utils.d.ts.map +0 -1
  179. package/dist/variables/Currency.d.ts +0 -30
  180. package/dist/variables/Currency.d.ts.map +0 -1
  181. package/dist/variables/DateTime.d.ts +0 -29
  182. package/dist/variables/DateTime.d.ts.map +0 -1
  183. package/dist/variables/Derive.d.ts +0 -76
  184. package/dist/variables/Derive.d.ts.map +0 -1
  185. package/dist/variables/Num.d.ts +0 -31
  186. package/dist/variables/Num.d.ts.map +0 -1
  187. package/dist/variables/RelativeTime.d.ts +0 -45
  188. package/dist/variables/RelativeTime.d.ts.map +0 -1
  189. package/dist/variables/Var.d.ts +0 -32
  190. package/dist/variables/Var.d.ts.map +0 -1
  191. package/dist/variables/_getVariableProps.d.ts +0 -11
  192. package/dist/variables/_getVariableProps.d.ts.map +0 -1
  193. package/dist/variables/getVariableName.d.ts +0 -11
  194. package/dist/variables/getVariableName.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @generaltranslation/react-core
2
2
 
3
+ ## 1.8.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1419](https://github.com/generaltranslation/gt/pull/1419) [`a877a2a`](https://github.com/generaltranslation/gt/commit/a877a2a5bd5ca47b199c6caf53a6d60d96e3a300) Thanks [@bgub](https://github.com/bgub)! - Improve diagnostic messages and package-local diagnostic formatting.
8
+
9
+ - Updated dependencies [[`bb3624e`](https://github.com/generaltranslation/gt/commit/bb3624e58546c334c04370a1f5a262238bd040fa), [`a877a2a`](https://github.com/generaltranslation/gt/commit/a877a2a5bd5ca47b199c6caf53a6d60d96e3a300)]:
10
+ - @generaltranslation/format@0.1.1
11
+ - generaltranslation@8.2.15
12
+ - gt-i18n@0.9.3
13
+ - @generaltranslation/supported-locales@2.0.73
14
+
15
+ ## 1.8.18
16
+
17
+ ### Patch Changes
18
+
19
+ - [#1408](https://github.com/generaltranslation/gt/pull/1408) [`425d3e4`](https://github.com/generaltranslation/gt/commit/425d3e4e6c61afd108c65c27f7693ba2470b33c6) Thanks [@bgub](https://github.com/bgub)! - Use @generaltranslation/format directly for shared formatting and locale helpers.
20
+
21
+ - [#1415](https://github.com/generaltranslation/gt/pull/1415) [`6e6c69e`](https://github.com/generaltranslation/gt/commit/6e6c69e3ca2f51937407674cf101b69e968952a1) Thanks [@bgub](https://github.com/bgub)! - Switch the React Core package build pipeline to tsdown while preserving the existing public entrypoints.
22
+
23
+ - Updated dependencies [[`73f3ac1`](https://github.com/generaltranslation/gt/commit/73f3ac1308df11c1e6230c13c1999bfc5f6afc99), [`425d3e4`](https://github.com/generaltranslation/gt/commit/425d3e4e6c61afd108c65c27f7693ba2470b33c6), [`8650ae9`](https://github.com/generaltranslation/gt/commit/8650ae9ced69755bf3eebc1bafdf7743ba0c5136)]:
24
+ - @generaltranslation/format@0.1.0
25
+ - generaltranslation@8.2.14
26
+ - gt-i18n@0.9.2
27
+ - @generaltranslation/supported-locales@2.0.72
28
+
3
29
  ## 1.8.17
4
30
 
5
31
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- "use strict";require("generaltranslation");exports.createUnsupportedLocaleWarning=(a,e,r="@generaltranslation/react-core")=>`${r} Warning: "${e}" is not a supported locale. Update supported locales in your dashboard or gt.config.json. Falling back to "${a}".`;
2
- //# sourceMappingURL=errors.cjs.min.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`@generaltranslation/format`);function e(e){let t=e.trim();return t?/[.!?)]$/.test(t)?t:`${t}.`:``}function t(e){let t=e.trim(),n=t.length;for(;n>0;){let e=t[n-1];if(e!==`.`&&e!==`!`&&e!==`?`)break;--n}return t.slice(0,n)}function n(e){return e.replace(/^[A-Z][a-z]/,e=>e.toLowerCase())}function r(t){if(!t)return``;let n=Array.isArray(t)?t.join(`, `):t;return n.trim()?e(`Details: ${n}`):``}function i({source:i,severity:a,whatHappened:o,reassurance:s,why:c,fix:l,wayOut:u,details:d,docsUrl:f}){let p=i?a?`${i} ${a}:`:`${i}:`:a?`${a}:`:``,m=c?`${t(o)} because ${n(t(c))}`:o,h=!!l&&!!u&&/^[a-z]/.test(t(u)),g=[m,s,h?`${t(l)}, or ${n(t(u))}`:l,h?void 0:u,r(d)].filter(e=>!!e).map(e);f&&g.push(`Learn more: ${f}`);let _=g.join(` `);return p?`${p} ${_}`:_}const a=`@generaltranslation/react-core`;function o(e){return i({source:a,...e})}o({severity:`Error`,whatHappened:`Runtime translation needs a project ID`,fix:`Add projectId to your <GTProvider> configuration or set GT_PROJECT_ID in your environment`,docsUrl:`https://generaltranslation.com/dashboard`}),o({severity:`Error`,whatHappened:`Production environments cannot use a development API key`,fix:`Replace it with a production API key before deploying`}),o({severity:`Error`,whatHappened:`The API key is available to client-side production code`,fix:`Move translation credentials to a server-only environment before deploying`}),o({severity:`Error`,whatHappened:`Runtime translation is not configured`,fix:`Add projectId and devApiKey to your environment, or pass them to <GTProvider> directly`}),o({severity:`Error`,whatHappened:`Runtime translations could not be loaded`,wayOut:`Source content will render as a fallback`,fix:`Check your runtime translation configuration and try again`}),o({severity:`Error`,whatHappened:`Runtime translation could not be completed`}),o({severity:`Warning`,whatHappened:`Runtime translation needs a project ID`,fix:`Add projectId to <GTProvider> or set GT_PROJECT_ID in your environment`,docsUrl:`https://generaltranslation.com/dashboard`}),o({severity:`Warning`,whatHappened:`Runtime translation needs a development API key`,fix:`Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation`}),o({severity:`Warning`,whatHappened:`Runtime translation timed out`});const s=(e,t,n=a)=>`${n} Warning: "${t}" is not a supported locale. Update supported locales in your dashboard or gt.config.json. Falling back to "${e}".`;o({severity:`Warning`,whatHappened:`No dictionary was found`,fix:`Pass a dictionary to <GTProvider> or configure a dictionary loader before rendering translations`}),`${a}`,exports.createUnsupportedLocaleWarning=s;
2
+ //# sourceMappingURL=errors.cjs.min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs.min.cjs","sources":["../src/errors-dir/createErrors.ts","../src/errors-dir/constants.ts"],"sourcesContent":[null,null],"names":["validatedLocale","newLocale","packageName"],"mappings":"kFA6H8C,CAC5CA,EACAC,EACAC,EChI0B,mCDmIxB,GAAGA,eAAyBD,gHAERD"}
1
+ {"version":3,"file":"errors.cjs.min.cjs","names":[],"sources":["../../core/dist/base64-r7YWJYWt.mjs","../src/errors-dir/constants.ts","../src/errors-dir/diagnostics.ts","../src/errors-dir/createErrors.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/utils/isSupportedFileFormatTransform.ts\nconst SUPPORTED_TRANSFORMATIONS = {\n\tGTJSON: [\"GTJSON\"],\n\tJSON: [\"JSON\"],\n\tPO: [\"PO\"],\n\tPOT: [\"POT\", \"PO\"],\n\tYAML: [\"YAML\"],\n\tMDX: [\"MDX\"],\n\tMD: [\"MD\"],\n\tTS: [\"TS\"],\n\tJS: [\"JS\"],\n\tHTML: [\"HTML\"],\n\tTXT: [\"TXT\"],\n\tTWILIO_CONTENT_JSON: [\"TWILIO_CONTENT_JSON\"]\n};\n/**\n* This function checks if a file format transformation is supported during translation\n* @param from - The source file format.\n* @param to - The target file format.\n* @returns True if the transformation is supported, false otherwise\n*/\nfunction isSupportedFileFormatTransform(from, to) {\n\treturn SUPPORTED_TRANSFORMATIONS[from]?.includes(to) ?? false;\n}\n//#endregion\n//#region src/translate/utils/validateFileFormatTransform.ts\n/**\n* Returns a user-facing validation error when a requested file format transform\n* is missing source format context or is not currently supported.\n*/\nfunction getFileFormatTransformError(file) {\n\tif (!file.transformFormat) return void 0;\n\tconst fileLabel = file.fileName ?? file.fileId ?? \"unknown file\";\n\tif (!file.fileFormat) return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n\tif (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n}\n/**\n* Validates file format transforms before sending upload/enqueue requests.\n*/\nfunction validateFileFormatTransforms(files) {\n\tfor (const file of files) {\n\t\tconst error = getFileFormatTransformError(file);\n\t\tif (error) throw new Error(error);\n\t}\n}\n//#endregion\n//#region src/utils/base64.ts\nfunction encode(data) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(data, \"utf8\").toString(\"base64\");\n\tconst bytes = new TextEncoder().encode(data);\n\tlet binary = \"\";\n\tfor (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);\n\treturn btoa(binary);\n}\nfunction decode(base64) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(base64, \"base64\").toString(\"utf8\");\n\tconst binary = atob(base64);\n\tconst bytes = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n\treturn new TextDecoder().decode(bytes);\n}\n//#endregion\nexport { defaultBaseUrl as a, createDiagnosticMessage as c, libraryDefaultLocale as d, isSupportedFileFormatTransform as i, formatDiagnosticErrorDetails as l, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t, defaultTimeout as u };\n\n//# sourceMappingURL=base64-r7YWJYWt.mjs.map","export const PACKAGE_NAME = '@generaltranslation/react-core';\n","import {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n type DiagnosticMessageInput,\n} from 'generaltranslation/internal';\nimport { PACKAGE_NAME } from './constants';\n\ntype ReactCoreDiagnosticInput = Omit<DiagnosticMessageInput, 'source'>;\n\nexport function createReactCoreDiagnostic(\n input: ReactCoreDiagnosticInput\n): string {\n return createDiagnosticMessage({\n source: PACKAGE_NAME,\n ...input,\n });\n}\n\nexport { formatDiagnosticErrorDetails };\n","import { getLocaleProperties } from '@generaltranslation/format';\nimport {\n createReactCoreDiagnostic,\n formatDiagnosticErrorDetails,\n} from './diagnostics';\nimport { PACKAGE_NAME } from './constants';\n\n// ---- ERRORS ---- //\n\nexport const projectIdMissingError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Add projectId to your <GTProvider> configuration or set GT_PROJECT_ID in your environment',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const devApiKeyProductionError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Production environments cannot use a development API key',\n fix: 'Replace it with a production API key before deploying',\n});\n\nexport const apiKeyInProductionError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'The API key is available to client-side production code',\n fix: 'Move translation credentials to a server-only environment before deploying',\n});\n\nexport const createNoAuthError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translation is not configured',\n fix: 'Add projectId and devApiKey to your environment, or pass them to <GTProvider> directly',\n});\n\nexport const createPluralMissingError = (children: unknown) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `<Plural> could not choose a plural form for \"${children}\"`,\n fix: 'Pass the required \"n\" option to <Plural>',\n });\n\nexport const createClientSideTDictionaryCollisionError = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `<T id=\"${id}\"> conflicts with a dictionary entry using the same ID`,\n fix: 'Rename the <T> id or the dictionary key so each translation source has a unique ID',\n });\n\nexport const createClientSideTHydrationError = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `<T id=\"${id}\"> is rendering in a client component without a saved translation`,\n why: 'This can cause hydration mismatches',\n fix: 'Use a dictionary with useGT() or push translations from the command line before rendering this component on the client',\n });\n\nexport const dynamicTranslationError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translations could not be loaded',\n wayOut: 'Source content will render as a fallback',\n fix: 'Check your runtime translation configuration and try again',\n});\n\nexport const createGenericRuntimeTranslationError = (\n id: string | undefined,\n hash: string,\n error?: unknown\n) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: id\n ? `Translation could not be found for id \"${id}\" and hash \"${hash}\"`\n : `Translation could not be found for hash \"${hash}\"`,\n wayOut: 'Source content will render as a fallback',\n fix: 'Push translations again or check that runtime translation is configured',\n details: formatDiagnosticErrorDetails(error),\n });\n\nexport const runtimeTranslationError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translation could not be completed',\n});\n\nexport const customLoadTranslationsError = (locale: string = '') =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `Locally stored translations could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadTranslations(), make sure it returns translations for the requested locale',\n });\n\nexport const customLoadDictionaryWarning = (locale: string = '') =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `The local dictionary could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadDictionary(), make sure it returns a dictionary for the requested locale',\n });\n\nexport const missingVariablesError = (variables: string[], message: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `The message \"${message}\" is missing variables: \"${variables.join('\", \"')}\"`,\n fix: 'Provide values for these variables before rendering the translation',\n });\n\nexport const createStringRenderError = (\n message: string,\n id: string | undefined,\n error?: unknown\n) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `The string ${id ? `for id \"${id}\" ` : ''}could not be rendered`,\n fix: `Check the message syntax and variables for: \"${message}\"`,\n details: formatDiagnosticErrorDetails(error),\n });\n\nexport const createStringTranslationError = (\n string: string,\n id?: string,\n functionName = 'tx'\n) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `${functionName}(\"${string}\")${id ? ` with id \"${id}\"` : ''} could not find a translation`,\n wayOut: 'Source content will render as a fallback',\n fix: 'Push translations again or check your dictionary/runtime translation configuration',\n });\n\nexport const invalidLocalesError = (locales: string[]) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid locale codes in your configuration',\n fix: 'Specify a list of valid locales or use \"customMapping\" to define aliases for the invalid locales',\n details: locales,\n });\n\nexport const invalidCanonicalLocalesError = (locales: string[]) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid canonical locale codes in your configuration',\n fix: 'Use valid BCP 47 locale codes before starting translation',\n details: locales,\n });\n\nexport const createEmptyIdError = () =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 't.obj() received an empty id',\n fix: 'Pass a non-empty dictionary id',\n });\n\nexport const createSubtreeNotFoundError = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `Dictionary subtree \"${id}\" could not be found`,\n fix: 'Check that the id matches your dictionary structure',\n });\n\nexport const createDictionaryEntryError = () =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'A dictionary entry cannot be injected as a subtree',\n fix: 'Pass a dictionary object instead',\n });\n\nexport const createCannotInjectDictionaryEntryError = () =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened:\n 'A dictionary entry cannot be merged into another dictionary entry',\n fix: 'Pass a dictionary subtree instead',\n });\n\nexport const createInvalidIcuDictionaryEntryError = (id: string | undefined) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `Dictionary entry \"${id}\" contains invalid ICU syntax`,\n fix: 'Fix the ICU message before rendering this translation',\n });\n\n// ---- WARNINGS ---- //\n\nexport const projectIdMissingWarning = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Add projectId to <GTProvider> or set GT_PROJECT_ID in your environment',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const createNoEntryFoundWarning = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `No valid dictionary entry was found for id \"${id}\"`,\n wayOut: 'Source content will render as a fallback',\n });\n\nexport const createInvalidDictionaryEntryWarning = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `Dictionary entry \"${id}\" is invalid`,\n wayOut: 'Source content will render as a fallback until the entry is fixed',\n });\n\nexport const createInvalidIcuDictionaryEntryWarning = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `Dictionary entry \"${id}\" contains invalid ICU syntax`,\n wayOut: 'Source content will render as a fallback until the entry is fixed',\n });\n\nexport const createNoEntryTranslationWarning = (\n id: string,\n prefixedId: string\n) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `t(\"${id}\") could not find a translation for dictionary item \"${prefixedId}\"`,\n wayOut: 'Source content will render as a fallback',\n });\n\nexport const createMismatchingHashWarning = (\n expectedHash: string,\n receivedHash: string\n) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Translation hashes do not match',\n reassurance: 'The translation will still render',\n fix: 'Update your translations to the newest version to avoid stale content',\n details: [`expected ${expectedHash}`, `received ${receivedHash}`],\n });\n\nexport const APIKeyMissingWarn = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Runtime translation needs a development API key',\n fix: 'Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation',\n});\n\nexport const createUnsupportedLocalesWarning = (locales: string[]) =>\n `${PACKAGE_NAME} Warning: The following locales are currently unsupported by our service: ${locales\n .map((locale) => {\n const { name } = getLocaleProperties(locale);\n return `${locale} (${name})`;\n })\n .join(', ')}`;\n\nexport const runtimeTranslationTimeoutWarning = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Runtime translation timed out',\n});\n\nexport const createUnsupportedLocaleWarning = (\n validatedLocale: string,\n newLocale: string,\n packageName: string = PACKAGE_NAME\n) => {\n return (\n `${packageName} Warning: \"${newLocale}\" is not a supported locale. ` +\n `Update supported locales in your dashboard or gt.config.json. ` +\n `Falling back to \"${validatedLocale}\".`\n );\n};\n\nexport const dictionaryMissingWarning = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'No dictionary was found',\n fix: 'Pass a dictionary to <GTProvider> or configure a dictionary loader before rendering translations',\n});\n\nexport const createStringRenderWarning = (\n message: string,\n id: string | undefined,\n error?: unknown\n) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `The string ${id ? `for id \"${id}\" ` : ''}could not be rendered`,\n wayOut: 'Source content will render as a fallback',\n fix: `Check the message syntax and variables for: \"${message}\"`,\n details: formatDiagnosticErrorDetails(error),\n });\n\n// Unlikely edge case: A <_T> component was injected outside of a <Derive> boundary. This would be caused by the compiler overeagerly injecting <_T> components.\nexport const warnNestedInternalTComponent = `${PACKAGE_NAME} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;\n"],"mappings":"yGAKA,SAAS,EAAe,EAAM,CAC7B,IAAM,EAAU,EAAK,MAAM,CAE3B,OADK,EACE,UAAU,KAAK,EAAQ,CAAG,EAAU,GAAG,EAAQ,GADjC,GAGtB,SAAS,EAAc,EAAM,CAC5B,IAAM,EAAU,EAAK,MAAM,CACvB,EAAM,EAAQ,OAClB,KAAO,EAAM,GAAG,CACf,IAAM,EAAO,EAAQ,EAAM,GAC3B,GAAI,IAAS,KAAO,IAAS,KAAO,IAAS,IAAK,MAClD,IAED,OAAO,EAAQ,MAAM,EAAG,EAAI,CAE7B,SAAS,EAAmB,EAAM,CACjC,OAAO,EAAK,QAAQ,cAAgB,GAAU,EAAM,aAAa,CAAC,CAEnE,SAAS,EAAc,EAAS,CAC/B,GAAI,CAAC,EAAS,MAAO,GACrB,IAAM,EAAa,MAAM,QAAQ,EAAQ,CAAG,EAAQ,KAAK,KAAK,CAAG,EAEjE,OADK,EAAW,MAAM,CACf,EAAe,YAAY,IAAa,CADhB,GAOhC,SAAS,EAAwB,CAAE,SAAQ,WAAU,eAAc,cAAa,MAAK,MAAK,SAAQ,UAAS,WAAW,CACrH,IAAM,EAAS,EAAS,EAAW,GAAG,EAAO,GAAG,EAAS,GAAK,GAAG,EAAO,GAAK,EAAW,GAAG,EAAS,GAAK,GACnG,EAAa,EAAM,GAAG,EAAc,EAAa,CAAC,WAAW,EAAmB,EAAc,EAAI,CAAC,GAAK,EACxG,EAAsB,CAAC,CAAC,GAAO,CAAC,CAAC,GAAU,SAAS,KAAK,EAAc,EAAO,CAAC,CAC/E,EAAe,CACpB,EACA,EACA,EAAsB,GAAG,EAAc,EAAI,CAAC,OAAO,EAAmB,EAAc,EAAO,CAAC,GAAK,EACjG,EAAsB,IAAK,GAAI,EAC/B,EAAc,EAAQ,CACtB,CAAC,OAAQ,GAAS,CAAC,CAAC,EAAK,CAAC,IAAI,EAAe,CAC1C,GAAS,EAAa,KAAK,eAAe,IAAU,CACxD,IAAM,EAAU,EAAa,KAAK,IAAI,CACtC,OAAO,EAAS,GAAG,EAAO,GAAG,IAAY,EC9C1C,MAAa,EAAe,iCCS5B,SAAgB,EACd,EACQ,CACR,OAAO,EAAwB,CAC7B,OAAQ,EACR,GAAG,EACJ,CAAC,CCNiC,EAA0B,CAC7D,SAAU,QACV,aAAc,yCACd,IAAK,4FACL,QAAS,2CACV,CAAC,CAEsC,EAA0B,CAChE,SAAU,QACV,aAAc,2DACd,IAAK,wDACN,CAAC,CAEqC,EAA0B,CAC/D,SAAU,QACV,aAAc,0DACd,IAAK,6EACN,CAAC,CAE+B,EAA0B,CACzD,SAAU,QACV,aAAc,wCACd,IAAK,yFACN,CAAC,CAwBqC,EAA0B,CAC/D,SAAU,QACV,aAAc,2CACd,OAAQ,2CACR,IAAK,6DACN,CAAC,CAiBqC,EAA0B,CAC/D,SAAU,QACV,aAAc,6CACf,CAAC,CAqGqC,EAA0B,CAC/D,SAAU,UACV,aAAc,yCACd,IAAK,yEACL,QAAS,2CACV,CAAC,CA6C+B,EAA0B,CACzD,SAAU,UACV,aAAc,kDACd,IAAK,yIACN,CAAC,CAU8C,EAA0B,CACxE,SAAU,UACV,aAAc,gCACf,CAAC,CAEF,MAAa,GACX,EACA,EACA,EAAsB,IAGpB,GAAG,EAAY,aAAa,EAAU,8GAElB,EAAgB,IAIA,EAA0B,CAChE,SAAU,UACV,aAAc,0BACd,IAAK,mGACN,CAAC,CAgB0C,GAAG,EAAH"}
package/dist/errors.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ //#region src/errors-dir/createErrors.d.ts
1
2
  declare const createUnsupportedLocaleWarning: (validatedLocale: string, newLocale: string, packageName?: string) => string;
2
-
3
+ //#endregion
3
4
  export { createUnsupportedLocaleWarning };
5
+ //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAE3E,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors-dir/createErrors.ts"],"mappings":";cA2Pa,8BAAA,GACX,eAAA,UACA,SAAA,UACA,WAAA"}
@@ -1,2 +1,2 @@
1
- import"generaltranslation";const o=(o,a,n="@generaltranslation/react-core")=>`${n} Warning: "${a}" is not a supported locale. Update supported locales in your dashboard or gt.config.json. Falling back to "${o}".`;export{o as createUnsupportedLocaleWarning};
2
- //# sourceMappingURL=errors.esm.min.mjs.map
1
+ import"@generaltranslation/format";function e(e){let t=e.trim();return t?/[.!?)]$/.test(t)?t:`${t}.`:``}function t(e){let t=e.trim(),n=t.length;for(;n>0;){let e=t[n-1];if(e!==`.`&&e!==`!`&&e!==`?`)break;--n}return t.slice(0,n)}function n(e){return e.replace(/^[A-Z][a-z]/,e=>e.toLowerCase())}function r(t){if(!t)return``;let n=Array.isArray(t)?t.join(`, `):t;return n.trim()?e(`Details: ${n}`):``}function i({source:i,severity:a,whatHappened:o,reassurance:s,why:c,fix:l,wayOut:u,details:d,docsUrl:f}){let p=i?a?`${i} ${a}:`:`${i}:`:a?`${a}:`:``,m=c?`${t(o)} because ${n(t(c))}`:o,h=!!l&&!!u&&/^[a-z]/.test(t(u)),g=[m,s,h?`${t(l)}, or ${n(t(u))}`:l,h?void 0:u,r(d)].filter(e=>!!e).map(e);f&&g.push(`Learn more: ${f}`);let _=g.join(` `);return p?`${p} ${_}`:_}const a=`@generaltranslation/react-core`;function o(e){return i({source:a,...e})}o({severity:`Error`,whatHappened:`Runtime translation needs a project ID`,fix:`Add projectId to your <GTProvider> configuration or set GT_PROJECT_ID in your environment`,docsUrl:`https://generaltranslation.com/dashboard`}),o({severity:`Error`,whatHappened:`Production environments cannot use a development API key`,fix:`Replace it with a production API key before deploying`}),o({severity:`Error`,whatHappened:`The API key is available to client-side production code`,fix:`Move translation credentials to a server-only environment before deploying`}),o({severity:`Error`,whatHappened:`Runtime translation is not configured`,fix:`Add projectId and devApiKey to your environment, or pass them to <GTProvider> directly`}),o({severity:`Error`,whatHappened:`Runtime translations could not be loaded`,wayOut:`Source content will render as a fallback`,fix:`Check your runtime translation configuration and try again`}),o({severity:`Error`,whatHappened:`Runtime translation could not be completed`}),o({severity:`Warning`,whatHappened:`Runtime translation needs a project ID`,fix:`Add projectId to <GTProvider> or set GT_PROJECT_ID in your environment`,docsUrl:`https://generaltranslation.com/dashboard`}),o({severity:`Warning`,whatHappened:`Runtime translation needs a development API key`,fix:`Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation`}),o({severity:`Warning`,whatHappened:`Runtime translation timed out`});const s=(e,t,n=a)=>`${n} Warning: "${t}" is not a supported locale. Update supported locales in your dashboard or gt.config.json. Falling back to "${e}".`;o({severity:`Warning`,whatHappened:`No dictionary was found`,fix:`Pass a dictionary to <GTProvider> or configure a dictionary loader before rendering translations`}),`${a}`;export{s as createUnsupportedLocaleWarning};
2
+ //# sourceMappingURL=errors.esm.min.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.esm.min.mjs","sources":["../src/errors-dir/constants.ts","../src/errors-dir/createErrors.ts"],"sourcesContent":[null,null],"names":["createUnsupportedLocaleWarning","validatedLocale","newLocale","packageName"],"mappings":"2BAAO,MC6HMA,EAAiC,CAC5CC,EACAC,EACAC,EDhI0B,mCCmIxB,GAAGA,eAAyBD,gHAERD"}
1
+ {"version":3,"file":"errors.esm.min.mjs","names":[],"sources":["../../core/dist/base64-r7YWJYWt.mjs","../src/errors-dir/constants.ts","../src/errors-dir/diagnostics.ts","../src/errors-dir/createErrors.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/utils/isSupportedFileFormatTransform.ts\nconst SUPPORTED_TRANSFORMATIONS = {\n\tGTJSON: [\"GTJSON\"],\n\tJSON: [\"JSON\"],\n\tPO: [\"PO\"],\n\tPOT: [\"POT\", \"PO\"],\n\tYAML: [\"YAML\"],\n\tMDX: [\"MDX\"],\n\tMD: [\"MD\"],\n\tTS: [\"TS\"],\n\tJS: [\"JS\"],\n\tHTML: [\"HTML\"],\n\tTXT: [\"TXT\"],\n\tTWILIO_CONTENT_JSON: [\"TWILIO_CONTENT_JSON\"]\n};\n/**\n* This function checks if a file format transformation is supported during translation\n* @param from - The source file format.\n* @param to - The target file format.\n* @returns True if the transformation is supported, false otherwise\n*/\nfunction isSupportedFileFormatTransform(from, to) {\n\treturn SUPPORTED_TRANSFORMATIONS[from]?.includes(to) ?? false;\n}\n//#endregion\n//#region src/translate/utils/validateFileFormatTransform.ts\n/**\n* Returns a user-facing validation error when a requested file format transform\n* is missing source format context or is not currently supported.\n*/\nfunction getFileFormatTransformError(file) {\n\tif (!file.transformFormat) return void 0;\n\tconst fileLabel = file.fileName ?? file.fileId ?? \"unknown file\";\n\tif (!file.fileFormat) return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n\tif (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n}\n/**\n* Validates file format transforms before sending upload/enqueue requests.\n*/\nfunction validateFileFormatTransforms(files) {\n\tfor (const file of files) {\n\t\tconst error = getFileFormatTransformError(file);\n\t\tif (error) throw new Error(error);\n\t}\n}\n//#endregion\n//#region src/utils/base64.ts\nfunction encode(data) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(data, \"utf8\").toString(\"base64\");\n\tconst bytes = new TextEncoder().encode(data);\n\tlet binary = \"\";\n\tfor (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);\n\treturn btoa(binary);\n}\nfunction decode(base64) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(base64, \"base64\").toString(\"utf8\");\n\tconst binary = atob(base64);\n\tconst bytes = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n\treturn new TextDecoder().decode(bytes);\n}\n//#endregion\nexport { defaultBaseUrl as a, createDiagnosticMessage as c, libraryDefaultLocale as d, isSupportedFileFormatTransform as i, formatDiagnosticErrorDetails as l, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t, defaultTimeout as u };\n\n//# sourceMappingURL=base64-r7YWJYWt.mjs.map","export const PACKAGE_NAME = '@generaltranslation/react-core';\n","import {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n type DiagnosticMessageInput,\n} from 'generaltranslation/internal';\nimport { PACKAGE_NAME } from './constants';\n\ntype ReactCoreDiagnosticInput = Omit<DiagnosticMessageInput, 'source'>;\n\nexport function createReactCoreDiagnostic(\n input: ReactCoreDiagnosticInput\n): string {\n return createDiagnosticMessage({\n source: PACKAGE_NAME,\n ...input,\n });\n}\n\nexport { formatDiagnosticErrorDetails };\n","import { getLocaleProperties } from '@generaltranslation/format';\nimport {\n createReactCoreDiagnostic,\n formatDiagnosticErrorDetails,\n} from './diagnostics';\nimport { PACKAGE_NAME } from './constants';\n\n// ---- ERRORS ---- //\n\nexport const projectIdMissingError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Add projectId to your <GTProvider> configuration or set GT_PROJECT_ID in your environment',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const devApiKeyProductionError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Production environments cannot use a development API key',\n fix: 'Replace it with a production API key before deploying',\n});\n\nexport const apiKeyInProductionError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'The API key is available to client-side production code',\n fix: 'Move translation credentials to a server-only environment before deploying',\n});\n\nexport const createNoAuthError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translation is not configured',\n fix: 'Add projectId and devApiKey to your environment, or pass them to <GTProvider> directly',\n});\n\nexport const createPluralMissingError = (children: unknown) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `<Plural> could not choose a plural form for \"${children}\"`,\n fix: 'Pass the required \"n\" option to <Plural>',\n });\n\nexport const createClientSideTDictionaryCollisionError = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `<T id=\"${id}\"> conflicts with a dictionary entry using the same ID`,\n fix: 'Rename the <T> id or the dictionary key so each translation source has a unique ID',\n });\n\nexport const createClientSideTHydrationError = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `<T id=\"${id}\"> is rendering in a client component without a saved translation`,\n why: 'This can cause hydration mismatches',\n fix: 'Use a dictionary with useGT() or push translations from the command line before rendering this component on the client',\n });\n\nexport const dynamicTranslationError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translations could not be loaded',\n wayOut: 'Source content will render as a fallback',\n fix: 'Check your runtime translation configuration and try again',\n});\n\nexport const createGenericRuntimeTranslationError = (\n id: string | undefined,\n hash: string,\n error?: unknown\n) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: id\n ? `Translation could not be found for id \"${id}\" and hash \"${hash}\"`\n : `Translation could not be found for hash \"${hash}\"`,\n wayOut: 'Source content will render as a fallback',\n fix: 'Push translations again or check that runtime translation is configured',\n details: formatDiagnosticErrorDetails(error),\n });\n\nexport const runtimeTranslationError = createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Runtime translation could not be completed',\n});\n\nexport const customLoadTranslationsError = (locale: string = '') =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `Locally stored translations could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadTranslations(), make sure it returns translations for the requested locale',\n });\n\nexport const customLoadDictionaryWarning = (locale: string = '') =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `The local dictionary could not be loaded${locale ? ` for \"${locale}\"` : ''}`,\n fix: 'If you use loadDictionary(), make sure it returns a dictionary for the requested locale',\n });\n\nexport const missingVariablesError = (variables: string[], message: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `The message \"${message}\" is missing variables: \"${variables.join('\", \"')}\"`,\n fix: 'Provide values for these variables before rendering the translation',\n });\n\nexport const createStringRenderError = (\n message: string,\n id: string | undefined,\n error?: unknown\n) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `The string ${id ? `for id \"${id}\" ` : ''}could not be rendered`,\n fix: `Check the message syntax and variables for: \"${message}\"`,\n details: formatDiagnosticErrorDetails(error),\n });\n\nexport const createStringTranslationError = (\n string: string,\n id?: string,\n functionName = 'tx'\n) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `${functionName}(\"${string}\")${id ? ` with id \"${id}\"` : ''} could not find a translation`,\n wayOut: 'Source content will render as a fallback',\n fix: 'Push translations again or check your dictionary/runtime translation configuration',\n });\n\nexport const invalidLocalesError = (locales: string[]) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid locale codes in your configuration',\n fix: 'Specify a list of valid locales or use \"customMapping\" to define aliases for the invalid locales',\n details: locales,\n });\n\nexport const invalidCanonicalLocalesError = (locales: string[]) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'Invalid canonical locale codes in your configuration',\n fix: 'Use valid BCP 47 locale codes before starting translation',\n details: locales,\n });\n\nexport const createEmptyIdError = () =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 't.obj() received an empty id',\n fix: 'Pass a non-empty dictionary id',\n });\n\nexport const createSubtreeNotFoundError = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `Dictionary subtree \"${id}\" could not be found`,\n fix: 'Check that the id matches your dictionary structure',\n });\n\nexport const createDictionaryEntryError = () =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: 'A dictionary entry cannot be injected as a subtree',\n fix: 'Pass a dictionary object instead',\n });\n\nexport const createCannotInjectDictionaryEntryError = () =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened:\n 'A dictionary entry cannot be merged into another dictionary entry',\n fix: 'Pass a dictionary subtree instead',\n });\n\nexport const createInvalidIcuDictionaryEntryError = (id: string | undefined) =>\n createReactCoreDiagnostic({\n severity: 'Error',\n whatHappened: `Dictionary entry \"${id}\" contains invalid ICU syntax`,\n fix: 'Fix the ICU message before rendering this translation',\n });\n\n// ---- WARNINGS ---- //\n\nexport const projectIdMissingWarning = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Runtime translation needs a project ID',\n fix: 'Add projectId to <GTProvider> or set GT_PROJECT_ID in your environment',\n docsUrl: 'https://generaltranslation.com/dashboard',\n});\n\nexport const createNoEntryFoundWarning = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `No valid dictionary entry was found for id \"${id}\"`,\n wayOut: 'Source content will render as a fallback',\n });\n\nexport const createInvalidDictionaryEntryWarning = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `Dictionary entry \"${id}\" is invalid`,\n wayOut: 'Source content will render as a fallback until the entry is fixed',\n });\n\nexport const createInvalidIcuDictionaryEntryWarning = (id: string) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `Dictionary entry \"${id}\" contains invalid ICU syntax`,\n wayOut: 'Source content will render as a fallback until the entry is fixed',\n });\n\nexport const createNoEntryTranslationWarning = (\n id: string,\n prefixedId: string\n) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `t(\"${id}\") could not find a translation for dictionary item \"${prefixedId}\"`,\n wayOut: 'Source content will render as a fallback',\n });\n\nexport const createMismatchingHashWarning = (\n expectedHash: string,\n receivedHash: string\n) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Translation hashes do not match',\n reassurance: 'The translation will still render',\n fix: 'Update your translations to the newest version to avoid stale content',\n details: [`expected ${expectedHash}`, `received ${receivedHash}`],\n });\n\nexport const APIKeyMissingWarn = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Runtime translation needs a development API key',\n fix: 'Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation',\n});\n\nexport const createUnsupportedLocalesWarning = (locales: string[]) =>\n `${PACKAGE_NAME} Warning: The following locales are currently unsupported by our service: ${locales\n .map((locale) => {\n const { name } = getLocaleProperties(locale);\n return `${locale} (${name})`;\n })\n .join(', ')}`;\n\nexport const runtimeTranslationTimeoutWarning = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'Runtime translation timed out',\n});\n\nexport const createUnsupportedLocaleWarning = (\n validatedLocale: string,\n newLocale: string,\n packageName: string = PACKAGE_NAME\n) => {\n return (\n `${packageName} Warning: \"${newLocale}\" is not a supported locale. ` +\n `Update supported locales in your dashboard or gt.config.json. ` +\n `Falling back to \"${validatedLocale}\".`\n );\n};\n\nexport const dictionaryMissingWarning = createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: 'No dictionary was found',\n fix: 'Pass a dictionary to <GTProvider> or configure a dictionary loader before rendering translations',\n});\n\nexport const createStringRenderWarning = (\n message: string,\n id: string | undefined,\n error?: unknown\n) =>\n createReactCoreDiagnostic({\n severity: 'Warning',\n whatHappened: `The string ${id ? `for id \"${id}\" ` : ''}could not be rendered`,\n wayOut: 'Source content will render as a fallback',\n fix: `Check the message syntax and variables for: \"${message}\"`,\n details: formatDiagnosticErrorDetails(error),\n });\n\n// Unlikely edge case: A <_T> component was injected outside of a <Derive> boundary. This would be caused by the compiler overeagerly injecting <_T> components.\nexport const warnNestedInternalTComponent = `${PACKAGE_NAME} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;\n"],"mappings":"mCAKA,SAAS,EAAe,EAAM,CAC7B,IAAM,EAAU,EAAK,MAAM,CAE3B,OADK,EACE,UAAU,KAAK,EAAQ,CAAG,EAAU,GAAG,EAAQ,GADjC,GAGtB,SAAS,EAAc,EAAM,CAC5B,IAAM,EAAU,EAAK,MAAM,CACvB,EAAM,EAAQ,OAClB,KAAO,EAAM,GAAG,CACf,IAAM,EAAO,EAAQ,EAAM,GAC3B,GAAI,IAAS,KAAO,IAAS,KAAO,IAAS,IAAK,MAClD,IAED,OAAO,EAAQ,MAAM,EAAG,EAAI,CAE7B,SAAS,EAAmB,EAAM,CACjC,OAAO,EAAK,QAAQ,cAAgB,GAAU,EAAM,aAAa,CAAC,CAEnE,SAAS,EAAc,EAAS,CAC/B,GAAI,CAAC,EAAS,MAAO,GACrB,IAAM,EAAa,MAAM,QAAQ,EAAQ,CAAG,EAAQ,KAAK,KAAK,CAAG,EAEjE,OADK,EAAW,MAAM,CACf,EAAe,YAAY,IAAa,CADhB,GAOhC,SAAS,EAAwB,CAAE,SAAQ,WAAU,eAAc,cAAa,MAAK,MAAK,SAAQ,UAAS,WAAW,CACrH,IAAM,EAAS,EAAS,EAAW,GAAG,EAAO,GAAG,EAAS,GAAK,GAAG,EAAO,GAAK,EAAW,GAAG,EAAS,GAAK,GACnG,EAAa,EAAM,GAAG,EAAc,EAAa,CAAC,WAAW,EAAmB,EAAc,EAAI,CAAC,GAAK,EACxG,EAAsB,CAAC,CAAC,GAAO,CAAC,CAAC,GAAU,SAAS,KAAK,EAAc,EAAO,CAAC,CAC/E,EAAe,CACpB,EACA,EACA,EAAsB,GAAG,EAAc,EAAI,CAAC,OAAO,EAAmB,EAAc,EAAO,CAAC,GAAK,EACjG,EAAsB,IAAK,GAAI,EAC/B,EAAc,EAAQ,CACtB,CAAC,OAAQ,GAAS,CAAC,CAAC,EAAK,CAAC,IAAI,EAAe,CAC1C,GAAS,EAAa,KAAK,eAAe,IAAU,CACxD,IAAM,EAAU,EAAa,KAAK,IAAI,CACtC,OAAO,EAAS,GAAG,EAAO,GAAG,IAAY,EC9C1C,MAAa,EAAe,iCCS5B,SAAgB,EACd,EACQ,CACR,OAAO,EAAwB,CAC7B,OAAQ,EACR,GAAG,EACJ,CAAC,CCNiC,EAA0B,CAC7D,SAAU,QACV,aAAc,yCACd,IAAK,4FACL,QAAS,2CACV,CAAC,CAEsC,EAA0B,CAChE,SAAU,QACV,aAAc,2DACd,IAAK,wDACN,CAAC,CAEqC,EAA0B,CAC/D,SAAU,QACV,aAAc,0DACd,IAAK,6EACN,CAAC,CAE+B,EAA0B,CACzD,SAAU,QACV,aAAc,wCACd,IAAK,yFACN,CAAC,CAwBqC,EAA0B,CAC/D,SAAU,QACV,aAAc,2CACd,OAAQ,2CACR,IAAK,6DACN,CAAC,CAiBqC,EAA0B,CAC/D,SAAU,QACV,aAAc,6CACf,CAAC,CAqGqC,EAA0B,CAC/D,SAAU,UACV,aAAc,yCACd,IAAK,yEACL,QAAS,2CACV,CAAC,CA6C+B,EAA0B,CACzD,SAAU,UACV,aAAc,kDACd,IAAK,yIACN,CAAC,CAU8C,EAA0B,CACxE,SAAU,UACV,aAAc,gCACf,CAAC,CAEF,MAAa,GACX,EACA,EACA,EAAsB,IAGpB,GAAG,EAAY,aAAa,EAAU,8GAElB,EAAgB,IAIA,EAA0B,CAChE,SAAU,UACV,aAAc,0BACd,IAAK,mGACN,CAAC,CAgB0C,GAAG,EAAH"}