@bleedingdev/modern-js-runtime-extensions 3.9.0-ultramodern.11 → 3.9.0-ultramodern.13

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 (68) hide show
  1. package/dist/cjs/localisedUrls/config.js +49 -0
  2. package/dist/cjs/localisedUrls/index.js +95 -0
  3. package/dist/cjs/localisedUrls/normalise.js +87 -0
  4. package/dist/cjs/localisedUrls/pathname.js +68 -0
  5. package/dist/cjs/localisedUrls/patterns.js +214 -0
  6. package/dist/cjs/localisedUrls/redirect.js +100 -0
  7. package/dist/cjs/localisedUrls/resolve.js +78 -0
  8. package/dist/cjs/localisedUrls/routeIdentity.js +92 -0
  9. package/dist/cjs/localisedUrls/routes.js +217 -0
  10. package/dist/cjs/localisedUrls/types.js +18 -0
  11. package/dist/cjs/routerState.js +48 -77
  12. package/dist/cjs/routerStatePlugin.js +36 -9
  13. package/dist/esm/localisedUrls/config.mjs +11 -0
  14. package/dist/esm/localisedUrls/index.mjs +8 -0
  15. package/dist/esm/localisedUrls/normalise.mjs +37 -0
  16. package/dist/esm/localisedUrls/pathname.mjs +24 -0
  17. package/dist/esm/localisedUrls/patterns.mjs +152 -0
  18. package/dist/esm/localisedUrls/redirect.mjs +53 -0
  19. package/dist/esm/localisedUrls/resolve.mjs +37 -0
  20. package/dist/esm/localisedUrls/routeIdentity.mjs +54 -0
  21. package/dist/esm/localisedUrls/routes.mjs +176 -0
  22. package/dist/esm/localisedUrls/types.mjs +0 -0
  23. package/dist/esm/routerState.mjs +49 -75
  24. package/dist/esm/routerStatePlugin.mjs +37 -10
  25. package/dist/esm-node/localisedUrls/config.mjs +12 -0
  26. package/dist/esm-node/localisedUrls/index.mjs +9 -0
  27. package/dist/esm-node/localisedUrls/normalise.mjs +38 -0
  28. package/dist/esm-node/localisedUrls/pathname.mjs +25 -0
  29. package/dist/esm-node/localisedUrls/patterns.mjs +153 -0
  30. package/dist/esm-node/localisedUrls/redirect.mjs +54 -0
  31. package/dist/esm-node/localisedUrls/resolve.mjs +38 -0
  32. package/dist/esm-node/localisedUrls/routeIdentity.mjs +55 -0
  33. package/dist/esm-node/localisedUrls/routes.mjs +177 -0
  34. package/dist/esm-node/localisedUrls/types.mjs +1 -0
  35. package/dist/esm-node/routerState.mjs +49 -75
  36. package/dist/esm-node/routerStatePlugin.mjs +37 -10
  37. package/dist/types/localisedUrls/config.d.ts +9 -0
  38. package/dist/types/localisedUrls/index.d.ts +10 -0
  39. package/dist/types/localisedUrls/normalise.d.ts +10 -0
  40. package/dist/types/localisedUrls/pathname.d.ts +4 -0
  41. package/dist/types/localisedUrls/patterns.d.ts +11 -0
  42. package/dist/types/localisedUrls/redirect.d.ts +19 -0
  43. package/dist/types/localisedUrls/resolve.d.ts +7 -0
  44. package/dist/types/localisedUrls/routeIdentity.d.ts +22 -0
  45. package/dist/types/localisedUrls/routes.d.ts +3 -0
  46. package/dist/types/localisedUrls/types.d.ts +14 -0
  47. package/dist/types/request-policy/types.d.ts +1 -1
  48. package/dist/types/routeHydration.d.ts +2 -2
  49. package/dist/types/routerState.d.ts +5 -6
  50. package/dist/types/routerStateTypes.d.ts +47 -17
  51. package/package.json +24 -12
  52. package/src/localisedUrls/config.ts +18 -0
  53. package/src/localisedUrls/index.ts +25 -0
  54. package/src/localisedUrls/normalise.ts +62 -0
  55. package/src/localisedUrls/pathname.ts +60 -0
  56. package/src/localisedUrls/patterns.ts +283 -0
  57. package/src/localisedUrls/redirect.ts +107 -0
  58. package/src/localisedUrls/resolve.ts +106 -0
  59. package/src/localisedUrls/routeIdentity.ts +83 -0
  60. package/src/localisedUrls/routes.ts +451 -0
  61. package/src/localisedUrls/types.ts +18 -0
  62. package/src/request-policy/types.ts +1 -1
  63. package/src/routeHydration.ts +2 -2
  64. package/src/routerState.ts +52 -122
  65. package/src/routerStatePlugin.ts +49 -10
  66. package/src/routerStateTypes.ts +47 -17
  67. package/tests/localisedUrls.test.ts +560 -0
  68. package/tests/routerState.test.ts +7 -8
@@ -0,0 +1,49 @@
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
+ });
@@ -0,0 +1,95 @@
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
+ createLocalisedRouteRewrite: ()=>external_routeIdentity_js_namespaceObject.createLocalisedRouteRewrite,
36
+ isDefaultLocaleRedirectSkipPath: ()=>external_redirect_js_namespaceObject.isDefaultLocaleRedirectSkipPath,
37
+ localiseTargetPathname: ()=>external_pathname_js_namespaceObject.localiseTargetPathname,
38
+ matchPathPattern: ()=>external_patterns_js_namespaceObject.matchPathPattern,
39
+ matchesPathPrefix: ()=>external_redirect_js_namespaceObject.matchesPathPrefix,
40
+ normalisePathPattern: ()=>external_normalise_js_namespaceObject.normalisePathPattern,
41
+ normalisePathname: ()=>external_normalise_js_namespaceObject.normalisePathname,
42
+ resolveCanonicalLocalisedPath: ()=>external_resolve_js_namespaceObject.resolveCanonicalLocalisedPath,
43
+ resolveLocalisedPath: ()=>external_resolve_js_namespaceObject.resolveLocalisedPath,
44
+ resolveLocalisedUrlsConfig: ()=>external_config_js_namespaceObject.resolveLocalisedUrlsConfig,
45
+ shouldSkipLocaleRedirect: ()=>external_redirect_js_namespaceObject.shouldSkipLocaleRedirect,
46
+ stripLanguagePrefix: ()=>external_pathname_js_namespaceObject.stripLanguagePrefix,
47
+ validateLocalisedUrls: ()=>external_routes_js_namespaceObject.validateLocalisedUrls
48
+ });
49
+ const external_config_js_namespaceObject = require("./config.js");
50
+ const external_normalise_js_namespaceObject = require("./normalise.js");
51
+ const external_pathname_js_namespaceObject = require("./pathname.js");
52
+ const external_patterns_js_namespaceObject = require("./patterns.js");
53
+ const external_redirect_js_namespaceObject = require("./redirect.js");
54
+ const external_resolve_js_namespaceObject = require("./resolve.js");
55
+ const external_routeIdentity_js_namespaceObject = require("./routeIdentity.js");
56
+ const external_routes_js_namespaceObject = require("./routes.js");
57
+ exports.DEFAULT_LOCALE_REDIRECT_SKIP_RULES = __webpack_exports__.DEFAULT_LOCALE_REDIRECT_SKIP_RULES;
58
+ exports.applyLocalisedUrlsToRoutes = __webpack_exports__.applyLocalisedUrlsToRoutes;
59
+ exports.buildPathFromPattern = __webpack_exports__.buildPathFromPattern;
60
+ exports.canonicalTargetPathname = __webpack_exports__.canonicalTargetPathname;
61
+ exports.createLocalisedRouteRewrite = __webpack_exports__.createLocalisedRouteRewrite;
62
+ exports.isDefaultLocaleRedirectSkipPath = __webpack_exports__.isDefaultLocaleRedirectSkipPath;
63
+ exports.localiseTargetPathname = __webpack_exports__.localiseTargetPathname;
64
+ exports.matchPathPattern = __webpack_exports__.matchPathPattern;
65
+ exports.matchesPathPrefix = __webpack_exports__.matchesPathPrefix;
66
+ exports.normalisePathPattern = __webpack_exports__.normalisePathPattern;
67
+ exports.normalisePathname = __webpack_exports__.normalisePathname;
68
+ exports.resolveCanonicalLocalisedPath = __webpack_exports__.resolveCanonicalLocalisedPath;
69
+ exports.resolveLocalisedPath = __webpack_exports__.resolveLocalisedPath;
70
+ exports.resolveLocalisedUrlsConfig = __webpack_exports__.resolveLocalisedUrlsConfig;
71
+ exports.shouldSkipLocaleRedirect = __webpack_exports__.shouldSkipLocaleRedirect;
72
+ exports.stripLanguagePrefix = __webpack_exports__.stripLanguagePrefix;
73
+ exports.validateLocalisedUrls = __webpack_exports__.validateLocalisedUrls;
74
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
75
+ "DEFAULT_LOCALE_REDIRECT_SKIP_RULES",
76
+ "applyLocalisedUrlsToRoutes",
77
+ "buildPathFromPattern",
78
+ "canonicalTargetPathname",
79
+ "createLocalisedRouteRewrite",
80
+ "isDefaultLocaleRedirectSkipPath",
81
+ "localiseTargetPathname",
82
+ "matchPathPattern",
83
+ "matchesPathPrefix",
84
+ "normalisePathPattern",
85
+ "normalisePathname",
86
+ "resolveCanonicalLocalisedPath",
87
+ "resolveLocalisedPath",
88
+ "resolveLocalisedUrlsConfig",
89
+ "shouldSkipLocaleRedirect",
90
+ "stripLanguagePrefix",
91
+ "validateLocalisedUrls"
92
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
93
+ Object.defineProperty(exports, '__esModule', {
94
+ value: true
95
+ });
@@ -0,0 +1,87 @@
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
+ });
@@ -0,0 +1,68 @@
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
+ canonicalTargetPathname: ()=>canonicalTargetPathname,
32
+ localiseTargetPathname: ()=>localiseTargetPathname,
33
+ stripLanguagePrefix: ()=>stripLanguagePrefix
34
+ });
35
+ const external_config_js_namespaceObject = require("./config.js");
36
+ const external_resolve_js_namespaceObject = require("./resolve.js");
37
+ const stripLanguagePrefix = (pathname, languages)=>{
38
+ const segments = pathname.split('/').filter(Boolean);
39
+ const firstSegment = segments[0]?.toLowerCase();
40
+ if (firstSegment && languages.some((language)=>language.toLowerCase() === firstSegment)) return `/${segments.slice(1).join('/')}`;
41
+ return pathname || '/';
42
+ };
43
+ const localiseTargetPathname = (pathname, language, languages, localisedUrls)=>{
44
+ const pathWithoutLanguage = stripLanguagePrefix(pathname, languages);
45
+ const localisedUrlsConfig = (0, external_config_js_namespaceObject.resolveLocalisedUrlsConfig)(localisedUrls);
46
+ const resolvedPath = localisedUrlsConfig.enabled ? (0, external_resolve_js_namespaceObject.resolveLocalisedPath)(pathWithoutLanguage, language, languages, localisedUrlsConfig.map) : pathWithoutLanguage;
47
+ const resolvedSegments = resolvedPath.split('/').filter(Boolean);
48
+ return `/${[
49
+ language,
50
+ ...resolvedSegments
51
+ ].join('/')}`;
52
+ };
53
+ const canonicalTargetPathname = (pathname, languages, localisedUrls)=>{
54
+ const pathWithoutLanguage = stripLanguagePrefix(pathname, languages);
55
+ const localisedUrlsConfig = (0, external_config_js_namespaceObject.resolveLocalisedUrlsConfig)(localisedUrls);
56
+ return localisedUrlsConfig.enabled ? (0, external_resolve_js_namespaceObject.resolveCanonicalLocalisedPath)(pathWithoutLanguage, languages, localisedUrlsConfig.map) : pathWithoutLanguage;
57
+ };
58
+ exports.canonicalTargetPathname = __webpack_exports__.canonicalTargetPathname;
59
+ exports.localiseTargetPathname = __webpack_exports__.localiseTargetPathname;
60
+ exports.stripLanguagePrefix = __webpack_exports__.stripLanguagePrefix;
61
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
62
+ "canonicalTargetPathname",
63
+ "localiseTargetPathname",
64
+ "stripLanguagePrefix"
65
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
66
+ Object.defineProperty(exports, '__esModule', {
67
+ value: true
68
+ });
@@ -0,0 +1,214 @@
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
+ buildPathFromPattern: ()=>buildPathFromPattern,
32
+ doPathPatternsOverlap: ()=>doPathPatternsOverlap,
33
+ getOrderedPathParamSignature: ()=>getOrderedPathParamSignature,
34
+ getPathParamSignature: ()=>getPathParamSignature,
35
+ getPathPatternValidationIssue: ()=>getPathPatternValidationIssue,
36
+ getPhysicalPathPattern: ()=>getPhysicalPathPattern,
37
+ haveEqualPatternSpecificity: ()=>haveEqualPatternSpecificity,
38
+ matchPathPattern: ()=>matchPathPattern,
39
+ sortPatternsBySpecificity: ()=>sortPatternsBySpecificity
40
+ });
41
+ const external_normalise_js_namespaceObject = require("./normalise.js");
42
+ const escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
43
+ const getParamName = (segment)=>segment.slice(1).replace(/\?$/, '');
44
+ const getOrderedPathParamSignature = (pattern)=>(0, external_normalise_js_namespaceObject.normalisePathPattern)(pattern).split('/').filter(Boolean).flatMap((segment)=>{
45
+ if ('*' === segment) return [
46
+ '*'
47
+ ];
48
+ if (!segment.startsWith(':')) return [];
49
+ return [
50
+ `:${getParamName(segment)}${segment.endsWith('?') ? '?' : ''}`
51
+ ];
52
+ });
53
+ const getPathParamSignature = (pattern)=>getOrderedPathParamSignature(pattern).sort((left, right)=>left < right ? -1 : left > right ? 1 : 0);
54
+ const getPathPatternValidationIssue = (pattern)=>{
55
+ const segments = (0, external_normalise_js_namespaceObject.normalisePathPattern)(pattern).split('/').filter(Boolean);
56
+ const seenParams = new Set();
57
+ for (const [index, segment] of segments.entries()){
58
+ if ('*' === segment) {
59
+ if (index !== segments.length - 1) return 'splat parameter "*" must be the final segment';
60
+ if (seenParams.has('*')) return 'duplicate splat parameter "*"';
61
+ seenParams.add('*');
62
+ continue;
63
+ }
64
+ if (!segment.startsWith(':')) continue;
65
+ const paramName = getParamName(segment);
66
+ if (seenParams.has(paramName)) return `duplicate path parameter ":${paramName}"`;
67
+ seenParams.add(paramName);
68
+ }
69
+ };
70
+ const getPhysicalPathPattern = (pattern)=>{
71
+ const segments = (0, external_normalise_js_namespaceObject.normalisePathPattern)(pattern).split('/').filter(Boolean);
72
+ const physicalSegments = segments.map((segment)=>{
73
+ if ('*' === segment) return '*';
74
+ if (segment.startsWith(':')) return segment.endsWith('?') ? ':param?' : ':param';
75
+ return segment;
76
+ });
77
+ return `/${physicalSegments.join('/')}`;
78
+ };
79
+ const compiledPathPatternCache = new Map();
80
+ const compilePathPattern = (pattern)=>{
81
+ const normalizedPattern = (0, external_normalise_js_namespaceObject.normalisePathPattern)(pattern);
82
+ const cached = compiledPathPatternCache.get(normalizedPattern);
83
+ if (cached) return cached;
84
+ const names = [];
85
+ const segments = normalizedPattern.split('/').filter(Boolean);
86
+ const source = segments.map((segment)=>{
87
+ if (segment.startsWith(':')) {
88
+ names.push(getParamName(segment));
89
+ const paramPattern = '([^/]+)';
90
+ return segment.endsWith('?') ? `(?:/${paramPattern})?` : `/${paramPattern}`;
91
+ }
92
+ if ('*' === segment) {
93
+ names.push('*');
94
+ return '(?:/(.*))?';
95
+ }
96
+ return `/${escapeRegExp(segment)}`;
97
+ }).join('');
98
+ const compiled = {
99
+ names,
100
+ regexp: new RegExp(`^${source || '/'}$`)
101
+ };
102
+ compiledPathPatternCache.set(normalizedPattern, compiled);
103
+ return compiled;
104
+ };
105
+ const getPatternSpecificity = (pattern)=>{
106
+ const segments = (0, external_normalise_js_namespaceObject.normalisePathPattern)(pattern).split('/').filter(Boolean);
107
+ let staticSegments = 0;
108
+ let dynamicSegments = 0;
109
+ let optionalSegments = 0;
110
+ let splatSegments = 0;
111
+ for (const segment of segments)if ('*' === segment) splatSegments++;
112
+ else if (segment.startsWith(':')) {
113
+ dynamicSegments++;
114
+ if (segment.endsWith('?')) optionalSegments++;
115
+ } else staticSegments++;
116
+ return {
117
+ staticSegments,
118
+ dynamicSegments,
119
+ optionalSegments,
120
+ splatSegments,
121
+ totalSegments: segments.length
122
+ };
123
+ };
124
+ const comparePatternSpecificity = (left, right)=>{
125
+ const a = getPatternSpecificity(left);
126
+ const b = getPatternSpecificity(right);
127
+ return b.staticSegments - a.staticSegments || a.splatSegments - b.splatSegments || a.optionalSegments - b.optionalSegments || b.totalSegments - a.totalSegments || a.dynamicSegments - b.dynamicSegments;
128
+ };
129
+ const haveEqualPatternSpecificity = (left, right)=>0 === comparePatternSpecificity(left, right);
130
+ const doPathPatternsOverlap = (left, right)=>{
131
+ const leftSegments = (0, external_normalise_js_namespaceObject.normalisePathPattern)(left).split('/').filter(Boolean);
132
+ const rightSegments = (0, external_normalise_js_namespaceObject.normalisePathPattern)(right).split('/').filter(Boolean);
133
+ if (leftSegments.length !== rightSegments.length) return false;
134
+ return leftSegments.every((leftSegment, index)=>{
135
+ const rightSegment = rightSegments[index];
136
+ const leftIsDynamic = '*' === leftSegment || leftSegment.startsWith(':');
137
+ const rightIsDynamic = '*' === rightSegment || rightSegment.startsWith(':');
138
+ return leftIsDynamic || rightIsDynamic || leftSegment === rightSegment;
139
+ });
140
+ };
141
+ const comparePatternNames = (left, right)=>{
142
+ const normalizedLeft = (0, external_normalise_js_namespaceObject.normalisePathPattern)(left);
143
+ const normalizedRight = (0, external_normalise_js_namespaceObject.normalisePathPattern)(right);
144
+ return normalizedLeft < normalizedRight ? -1 : normalizedLeft > normalizedRight ? 1 : 0;
145
+ };
146
+ const sortPatternsBySpecificity = (patterns)=>patterns.map((pattern, index)=>({
147
+ pattern,
148
+ index
149
+ })).sort((left, right)=>comparePatternSpecificity(left.pattern.pattern, right.pattern.pattern) || comparePatternNames(left.pattern.pattern, right.pattern.pattern) || left.index - right.index).map(({ pattern })=>pattern);
150
+ const decodePathParam = (value)=>{
151
+ try {
152
+ return decodeURIComponent(value);
153
+ } catch {
154
+ return null;
155
+ }
156
+ };
157
+ const encodeSplatParam = (value)=>value.split('/').map(encodeURIComponent).join('/');
158
+ const matchPathPattern = (pathname, pattern)=>{
159
+ const { names, regexp } = compilePathPattern(pattern);
160
+ const match = regexp.exec((0, external_normalise_js_namespaceObject.normalisePathname)(pathname));
161
+ if (!match) return null;
162
+ const params = {};
163
+ for(let index = 0; index < names.length; index++){
164
+ const decoded = decodePathParam(match[index + 1] || '');
165
+ if (null === decoded) return null;
166
+ Object.defineProperty(params, names[index], {
167
+ configurable: true,
168
+ enumerable: true,
169
+ value: decoded,
170
+ writable: true
171
+ });
172
+ }
173
+ return params;
174
+ };
175
+ const buildPathFromPattern = (pattern, params)=>{
176
+ const segments = (0, external_normalise_js_namespaceObject.normalisePathPattern)(pattern).split('/').filter(Boolean);
177
+ const path = segments.map((segment)=>{
178
+ if (segment.startsWith(':')) {
179
+ const paramName = getParamName(segment);
180
+ const param = Object.hasOwn(params, paramName) ? params[paramName] : void 0;
181
+ if (void 0 === param || '' === param) {
182
+ if (segment.endsWith('?')) return '';
183
+ throw new Error(`Missing required path parameter "${paramName}" for pattern "${(0, external_normalise_js_namespaceObject.normalisePathPattern)(pattern)}".`);
184
+ }
185
+ return encodeURIComponent(param);
186
+ }
187
+ if ('*' === segment) return encodeSplatParam(params['*'] || '');
188
+ return segment;
189
+ }).filter(Boolean).join('/');
190
+ return `/${path}`;
191
+ };
192
+ exports.buildPathFromPattern = __webpack_exports__.buildPathFromPattern;
193
+ exports.doPathPatternsOverlap = __webpack_exports__.doPathPatternsOverlap;
194
+ exports.getOrderedPathParamSignature = __webpack_exports__.getOrderedPathParamSignature;
195
+ exports.getPathParamSignature = __webpack_exports__.getPathParamSignature;
196
+ exports.getPathPatternValidationIssue = __webpack_exports__.getPathPatternValidationIssue;
197
+ exports.getPhysicalPathPattern = __webpack_exports__.getPhysicalPathPattern;
198
+ exports.haveEqualPatternSpecificity = __webpack_exports__.haveEqualPatternSpecificity;
199
+ exports.matchPathPattern = __webpack_exports__.matchPathPattern;
200
+ exports.sortPatternsBySpecificity = __webpack_exports__.sortPatternsBySpecificity;
201
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
202
+ "buildPathFromPattern",
203
+ "doPathPatternsOverlap",
204
+ "getOrderedPathParamSignature",
205
+ "getPathParamSignature",
206
+ "getPathPatternValidationIssue",
207
+ "getPhysicalPathPattern",
208
+ "haveEqualPatternSpecificity",
209
+ "matchPathPattern",
210
+ "sortPatternsBySpecificity"
211
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
212
+ Object.defineProperty(exports, '__esModule', {
213
+ value: true
214
+ });
@@ -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
+ DEFAULT_LOCALE_REDIRECT_SKIP_RULES: ()=>DEFAULT_LOCALE_REDIRECT_SKIP_RULES,
32
+ isDefaultLocaleRedirectSkipPath: ()=>isDefaultLocaleRedirectSkipPath,
33
+ matchesPathPrefix: ()=>matchesPathPrefix,
34
+ shouldSkipLocaleRedirect: ()=>shouldSkipLocaleRedirect
35
+ });
36
+ const external_normalise_js_namespaceObject = require("./normalise.js");
37
+ const external_pathname_js_namespaceObject = require("./pathname.js");
38
+ const DEFAULT_LOCALE_REDIRECT_SKIP_RULES = [
39
+ {
40
+ type: 'exact',
41
+ path: '/backend-mf-manifest.json'
42
+ },
43
+ {
44
+ type: 'exact',
45
+ path: '/mf-manifest.json'
46
+ },
47
+ {
48
+ type: 'exact',
49
+ path: '/mf-stats.json'
50
+ },
51
+ {
52
+ type: 'pattern',
53
+ path: /^\/(?:backendRemoteEntry(?:\.[a-zA-Z0-9_-]+)?\.cjs|remoteEntry(?:\.[a-zA-Z0-9_-]+)?\.js)$/
54
+ },
55
+ {
56
+ type: 'prefix',
57
+ path: '/static/'
58
+ },
59
+ {
60
+ type: 'prefix',
61
+ path: '/upload/'
62
+ }
63
+ ];
64
+ const stripTrailingSlash = (pathname)=>pathname.length > 1 ? pathname.replace(/\/+$/, '') : pathname;
65
+ const matchesPathPrefix = (pathname, prefix)=>{
66
+ const normalizedPathname = (0, external_normalise_js_namespaceObject.normalisePathname)(pathname);
67
+ const normalizedPrefix = stripTrailingSlash((0, external_normalise_js_namespaceObject.normalisePathname)(prefix));
68
+ return normalizedPathname === normalizedPrefix || normalizedPathname.startsWith(`${normalizedPrefix}/`);
69
+ };
70
+ const matchesSkipRule = (pathname, rule)=>{
71
+ if ('exact' === rule.type) return (0, external_normalise_js_namespaceObject.normalisePathname)(pathname) === (0, external_normalise_js_namespaceObject.normalisePathname)(rule.path);
72
+ if ('pattern' === rule.type) return rule.path.test((0, external_normalise_js_namespaceObject.normalisePathname)(pathname));
73
+ return matchesPathPrefix(pathname, rule.path);
74
+ };
75
+ const isDefaultLocaleRedirectSkipPath = (pathname, languages = [])=>{
76
+ const normalizedPathname = (0, external_normalise_js_namespaceObject.normalisePathname)(pathname);
77
+ const pathWithoutLanguage = (0, external_pathname_js_namespaceObject.stripLanguagePrefix)(normalizedPathname, languages);
78
+ return DEFAULT_LOCALE_REDIRECT_SKIP_RULES.some((rule)=>matchesSkipRule(pathWithoutLanguage, rule));
79
+ };
80
+ const shouldSkipLocaleRedirect = (pathname, languages = [], ignoreRedirectRoutes)=>{
81
+ const normalizedPathname = (0, external_normalise_js_namespaceObject.normalisePathname)(pathname);
82
+ const pathWithoutLanguage = (0, external_pathname_js_namespaceObject.stripLanguagePrefix)(normalizedPathname, languages);
83
+ if (isDefaultLocaleRedirectSkipPath(pathWithoutLanguage)) return true;
84
+ if (!ignoreRedirectRoutes) return false;
85
+ if ('function' == typeof ignoreRedirectRoutes) return ignoreRedirectRoutes(pathWithoutLanguage);
86
+ return ignoreRedirectRoutes.some((pattern)=>matchesPathPrefix(pathWithoutLanguage, pattern));
87
+ };
88
+ exports.DEFAULT_LOCALE_REDIRECT_SKIP_RULES = __webpack_exports__.DEFAULT_LOCALE_REDIRECT_SKIP_RULES;
89
+ exports.isDefaultLocaleRedirectSkipPath = __webpack_exports__.isDefaultLocaleRedirectSkipPath;
90
+ exports.matchesPathPrefix = __webpack_exports__.matchesPathPrefix;
91
+ exports.shouldSkipLocaleRedirect = __webpack_exports__.shouldSkipLocaleRedirect;
92
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
93
+ "DEFAULT_LOCALE_REDIRECT_SKIP_RULES",
94
+ "isDefaultLocaleRedirectSkipPath",
95
+ "matchesPathPrefix",
96
+ "shouldSkipLocaleRedirect"
97
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
98
+ Object.defineProperty(exports, '__esModule', {
99
+ value: true
100
+ });