@bleedingdev/modern-js-i18n-integration 0.0.0 → 3.9.0-ultramodern.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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/cli.js +97 -0
  3. package/dist/cjs/federation/boundary.js +100 -0
  4. package/dist/cjs/federation/registration.js +43 -0
  5. package/dist/cjs/languageSynchronization.js +44 -0
  6. package/dist/cjs/navigation.js +220 -0
  7. package/dist/cjs/options.js +18 -0
  8. package/dist/cjs/runtime-no-react-i18next.js +46 -0
  9. package/dist/cjs/runtime.js +46 -0
  10. package/dist/cjs/runtimeComposition.js +60 -0
  11. package/dist/cjs/server.js +50 -0
  12. package/dist/cjs/urlStrategy.js +51 -0
  13. package/dist/esm/cli.mjs +57 -0
  14. package/dist/esm/federation/boundary.mjs +62 -0
  15. package/dist/esm/federation/registration.mjs +5 -0
  16. package/dist/esm/languageSynchronization.mjs +6 -0
  17. package/dist/esm/navigation.mjs +182 -0
  18. package/dist/esm/options.mjs +0 -0
  19. package/dist/esm/runtime-no-react-i18next.mjs +6 -0
  20. package/dist/esm/runtime.mjs +6 -0
  21. package/dist/esm/runtimeComposition.mjs +22 -0
  22. package/dist/esm/server.mjs +10 -0
  23. package/dist/esm/urlStrategy.mjs +13 -0
  24. package/dist/esm-node/cli.mjs +58 -0
  25. package/dist/esm-node/federation/boundary.mjs +63 -0
  26. package/dist/esm-node/federation/registration.mjs +6 -0
  27. package/dist/esm-node/languageSynchronization.mjs +7 -0
  28. package/dist/esm-node/navigation.mjs +183 -0
  29. package/dist/esm-node/options.mjs +1 -0
  30. package/dist/esm-node/runtime-no-react-i18next.mjs +7 -0
  31. package/dist/esm-node/runtime.mjs +7 -0
  32. package/dist/esm-node/runtimeComposition.mjs +23 -0
  33. package/dist/esm-node/server.mjs +11 -0
  34. package/dist/esm-node/urlStrategy.mjs +14 -0
  35. package/dist/types/cli.d.ts +4 -0
  36. package/dist/types/federation/boundary.d.ts +9 -0
  37. package/dist/types/federation/registration.d.ts +2 -0
  38. package/dist/types/languageSynchronization.d.ts +3 -0
  39. package/dist/types/navigation.d.ts +3 -0
  40. package/dist/types/options.d.ts +13 -0
  41. package/dist/types/runtime-no-react-i18next.d.ts +2 -0
  42. package/dist/types/runtime.d.ts +2 -0
  43. package/dist/types/runtimeComposition.d.ts +4 -0
  44. package/dist/types/server.d.ts +3 -0
  45. package/dist/types/urlStrategy.d.ts +4 -0
  46. package/package.json +139 -5
  47. package/src/cli.ts +72 -0
  48. package/src/federation/boundary.tsx +129 -0
  49. package/src/federation/registration.ts +8 -0
  50. package/src/languageSynchronization.tsx +23 -0
  51. package/src/navigation.tsx +399 -0
  52. package/src/options.ts +18 -0
  53. package/src/runtime-no-react-i18next.ts +5 -0
  54. package/src/runtime.ts +5 -0
  55. package/src/runtimeComposition.ts +33 -0
  56. package/src/server.ts +27 -0
  57. package/src/urlStrategy.ts +19 -0
  58. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Modern.js
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ default: ()=>cli,
32
+ ultramodernI18nIntegrationPlugin: ()=>ultramodernI18nIntegrationPlugin
33
+ });
34
+ const i18n_runtime_extensions_namespaceObject = require("@modern-js/i18n-runtime-extensions");
35
+ const runtimePaths = new Map([
36
+ [
37
+ '@modern-js/plugin-i18n/runtime',
38
+ '@modern-js/i18n-integration/runtime'
39
+ ],
40
+ [
41
+ '@modern-js/plugin-i18n/runtime/no-react-i18next',
42
+ '@modern-js/i18n-integration/runtime/no-react-i18next'
43
+ ]
44
+ ]);
45
+ const integrationRuntimePaths = new Set(runtimePaths.values());
46
+ const ultramodernI18nIntegrationPlugin = ()=>({
47
+ name: '@modern-js/i18n-integration',
48
+ pre: [
49
+ '@modern-js/plugin-i18n'
50
+ ],
51
+ setup (api) {
52
+ api._internalRuntimePlugins(({ entrypoint, plugins })=>({
53
+ entrypoint,
54
+ plugins: plugins.map((plugin)=>{
55
+ const path = runtimePaths.get(plugin.path);
56
+ return path ? {
57
+ ...plugin,
58
+ path
59
+ } : plugin;
60
+ })
61
+ }));
62
+ api._internalServerPlugins(({ plugins })=>({
63
+ plugins: plugins.map((plugin)=>'@modern-js/plugin-i18n/server' === plugin.name ? {
64
+ ...plugin,
65
+ name: '@modern-js/i18n-integration/server'
66
+ } : plugin)
67
+ }));
68
+ api.modifyFileSystemRoutes(async ({ entrypoint, routes })=>{
69
+ const { plugins } = await api.getHooks()._internalRuntimePlugins.call({
70
+ entrypoint,
71
+ plugins: []
72
+ });
73
+ const descriptor = plugins.find((plugin)=>integrationRuntimePaths.has(plugin.path));
74
+ const config = descriptor?.config;
75
+ const { localePathRedirect, languages = [], localisedUrls } = config?.localeDetection ?? {};
76
+ const resolved = (0, i18n_runtime_extensions_namespaceObject.resolveLocalisedUrlsConfig)(localisedUrls);
77
+ if (!localePathRedirect || !languages.length || !resolved.enabled) return {
78
+ entrypoint,
79
+ routes
80
+ };
81
+ return {
82
+ entrypoint,
83
+ routes: (0, i18n_runtime_extensions_namespaceObject.applyLocalisedUrlsToRoutes)(routes, languages, resolved.map)
84
+ };
85
+ });
86
+ }
87
+ });
88
+ const cli = ultramodernI18nIntegrationPlugin;
89
+ exports["default"] = __webpack_exports__["default"];
90
+ exports.ultramodernI18nIntegrationPlugin = __webpack_exports__.ultramodernI18nIntegrationPlugin;
91
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
92
+ "default",
93
+ "ultramodernI18nIntegrationPlugin"
94
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
95
+ Object.defineProperty(exports, '__esModule', {
96
+ value: true
97
+ });
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ FederatedI18nBoundary: ()=>FederatedI18nBoundary
32
+ });
33
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
34
+ const consumer_namespaceObject = require("@modern-js/plugin-i18n/runtime/consumer");
35
+ const external_react_namespaceObject = require("react");
36
+ const FederatedI18nBoundary = ({ children, defaultNamespace, fallbackLanguage, resources, supportedLanguages })=>{
37
+ const parent = (0, external_react_namespaceObject.useContext)(consumer_namespaceObject.ModernI18nContext);
38
+ const I18nextProvider = (0, external_react_namespaceObject.useContext)(consumer_namespaceObject.ReactI18nextProviderContext);
39
+ if (!parent) throw new Error('FederatedI18nBoundary must be used within ModernI18nProvider');
40
+ const languages = supportedLanguages ?? parent.languages ?? Object.keys(resources);
41
+ const scopedInstance = (0, external_react_namespaceObject.useMemo)(()=>{
42
+ const parentInstance = (0, consumer_namespaceObject.getActualI18nextInstance)(parent.i18nInstance);
43
+ const clone = parentInstance.cloneInstance?.({
44
+ defaultNS: defaultNamespace,
45
+ fallbackLng: fallbackLanguage ?? languages[0] ?? parent.language,
46
+ forkResourceStore: true,
47
+ initImmediate: false,
48
+ lng: parent.language,
49
+ ns: [
50
+ defaultNamespace
51
+ ],
52
+ resources,
53
+ supportedLngs: languages
54
+ });
55
+ if (!clone) throw new Error('FederatedI18nBoundary requires an i18n instance with cloneInstance support');
56
+ const resourceStore = clone.store;
57
+ const parentResourceStore = parentInstance.store;
58
+ const sharesNestedResourceState = Object.entries(resourceStore?.data ?? {}).some(([language, namespaces])=>{
59
+ const parentNamespaces = parentResourceStore?.data?.[language];
60
+ return namespaces === parentNamespaces || Object.entries(namespaces).some(([namespace, resource])=>null !== resource && 'object' == typeof resource && resource === parentNamespaces?.[namespace]);
61
+ });
62
+ if (clone === parentInstance || resourceStore === parentResourceStore || resourceStore?.data === parentResourceStore?.data || sharesNestedResourceState) throw new Error('FederatedI18nBoundary cloneInstance did not isolate the host resource store');
63
+ if (!resourceStore?.addResourceBundle || !clone.removeResourceBundle || !resourceStore.data) throw new Error('FederatedI18nBoundary requires an isolated mutable i18n resource store');
64
+ for (const [language, namespaces] of Object.entries(resourceStore.data))for (const namespace of Object.keys(namespaces))clone.removeResourceBundle(language, namespace);
65
+ for (const [language, namespaces] of Object.entries(resources))for (const [namespace, resource] of Object.entries(namespaces))resourceStore.addResourceBundle(language, namespace, resource, true, true);
66
+ return clone;
67
+ }, [
68
+ defaultNamespace,
69
+ fallbackLanguage,
70
+ languages,
71
+ parent.i18nInstance,
72
+ parent.language,
73
+ resources
74
+ ]);
75
+ const value = (0, external_react_namespaceObject.useMemo)(()=>({
76
+ ...parent,
77
+ i18nInstance: scopedInstance,
78
+ language: parent.language,
79
+ languages
80
+ }), [
81
+ languages,
82
+ parent,
83
+ scopedInstance
84
+ ]);
85
+ const scopedContent = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(consumer_namespaceObject.ModernI18nProvider, {
86
+ value: value,
87
+ children: children
88
+ });
89
+ return I18nextProvider ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(I18nextProvider, {
90
+ i18n: scopedInstance,
91
+ children: scopedContent
92
+ }) : scopedContent;
93
+ };
94
+ exports.FederatedI18nBoundary = __webpack_exports__.FederatedI18nBoundary;
95
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
96
+ "FederatedI18nBoundary"
97
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
98
+ Object.defineProperty(exports, '__esModule', {
99
+ value: true
100
+ });
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ registerFederatedI18nBoundary: ()=>registerFederatedI18nBoundary
32
+ });
33
+ const external_boundary_js_namespaceObject = require("./boundary.js");
34
+ function registerFederatedI18nBoundary(api) {
35
+ api.resolveComponent((component, { name })=>'i18n.FederatedI18nBoundary' === name ? external_boundary_js_namespaceObject.FederatedI18nBoundary : component);
36
+ }
37
+ exports.registerFederatedI18nBoundary = __webpack_exports__.registerFederatedI18nBoundary;
38
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
39
+ "registerFederatedI18nBoundary"
40
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
41
+ Object.defineProperty(exports, '__esModule', {
42
+ value: true
43
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ I18nLanguageSynchronization: ()=>I18nLanguageSynchronization
32
+ });
33
+ const i18n_runtime_extensions_namespaceObject = require("@modern-js/i18n-runtime-extensions");
34
+ const I18nLanguageSynchronization = ({ i18nInstance, localePathRedirect, languages, pathname, prevLangRef, setLang, children })=>{
35
+ const synchronizeLanguage = (0, i18n_runtime_extensions_namespaceObject.useLanguageSync)(i18nInstance, localePathRedirect, languages, pathname, prevLangRef, setLang);
36
+ return children(synchronizeLanguage);
37
+ };
38
+ exports.I18nLanguageSynchronization = __webpack_exports__.I18nLanguageSynchronization;
39
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
40
+ "I18nLanguageSynchronization"
41
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
42
+ Object.defineProperty(exports, '__esModule', {
43
+ value: true
44
+ });
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ I18nRouterNavigationProvider: ()=>I18nRouterNavigationProvider
32
+ });
33
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
34
+ const no_react_i18next_namespaceObject = require("@modern-js/plugin-i18n/runtime/no-react-i18next");
35
+ const runtime_namespaceObject = require("@modern-js/runtime");
36
+ const context_namespaceObject = require("@modern-js/runtime/context");
37
+ const router_state_namespaceObject = require("@modern-js/runtime-extensions/router-state");
38
+ const external_react_namespaceObject = require("react");
39
+ const normalizeUrlPart = (value, prefix)=>{
40
+ if ('string' != typeof value || !value) return '';
41
+ return value.startsWith(prefix) ? value : `${prefix}${value}`;
42
+ };
43
+ const normalizeLocation = (location)=>{
44
+ if (!location || 'object' != typeof location) return null;
45
+ const locationValue = location;
46
+ if ('string' != typeof locationValue.pathname) return null;
47
+ return {
48
+ pathname: locationValue.pathname,
49
+ search: normalizeUrlPart('string' == typeof locationValue.search ? locationValue.search : locationValue.searchStr, '?'),
50
+ hash: normalizeUrlPart(locationValue.hash, '#')
51
+ };
52
+ };
53
+ const getWindowLocation = ()=>{
54
+ if (!(0, runtime_namespaceObject.isBrowser)()) return null;
55
+ return {
56
+ pathname: window.location.pathname,
57
+ search: window.location.search,
58
+ hash: window.location.hash
59
+ };
60
+ };
61
+ const getRouterFramework = (runtimeContext, internalContext, inReactRouter)=>{
62
+ const framework = (0, router_state_namespaceObject.getRouterRuntimeState)(internalContext)?.framework || (0, router_state_namespaceObject.getRouterRuntimeState)(runtimeContext)?.framework;
63
+ if (framework) return framework;
64
+ if (internalContext.router?.useRouter || runtimeContext.router?.useRouter) return 'tanstack';
65
+ if (internalContext.router?.useLocation || internalContext.router?.useHref || runtimeContext.router?.useLocation || runtimeContext.router?.useHref) return 'react-router';
66
+ if (inReactRouter) return 'react-router';
67
+ };
68
+ const getRouterInstance = (internalContext, contextRouter)=>{
69
+ if (contextRouter) return contextRouter;
70
+ const router = (0, router_state_namespaceObject.getRouterRuntimeState)(internalContext)?.instance;
71
+ if (!router || 'object' != typeof router) return null;
72
+ return router;
73
+ };
74
+ const getRouterStateLocation = (internalContext, contextRouter)=>{
75
+ const router = getRouterInstance(internalContext, contextRouter);
76
+ return normalizeLocation(router?.stores?.location?.get?.()) || normalizeLocation(router?.state?.location);
77
+ };
78
+ const getRouterParams = (internalContext, contextRouter)=>{
79
+ const router = getRouterInstance(internalContext, contextRouter);
80
+ const matches = router?.stores?.matches?.get?.() || router?.state?.matches;
81
+ if (!Array.isArray(matches)) return {};
82
+ return matches.reduce((params, match)=>{
83
+ if (match?.params) Object.assign(params, match.params);
84
+ return params;
85
+ }, {});
86
+ };
87
+ const getRouterSnapshot = (internalContext, contextRouter)=>{
88
+ const location = getRouterStateLocation(internalContext, contextRouter);
89
+ const params = getRouterParams(internalContext, contextRouter);
90
+ return JSON.stringify([
91
+ location?.pathname ?? '',
92
+ location?.search ?? '',
93
+ location?.hash ?? '',
94
+ Object.entries(params).sort(([left], [right])=>left.localeCompare(right))
95
+ ]);
96
+ };
97
+ const useIntegratedRouterAdapter = ()=>{
98
+ const runtimeContext = (0, external_react_namespaceObject.useContext)(runtime_namespaceObject.RuntimeContext);
99
+ const internalContext = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext);
100
+ const routerApi = internalContext.router || runtimeContext.router;
101
+ const native = (0, no_react_i18next_namespaceObject.useNativeI18nRouterAdapter)();
102
+ const inReactRouter = native.hasRouter;
103
+ const reactRouterNavigate = native.navigate;
104
+ const reactRouterLocation = inReactRouter ? native.location : null;
105
+ const reactRouterParams = native.params;
106
+ const framework = getRouterFramework(runtimeContext, internalContext, inReactRouter);
107
+ const contextUseRouter = inReactRouter || 'tanstack' !== framework ? void 0 : internalContext.router?.useRouter || runtimeContext.router?.useRouter;
108
+ const contextRouter = contextUseRouter ? contextUseRouter({
109
+ warn: false
110
+ }) : null;
111
+ const hasRouter = 'tanstack' === framework || 'react-router' === framework || Boolean(reactRouterNavigate);
112
+ const subscribeToRouter = (0, external_react_namespaceObject.useCallback)((update)=>{
113
+ const router = getRouterInstance(internalContext, contextRouter);
114
+ if (!router) return ()=>void 0;
115
+ const unsubscribers = [];
116
+ if ('react-router' === framework && !inReactRouter && 'function' == typeof router.subscribe) {
117
+ const subscribe = router.subscribe;
118
+ const unsubscribe = subscribe.call(router, update);
119
+ if ('function' == typeof unsubscribe) unsubscribers.push(unsubscribe);
120
+ }
121
+ if ('tanstack' === framework && 'function' == typeof router.stores?.location?.subscribe) {
122
+ const unsubscribe = router.stores.location.subscribe(update);
123
+ if ('function' == typeof unsubscribe) unsubscribers.push(unsubscribe);
124
+ }
125
+ if ('tanstack' === framework && 'function' == typeof router.subscribe) {
126
+ const subscribe = router.subscribe;
127
+ for (const eventType of [
128
+ 'onBeforeNavigate',
129
+ 'onBeforeLoad'
130
+ ]){
131
+ const unsubscribe = subscribe.call(router, eventType, update);
132
+ if ('function' == typeof unsubscribe) unsubscribers.push(unsubscribe);
133
+ }
134
+ }
135
+ return ()=>{
136
+ for (const unsubscribe of unsubscribers)unsubscribe();
137
+ };
138
+ }, [
139
+ contextRouter,
140
+ framework,
141
+ inReactRouter,
142
+ internalContext
143
+ ]);
144
+ const getSnapshot = (0, external_react_namespaceObject.useCallback)(()=>getRouterSnapshot(internalContext, contextRouter), [
145
+ contextRouter,
146
+ internalContext
147
+ ]);
148
+ (0, external_react_namespaceObject.useSyncExternalStore)(subscribeToRouter, getSnapshot, getSnapshot);
149
+ const navigate = (0, external_react_namespaceObject.useCallback)((href, options)=>{
150
+ const router = getRouterInstance(internalContext, contextRouter);
151
+ const activeFramework = getRouterFramework(runtimeContext, internalContext, inReactRouter);
152
+ if ('tanstack' === activeFramework) {
153
+ if ('function' == typeof router?.navigate) return router.navigate({
154
+ to: href,
155
+ replace: options?.replace,
156
+ ...options?.state === void 0 ? {} : {
157
+ state: options.state
158
+ }
159
+ });
160
+ throw new Error('TanStack router instance is not available.');
161
+ }
162
+ if (reactRouterNavigate) return reactRouterNavigate(href, options);
163
+ if ('react-router' === activeFramework) {
164
+ if ('function' == typeof router?.navigate) return router.navigate(href, options);
165
+ throw new Error('React Router instance is not available.');
166
+ }
167
+ }, [
168
+ contextRouter,
169
+ internalContext,
170
+ inReactRouter,
171
+ reactRouterNavigate,
172
+ runtimeContext
173
+ ]);
174
+ const location = (reactRouterLocation ? normalizeLocation(reactRouterLocation) : getRouterStateLocation(internalContext, contextRouter)) || getWindowLocation();
175
+ const params = inReactRouter ? reactRouterParams : getRouterParams(internalContext, contextRouter);
176
+ const Link = 'tanstack' === framework ? internalContext.router?.Link || runtimeContext.router?.Link || null : 'react-router' === framework || inReactRouter ? routerApi?.Link ?? null : null;
177
+ return {
178
+ framework,
179
+ hasRouter,
180
+ location,
181
+ navigate: hasRouter ? navigate : null,
182
+ Link,
183
+ params,
184
+ ...'tanstack' === framework ? {
185
+ createLinkProps: createTanstackLinkProps
186
+ } : {}
187
+ };
188
+ };
189
+ const createTanstackLinkProps = (target)=>{
190
+ const preload = void 0 !== target.preload ? target.preload : 'none' === target.prefetch ? false : target.prefetch;
191
+ return {
192
+ to: target.pathname,
193
+ ...target.search ? {
194
+ search: target.search
195
+ } : {},
196
+ ...target.hash ? {
197
+ hash: target.hash
198
+ } : {},
199
+ ...void 0 === target.hashScrollIntoView ? {} : {
200
+ hashScrollIntoView: target.hashScrollIntoView
201
+ },
202
+ ...void 0 === preload ? {} : {
203
+ preload
204
+ }
205
+ };
206
+ };
207
+ const I18nRouterNavigationProvider = ({ children })=>{
208
+ const value = useIntegratedRouterAdapter();
209
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(no_react_i18next_namespaceObject.I18nNavigationProvider, {
210
+ value: value,
211
+ children: children
212
+ });
213
+ };
214
+ exports.I18nRouterNavigationProvider = __webpack_exports__.I18nRouterNavigationProvider;
215
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
216
+ "I18nRouterNavigationProvider"
217
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
218
+ Object.defineProperty(exports, '__esModule', {
219
+ value: true
220
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ default: ()=>runtime_no_react_i18next,
32
+ i18nPlugin: ()=>i18nPlugin
33
+ });
34
+ const no_react_i18next_namespaceObject = require("@modern-js/plugin-i18n/runtime/no-react-i18next");
35
+ const external_runtimeComposition_js_namespaceObject = require("./runtimeComposition.js");
36
+ const i18nPlugin = (0, external_runtimeComposition_js_namespaceObject.composeI18nPlugin)(no_react_i18next_namespaceObject.i18nPlugin);
37
+ const runtime_no_react_i18next = i18nPlugin;
38
+ exports["default"] = __webpack_exports__["default"];
39
+ exports.i18nPlugin = __webpack_exports__.i18nPlugin;
40
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
41
+ "default",
42
+ "i18nPlugin"
43
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
44
+ Object.defineProperty(exports, '__esModule', {
45
+ value: true
46
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ default: ()=>runtime,
32
+ i18nPlugin: ()=>i18nPlugin
33
+ });
34
+ const runtime_namespaceObject = require("@modern-js/plugin-i18n/runtime");
35
+ const external_runtimeComposition_js_namespaceObject = require("./runtimeComposition.js");
36
+ const i18nPlugin = (0, external_runtimeComposition_js_namespaceObject.composeI18nPlugin)(runtime_namespaceObject.i18nPlugin);
37
+ const runtime = i18nPlugin;
38
+ exports["default"] = __webpack_exports__["default"];
39
+ exports.i18nPlugin = __webpack_exports__.i18nPlugin;
40
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
41
+ "default",
42
+ "i18nPlugin"
43
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
44
+ Object.defineProperty(exports, '__esModule', {
45
+ value: true
46
+ });