@bleedingdev/modern-js-plugin-i18n 3.8.2-ultramodern.9 → 3.8.3-ultramodern.2

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 (97) hide show
  1. package/dist/cjs/cli/index.js +3 -3
  2. package/dist/cjs/runtime/context.js +19 -6
  3. package/dist/cjs/runtime/hooks.js +8 -11
  4. package/dist/cjs/runtime/localizedPaths.js +2 -2
  5. package/dist/cjs/runtime/providerComposition.js +3 -1
  6. package/dist/cjs/runtime/utils.js +3 -3
  7. package/dist/cjs/server/index.js +2 -2
  8. package/dist/cjs/server/redirectPolicy.js +6 -6
  9. package/dist/esm/cli/index.mjs +1 -1
  10. package/dist/esm/runtime/context.mjs +19 -6
  11. package/dist/esm/runtime/hooks.mjs +8 -11
  12. package/dist/esm/runtime/localizedPaths.mjs +1 -1
  13. package/dist/esm/runtime/providerComposition.mjs +3 -1
  14. package/dist/esm/runtime/utils.mjs +1 -1
  15. package/dist/esm/server/index.mjs +1 -1
  16. package/dist/esm/server/redirectPolicy.mjs +1 -1
  17. package/dist/esm-node/cli/index.mjs +1 -1
  18. package/dist/esm-node/runtime/context.mjs +19 -6
  19. package/dist/esm-node/runtime/hooks.mjs +8 -11
  20. package/dist/esm-node/runtime/localizedPaths.mjs +1 -1
  21. package/dist/esm-node/runtime/providerComposition.mjs +3 -1
  22. package/dist/esm-node/runtime/utils.mjs +1 -1
  23. package/dist/esm-node/server/index.mjs +1 -1
  24. package/dist/esm-node/server/redirectPolicy.mjs +1 -1
  25. package/dist/types/runtime/context.d.ts +3 -2
  26. package/dist/types/runtime/contextHelpers.d.ts +1 -1
  27. package/dist/types/runtime/hooks.d.ts +1 -1
  28. package/dist/types/runtime/localizedPaths.d.ts +1 -1
  29. package/dist/types/runtime/utils.d.ts +1 -1
  30. package/dist/types/shared/type.d.ts +1 -1
  31. package/package.json +32 -11
  32. package/src/cli/index.ts +4 -4
  33. package/src/runtime/context.tsx +38 -14
  34. package/src/runtime/contextHelpers.ts +1 -1
  35. package/src/runtime/hooks.ts +9 -10
  36. package/src/runtime/localizedPaths.ts +4 -2
  37. package/src/runtime/providerComposition.tsx +5 -2
  38. package/src/runtime/utils.ts +4 -4
  39. package/src/server/index.ts +1 -1
  40. package/src/server/redirectPolicy.ts +1 -1
  41. package/src/shared/type.ts +1 -1
  42. package/tests/federatedI18nBoundary.client.test.tsx +21 -4
  43. package/tests/federatedI18nBoundary.test.tsx +15 -3
  44. package/tests/linkTypes.test.ts +20 -0
  45. package/tests/localisedUrlRewriteMatrix.fork.test.ts +1 -1
  46. package/tests/localisedUrls.test.ts +0 -351
  47. package/tests/routerAdapter.test.tsx +5 -12
  48. package/dist/cjs/shared/localisedUrls/config.js +0 -49
  49. package/dist/cjs/shared/localisedUrls/index.js +0 -91
  50. package/dist/cjs/shared/localisedUrls/normalise.js +0 -87
  51. package/dist/cjs/shared/localisedUrls/pathname.js +0 -68
  52. package/dist/cjs/shared/localisedUrls/patterns.js +0 -130
  53. package/dist/cjs/shared/localisedUrls/redirect.js +0 -103
  54. package/dist/cjs/shared/localisedUrls/resolve.js +0 -88
  55. package/dist/cjs/shared/localisedUrls/routes.js +0 -130
  56. package/dist/cjs/shared/localisedUrls/types.js +0 -18
  57. package/dist/cjs/shared/localisedUrls.js +0 -85
  58. package/dist/esm/shared/localisedUrls/config.mjs +0 -11
  59. package/dist/esm/shared/localisedUrls/index.mjs +0 -7
  60. package/dist/esm/shared/localisedUrls/normalise.mjs +0 -37
  61. package/dist/esm/shared/localisedUrls/pathname.mjs +0 -24
  62. package/dist/esm/shared/localisedUrls/patterns.mjs +0 -86
  63. package/dist/esm/shared/localisedUrls/redirect.mjs +0 -56
  64. package/dist/esm/shared/localisedUrls/resolve.mjs +0 -47
  65. package/dist/esm/shared/localisedUrls/routes.mjs +0 -89
  66. package/dist/esm/shared/localisedUrls/types.mjs +0 -0
  67. package/dist/esm/shared/localisedUrls.mjs +0 -1
  68. package/dist/esm-node/shared/localisedUrls/config.mjs +0 -12
  69. package/dist/esm-node/shared/localisedUrls/index.mjs +0 -8
  70. package/dist/esm-node/shared/localisedUrls/normalise.mjs +0 -38
  71. package/dist/esm-node/shared/localisedUrls/pathname.mjs +0 -25
  72. package/dist/esm-node/shared/localisedUrls/patterns.mjs +0 -87
  73. package/dist/esm-node/shared/localisedUrls/redirect.mjs +0 -57
  74. package/dist/esm-node/shared/localisedUrls/resolve.mjs +0 -48
  75. package/dist/esm-node/shared/localisedUrls/routes.mjs +0 -90
  76. package/dist/esm-node/shared/localisedUrls/types.mjs +0 -1
  77. package/dist/esm-node/shared/localisedUrls.mjs +0 -2
  78. package/dist/types/shared/localisedUrls/config.d.ts +0 -9
  79. package/dist/types/shared/localisedUrls/index.d.ts +0 -9
  80. package/dist/types/shared/localisedUrls/normalise.d.ts +0 -10
  81. package/dist/types/shared/localisedUrls/pathname.d.ts +0 -4
  82. package/dist/types/shared/localisedUrls/patterns.d.ts +0 -5
  83. package/dist/types/shared/localisedUrls/redirect.d.ts +0 -11
  84. package/dist/types/shared/localisedUrls/resolve.d.ts +0 -7
  85. package/dist/types/shared/localisedUrls/routes.d.ts +0 -3
  86. package/dist/types/shared/localisedUrls/types.d.ts +0 -14
  87. package/dist/types/shared/localisedUrls.d.ts +0 -2
  88. package/src/shared/localisedUrls/config.ts +0 -18
  89. package/src/shared/localisedUrls/index.ts +0 -24
  90. package/src/shared/localisedUrls/normalise.ts +0 -67
  91. package/src/shared/localisedUrls/pathname.ts +0 -60
  92. package/src/shared/localisedUrls/patterns.ts +0 -160
  93. package/src/shared/localisedUrls/redirect.ts +0 -93
  94. package/src/shared/localisedUrls/resolve.ts +0 -135
  95. package/src/shared/localisedUrls/routes.ts +0 -234
  96. package/src/shared/localisedUrls/types.ts +0 -18
  97. package/src/shared/localisedUrls.ts +0 -26
@@ -6,16 +6,6 @@ import {
6
6
  i18nServerPlugin,
7
7
  matchesApiPrefix,
8
8
  } from '../src/server';
9
- import {
10
- applyLocalisedUrlsToRoutes,
11
- canonicalTargetPathname,
12
- localiseTargetPathname,
13
- matchPathPattern,
14
- resolveCanonicalLocalisedPath,
15
- resolveLocalisedPath,
16
- resolveLocalisedUrlsConfig,
17
- validateLocalisedUrls,
18
- } from '../src/shared/localisedUrls';
19
9
 
20
10
  const createRoute = (
21
11
  path: string,
@@ -37,21 +27,6 @@ const createRequestContext = (pathname: string) =>
37
27
  },
38
28
  }) as any;
39
29
 
40
- describe('resolveLocalisedUrlsConfig', () => {
41
- test('is opt-in: only a non-empty map enables the feature', () => {
42
- const map = { '/about': { en: '/about', cs: '/o-nas' } };
43
- expect(resolveLocalisedUrlsConfig(map)).toEqual({ enabled: true, map });
44
- });
45
-
46
- test('absent, boolean and empty-map options resolve to disabled', () => {
47
- const disabled = { enabled: false, map: {} };
48
- expect(resolveLocalisedUrlsConfig(undefined)).toEqual(disabled);
49
- expect(resolveLocalisedUrlsConfig(false)).toEqual(disabled);
50
- expect(resolveLocalisedUrlsConfig(true)).toEqual(disabled);
51
- expect(resolveLocalisedUrlsConfig({})).toEqual(disabled);
52
- });
53
- });
54
-
55
30
  describe('cli modifyFileSystemRoutes', () => {
56
31
  test('uses the no-react runtime entry when reactI18next is disabled', () => {
57
32
  let runtimePlugin:
@@ -234,332 +209,6 @@ describe('cli modifyFileSystemRoutes', () => {
234
209
  });
235
210
  });
236
211
 
237
- describe('localisedUrls', () => {
238
- test('leaves framework-internal Module Federation routes unlocalised', () => {
239
- const internalRoute = createRoute('_mf', [
240
- createRoute('fragment', [createRoute('product-card')]),
241
- ]);
242
- const publicRoute = createRoute(':lang', [createRoute('products')]);
243
- const routes = [internalRoute, publicRoute];
244
-
245
- expect(() =>
246
- validateLocalisedUrls(routes, ['en', 'cs'], {
247
- '/products': { en: '/products', cs: '/produkty' },
248
- }),
249
- ).not.toThrow();
250
- expect(
251
- applyLocalisedUrlsToRoutes(routes, ['en', 'cs'], {
252
- '/products': { en: '/products', cs: '/produkty' },
253
- })[0],
254
- ).toEqual(internalRoute);
255
- });
256
-
257
- test('requires every localisable route path to define every language', () => {
258
- const routes = [createRoute(':lang', [createRoute('terms-of-service')])];
259
-
260
- expect(() =>
261
- validateLocalisedUrls(routes, ['en', 'cs'], {
262
- '/terms-of-service': {
263
- en: '/terms-of-service',
264
- },
265
- }),
266
- ).toThrow('missing languages: cs');
267
- });
268
-
269
- test('expands route paths to localised aliases', () => {
270
- const routes = [
271
- createRoute(':lang', [
272
- createRoute('terms-of-service'),
273
- createRoute('products', [createRoute(':slug')]),
274
- ]),
275
- ];
276
-
277
- const localisedRoutes = applyLocalisedUrlsToRoutes(routes, ['en', 'cs'], {
278
- '/terms-of-service': {
279
- en: '/terms-of-service',
280
- cs: '/podminky-pouzivani',
281
- },
282
- '/products': {
283
- en: '/products',
284
- cs: '/produkty',
285
- },
286
- '/products/:slug': {
287
- en: '/products/:slug',
288
- cs: '/produkty/:slug',
289
- },
290
- });
291
-
292
- const localeRoute = localisedRoutes[0] as NestedRouteForCli;
293
- expect(localeRoute.children?.map(route => route.path)).toEqual([
294
- 'terms-of-service',
295
- 'podminky-pouzivani',
296
- 'products',
297
- 'produkty',
298
- ]);
299
-
300
- const productRoutes = localeRoute.children?.filter(
301
- route => route.path === 'products' || route.path === 'produkty',
302
- );
303
- expect(productRoutes?.[0].children?.map(route => route.path)).toEqual([
304
- ':slug',
305
- ]);
306
- expect(productRoutes?.[1].children?.map(route => route.path)).toEqual([
307
- ':slug',
308
- ]);
309
- });
310
-
311
- test('expands flat locale-prefixed route paths with canonical keys', () => {
312
- const routes = [
313
- createRoute('/:lang/about'),
314
- createRoute('/:lang/products/:slug'),
315
- ];
316
-
317
- const localisedRoutes = applyLocalisedUrlsToRoutes(routes, ['en', 'cs'], {
318
- '/about': {
319
- en: '/about',
320
- cs: '/o-nas',
321
- },
322
- '/products/:slug': {
323
- en: '/products/:slug',
324
- cs: '/produkty/:slug',
325
- },
326
- });
327
-
328
- expect(localisedRoutes.map(route => route.path)).toEqual([
329
- ':lang/about',
330
- ':lang/o-nas',
331
- ':lang/products/:slug',
332
- ':lang/produkty/:slug',
333
- ]);
334
- });
335
-
336
- test('resolves current localized path to the target language', () => {
337
- const localisedUrls = {
338
- '/terms-of-service': {
339
- en: '/terms-of-service',
340
- cs: '/podminky-pouzivani',
341
- },
342
- '/products/:slug': {
343
- en: '/products/:slug',
344
- cs: '/produkty/:slug',
345
- },
346
- };
347
-
348
- expect(
349
- resolveLocalisedPath(
350
- '/terms-of-service',
351
- 'cs',
352
- ['en', 'cs'],
353
- localisedUrls,
354
- ),
355
- ).toBe('/podminky-pouzivani');
356
- expect(
357
- resolveLocalisedPath('/produkty/cervena-bota', 'en', ['en', 'cs'], {
358
- ...localisedUrls,
359
- '/products/:slug': {
360
- en: '/products/:slug',
361
- cs: '/produkty/:slug',
362
- },
363
- }),
364
- ).toBe('/products/cervena-bota');
365
- });
366
-
367
- test('resolves optional route params', () => {
368
- const localisedUrls = {
369
- '/products/:slug?': {
370
- en: '/products/:slug?',
371
- cs: '/produkty/:slug?',
372
- },
373
- };
374
-
375
- expect(
376
- resolveLocalisedPath('/products', 'cs', ['en', 'cs'], localisedUrls),
377
- ).toBe('/produkty');
378
- expect(
379
- resolveLocalisedPath(
380
- '/produkty/cervena-bota',
381
- 'en',
382
- ['en', 'cs'],
383
- localisedUrls,
384
- ),
385
- ).toBe('/products/cervena-bota');
386
- });
387
-
388
- test('encodes wildcard params while preserving path separators', () => {
389
- const localisedUrls = {
390
- '/docs/*': {
391
- en: '/docs/*',
392
- cs: '/dokumenty/*',
393
- },
394
- };
395
-
396
- expect(
397
- resolveLocalisedPath(
398
- '/docs/a%20b/c%23d',
399
- 'cs',
400
- ['en', 'cs'],
401
- localisedUrls,
402
- ),
403
- ).toBe('/dokumenty/a%20b/c%23d');
404
- expect(
405
- resolveCanonicalLocalisedPath(
406
- '/dokumenty/a%20b/c%23d',
407
- ['en', 'cs'],
408
- localisedUrls,
409
- ),
410
- ).toBe('/docs/a%20b/c%23d');
411
- });
412
-
413
- test('resolves static patterns before param patterns', () => {
414
- const localisedUrls = {
415
- '/products/:slug': {
416
- en: '/products/:slug',
417
- cs: '/produkty/:slug',
418
- },
419
- '/products/new': {
420
- en: '/products/new',
421
- cs: '/produkty/novinka',
422
- },
423
- };
424
-
425
- expect(
426
- resolveLocalisedPath('/products/new', 'cs', ['en', 'cs'], localisedUrls),
427
- ).toBe('/produkty/novinka');
428
- expect(
429
- resolveCanonicalLocalisedPath(
430
- '/produkty/novinka',
431
- ['en', 'cs'],
432
- localisedUrls,
433
- ),
434
- ).toBe('/products/new');
435
- });
436
-
437
- test('localises and canonicalises full target pathnames through one helper', () => {
438
- const localisedUrls = {
439
- '/products/:slug': {
440
- en: '/products/:slug',
441
- cs: '/produkty/:slug',
442
- },
443
- };
444
-
445
- expect(
446
- localiseTargetPathname(
447
- '/en/products/cervena-bota',
448
- 'cs',
449
- ['en', 'cs'],
450
- localisedUrls,
451
- ),
452
- ).toBe('/cs/produkty/cervena-bota');
453
- expect(
454
- canonicalTargetPathname(
455
- '/cs/produkty/cervena-bota',
456
- ['en', 'cs'],
457
- localisedUrls,
458
- ),
459
- ).toBe('/products/cervena-bota');
460
- });
461
-
462
- test('strips case-insensitive locale prefixes before relocalising full pathnames', () => {
463
- const localisedUrls = {
464
- '/products/:slug': {
465
- en: '/products/:slug',
466
- cs: '/produkty/:slug',
467
- },
468
- };
469
-
470
- expect(
471
- localiseTargetPathname(
472
- '/CS/produkty/cervena-bota',
473
- 'en',
474
- ['en', 'cs'],
475
- localisedUrls,
476
- ),
477
- ).toBe('/en/products/cervena-bota');
478
- expect(
479
- canonicalTargetPathname(
480
- '/CS/produkty/cervena-bota',
481
- ['en', 'cs'],
482
- localisedUrls,
483
- ),
484
- ).toBe('/products/cervena-bota');
485
- });
486
-
487
- test('resolves nested optional route params with translated ancestors', () => {
488
- const localisedUrls = {
489
- '/checkout': {
490
- en: '/checkout',
491
- cs: '/pokladna',
492
- },
493
- '/checkout/thank-you': {
494
- en: '/checkout/thank-you',
495
- cs: '/pokladna/dekujeme',
496
- },
497
- '/checkout/thank-you/:orderId?': {
498
- en: '/checkout/thank-you/:orderId?',
499
- cs: '/pokladna/dekujeme/:orderId?',
500
- },
501
- };
502
-
503
- expect(
504
- resolveLocalisedPath(
505
- '/checkout/thank-you',
506
- 'cs',
507
- ['en', 'cs'],
508
- localisedUrls,
509
- ),
510
- ).toBe('/pokladna/dekujeme');
511
- expect(
512
- resolveLocalisedPath(
513
- '/pokladna/dekujeme/ABC-123',
514
- 'en',
515
- ['en', 'cs'],
516
- localisedUrls,
517
- ),
518
- ).toBe('/checkout/thank-you/ABC-123');
519
- });
520
- });
521
-
522
- describe('matchPathPattern decoding', () => {
523
- test('decodes valid percent-encoded params', () => {
524
- expect(
525
- matchPathPattern('/produkty/%C4%8Derven%C3%A1', '/produkty/:slug'),
526
- ).toEqual({ slug: 'červená' });
527
- });
528
-
529
- test('treats malformed percent-encoding as no match instead of throwing', () => {
530
- expect(() =>
531
- matchPathPattern('/produkty/%E0%A4%A', '/produkty/:slug'),
532
- ).not.toThrow();
533
- expect(
534
- matchPathPattern('/produkty/%E0%A4%A', '/produkty/:slug'),
535
- ).toBeNull();
536
- });
537
-
538
- test('keeps literal bracket segments in pathnames (no pattern rewrite)', () => {
539
- expect(matchPathPattern('/produkty/[x]', '/produkty/:slug')).toEqual({
540
- slug: '[x]',
541
- });
542
- });
543
-
544
- test('resolveLocalisedPath returns malformed paths unchanged', () => {
545
- const localisedUrls = {
546
- '/products/:slug': {
547
- en: '/products/:slug',
548
- cs: '/produkty/:slug',
549
- },
550
- };
551
-
552
- expect(
553
- resolveLocalisedPath(
554
- '/produkty/%E0%A4%A',
555
- 'en',
556
- ['en', 'cs'],
557
- localisedUrls,
558
- ),
559
- ).toBe('/produkty/%E0%A4%A');
560
- });
561
- });
562
-
563
212
  describe('i18n server API prefix skips', () => {
564
213
  test('collects API route prefixes and normalized BFF config prefixes', () => {
565
214
  expect(
@@ -455,6 +455,7 @@ describe('i18n runtime wrapRoot', () => {
455
455
  afterEach(() => {
456
456
  cleanup(rendered);
457
457
  rendered = undefined;
458
+ rstest.useRealTimers();
458
459
  rstest.restoreAllMocks();
459
460
  window.history.replaceState(null, '', '/');
460
461
  });
@@ -759,11 +760,10 @@ describe('i18n runtime wrapRoot', () => {
759
760
  expect(rendered.container.textContent).toBe('Language');
760
761
  });
761
762
 
762
- test('keeps committed copy after a failed change and recovers later', async () => {
763
+ test('keeps committed copy after a failed change and retries automatically', async () => {
764
+ rstest.useFakeTimers();
763
765
  window.history.replaceState(null, '', '/en');
764
- const consoleError = rstest
765
- .spyOn(console, 'error')
766
- .mockImplementation(() => undefined);
766
+ rstest.spyOn(console, 'error').mockImplementation(() => undefined);
767
767
  const router = createMutableTanstackRouter();
768
768
  const runtimeContext = createTanstackRuntimeContext(router);
769
769
  const { instance, pending } = createDeferredI18nInstance();
@@ -801,16 +801,9 @@ describe('i18n runtime wrapRoot', () => {
801
801
  });
802
802
 
803
803
  expect(rendered.container.textContent).toContain('en:Language');
804
- expect(consoleError).toHaveBeenCalledTimes(1);
805
- expect(consoleError).toHaveBeenCalledWith(
806
- 'Failed to synchronize i18n language "cs".',
807
- languageError,
808
- );
809
804
 
810
805
  await act(async () => {
811
- rendered?.container
812
- .querySelector('button')
813
- ?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
806
+ await rstest.advanceTimersByTimeAsync(50);
814
807
  });
815
808
  expect(pending).toHaveLength(2);
816
809
 
@@ -1,49 +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
- const resolveLocalisedUrlsConfig = (option)=>{
31
- if (option && 'object' == typeof option && Object.keys(option).length > 0) return {
32
- enabled: true,
33
- map: option
34
- };
35
- return {
36
- enabled: false,
37
- map: {}
38
- };
39
- };
40
- __webpack_require__.d(__webpack_exports__, {}, {
41
- resolveLocalisedUrlsConfig: resolveLocalisedUrlsConfig
42
- });
43
- exports.resolveLocalisedUrlsConfig = __webpack_exports__.resolveLocalisedUrlsConfig;
44
- for(var __rspack_i in __webpack_exports__)if (-1 === [
45
- "resolveLocalisedUrlsConfig"
46
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
47
- Object.defineProperty(exports, '__esModule', {
48
- value: true
49
- });
@@ -1,91 +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_LOCALE_REDIRECT_SKIP_RULES: ()=>external_redirect_js_namespaceObject.DEFAULT_LOCALE_REDIRECT_SKIP_RULES,
32
- applyLocalisedUrlsToRoutes: ()=>external_routes_js_namespaceObject.applyLocalisedUrlsToRoutes,
33
- buildPathFromPattern: ()=>external_patterns_js_namespaceObject.buildPathFromPattern,
34
- canonicalTargetPathname: ()=>external_pathname_js_namespaceObject.canonicalTargetPathname,
35
- isDefaultLocaleRedirectSkipPath: ()=>external_redirect_js_namespaceObject.isDefaultLocaleRedirectSkipPath,
36
- localiseTargetPathname: ()=>external_pathname_js_namespaceObject.localiseTargetPathname,
37
- matchPathPattern: ()=>external_patterns_js_namespaceObject.matchPathPattern,
38
- matchesPathPrefix: ()=>external_redirect_js_namespaceObject.matchesPathPrefix,
39
- normalisePathPattern: ()=>external_normalise_js_namespaceObject.normalisePathPattern,
40
- normalisePathname: ()=>external_normalise_js_namespaceObject.normalisePathname,
41
- resolveCanonicalLocalisedPath: ()=>external_resolve_js_namespaceObject.resolveCanonicalLocalisedPath,
42
- resolveLocalisedPath: ()=>external_resolve_js_namespaceObject.resolveLocalisedPath,
43
- resolveLocalisedUrlsConfig: ()=>external_config_js_namespaceObject.resolveLocalisedUrlsConfig,
44
- shouldSkipLocaleRedirect: ()=>external_redirect_js_namespaceObject.shouldSkipLocaleRedirect,
45
- stripLanguagePrefix: ()=>external_pathname_js_namespaceObject.stripLanguagePrefix,
46
- validateLocalisedUrls: ()=>external_routes_js_namespaceObject.validateLocalisedUrls
47
- });
48
- const external_config_js_namespaceObject = require("./config.js");
49
- const external_normalise_js_namespaceObject = require("./normalise.js");
50
- const external_pathname_js_namespaceObject = require("./pathname.js");
51
- const external_patterns_js_namespaceObject = require("./patterns.js");
52
- const external_redirect_js_namespaceObject = require("./redirect.js");
53
- const external_resolve_js_namespaceObject = require("./resolve.js");
54
- const external_routes_js_namespaceObject = require("./routes.js");
55
- exports.DEFAULT_LOCALE_REDIRECT_SKIP_RULES = __webpack_exports__.DEFAULT_LOCALE_REDIRECT_SKIP_RULES;
56
- exports.applyLocalisedUrlsToRoutes = __webpack_exports__.applyLocalisedUrlsToRoutes;
57
- exports.buildPathFromPattern = __webpack_exports__.buildPathFromPattern;
58
- exports.canonicalTargetPathname = __webpack_exports__.canonicalTargetPathname;
59
- exports.isDefaultLocaleRedirectSkipPath = __webpack_exports__.isDefaultLocaleRedirectSkipPath;
60
- exports.localiseTargetPathname = __webpack_exports__.localiseTargetPathname;
61
- exports.matchPathPattern = __webpack_exports__.matchPathPattern;
62
- exports.matchesPathPrefix = __webpack_exports__.matchesPathPrefix;
63
- exports.normalisePathPattern = __webpack_exports__.normalisePathPattern;
64
- exports.normalisePathname = __webpack_exports__.normalisePathname;
65
- exports.resolveCanonicalLocalisedPath = __webpack_exports__.resolveCanonicalLocalisedPath;
66
- exports.resolveLocalisedPath = __webpack_exports__.resolveLocalisedPath;
67
- exports.resolveLocalisedUrlsConfig = __webpack_exports__.resolveLocalisedUrlsConfig;
68
- exports.shouldSkipLocaleRedirect = __webpack_exports__.shouldSkipLocaleRedirect;
69
- exports.stripLanguagePrefix = __webpack_exports__.stripLanguagePrefix;
70
- exports.validateLocalisedUrls = __webpack_exports__.validateLocalisedUrls;
71
- for(var __rspack_i in __webpack_exports__)if (-1 === [
72
- "DEFAULT_LOCALE_REDIRECT_SKIP_RULES",
73
- "applyLocalisedUrlsToRoutes",
74
- "buildPathFromPattern",
75
- "canonicalTargetPathname",
76
- "isDefaultLocaleRedirectSkipPath",
77
- "localiseTargetPathname",
78
- "matchPathPattern",
79
- "matchesPathPrefix",
80
- "normalisePathPattern",
81
- "normalisePathname",
82
- "resolveCanonicalLocalisedPath",
83
- "resolveLocalisedPath",
84
- "resolveLocalisedUrlsConfig",
85
- "shouldSkipLocaleRedirect",
86
- "stripLanguagePrefix",
87
- "validateLocalisedUrls"
88
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
89
- Object.defineProperty(exports, '__esModule', {
90
- value: true
91
- });
@@ -1,87 +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
- const LOCALE_PARAM_NAMES = new Set([
31
- 'lang',
32
- 'locale',
33
- 'language'
34
- ]);
35
- const normaliseSlashes = (path)=>{
36
- const withoutDuplicateSlashes = path.replace(/\/+/g, '/');
37
- const withLeadingSlash = withoutDuplicateSlashes.startsWith('/') ? withoutDuplicateSlashes : `/${withoutDuplicateSlashes}`;
38
- return withLeadingSlash.length > 1 ? withLeadingSlash.replace(/\/+$/, '') : withLeadingSlash;
39
- };
40
- const normalisePathPattern = (path)=>normaliseSlashes(path).replace(/\[(.+?)\]/g, ':$1');
41
- const normalisePathname = (pathname)=>normaliseSlashes(pathname);
42
- const normaliseRoutePath = (path)=>{
43
- const normalized = normalisePathPattern(path);
44
- return '/' === normalized ? '' : normalized.slice(1);
45
- };
46
- const getLocaleParamSegment = (segment)=>{
47
- if (!segment.startsWith(':')) return null;
48
- const paramName = segment.slice(1).replace(/\?$/, '');
49
- return LOCALE_PARAM_NAMES.has(paramName) ? segment : null;
50
- };
51
- const splitPathSegments = (path)=>{
52
- if (!path) return [];
53
- return normalisePathPattern(path).split('/').filter(Boolean);
54
- };
55
- const stripLeadingLocaleParam = (path)=>{
56
- const segments = splitPathSegments(path);
57
- const leadingLocaleParam = getLocaleParamSegment(segments[0] || '');
58
- if (!leadingLocaleParam) return path;
59
- const remainingPath = segments.slice(1).join('/');
60
- return remainingPath ? `/${remainingPath}` : void 0;
61
- };
62
- const getLeadingLocaleParam = (path)=>{
63
- const segments = splitPathSegments(path);
64
- return getLocaleParamSegment(segments[0] || '');
65
- };
66
- __webpack_require__.d(__webpack_exports__, {}, {
67
- getLeadingLocaleParam: getLeadingLocaleParam,
68
- normalisePathPattern: normalisePathPattern,
69
- normalisePathname: normalisePathname,
70
- normaliseRoutePath: normaliseRoutePath,
71
- stripLeadingLocaleParam: stripLeadingLocaleParam
72
- });
73
- exports.getLeadingLocaleParam = __webpack_exports__.getLeadingLocaleParam;
74
- exports.normalisePathPattern = __webpack_exports__.normalisePathPattern;
75
- exports.normalisePathname = __webpack_exports__.normalisePathname;
76
- exports.normaliseRoutePath = __webpack_exports__.normaliseRoutePath;
77
- exports.stripLeadingLocaleParam = __webpack_exports__.stripLeadingLocaleParam;
78
- for(var __rspack_i in __webpack_exports__)if (-1 === [
79
- "getLeadingLocaleParam",
80
- "normalisePathPattern",
81
- "normalisePathname",
82
- "normaliseRoutePath",
83
- "stripLeadingLocaleParam"
84
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
85
- Object.defineProperty(exports, '__esModule', {
86
- value: true
87
- });