@bleedingdev/modern-js-i18n-integration 3.9.0-ultramodern.9 → 3.9.3-ultramodern.1
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/dist/cjs/runtimeComposition.js +2 -2
- package/dist/esm/runtimeComposition.mjs +1 -1
- package/dist/esm-node/runtimeComposition.mjs +1 -1
- package/dist/types/federation/registration.d.ts +1 -1
- package/dist/types/options.d.ts +0 -4
- package/dist/types/runtimeComposition.d.ts +1 -1
- package/package.json +27 -37
- package/src/cli.ts +1 -4
- package/src/federation/registration.ts +3 -1
- package/src/options.ts +0 -5
- package/src/runtimeComposition.ts +4 -2
- package/dist/cjs/navigation.js +0 -220
- package/dist/cjs/server.js +0 -50
- package/dist/esm/navigation.mjs +0 -182
- package/dist/esm/server.mjs +0 -10
- package/dist/esm-node/navigation.mjs +0 -183
- package/dist/esm-node/server.mjs +0 -11
- package/dist/types/navigation.d.ts +0 -3
- package/dist/types/server.d.ts +0 -3
- package/src/navigation.tsx +0 -399
- package/src/server.ts +0 -27
|
@@ -30,9 +30,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
composeI18nPlugin: ()=>composeI18nPlugin
|
|
32
32
|
});
|
|
33
|
+
const no_react_i18next_namespaceObject = require("@modern-js/plugin-i18n/runtime/no-react-i18next");
|
|
33
34
|
const registration_js_namespaceObject = require("./federation/registration.js");
|
|
34
35
|
const external_languageSynchronization_js_namespaceObject = require("./languageSynchronization.js");
|
|
35
|
-
const external_navigation_js_namespaceObject = require("./navigation.js");
|
|
36
36
|
const external_urlStrategy_js_namespaceObject = require("./urlStrategy.js");
|
|
37
37
|
const composeI18nPlugin = (nativeI18nPlugin)=>(options = {})=>{
|
|
38
38
|
const { localisedUrls, localeDetectionByEntry: _entryOptions, ...nativeLocaleDetection } = options.localeDetection ?? {};
|
|
@@ -40,7 +40,7 @@ const composeI18nPlugin = (nativeI18nPlugin)=>(options = {})=>{
|
|
|
40
40
|
...options,
|
|
41
41
|
localeDetection: nativeLocaleDetection,
|
|
42
42
|
urlStrategy: options.urlStrategy ?? (0, external_urlStrategy_js_namespaceObject.createI18nUrlStrategy)(localisedUrls),
|
|
43
|
-
NavigationProvider: options.NavigationProvider ??
|
|
43
|
+
NavigationProvider: options.NavigationProvider ?? no_react_i18next_namespaceObject.I18nRouterNavigationProvider,
|
|
44
44
|
LanguageSynchronization: options.LanguageSynchronization ?? external_languageSynchronization_js_namespaceObject.I18nLanguageSynchronization
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { I18nRouterNavigationProvider } from "@modern-js/plugin-i18n/runtime/no-react-i18next";
|
|
1
2
|
import { registerFederatedI18nBoundary } from "./federation/registration.mjs";
|
|
2
3
|
import { I18nLanguageSynchronization } from "./languageSynchronization.mjs";
|
|
3
|
-
import { I18nRouterNavigationProvider } from "./navigation.mjs";
|
|
4
4
|
import { createI18nUrlStrategy } from "./urlStrategy.mjs";
|
|
5
5
|
const composeI18nPlugin = (nativeI18nPlugin)=>(options = {})=>{
|
|
6
6
|
const { localisedUrls, localeDetectionByEntry: _entryOptions, ...nativeLocaleDetection } = options.localeDetection ?? {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { I18nRouterNavigationProvider } from "@modern-js/plugin-i18n/runtime/no-react-i18next";
|
|
2
3
|
import { registerFederatedI18nBoundary } from "./federation/registration.mjs";
|
|
3
4
|
import { I18nLanguageSynchronization } from "./languageSynchronization.mjs";
|
|
4
|
-
import { I18nRouterNavigationProvider } from "./navigation.mjs";
|
|
5
5
|
import { createI18nUrlStrategy } from "./urlStrategy.mjs";
|
|
6
6
|
const composeI18nPlugin = (nativeI18nPlugin)=>(options = {})=>{
|
|
7
7
|
const { localisedUrls, localeDetectionByEntry: _entryOptions, ...nativeLocaleDetection } = options.localeDetection ?? {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
|
|
2
|
-
export declare function registerFederatedI18nBoundary(api: RuntimePluginAPI<{}>): void;
|
|
2
|
+
export declare function registerFederatedI18nBoundary(api: Pick<RuntimePluginAPI<{}>, 'resolveComponent'>): void;
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { LocalisedUrlsOption } from '@modern-js/i18n-runtime-extensions';
|
|
2
2
|
import type { I18nPluginOptions as NativeRuntimeOptions } from '@modern-js/plugin-i18n/runtime/no-react-i18next';
|
|
3
|
-
import type { I18nPluginOptions as NativeServerOptions } from '@modern-js/plugin-i18n/server';
|
|
4
3
|
export type IntegratedLocaleDetectionOptions = NonNullable<NativeRuntimeOptions['localeDetection']> & {
|
|
5
4
|
localisedUrls?: LocalisedUrlsOption;
|
|
6
5
|
localeDetectionByEntry?: Record<string, IntegratedLocaleDetectionOptions>;
|
|
@@ -8,6 +7,3 @@ export type IntegratedLocaleDetectionOptions = NonNullable<NativeRuntimeOptions[
|
|
|
8
7
|
export type I18nPluginOptions = NativeRuntimeOptions & {
|
|
9
8
|
localeDetection?: IntegratedLocaleDetectionOptions;
|
|
10
9
|
};
|
|
11
|
-
export type I18nServerPluginOptions = NativeServerOptions & {
|
|
12
|
-
localeDetection: IntegratedLocaleDetectionOptions;
|
|
13
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type I18nPluginOptions as NativeI18nPluginOptions } from '@modern-js/plugin-i18n/runtime/no-react-i18next';
|
|
2
2
|
import type { RuntimePlugin } from '@modern-js/runtime';
|
|
3
3
|
import type { I18nPluginOptions } from './options.js';
|
|
4
4
|
export declare const composeI18nPlugin: (nativeI18nPlugin: (options: NativeI18nPluginOptions) => RuntimePlugin) => (options?: I18nPluginOptions) => RuntimePlugin;
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bleedingdev/modern-js-i18n-integration",
|
|
3
3
|
"description": "UltraModern.js localized routing and federated resource integration through native Modern.js i18n plugins.",
|
|
4
|
-
"homepage": "https://github.com/
|
|
4
|
+
"homepage": "https://github.com/ultramodernjs/ultramodern.js#readme",
|
|
5
5
|
"bugs": {
|
|
6
|
-
"url": "https://github.com/
|
|
6
|
+
"url": "https://github.com/ultramodernjs/ultramodern.js/issues"
|
|
7
7
|
},
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/ultramodernjs/ultramodern.js.git",
|
|
11
11
|
"directory": "packages/runtime/i18n-integration"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"version": "3.9.
|
|
14
|
+
"version": "3.9.3-ultramodern.1",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"src"
|
|
18
18
|
],
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=26.
|
|
20
|
+
"node": ">=26.10.0"
|
|
21
21
|
},
|
|
22
22
|
"types": "./dist/types/cli.d.ts",
|
|
23
23
|
"main": "./dist/cjs/cli.js",
|
|
@@ -54,14 +54,6 @@
|
|
|
54
54
|
},
|
|
55
55
|
"default": "./dist/esm/runtime-no-react-i18next.mjs"
|
|
56
56
|
},
|
|
57
|
-
"./server": {
|
|
58
|
-
"types": "./dist/types/server.d.ts",
|
|
59
|
-
"node": {
|
|
60
|
-
"import": "./dist/esm-node/server.mjs",
|
|
61
|
-
"require": "./dist/cjs/server.js"
|
|
62
|
-
},
|
|
63
|
-
"default": "./dist/cjs/server.js"
|
|
64
|
-
},
|
|
65
57
|
"./federation": {
|
|
66
58
|
"types": "./dist/types/federation/boundary.d.ts",
|
|
67
59
|
"node": {
|
|
@@ -94,9 +86,6 @@
|
|
|
94
86
|
"runtime/no-react-i18next": [
|
|
95
87
|
"./dist/types/runtime-no-react-i18next.d.ts"
|
|
96
88
|
],
|
|
97
|
-
"server": [
|
|
98
|
-
"./dist/types/server.d.ts"
|
|
99
|
-
],
|
|
100
89
|
"federation": [
|
|
101
90
|
"./dist/types/federation/boundary.d.ts"
|
|
102
91
|
],
|
|
@@ -106,37 +95,35 @@
|
|
|
106
95
|
}
|
|
107
96
|
},
|
|
108
97
|
"dependencies": {
|
|
109
|
-
"@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.
|
|
110
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.
|
|
111
|
-
"@modern-js/plugin-i18n": "npm:@bleedingdev/modern-js-plugin-i18n@3.9.
|
|
112
|
-
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.
|
|
113
|
-
"@modern-js/server-runtime": "npm:@bleedingdev/modern-js-server-runtime@3.9.0-ultramodern.9",
|
|
114
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.9"
|
|
98
|
+
"@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.3-ultramodern.1",
|
|
99
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.3-ultramodern.1",
|
|
100
|
+
"@modern-js/plugin-i18n": "npm:@bleedingdev/modern-js-plugin-i18n@3.9.3-ultramodern.1",
|
|
101
|
+
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.3-ultramodern.1"
|
|
115
102
|
},
|
|
116
103
|
"peerDependencies": {
|
|
117
|
-
"@modern-js/app-tools": "3.9.
|
|
118
|
-
"@modern-js/runtime": "3.9.
|
|
104
|
+
"@modern-js/app-tools": "3.9.3-ultramodern.1",
|
|
105
|
+
"@modern-js/runtime": "3.9.3-ultramodern.1",
|
|
119
106
|
"react": "^19.2.8"
|
|
120
107
|
},
|
|
121
108
|
"peerDependenciesMeta": {},
|
|
122
109
|
"optionalDependencies": {},
|
|
123
110
|
"devDependencies": {
|
|
124
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.
|
|
125
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.
|
|
126
|
-
"@modern-js/tsconfig": "npm:@bleedingdev/modern-js-tsconfig@3.9.
|
|
127
|
-
"@
|
|
128
|
-
"@
|
|
111
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.3-ultramodern.1",
|
|
112
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.3-ultramodern.1",
|
|
113
|
+
"@modern-js/tsconfig": "npm:@bleedingdev/modern-js-tsconfig@3.9.3-ultramodern.1",
|
|
114
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.3-ultramodern.1",
|
|
115
|
+
"@rslib/core": "1.0.3",
|
|
116
|
+
"@rstest/core": "0.12.3",
|
|
129
117
|
"@scripts/rstest-config": "2.66.0",
|
|
130
|
-
"@types/node": "^26.
|
|
131
|
-
"@types/react": "^19.
|
|
132
|
-
"@types/react-dom": "^19.
|
|
133
|
-
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
118
|
+
"@types/node": "^26.6.3",
|
|
119
|
+
"@types/react": "^19.3.0",
|
|
120
|
+
"@types/react-dom": "^19.3.0",
|
|
134
121
|
"esbuild": "^0.28.2",
|
|
135
122
|
"i18next": "26.4.2",
|
|
136
|
-
"react": "^19.
|
|
137
|
-
"react-dom": "^19.
|
|
138
|
-
"react-i18next": "17.0.
|
|
139
|
-
"typescript": "
|
|
123
|
+
"react": "^19.3.0",
|
|
124
|
+
"react-dom": "^19.3.0",
|
|
125
|
+
"react-i18next": "17.0.15",
|
|
126
|
+
"typescript": "7.0.2"
|
|
140
127
|
},
|
|
141
128
|
"sideEffects": false,
|
|
142
129
|
"publishConfig": {
|
|
@@ -146,5 +133,8 @@
|
|
|
146
133
|
"dev": "rslib build --watch",
|
|
147
134
|
"build": "rslib build",
|
|
148
135
|
"test": "rstest"
|
|
136
|
+
},
|
|
137
|
+
"ultramodern": {
|
|
138
|
+
"sourceName": "@modern-js/i18n-integration"
|
|
149
139
|
}
|
|
150
140
|
}
|
package/src/cli.ts
CHANGED
|
@@ -22,10 +22,7 @@ export const ultramodernI18nIntegrationPlugin = (): CliPlugin<AppTools> => ({
|
|
|
22
22
|
}));
|
|
23
23
|
|
|
24
24
|
// The native server plugin derives its URL policy from
|
|
25
|
-
// `localeDetection.localisedUrls
|
|
26
|
-
// alone. Rewriting it to `@modern-js/i18n-integration/server` would make
|
|
27
|
-
// the server unbootable for an app that only declares
|
|
28
|
-
// `@modern-js/ultramodern-app-tools`.
|
|
25
|
+
// `localeDetection.localisedUrls`, so its descriptor needs no replacement.
|
|
29
26
|
|
|
30
27
|
// Localised route generation used to live here. It now ships in
|
|
31
28
|
// `@modern-js/plugin-i18n`'s own CLI plugin so a bare `appTools()`
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
|
|
2
2
|
import { FederatedI18nBoundary } from './boundary';
|
|
3
3
|
|
|
4
|
-
export function registerFederatedI18nBoundary(
|
|
4
|
+
export function registerFederatedI18nBoundary(
|
|
5
|
+
api: Pick<RuntimePluginAPI<{}>, 'resolveComponent'>,
|
|
6
|
+
): void {
|
|
5
7
|
api.resolveComponent((component, { name }) =>
|
|
6
8
|
name === 'i18n.FederatedI18nBoundary' ? FederatedI18nBoundary : component,
|
|
7
9
|
);
|
package/src/options.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { LocalisedUrlsOption } from '@modern-js/i18n-runtime-extensions';
|
|
2
2
|
import type { I18nPluginOptions as NativeRuntimeOptions } from '@modern-js/plugin-i18n/runtime/no-react-i18next';
|
|
3
|
-
import type { I18nPluginOptions as NativeServerOptions } from '@modern-js/plugin-i18n/server';
|
|
4
3
|
|
|
5
4
|
export type IntegratedLocaleDetectionOptions = NonNullable<
|
|
6
5
|
NativeRuntimeOptions['localeDetection']
|
|
@@ -12,7 +11,3 @@ export type IntegratedLocaleDetectionOptions = NonNullable<
|
|
|
12
11
|
export type I18nPluginOptions = NativeRuntimeOptions & {
|
|
13
12
|
localeDetection?: IntegratedLocaleDetectionOptions;
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
export type I18nServerPluginOptions = NativeServerOptions & {
|
|
17
|
-
localeDetection: IntegratedLocaleDetectionOptions;
|
|
18
|
-
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
I18nRouterNavigationProvider,
|
|
3
|
+
type I18nPluginOptions as NativeI18nPluginOptions,
|
|
4
|
+
} from '@modern-js/plugin-i18n/runtime/no-react-i18next';
|
|
2
5
|
import type { RuntimePlugin } from '@modern-js/runtime';
|
|
3
6
|
import { registerFederatedI18nBoundary } from './federation/registration';
|
|
4
7
|
import { I18nLanguageSynchronization } from './languageSynchronization';
|
|
5
|
-
import { I18nRouterNavigationProvider } from './navigation';
|
|
6
8
|
import type { I18nPluginOptions } from './options';
|
|
7
9
|
import { createI18nUrlStrategy } from './urlStrategy';
|
|
8
10
|
|
package/dist/cjs/navigation.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
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
|
-
});
|
package/dist/cjs/server.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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: ()=>server,
|
|
32
|
-
i18nServerPlugin: ()=>i18nServerPlugin
|
|
33
|
-
});
|
|
34
|
-
const config_namespaceObject = require("@modern-js/plugin-i18n/config");
|
|
35
|
-
const server_namespaceObject = require("@modern-js/plugin-i18n/server");
|
|
36
|
-
const external_urlStrategy_js_namespaceObject = require("./urlStrategy.js");
|
|
37
|
-
const i18nServerPlugin = (options)=>(0, server_namespaceObject.i18nServerPlugin)({
|
|
38
|
-
...options,
|
|
39
|
-
resolveUrlStrategy: options.resolveUrlStrategy ?? ((entryName)=>(0, external_urlStrategy_js_namespaceObject.createI18nUrlStrategy)(options.localeDetection ? (0, config_namespaceObject.getLocaleDetectionOptions)(entryName, options.localeDetection).localisedUrls : void 0))
|
|
40
|
-
});
|
|
41
|
-
const server = i18nServerPlugin;
|
|
42
|
-
exports["default"] = __webpack_exports__["default"];
|
|
43
|
-
exports.i18nServerPlugin = __webpack_exports__.i18nServerPlugin;
|
|
44
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
45
|
-
"default",
|
|
46
|
-
"i18nServerPlugin"
|
|
47
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
48
|
-
Object.defineProperty(exports, '__esModule', {
|
|
49
|
-
value: true
|
|
50
|
-
});
|