@bleedingdev/modern-js-plugin-i18n 3.2.0-ultramodern.22 → 3.2.0-ultramodern.23

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,19 +1,5 @@
1
1
  "use strict";
2
- var __webpack_modules__ = {
3
- "react-i18next" (module) {
4
- module.exports = require("react-i18next");
5
- }
6
- };
7
- var __webpack_module_cache__ = {};
8
- function __webpack_require__(moduleId) {
9
- var cachedModule = __webpack_module_cache__[moduleId];
10
- if (void 0 !== cachedModule) return cachedModule.exports;
11
- var module = __webpack_module_cache__[moduleId] = {
12
- exports: {}
13
- };
14
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
- return module.exports;
16
- }
2
+ var __webpack_require__ = {};
17
3
  (()=>{
18
4
  __webpack_require__.d = (exports1, definition)=>{
19
5
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
@@ -36,94 +22,95 @@ function __webpack_require__(moduleId) {
36
22
  };
37
23
  })();
38
24
  var __webpack_exports__ = {};
39
- (()=>{
40
- __webpack_require__.r(__webpack_exports__);
41
- __webpack_require__.d(__webpack_exports__, {
42
- getActualI18nextInstance: ()=>getActualI18nextInstance,
43
- getI18nInstance: ()=>getI18nInstance,
44
- getI18nWrapperI18nextInstance: ()=>getI18nWrapperI18nextInstance,
45
- getI18nextInstanceForProvider: ()=>getI18nextInstanceForProvider,
46
- getI18nextProvider: ()=>getI18nextProvider,
47
- getInitReactI18next: ()=>getInitReactI18next,
48
- isI18nInstance: ()=>isI18nInstance,
49
- isI18nWrapperInstance: ()=>isI18nWrapperInstance
50
- });
51
- function isI18nWrapperInstance(obj) {
52
- if (!obj || 'object' != typeof obj) return false;
53
- if (!obj.i18nInstance || 'object' != typeof obj.i18nInstance) return false;
54
- if (!obj.i18nInstance.instance) return false;
55
- if ('function' != typeof obj.init || 'function' != typeof obj.use) return false;
56
- return true;
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ getActualI18nextInstance: ()=>getActualI18nextInstance,
28
+ getI18nInstance: ()=>getI18nInstance,
29
+ getI18nWrapperI18nextInstance: ()=>getI18nWrapperI18nextInstance,
30
+ getI18nextInstanceForProvider: ()=>getI18nextInstanceForProvider,
31
+ getI18nextProvider: ()=>getI18nextProvider,
32
+ getInitReactI18next: ()=>getInitReactI18next,
33
+ isI18nInstance: ()=>isI18nInstance,
34
+ isI18nWrapperInstance: ()=>isI18nWrapperInstance
35
+ });
36
+ function isI18nWrapperInstance(obj) {
37
+ if (!obj || 'object' != typeof obj) return false;
38
+ if (!obj.i18nInstance || 'object' != typeof obj.i18nInstance) return false;
39
+ if (!obj.i18nInstance.instance) return false;
40
+ if ('function' != typeof obj.init || 'function' != typeof obj.use) return false;
41
+ return true;
42
+ }
43
+ function getI18nWrapperI18nextInstance(wrapperInstance) {
44
+ if (isI18nWrapperInstance(wrapperInstance)) return wrapperInstance.i18nInstance?.instance;
45
+ return null;
46
+ }
47
+ function getActualI18nextInstance(instance) {
48
+ if (isI18nWrapperInstance(instance)) {
49
+ const i18nextInstance = getI18nWrapperI18nextInstance(instance);
50
+ return i18nextInstance || instance;
57
51
  }
58
- function getI18nWrapperI18nextInstance(wrapperInstance) {
59
- if (isI18nWrapperInstance(wrapperInstance)) return wrapperInstance.i18nInstance?.instance;
52
+ return instance;
53
+ }
54
+ function isI18nInstance(obj) {
55
+ if (!obj || 'object' != typeof obj) return false;
56
+ if (isI18nWrapperInstance(obj)) return true;
57
+ return 'function' == typeof obj.init && 'function' == typeof obj.use;
58
+ }
59
+ async function tryImportI18next() {
60
+ try {
61
+ const i18next = await import("i18next");
62
+ return i18next.default;
63
+ } catch (error) {
60
64
  return null;
61
65
  }
62
- function getActualI18nextInstance(instance) {
63
- if (isI18nWrapperInstance(instance)) {
64
- const i18nextInstance = getI18nWrapperI18nextInstance(instance);
65
- return i18nextInstance || instance;
66
- }
67
- return instance;
68
- }
69
- function isI18nInstance(obj) {
70
- if (!obj || 'object' != typeof obj) return false;
71
- if (isI18nWrapperInstance(obj)) return true;
72
- return 'function' == typeof obj.init && 'function' == typeof obj.use;
73
- }
74
- async function tryImportI18next() {
75
- try {
76
- const i18next = await import("i18next");
77
- return i18next.default;
78
- } catch (error) {
79
- return null;
80
- }
81
- }
82
- async function createI18nextInstance() {
83
- try {
84
- const i18next = await tryImportI18next();
85
- if (!i18next) return null;
86
- return i18next.createInstance?.({
87
- initImmediate: false
88
- });
89
- } catch (error) {
90
- return null;
91
- }
92
- }
93
- async function tryImportReactI18next() {
94
- try {
95
- return __webpack_require__("react-i18next");
96
- } catch (error) {
97
- return null;
98
- }
66
+ }
67
+ async function createI18nextInstance() {
68
+ try {
69
+ const i18next = await tryImportI18next();
70
+ if (!i18next) return null;
71
+ return i18next.createInstance?.({
72
+ initImmediate: false
73
+ });
74
+ } catch (error) {
75
+ return null;
99
76
  }
100
- function getI18nextInstanceForProvider(instance) {
101
- if (isI18nWrapperInstance(instance)) {
102
- const i18nextInstance = getI18nWrapperI18nextInstance(instance);
103
- if (i18nextInstance) return i18nextInstance;
104
- }
105
- return instance;
77
+ }
78
+ function getOptionalReactI18nextPackageName() {
79
+ return "react-i18next";
80
+ }
81
+ async function tryImportReactI18next() {
82
+ try {
83
+ return await import(getOptionalReactI18nextPackageName());
84
+ } catch (error) {
85
+ return null;
106
86
  }
107
- async function getI18nInstance(userInstance) {
108
- if (userInstance) {
109
- if (isI18nWrapperInstance(userInstance)) return userInstance;
110
- if (isI18nInstance(userInstance)) return userInstance;
111
- }
112
- const i18nextInstance = await createI18nextInstance();
87
+ }
88
+ function getI18nextInstanceForProvider(instance) {
89
+ if (isI18nWrapperInstance(instance)) {
90
+ const i18nextInstance = getI18nWrapperI18nextInstance(instance);
113
91
  if (i18nextInstance) return i18nextInstance;
114
- throw new Error('No i18n instance found');
115
- }
116
- async function getInitReactI18next() {
117
- const reactI18nextModule = await tryImportReactI18next();
118
- if (reactI18nextModule) return reactI18nextModule.initReactI18next;
119
- return null;
120
92
  }
121
- async function getI18nextProvider() {
122
- const reactI18nextModule = await tryImportReactI18next();
123
- if (reactI18nextModule) return reactI18nextModule.I18nextProvider;
124
- return null;
93
+ return instance;
94
+ }
95
+ async function getI18nInstance(userInstance) {
96
+ if (userInstance) {
97
+ if (isI18nWrapperInstance(userInstance)) return userInstance;
98
+ if (isI18nInstance(userInstance)) return userInstance;
125
99
  }
126
- })();
100
+ const i18nextInstance = await createI18nextInstance();
101
+ if (i18nextInstance) return i18nextInstance;
102
+ throw new Error('No i18n instance found');
103
+ }
104
+ async function getInitReactI18next() {
105
+ const reactI18nextModule = await tryImportReactI18next();
106
+ if (reactI18nextModule) return reactI18nextModule.initReactI18next;
107
+ return null;
108
+ }
109
+ async function getI18nextProvider() {
110
+ const reactI18nextModule = await tryImportReactI18next();
111
+ if (reactI18nextModule) return reactI18nextModule.I18nextProvider;
112
+ return null;
113
+ }
127
114
  exports.getActualI18nextInstance = __webpack_exports__.getActualI18nextInstance;
128
115
  exports.getI18nInstance = __webpack_exports__.getI18nInstance;
129
116
  exports.getI18nWrapperI18nextInstance = __webpack_exports__.getI18nWrapperI18nextInstance;
@@ -29,7 +29,6 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  const runtime_namespaceObject = require("@modern-js/runtime");
30
30
  const context_namespaceObject = require("@modern-js/runtime/context");
31
31
  const router_namespaceObject = require("@modern-js/runtime/router");
32
- const runtime_utils_router_namespaceObject = require("@modern-js/runtime-utils/router");
33
32
  const external_react_namespaceObject = require("react");
34
33
  const normalizeUrlPart = (value, prefix)=>{
35
34
  if ('string' != typeof value || !value) return '';
@@ -145,7 +144,7 @@ const useI18nRouterAdapter = ()=>{
145
144
  ]);
146
145
  const location = (reactRouterLocation ? normalizeLocation(reactRouterLocation) : getRouterStateLocation(internalContext, contextRouter)) || getWindowLocation();
147
146
  const params = inReactRouter ? reactRouterParams : getRouterParams(internalContext, contextRouter);
148
- const Link = 'tanstack' === framework ? internalContext.router?.Link || runtimeContext.router?.Link || null : 'react-router' === framework || inReactRouter ? runtime_utils_router_namespaceObject.Link : null;
147
+ const Link = 'tanstack' === framework ? internalContext.router?.Link || runtimeContext.router?.Link || null : 'react-router' === framework || inReactRouter ? router_namespaceObject.Link : null;
149
148
  return {
150
149
  framework,
151
150
  hasRouter,
@@ -1,10 +1,3 @@
1
- import { __webpack_require__ } from "../../rslib-runtime.mjs";
2
- import * as __rspack_external_react_i18next_05dede28 from "react-i18next";
3
- __webpack_require__.add({
4
- "react-i18next" (module) {
5
- module.exports = __rspack_external_react_i18next_05dede28;
6
- }
7
- });
8
1
  function isI18nWrapperInstance(obj) {
9
2
  if (!obj || 'object' != typeof obj) return false;
10
3
  if (!obj.i18nInstance || 'object' != typeof obj.i18nInstance) return false;
@@ -47,9 +40,12 @@ async function createI18nextInstance() {
47
40
  return null;
48
41
  }
49
42
  }
43
+ function getOptionalReactI18nextPackageName() {
44
+ return "react-i18next";
45
+ }
50
46
  async function tryImportReactI18next() {
51
47
  try {
52
- return __webpack_require__("react-i18next");
48
+ return await import(getOptionalReactI18nextPackageName());
53
49
  } catch (error) {
54
50
  return null;
55
51
  }
@@ -1,7 +1,6 @@
1
1
  import { RuntimeContext, isBrowser } from "@modern-js/runtime";
2
2
  import { InternalRuntimeContext } from "@modern-js/runtime/context";
3
- import { useInRouterContext, useLocation, useNavigate, useParams } from "@modern-js/runtime/router";
4
- import { Link as router_Link } from "@modern-js/runtime-utils/router";
3
+ import { Link as router_Link, useInRouterContext, useLocation, useNavigate, useParams } from "@modern-js/runtime/router";
5
4
  import { useCallback, useContext, useEffect, useState } from "react";
6
5
  const normalizeUrlPart = (value, prefix)=>{
7
6
  if ('string' != typeof value || !value) return '';
@@ -1,11 +1,4 @@
1
1
  import "node:module";
2
- import { __webpack_require__ } from "../../rslib-runtime.mjs";
3
- import * as __rspack_external_react_i18next_05dede28 from "react-i18next";
4
- __webpack_require__.add({
5
- "react-i18next" (module) {
6
- module.exports = __rspack_external_react_i18next_05dede28;
7
- }
8
- });
9
2
  function isI18nWrapperInstance(obj) {
10
3
  if (!obj || 'object' != typeof obj) return false;
11
4
  if (!obj.i18nInstance || 'object' != typeof obj.i18nInstance) return false;
@@ -48,9 +41,12 @@ async function createI18nextInstance() {
48
41
  return null;
49
42
  }
50
43
  }
44
+ function getOptionalReactI18nextPackageName() {
45
+ return "react-i18next";
46
+ }
51
47
  async function tryImportReactI18next() {
52
48
  try {
53
- return __webpack_require__("react-i18next");
49
+ return await import(getOptionalReactI18nextPackageName());
54
50
  } catch (error) {
55
51
  return null;
56
52
  }
@@ -1,8 +1,7 @@
1
1
  import "node:module";
2
2
  import { RuntimeContext, isBrowser } from "@modern-js/runtime";
3
3
  import { InternalRuntimeContext } from "@modern-js/runtime/context";
4
- import { useInRouterContext, useLocation, useNavigate, useParams } from "@modern-js/runtime/router";
5
- import { Link as router_Link } from "@modern-js/runtime-utils/router";
4
+ import { Link as router_Link, useInRouterContext, useLocation, useNavigate, useParams } from "@modern-js/runtime/router";
6
5
  import { useCallback, useContext, useEffect, useState } from "react";
7
6
  const normalizeUrlPart = (value, prefix)=>{
8
7
  if ('string' != typeof value || !value) return '';
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.2.0-ultramodern.22",
20
+ "version": "3.2.0-ultramodern.23",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -87,15 +87,15 @@
87
87
  "i18next-fs-backend": "^2.6.6",
88
88
  "i18next-http-backend": "^4.0.0",
89
89
  "i18next-http-middleware": "^3.9.7",
90
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.22",
91
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.22",
92
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.22",
93
- "@modern-js/server-runtime": "npm:@bleedingdev/modern-js-server-runtime@3.2.0-ultramodern.22",
94
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.22",
95
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.22"
90
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.23",
91
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.23",
92
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.23",
93
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.23",
94
+ "@modern-js/server-runtime": "npm:@bleedingdev/modern-js-server-runtime@3.2.0-ultramodern.23",
95
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.23"
96
96
  },
97
97
  "peerDependencies": {
98
- "@modern-js/runtime": "3.2.0-ultramodern.22",
98
+ "@modern-js/runtime": "3.2.0-ultramodern.23",
99
99
  "i18next": ">=25.7.4",
100
100
  "react": "^19.2.6",
101
101
  "react-dom": "^19.2.6",
@@ -120,8 +120,8 @@
120
120
  "react-dom": "^19.2.6",
121
121
  "react-i18next": "17.0.8",
122
122
  "ts-jest": "^29.4.11",
123
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.22",
124
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.22"
123
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.23",
124
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.23"
125
125
  },
126
126
  "sideEffects": false,
127
127
  "publishConfig": {
@@ -171,9 +171,15 @@ async function createI18nextInstance(): Promise<I18nInstance | null> {
171
171
  }
172
172
  }
173
173
 
174
+ function getOptionalReactI18nextPackageName(): string {
175
+ return ['react', 'i18next'].join('-');
176
+ }
177
+
174
178
  async function tryImportReactI18next(): Promise<ReactI18nextModule | null> {
175
179
  try {
176
- return require('react-i18next') as ReactI18nextModule;
180
+ return (await import(
181
+ getOptionalReactI18nextPackageName()
182
+ )) as ReactI18nextModule;
177
183
  } catch (error) {
178
184
  return null;
179
185
  }
@@ -5,12 +5,12 @@ import {
5
5
  type TRuntimeContext,
6
6
  } from '@modern-js/runtime/context';
7
7
  import {
8
+ Link as ReactRouterLink,
8
9
  useInRouterContext,
9
10
  useLocation as useReactRouterLocation,
10
11
  useNavigate as useReactRouterNavigate,
11
12
  useParams as useReactRouterParams,
12
13
  } from '@modern-js/runtime/router';
13
- import { Link as ReactRouterLink } from '@modern-js/runtime-utils/router';
14
14
  import type React from 'react';
15
15
  import { useCallback, useContext, useEffect, useState } from 'react';
16
16
 
@@ -1,18 +0,0 @@
1
- var __webpack_modules__ = {};
2
- var __webpack_module_cache__ = {};
3
- function __webpack_require__(moduleId) {
4
- var cachedModule = __webpack_module_cache__[moduleId];
5
- if (void 0 !== cachedModule) return cachedModule.exports;
6
- var module = __webpack_module_cache__[moduleId] = {
7
- exports: {}
8
- };
9
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
10
- return module.exports;
11
- }
12
- __webpack_require__.m = __webpack_modules__;
13
- (()=>{
14
- __webpack_require__.add = function(modules) {
15
- Object.assign(__webpack_require__.m, modules);
16
- };
17
- })();
18
- export { __webpack_require__ };
@@ -1,19 +0,0 @@
1
- import "node:module";
2
- var __webpack_modules__ = {};
3
- var __webpack_module_cache__ = {};
4
- function __webpack_require__(moduleId) {
5
- var cachedModule = __webpack_module_cache__[moduleId];
6
- if (void 0 !== cachedModule) return cachedModule.exports;
7
- var module = __webpack_module_cache__[moduleId] = {
8
- exports: {}
9
- };
10
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
11
- return module.exports;
12
- }
13
- __webpack_require__.m = __webpack_modules__;
14
- (()=>{
15
- __webpack_require__.add = function(modules) {
16
- Object.assign(__webpack_require__.m, modules);
17
- };
18
- })();
19
- export { __webpack_require__ };