react-i18next 16.6.6 → 17.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 17.0.0
2
+
3
+ ### Potentially breaking changes
4
+
5
+ - fix: `transKeepBasicHtmlNodesFor` now correctly preserves HTML tag names when children contain interpolations or mixed content [230](https://github.com/i18next/i18next-cli/issues/230)
6
+ - Previously, `<strong>{{name}}</strong>` was incorrectly serialized as `<1>{{name}}</1>` — the tag name was only preserved for plain string children
7
+ - This bug existed since the feature was introduced and affects auto-generated keys (when no explicit `i18nKey` is provided)
8
+ - If you rely on auto-generated Trans keys containing indexed tags for kept HTML elements with interpolation children, you will need to update your translation files
9
+
10
+ ### Other changes
11
+
12
+ - updated dev dependencies (vitest, rollup plugins, happy-dom, typescript, etc.)
13
+
1
14
  ### 16.6.6
2
15
 
3
16
  - fix(peer-deps): bump i18next peer dependency to `>= 25.10.9` to match required type exports (`ConstrainTarget`, `ApplyTarget`, `GetSource`) used by `TransSelector` [1911](https://github.com/i18next/react-i18next/issues/1911)
@@ -1707,6 +1707,7 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
1707
1707
  const getSupportNoticeShown = () => {
1708
1708
  if (typeof globalThis !== 'undefined' && !!globalThis[SUPPORT_NOTICE_KEY]) return true;
1709
1709
  if (typeof process !== 'undefined' && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE) return true;
1710
+ if (typeof process !== 'undefined' && process.env && "development" === 'production') ;
1710
1711
  return false;
1711
1712
  };
1712
1713
  const setSupportNoticeShown = () => {
@@ -2248,24 +2249,33 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
2248
2249
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2249
2250
  }
2250
2251
 
2251
- var voidElements = {
2252
- "area": true,
2253
- "base": true,
2254
- "br": true,
2255
- "col": true,
2256
- "embed": true,
2257
- "hr": true,
2258
- "img": true,
2259
- "input": true,
2260
- "link": true,
2261
- "meta": true,
2262
- "param": true,
2263
- "source": true,
2264
- "track": true,
2265
- "wbr": true
2266
- };
2252
+ var voidElements;
2253
+ var hasRequiredVoidElements;
2254
+
2255
+ function requireVoidElements () {
2256
+ if (hasRequiredVoidElements) return voidElements;
2257
+ hasRequiredVoidElements = 1;
2258
+ voidElements = {
2259
+ "area": true,
2260
+ "base": true,
2261
+ "br": true,
2262
+ "col": true,
2263
+ "embed": true,
2264
+ "hr": true,
2265
+ "img": true,
2266
+ "input": true,
2267
+ "link": true,
2268
+ "meta": true,
2269
+ "param": true,
2270
+ "source": true,
2271
+ "track": true,
2272
+ "wbr": true
2273
+ };
2274
+ return voidElements;
2275
+ }
2267
2276
 
2268
- var e = /*@__PURE__*/getDefaultExportFromCjs(voidElements);
2277
+ var voidElementsExports = requireVoidElements();
2278
+ var e = /*@__PURE__*/getDefaultExportFromCjs(voidElementsExports);
2269
2279
 
2270
2280
  var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
2271
2281
  function n(n) {
@@ -2534,8 +2544,9 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
2534
2544
  stringNode += `<${childIndex}></${childIndex}>`;
2535
2545
  return;
2536
2546
  }
2537
- if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
2538
- stringNode += `<${type}>${childChildren}</${type}>`;
2547
+ if (shouldKeepChild && childPropsCount <= 1) {
2548
+ const cnt = isString(childChildren) ? childChildren : nodesToString(childChildren, i18nOptions, i18n, i18nKey);
2549
+ stringNode += `<${type}>${cnt}</${type}>`;
2539
2550
  return;
2540
2551
  }
2541
2552
  const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
@@ -3440,77 +3451,93 @@ define(['exports', 'react'], (function (exports, React) { 'use strict';
3440
3451
  * LICENSE file in the root directory of this source tree.
3441
3452
  */
3442
3453
 
3443
- (function () {
3444
- function is(x, y) {
3445
- return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
3446
- }
3447
- function useSyncExternalStore$2(subscribe, getSnapshot) {
3448
- didWarnOld18Alpha || void 0 === React$1.startTransition || (didWarnOld18Alpha = true, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
3449
- var value = getSnapshot();
3450
- if (!didWarnUncachedGetSnapshot) {
3451
- var cachedValue = getSnapshot();
3452
- objectIs(value, cachedValue) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), didWarnUncachedGetSnapshot = true);
3453
- }
3454
- cachedValue = useState({
3455
- inst: {
3456
- value: value,
3457
- getSnapshot: getSnapshot
3458
- }
3459
- });
3460
- var inst = cachedValue[0].inst,
3461
- forceUpdate = cachedValue[1];
3462
- useLayoutEffect(function () {
3463
- inst.value = value;
3464
- inst.getSnapshot = getSnapshot;
3465
- checkIfSnapshotChanged(inst) && forceUpdate({
3466
- inst: inst
3467
- });
3468
- }, [subscribe, value, getSnapshot]);
3469
- useEffect(function () {
3470
- checkIfSnapshotChanged(inst) && forceUpdate({
3471
- inst: inst
3472
- });
3473
- return subscribe(function () {
3474
- checkIfSnapshotChanged(inst) && forceUpdate({
3475
- inst: inst
3476
- });
3477
- });
3478
- }, [subscribe]);
3479
- useDebugValue(value);
3480
- return value;
3481
- }
3482
- function checkIfSnapshotChanged(inst) {
3483
- var latestGetSnapshot = inst.getSnapshot;
3484
- inst = inst.value;
3485
- try {
3486
- var nextValue = latestGetSnapshot();
3487
- return !objectIs(inst, nextValue);
3488
- } catch (error) {
3489
- return true;
3490
- }
3491
- }
3492
- function useSyncExternalStore$1(subscribe, getSnapshot) {
3493
- return getSnapshot();
3494
- }
3495
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
3496
- var React$1 = React,
3497
- objectIs = "function" === typeof Object.is ? Object.is : is,
3498
- useState = React$1.useState,
3499
- useEffect = React$1.useEffect,
3500
- useLayoutEffect = React$1.useLayoutEffect,
3501
- useDebugValue = React$1.useDebugValue,
3502
- didWarnOld18Alpha = false,
3503
- didWarnUncachedGetSnapshot = false,
3504
- shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
3505
- useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
3506
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
3507
- })();
3454
+ var hasRequiredUseSyncExternalStoreShim_development;
3455
+
3456
+ function requireUseSyncExternalStoreShim_development () {
3457
+ if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
3458
+ hasRequiredUseSyncExternalStoreShim_development = 1;
3459
+
3460
+ (function () {
3461
+ function is(x, y) {
3462
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
3463
+ }
3464
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
3465
+ didWarnOld18Alpha || void 0 === React$1.startTransition || (didWarnOld18Alpha = true, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
3466
+ var value = getSnapshot();
3467
+ if (!didWarnUncachedGetSnapshot) {
3468
+ var cachedValue = getSnapshot();
3469
+ objectIs(value, cachedValue) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), didWarnUncachedGetSnapshot = true);
3470
+ }
3471
+ cachedValue = useState({
3472
+ inst: {
3473
+ value: value,
3474
+ getSnapshot: getSnapshot
3475
+ }
3476
+ });
3477
+ var inst = cachedValue[0].inst,
3478
+ forceUpdate = cachedValue[1];
3479
+ useLayoutEffect(function () {
3480
+ inst.value = value;
3481
+ inst.getSnapshot = getSnapshot;
3482
+ checkIfSnapshotChanged(inst) && forceUpdate({
3483
+ inst: inst
3484
+ });
3485
+ }, [subscribe, value, getSnapshot]);
3486
+ useEffect(function () {
3487
+ checkIfSnapshotChanged(inst) && forceUpdate({
3488
+ inst: inst
3489
+ });
3490
+ return subscribe(function () {
3491
+ checkIfSnapshotChanged(inst) && forceUpdate({
3492
+ inst: inst
3493
+ });
3494
+ });
3495
+ }, [subscribe]);
3496
+ useDebugValue(value);
3497
+ return value;
3498
+ }
3499
+ function checkIfSnapshotChanged(inst) {
3500
+ var latestGetSnapshot = inst.getSnapshot;
3501
+ inst = inst.value;
3502
+ try {
3503
+ var nextValue = latestGetSnapshot();
3504
+ return !objectIs(inst, nextValue);
3505
+ } catch (error) {
3506
+ return true;
3507
+ }
3508
+ }
3509
+ function useSyncExternalStore$1(subscribe, getSnapshot) {
3510
+ return getSnapshot();
3511
+ }
3512
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
3513
+ var React$1 = React,
3514
+ objectIs = "function" === typeof Object.is ? Object.is : is,
3515
+ useState = React$1.useState,
3516
+ useEffect = React$1.useEffect,
3517
+ useLayoutEffect = React$1.useLayoutEffect,
3518
+ useDebugValue = React$1.useDebugValue,
3519
+ didWarnOld18Alpha = false,
3520
+ didWarnUncachedGetSnapshot = false,
3521
+ shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
3522
+ useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
3523
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
3524
+ })();
3525
+ return useSyncExternalStoreShim_development;
3526
+ }
3527
+
3528
+ var hasRequiredShim;
3529
+
3530
+ function requireShim () {
3531
+ if (hasRequiredShim) return shim.exports;
3532
+ hasRequiredShim = 1;
3508
3533
 
3509
- {
3510
- shim.exports = useSyncExternalStoreShim_development;
3534
+ {
3535
+ shim.exports = requireUseSyncExternalStoreShim_development();
3536
+ }
3537
+ return shim.exports;
3511
3538
  }
3512
3539
 
3513
- var shimExports = shim.exports;
3540
+ var shimExports = requireShim();
3514
3541
 
3515
3542
  const notReadyT = (k, optsOrDefaultValue) => {
3516
3543
  if (isString(optsOrDefaultValue)) return optsOrDefaultValue;