@bleedingdev/modern-js-plugin-i18n 3.5.0-ultramodern.1 → 3.5.0-ultramodern.11

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,4 +1,10 @@
1
- import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
1
+ export type LocalisedRoute = {
2
+ type: 'nested' | 'page';
3
+ path?: string;
4
+ id?: string;
5
+ children?: LocalisedRoute[];
6
+ [key: string]: any;
7
+ };
2
8
  export type LocalisedUrlPathMap = Record<string, string>;
3
9
  export type LocalisedUrlsMap = Record<string, LocalisedUrlPathMap>;
4
10
  export type LocalisedUrlsOption = boolean | LocalisedUrlsMap;
@@ -21,8 +27,8 @@ export declare const normalisePathname: (pathname: string) => string;
21
27
  * failing the build for every route missing from a map they never wrote.
22
28
  */
23
29
  export declare const resolveLocalisedUrlsConfig: (option: LocalisedUrlsOption | undefined) => ResolvedLocalisedUrlsConfig;
24
- export declare const validateLocalisedUrls: (routes: (NestedRouteForCli | PageRoute)[], languages: string[], localisedUrls: LocalisedUrlsMap) => void;
25
- export declare const applyLocalisedUrlsToRoutes: (routes: (NestedRouteForCli | PageRoute)[], languages: string[], localisedUrls: LocalisedUrlsMap) => (NestedRouteForCli | PageRoute)[];
30
+ export declare const validateLocalisedUrls: (routes: LocalisedRoute[], languages: string[], localisedUrls: LocalisedUrlsMap) => void;
31
+ export declare const applyLocalisedUrlsToRoutes: (routes: LocalisedRoute[], languages: string[], localisedUrls: LocalisedUrlsMap) => LocalisedRoute[];
26
32
  export declare const matchPathPattern: (pathname: string, pattern: string) => Record<string, string> | null;
27
33
  export declare const buildPathFromPattern: (pattern: string, params: Record<string, string>) => string;
28
34
  export declare const resolveLocalisedPath: (pathname: string, targetLanguage: string, languages: string[], localisedUrls: LocalisedUrlsMap) => string;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.5.0-ultramodern.1",
20
+ "version": "3.5.0-ultramodern.11",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -97,15 +97,15 @@
97
97
  "i18next-fs-backend": "^2.6.6",
98
98
  "i18next-http-backend": "^4.0.0",
99
99
  "i18next-http-middleware": "^3.9.7",
100
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.1",
101
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.5.0-ultramodern.1",
102
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.1",
103
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.1",
104
- "@modern-js/server-runtime": "npm:@bleedingdev/modern-js-server-runtime@3.5.0-ultramodern.1",
105
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.1"
100
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.11",
101
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.5.0-ultramodern.11",
102
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.11",
103
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.11",
104
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.11",
105
+ "@modern-js/server-runtime": "npm:@bleedingdev/modern-js-server-runtime@3.5.0-ultramodern.11"
106
106
  },
107
107
  "peerDependencies": {
108
- "@modern-js/runtime": "3.5.0-ultramodern.1",
108
+ "@modern-js/runtime": "3.5.0-ultramodern.11",
109
109
  "i18next": ">=26.3.1",
110
110
  "react": "^19.2.7",
111
111
  "react-dom": "^19.2.7",
@@ -120,17 +120,17 @@
120
120
  }
121
121
  },
122
122
  "devDependencies": {
123
- "@rslib/core": "0.23.0",
123
+ "@rslib/core": "0.23.1",
124
124
  "@types/node": "^26.0.1",
125
- "@typescript/native-preview": "7.0.0-dev.20260624.1",
126
- "i18next": "26.3.2",
125
+ "@typescript/native-preview": "7.0.0-dev.20260628.1",
126
+ "i18next": "26.3.3",
127
127
  "react": "^19.2.7",
128
128
  "react-dom": "^19.2.7",
129
129
  "react-i18next": "17.0.8",
130
130
  "ts-node": "^10.9.2",
131
131
  "typescript": "^6.0.3",
132
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.1",
133
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.1"
132
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.11",
133
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.11"
134
134
  },
135
135
  "sideEffects": false,
136
136
  "publishConfig": {
@@ -1,4 +1,10 @@
1
- import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
1
+ export type LocalisedRoute = {
2
+ type: 'nested' | 'page';
3
+ path?: string;
4
+ id?: string;
5
+ children?: LocalisedRoute[];
6
+ [key: string]: any;
7
+ };
2
8
 
3
9
  export type LocalisedUrlPathMap = Record<string, string>;
4
10
  export type LocalisedUrlsMap = Record<string, LocalisedUrlPathMap>;
@@ -144,11 +150,11 @@ const ensureLocalisedUrlsForPath = (
144
150
  };
145
151
 
146
152
  export const validateLocalisedUrls = (
147
- routes: (NestedRouteForCli | PageRoute)[],
153
+ routes: LocalisedRoute[],
148
154
  languages: string[],
149
155
  localisedUrls: LocalisedUrlsMap,
150
156
  ) => {
151
- const visit = (route: NestedRouteForCli | PageRoute, parentPath: string) => {
157
+ const visit = (route: LocalisedRoute, parentPath: string) => {
152
158
  const canonicalPath = joinPath(parentPath, route.path);
153
159
  if (isLocalisableRoutePath(route.path)) {
154
160
  ensureLocalisedUrlsForPath(canonicalPath, languages, localisedUrls);
@@ -191,12 +197,12 @@ const getLocalisedRoutePaths = (
191
197
  };
192
198
 
193
199
  const transformLocalisedRoute = (
194
- route: NestedRouteForCli | PageRoute,
200
+ route: LocalisedRoute,
195
201
  parentCanonicalPath: string,
196
202
  parentLocalisedPaths: Record<string, string>,
197
203
  languages: string[],
198
204
  localisedUrls: LocalisedUrlsMap,
199
- ): (NestedRouteForCli | PageRoute)[] => {
205
+ ): LocalisedRoute[] => {
200
206
  const canonicalPath = joinPath(parentCanonicalPath, route.path);
201
207
  const localisedUrlEntry = isLocalisableRoutePath(route.path)
202
208
  ? ensureLocalisedUrlsForPath(canonicalPath, languages, localisedUrls)
@@ -224,7 +230,7 @@ const transformLocalisedRoute = (
224
230
  const baseRoute = {
225
231
  ...route,
226
232
  ...(children ? { children } : {}),
227
- } as NestedRouteForCli | PageRoute;
233
+ } as LocalisedRoute;
228
234
 
229
235
  if (!localisedUrlEntry) {
230
236
  return [baseRoute];
@@ -243,7 +249,7 @@ const transformLocalisedRoute = (
243
249
  const legalRouteIdPart = (value: string): string =>
244
250
  value.replace(/[^a-zA-Z0-9_$-]+/g, '_').replace(/^_+|_+$/g, '') || 'index';
245
251
 
246
- const suffixRouteIds = <T extends NestedRouteForCli | PageRoute>(
252
+ const suffixRouteIds = <T extends LocalisedRoute>(
247
253
  route: T,
248
254
  suffix: string,
249
255
  ): T => {
@@ -260,11 +266,11 @@ const suffixRouteIds = <T extends NestedRouteForCli | PageRoute>(
260
266
  };
261
267
 
262
268
  const cloneRouteWithLocalisedPath = (
263
- route: NestedRouteForCli | PageRoute,
269
+ route: LocalisedRoute,
264
270
  path: string,
265
271
  index: number,
266
272
  canonicalPath: string,
267
- ): NestedRouteForCli | PageRoute => {
273
+ ): LocalisedRoute => {
268
274
  const leadingLocaleParam = getLeadingLocaleParam(route.path);
269
275
  const localisedPath = leadingLocaleParam
270
276
  ? normaliseRoutePath(`${leadingLocaleParam}/${path}`)
@@ -272,7 +278,7 @@ const cloneRouteWithLocalisedPath = (
272
278
  const routeWithPath = {
273
279
  ...route,
274
280
  path: localisedPath,
275
- } as NestedRouteForCli | PageRoute;
281
+ } as LocalisedRoute;
276
282
  // Language-agnostic source pattern; lets downstream codegen collapse the
277
283
  // localized physical variants back to one canonical route.
278
284
  (routeWithPath as { modernCanonicalPath?: string }).modernCanonicalPath =
@@ -284,10 +290,10 @@ const cloneRouteWithLocalisedPath = (
284
290
  };
285
291
 
286
292
  export const applyLocalisedUrlsToRoutes = (
287
- routes: (NestedRouteForCli | PageRoute)[],
293
+ routes: LocalisedRoute[],
288
294
  languages: string[],
289
295
  localisedUrls: LocalisedUrlsMap,
290
- ): (NestedRouteForCli | PageRoute)[] => {
296
+ ): LocalisedRoute[] => {
291
297
  const rootLocalisedPaths = languages.reduce<Record<string, string>>(
292
298
  (acc, language) => {
293
299
  acc[language] = '/';
@@ -3,10 +3,21 @@ import path from 'node:path';
3
3
 
4
4
  const fixtureDir = path.resolve(__dirname, 'type-fixture');
5
5
 
6
- const tsgoBin = path.join(
7
- path.dirname(require.resolve('@typescript/native-preview/package.json')),
8
- 'bin/tsgo.js',
9
- );
6
+ function resolveTsgoBin() {
7
+ const pkgPath = require.resolve('@typescript/native-preview/package.json');
8
+ const pkgDir = path.dirname(pkgPath);
9
+ const pkg = require(pkgPath) as {
10
+ bin?:
11
+ | string
12
+ | {
13
+ tsgo?: string;
14
+ };
15
+ };
16
+ const binEntry = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.tsgo;
17
+ return path.resolve(pkgDir, binEntry ?? 'bin/tsgo.js');
18
+ }
19
+
20
+ const tsgoBin = resolveTsgoBin();
10
21
 
11
22
  describe('Link type-level tests', () => {
12
23
  test('fixture type-checks correctly: valid uses compile, invalid uses are rejected', () => {