@bleedingdev/modern-js-runtime-extensions 3.9.0-ultramodern.8 → 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.
Files changed (117) hide show
  1. package/dist/cjs/{reactContext.js → localisedUrls/config.js} +14 -10
  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 +104 -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/rendererHead.js +18 -5
  12. package/dist/cjs/request-policy/policyCore.js +1 -1
  13. package/dist/cjs/request-policy/transport.js +2 -2
  14. package/dist/cjs/routerState.js +85 -77
  15. package/dist/cjs/routerStatePlugin.js +63 -9
  16. package/dist/esm/localisedUrls/config.mjs +11 -0
  17. package/dist/esm/localisedUrls/index.mjs +8 -0
  18. package/dist/esm/localisedUrls/normalise.mjs +37 -0
  19. package/dist/esm/localisedUrls/pathname.mjs +24 -0
  20. package/dist/esm/localisedUrls/patterns.mjs +152 -0
  21. package/dist/esm/localisedUrls/redirect.mjs +57 -0
  22. package/dist/esm/localisedUrls/resolve.mjs +37 -0
  23. package/dist/esm/localisedUrls/routeIdentity.mjs +54 -0
  24. package/dist/esm/localisedUrls/routes.mjs +176 -0
  25. package/dist/esm/localisedUrls/types.mjs +0 -0
  26. package/dist/esm/rendererHead.mjs +14 -5
  27. package/dist/esm/request-policy/policyCore.mjs +1 -1
  28. package/dist/esm/request-policy/transport.mjs +2 -2
  29. package/dist/esm/routerState.mjs +81 -73
  30. package/dist/esm/routerStatePlugin.mjs +62 -11
  31. package/dist/esm-node/localisedUrls/config.mjs +12 -0
  32. package/dist/esm-node/localisedUrls/index.mjs +9 -0
  33. package/dist/esm-node/localisedUrls/normalise.mjs +38 -0
  34. package/dist/esm-node/localisedUrls/pathname.mjs +25 -0
  35. package/dist/esm-node/localisedUrls/patterns.mjs +153 -0
  36. package/dist/esm-node/localisedUrls/redirect.mjs +58 -0
  37. package/dist/esm-node/localisedUrls/resolve.mjs +38 -0
  38. package/dist/esm-node/localisedUrls/routeIdentity.mjs +55 -0
  39. package/dist/esm-node/localisedUrls/routes.mjs +177 -0
  40. package/dist/esm-node/localisedUrls/types.mjs +1 -0
  41. package/dist/esm-node/rendererHead.mjs +14 -5
  42. package/dist/esm-node/request-policy/policyCore.mjs +1 -1
  43. package/dist/esm-node/request-policy/transport.mjs +2 -2
  44. package/dist/esm-node/routerState.mjs +81 -73
  45. package/dist/esm-node/routerStatePlugin.mjs +62 -11
  46. package/dist/types/helmetCompat.d.ts +1 -1
  47. package/dist/types/localisedUrls/config.d.ts +9 -0
  48. package/dist/types/localisedUrls/index.d.ts +10 -0
  49. package/dist/types/localisedUrls/normalise.d.ts +10 -0
  50. package/dist/types/localisedUrls/pathname.d.ts +4 -0
  51. package/dist/types/localisedUrls/patterns.d.ts +11 -0
  52. package/dist/types/localisedUrls/redirect.d.ts +19 -0
  53. package/dist/types/localisedUrls/resolve.d.ts +7 -0
  54. package/dist/types/localisedUrls/routeIdentity.d.ts +22 -0
  55. package/dist/types/localisedUrls/routes.d.ts +3 -0
  56. package/dist/types/localisedUrls/types.d.ts +14 -0
  57. package/dist/types/rendererHead.d.ts +5 -3
  58. package/dist/types/request-policy/types.d.ts +1 -1
  59. package/dist/types/routeHydration.d.ts +2 -2
  60. package/dist/types/routerProvider.d.ts +1 -3
  61. package/dist/types/routerState.d.ts +11 -6
  62. package/dist/types/routerStatePlugin.d.ts +12 -0
  63. package/dist/types/routerStateTypes.d.ts +47 -17
  64. package/package.json +42 -44
  65. package/src/helmetCompat.ts +1 -1
  66. package/src/localisedUrls/config.ts +18 -0
  67. package/src/localisedUrls/index.ts +25 -0
  68. package/src/localisedUrls/normalise.ts +62 -0
  69. package/src/localisedUrls/pathname.ts +60 -0
  70. package/src/localisedUrls/patterns.ts +283 -0
  71. package/src/localisedUrls/redirect.ts +110 -0
  72. package/src/localisedUrls/resolve.ts +106 -0
  73. package/src/localisedUrls/routeIdentity.ts +83 -0
  74. package/src/localisedUrls/routes.ts +451 -0
  75. package/src/localisedUrls/types.ts +18 -0
  76. package/src/rendererHead.ts +25 -8
  77. package/src/request-policy/policyCore.ts +1 -1
  78. package/src/request-policy/transport.ts +2 -2
  79. package/src/request-policy/types.ts +1 -1
  80. package/src/routeHydration.ts +2 -2
  81. package/src/routerProvider.ts +1 -1
  82. package/src/routerState.ts +127 -115
  83. package/src/routerStatePlugin.ts +106 -10
  84. package/src/routerStateTypes.ts +47 -17
  85. package/dist/cjs/buildIdentity.js +0 -73
  86. package/dist/esm/buildIdentity.mjs +0 -35
  87. package/dist/esm/reactContext.mjs +0 -7
  88. package/dist/esm-node/buildIdentity.mjs +0 -36
  89. package/dist/esm-node/reactContext.mjs +0 -8
  90. package/dist/types/buildIdentity.d.ts +0 -37
  91. package/dist/types/reactContext.d.ts +0 -6
  92. package/rslib.config.mts +0 -19
  93. package/rstest.config.mts +0 -38
  94. package/src/buildIdentity.ts +0 -61
  95. package/src/reactContext.ts +0 -16
  96. package/tests/buildIdentity.test.ts +0 -51
  97. package/tests/contextExtensions.test.ts +0 -27
  98. package/tests/headRuntime.test.tsx +0 -229
  99. package/tests/rendererHead.test.ts +0 -187
  100. package/tests/request-policy/browser-policy.test.ts +0 -108
  101. package/tests/request-policy/client-isolation.test.ts +0 -109
  102. package/tests/request-policy/node-policy.test.ts +0 -447
  103. package/tests/request-policy/policyCore.test.ts +0 -129
  104. package/tests/request-policy/requestContext.test.ts +0 -66
  105. package/tests/request-policy/requestFactory.outbound-contract.test.ts +0 -290
  106. package/tests/request-policy/traceparent.test.ts +0 -52
  107. package/tests/request-policy/transport-retry.test.ts +0 -367
  108. package/tests/routeHydration.test.ts +0 -180
  109. package/tests/routerPrefetchPolicy.test.ts +0 -102
  110. package/tests/routerProvider.test.ts +0 -29
  111. package/tests/routerState.test.ts +0 -78
  112. package/tests/routerStatePlugin.test.ts +0 -63
  113. package/tests/runtimeContextProjection.test.ts +0 -83
  114. package/tests/safeFailure.test.ts +0 -136
  115. package/tests/shellStream.test.ts +0 -122
  116. package/tests/workspaceEvents.test.ts +0 -221
  117. package/tsconfig.json +0 -10
@@ -0,0 +1,78 @@
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
+ resolveCanonicalLocalisedPath: ()=>resolveCanonicalLocalisedPath,
32
+ resolveLocalisedPath: ()=>resolveLocalisedPath
33
+ });
34
+ const external_normalise_js_namespaceObject = require("./normalise.js");
35
+ const external_patterns_js_namespaceObject = require("./patterns.js");
36
+ const getCanonicalCandidates = (localisedUrls)=>(0, external_patterns_js_namespaceObject.sortPatternsBySpecificity)(Object.entries(localisedUrls).map(([canonicalPattern, localisedUrlEntry])=>({
37
+ pattern: canonicalPattern,
38
+ canonicalPattern,
39
+ localisedUrlEntry
40
+ })));
41
+ const resolveLocalisedUrlPath = (pathname, languages, localisedUrls, options)=>{
42
+ const normalizedPathname = (0, external_normalise_js_namespaceObject.normalisePathname)(pathname);
43
+ const canonicalCandidates = getCanonicalCandidates(localisedUrls);
44
+ const candidates = (0, external_patterns_js_namespaceObject.sortPatternsBySpecificity)(canonicalCandidates.flatMap(({ canonicalPattern, localisedUrlEntry })=>{
45
+ const targetPattern = 'localised' === options.mode ? localisedUrlEntry[options.targetLanguage] : canonicalPattern;
46
+ if (!targetPattern) return [];
47
+ const sourcePatterns = new Set([
48
+ canonicalPattern,
49
+ ...languages.map((language)=>localisedUrlEntry[language]).filter((sourcePattern)=>Boolean(sourcePattern))
50
+ ]);
51
+ return Array.from(sourcePatterns, (sourcePattern)=>({
52
+ pattern: sourcePattern,
53
+ sourcePattern,
54
+ targetPattern
55
+ }));
56
+ }));
57
+ for (const { sourcePattern, targetPattern } of candidates){
58
+ const params = (0, external_patterns_js_namespaceObject.matchPathPattern)(normalizedPathname, sourcePattern);
59
+ if (params) return (0, external_patterns_js_namespaceObject.buildPathFromPattern)(targetPattern, params);
60
+ }
61
+ return normalizedPathname;
62
+ };
63
+ const resolveLocalisedPath = (pathname, targetLanguage, languages, localisedUrls)=>resolveLocalisedUrlPath(pathname, languages, localisedUrls, {
64
+ mode: 'localised',
65
+ targetLanguage
66
+ });
67
+ const resolveCanonicalLocalisedPath = (pathname, languages, localisedUrls)=>resolveLocalisedUrlPath(pathname, languages, localisedUrls, {
68
+ mode: 'canonical'
69
+ });
70
+ exports.resolveCanonicalLocalisedPath = __webpack_exports__.resolveCanonicalLocalisedPath;
71
+ exports.resolveLocalisedPath = __webpack_exports__.resolveLocalisedPath;
72
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
73
+ "resolveCanonicalLocalisedPath",
74
+ "resolveLocalisedPath"
75
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
76
+ Object.defineProperty(exports, '__esModule', {
77
+ value: true
78
+ });
@@ -0,0 +1,92 @@
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
+ createLocalisedRouteRewrite: ()=>createLocalisedRouteRewrite
32
+ });
33
+ const external_normalise_js_namespaceObject = require("./normalise.js");
34
+ const external_patterns_js_namespaceObject = require("./patterns.js");
35
+ function rewritePath(url, mappings) {
36
+ for (const { from, to } of mappings){
37
+ const params = (0, external_patterns_js_namespaceObject.matchPathPattern)(url.pathname, from);
38
+ if (params) {
39
+ url.pathname = (0, external_patterns_js_namespaceObject.buildPathFromPattern)(to, params);
40
+ break;
41
+ }
42
+ }
43
+ return url;
44
+ }
45
+ function createLocalisedRouteRewrite(routes) {
46
+ const input = [];
47
+ const output = [];
48
+ const visit = (nodes, parent)=>{
49
+ for (const route of nodes){
50
+ const fullPath = (0, external_normalise_js_namespaceObject.normalisePathPattern)(`${parent}/${route.path ?? ''}`);
51
+ const identity = route.modernLocalisedRoute;
52
+ if (identity?.paths && fullPath.endsWith(identity.canonicalPath)) {
53
+ const prefix = fullPath.slice(0, -identity.canonicalPath.length);
54
+ const hasLocale = prefix.split('/').some((segment)=>/^:(?:lang|locale|language)\??$/.test(segment));
55
+ for (const [language, localisedPath] of Object.entries(identity.paths)){
56
+ const localePrefix = prefix.split('/').map((segment)=>/^:(?:lang|locale|language)\??$/.test(segment) ? language : segment).join('/');
57
+ const canonical = (0, external_normalise_js_namespaceObject.normalisePathPattern)(`${localePrefix}/${identity.canonicalPath}`);
58
+ const localised = (0, external_normalise_js_namespaceObject.normalisePathPattern)(`${localePrefix}/${localisedPath}`);
59
+ if (canonical !== localised) {
60
+ input.push({
61
+ from: localised,
62
+ to: canonical
63
+ });
64
+ if (hasLocale) output.push({
65
+ from: canonical,
66
+ to: localised
67
+ });
68
+ }
69
+ }
70
+ }
71
+ if (route.children) visit(route.children, fullPath);
72
+ }
73
+ };
74
+ visit(routes, '');
75
+ if (0 === input.length) return;
76
+ const specificity = (pattern)=>pattern.split('/').filter((segment)=>segment && !segment.startsWith(':') && '*' !== segment).length;
77
+ for (const mappings of [
78
+ input,
79
+ output
80
+ ])mappings.sort((a, b)=>specificity(b.from) - specificity(a.from));
81
+ return {
82
+ input: ({ url })=>rewritePath(url, input),
83
+ output: ({ url })=>rewritePath(url, output)
84
+ };
85
+ }
86
+ exports.createLocalisedRouteRewrite = __webpack_exports__.createLocalisedRouteRewrite;
87
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
88
+ "createLocalisedRouteRewrite"
89
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
90
+ Object.defineProperty(exports, '__esModule', {
91
+ value: true
92
+ });
@@ -0,0 +1,217 @@
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
+ applyLocalisedUrlsToRoutes: ()=>applyLocalisedUrlsToRoutes,
32
+ validateLocalisedUrls: ()=>validateLocalisedUrls
33
+ });
34
+ const external_normalise_js_namespaceObject = require("./normalise.js");
35
+ const external_patterns_js_namespaceObject = require("./patterns.js");
36
+ const isLocalisableRoutePath = (path)=>{
37
+ const pathWithoutLocale = (0, external_normalise_js_namespaceObject.stripLeadingLocaleParam)(path);
38
+ if (!pathWithoutLocale || '/' === pathWithoutLocale || '*' === pathWithoutLocale) return false;
39
+ return true;
40
+ };
41
+ const joinPath = (parentPath, routePath)=>{
42
+ if (!isLocalisableRoutePath(routePath)) return parentPath;
43
+ const segment = (0, external_normalise_js_namespaceObject.normaliseRoutePath)((0, external_normalise_js_namespaceObject.stripLeadingLocaleParam)(routePath) || '');
44
+ return (0, external_normalise_js_namespaceObject.normalisePathPattern)(`${parentPath}/${segment}`);
45
+ };
46
+ const isFrameworkInternalRoutePath = (canonicalPath)=>'/_mf' === canonicalPath || canonicalPath.startsWith('/_mf/');
47
+ const legalRouteIdPart = (value)=>value.replace(/[^a-zA-Z0-9_$-]+/g, '_').replace(/^_+|_+$/g, '') || 'index';
48
+ const formatParamSignature = (signature)=>signature.length > 0 ? signature.join(', ') : '(none)';
49
+ const validateLocalisedUrlPatterns = (languages, localisedUrls)=>{
50
+ const physicalPatterns = new Map();
51
+ const claimedPatterns = [];
52
+ const claimPhysicalPattern = (sourcePattern, canonicalPath, source)=>{
53
+ const physicalPattern = (0, external_patterns_js_namespaceObject.getPhysicalPathPattern)(sourcePattern);
54
+ const existing = physicalPatterns.get(physicalPattern);
55
+ if (existing && existing.canonicalPath !== canonicalPath) throw new Error(`localisedUrls["${existing.canonicalPath}"] ${existing.source} and localisedUrls["${canonicalPath}"] ${source} generate the same physical route pattern "${physicalPattern}". Localised route patterns must identify exactly one canonical route.`);
56
+ const overlapping = claimedPatterns.find((claimed)=>claimed.canonicalPath !== canonicalPath && (0, external_patterns_js_namespaceObject.haveEqualPatternSpecificity)(claimed.pattern, sourcePattern) && (0, external_patterns_js_namespaceObject.doPathPatternsOverlap)(claimed.pattern, sourcePattern));
57
+ if (overlapping) throw new Error(`localisedUrls["${overlapping.canonicalPath}"] ${overlapping.source} pattern "${overlapping.pattern}" and localisedUrls["${canonicalPath}"] ${source} pattern "${sourcePattern}" are equal-specificity overlapping route patterns. Localised route patterns must identify exactly one canonical route.`);
58
+ physicalPatterns.set(physicalPattern, {
59
+ canonicalPath,
60
+ source
61
+ });
62
+ claimedPatterns.push({
63
+ canonicalPath,
64
+ pattern: sourcePattern,
65
+ source
66
+ });
67
+ };
68
+ for (const [canonicalPath, entry] of Object.entries(localisedUrls).sort(([left], [right])=>left < right ? -1 : left > right ? 1 : 0)){
69
+ const canonicalIssue = (0, external_patterns_js_namespaceObject.getPathPatternValidationIssue)(canonicalPath);
70
+ if (canonicalIssue) throw new Error(`localisedUrls["${canonicalPath}"] canonical pattern has ${canonicalIssue}.`);
71
+ const expectedSignature = (0, external_patterns_js_namespaceObject.getPathParamSignature)(canonicalPath);
72
+ const expectedOrderedSignature = (0, external_patterns_js_namespaceObject.getOrderedPathParamSignature)(canonicalPath);
73
+ claimPhysicalPattern(canonicalPath, canonicalPath, 'canonical pattern');
74
+ for (const language of languages){
75
+ const localisedPattern = entry[language];
76
+ if (!localisedPattern) continue;
77
+ const localisedIssue = (0, external_patterns_js_namespaceObject.getPathPatternValidationIssue)(localisedPattern);
78
+ if (localisedIssue) throw new Error(`localisedUrls["${canonicalPath}"].${language} has ${localisedIssue}.`);
79
+ const actualSignature = (0, external_patterns_js_namespaceObject.getPathParamSignature)(localisedPattern);
80
+ if (actualSignature.length !== expectedSignature.length || actualSignature.some((parameter, index)=>parameter !== expectedSignature[index])) throw new Error(`localisedUrls["${canonicalPath}"].${language} must use the same parameter signature as "${canonicalPath}": expected ${formatParamSignature(expectedSignature)}; received ${formatParamSignature(actualSignature)}.`);
81
+ const actualOrderedSignature = (0, external_patterns_js_namespaceObject.getOrderedPathParamSignature)(localisedPattern);
82
+ if (expectedOrderedSignature.some((parameter)=>'*' === parameter || parameter.endsWith('?')) && actualOrderedSignature.some((parameter, index)=>parameter !== expectedOrderedSignature[index])) throw new Error(`localisedUrls["${canonicalPath}"].${language} must keep optional and splat parameters in canonical order: expected ${formatParamSignature(expectedOrderedSignature)}; received ${formatParamSignature(actualOrderedSignature)}.`);
83
+ claimPhysicalPattern(localisedPattern, canonicalPath, `.${language}`);
84
+ }
85
+ }
86
+ };
87
+ const ensureLocalisedUrlsForPath = (canonicalPath, languages, localisedUrls)=>{
88
+ const entry = localisedUrls[canonicalPath];
89
+ if (!entry) throw new Error(`localisedUrls is enabled, but route "${canonicalPath}" does not define localised URLs for languages: ${languages.join(', ')}. Add localisedUrls["${canonicalPath}"] or set localeDetection.localisedUrls to false.`);
90
+ const missingLanguages = languages.filter((language)=>!entry[language]);
91
+ if (missingLanguages.length > 0) throw new Error(`localisedUrls["${canonicalPath}"] is missing languages: ${missingLanguages.join(', ')}. Every configured language must have a localised URL.`);
92
+ return entry;
93
+ };
94
+ const validateLocalisedUrls = (routes, languages, localisedUrls)=>{
95
+ validateLocalisedUrlPatterns(languages, localisedUrls);
96
+ const visit = (route, parentPath)=>{
97
+ const canonicalPath = joinPath(parentPath, route.path);
98
+ if (isLocalisableRoutePath(route.path) && !isFrameworkInternalRoutePath(canonicalPath)) ensureLocalisedUrlsForPath(canonicalPath, languages, localisedUrls);
99
+ if ('children' in route && route.children) route.children.forEach((child)=>visit(child, canonicalPath));
100
+ };
101
+ routes.forEach((route)=>visit(route, ''));
102
+ };
103
+ const getLocalisedRouteIdSuffixes = (paths)=>{
104
+ const usedSuffixes = new Set();
105
+ return paths.map((path, index)=>{
106
+ if (0 === index) return;
107
+ const baseSuffix = legalRouteIdPart(path);
108
+ let suffix = baseSuffix;
109
+ let disambiguator = 2;
110
+ while(usedSuffixes.has(suffix))suffix = `${baseSuffix}_${disambiguator++}`;
111
+ usedSuffixes.add(suffix);
112
+ return suffix;
113
+ });
114
+ };
115
+ const getLocalisedRoutePaths = (canonicalPath, parentLocalisedPaths, languages, entry)=>{
116
+ const paths = languages.map((language)=>{
117
+ const fullPath = (0, external_normalise_js_namespaceObject.normalisePathPattern)(entry[language]);
118
+ const parentPath = (0, external_normalise_js_namespaceObject.normalisePathPattern)(parentLocalisedPaths[language] || '/');
119
+ if ('/' === parentPath) return (0, external_normalise_js_namespaceObject.normaliseRoutePath)(fullPath) || void 0;
120
+ const parentPrefix = `${parentPath}/`;
121
+ if (!fullPath.startsWith(parentPrefix)) throw new Error(`localisedUrls["${canonicalPath}"].${language} must be nested under "${parentPath}" because its parent route is localised there.`);
122
+ return (0, external_normalise_js_namespaceObject.normaliseRoutePath)(fullPath.slice(parentPath.length));
123
+ });
124
+ const uniquePaths = Array.from(new Set(paths.filter(Boolean)));
125
+ return uniquePaths;
126
+ };
127
+ const transformLocalisedRoute = (route, parentCanonicalPath, parentLocalisedPaths, languages, localisedUrls, projection)=>{
128
+ const isSplat = '*' === (0, external_normalise_js_namespaceObject.stripLeadingLocaleParam)(route.path);
129
+ const canonicalPath = isSplat ? (0, external_normalise_js_namespaceObject.normalisePathPattern)(`${parentCanonicalPath}/*`) : joinPath(parentCanonicalPath, route.path);
130
+ const localisedUrlEntry = isLocalisableRoutePath(route.path) && !isFrameworkInternalRoutePath(canonicalPath) ? ensureLocalisedUrlsForPath(canonicalPath, languages, localisedUrls) : void 0;
131
+ const routeLocalisedPaths = localisedUrlEntry ? languages.reduce((acc, language)=>{
132
+ acc[language] = (0, external_normalise_js_namespaceObject.normalisePathPattern)(localisedUrlEntry[language]);
133
+ return acc;
134
+ }, {}) : isSplat ? Object.fromEntries(Object.entries(parentLocalisedPaths).map(([language, path])=>[
135
+ language,
136
+ (0, external_normalise_js_namespaceObject.normalisePathPattern)(`${path}/*`)
137
+ ])) : parentLocalisedPaths;
138
+ const children = 'children' in route && route.children ? route.children.flatMap((child)=>transformLocalisedRoute(child, canonicalPath, routeLocalisedPaths, languages, localisedUrls, projection)) : void 0;
139
+ const baseRoute = {
140
+ ...route,
141
+ ...!isFrameworkInternalRoutePath(canonicalPath) ? {
142
+ modernLocalisedRoute: {
143
+ id: route.id,
144
+ path: route.path,
145
+ canonicalPath,
146
+ paths: localisedUrlEntry ?? (isSplat ? routeLocalisedPaths : void 0)
147
+ }
148
+ } : {},
149
+ ...children ? {
150
+ children
151
+ } : {}
152
+ };
153
+ if (!localisedUrlEntry) return [
154
+ baseRoute
155
+ ];
156
+ const localisedPaths = getLocalisedRoutePaths(canonicalPath, parentLocalisedPaths, languages, localisedUrlEntry);
157
+ if ('canonical' === projection) return [
158
+ baseRoute
159
+ ];
160
+ const leadingLocaleParam = (0, external_normalise_js_namespaceObject.getLeadingLocaleParam)(route.path);
161
+ const routeIdPaths = leadingLocaleParam ? localisedPaths.map((path)=>(0, external_normalise_js_namespaceObject.normaliseRoutePath)(`${leadingLocaleParam}/${path}`)) : localisedPaths;
162
+ const routeIdSuffixes = getLocalisedRouteIdSuffixes(routeIdPaths);
163
+ return localisedPaths.map((localisedPath, index)=>cloneRouteWithLocalisedPath(baseRoute, localisedPath, routeIdSuffixes[index], canonicalPath));
164
+ };
165
+ const suffixRouteIds = (route, suffix)=>{
166
+ const children = 'children' in route && route.children ? route.children.map((child)=>suffixRouteIds(child, suffix)) : void 0;
167
+ return {
168
+ ...route,
169
+ ...route.id ? {
170
+ id: `${route.id}__localised_${suffix}`
171
+ } : {},
172
+ ...children ? {
173
+ children
174
+ } : {}
175
+ };
176
+ };
177
+ const collectRouteIdCounts = (routes, counts = new Map())=>{
178
+ for (const route of routes){
179
+ if (route.id) counts.set(route.id, (counts.get(route.id) ?? 0) + 1);
180
+ if ('children' in route && route.children) collectRouteIdCounts(route.children, counts);
181
+ }
182
+ return counts;
183
+ };
184
+ const validateNoNewRouteIdCollisions = (sourceRoutes, localisedRoutes)=>{
185
+ const sourceCounts = collectRouteIdCounts(sourceRoutes);
186
+ const localisedCounts = collectRouteIdCounts(localisedRoutes);
187
+ for (const [routeId, count] of localisedCounts)if (count > 1 && count > (sourceCounts.get(routeId) ?? 0)) throw new Error(`Localised route expansion generated duplicate route ID "${routeId}". Change the source route ID or localised path so every generated route remains identifiable.`);
188
+ };
189
+ const cloneRouteWithLocalisedPath = (route, path, routeIdSuffix, canonicalPath)=>{
190
+ const leadingLocaleParam = (0, external_normalise_js_namespaceObject.getLeadingLocaleParam)(route.path);
191
+ const localisedPath = leadingLocaleParam ? (0, external_normalise_js_namespaceObject.normaliseRoutePath)(`${leadingLocaleParam}/${path}`) : path;
192
+ const routeWithPath = {
193
+ ...route,
194
+ path: localisedPath
195
+ };
196
+ routeWithPath.modernCanonicalPath = canonicalPath;
197
+ return routeIdSuffix ? suffixRouteIds(routeWithPath, routeIdSuffix) : routeWithPath;
198
+ };
199
+ const applyLocalisedUrlsToRoutes = (routes, languages, localisedUrls, projection = 'physical')=>{
200
+ const rootLocalisedPaths = languages.reduce((acc, language)=>{
201
+ acc[language] = '/';
202
+ return acc;
203
+ }, {});
204
+ validateLocalisedUrls(routes, languages, localisedUrls);
205
+ const localisedRoutes = routes.flatMap((route)=>transformLocalisedRoute(route, '', rootLocalisedPaths, languages, localisedUrls, projection));
206
+ validateNoNewRouteIdCollisions(routes, localisedRoutes);
207
+ return localisedRoutes;
208
+ };
209
+ exports.applyLocalisedUrlsToRoutes = __webpack_exports__.applyLocalisedUrlsToRoutes;
210
+ exports.validateLocalisedUrls = __webpack_exports__.validateLocalisedUrls;
211
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
212
+ "applyLocalisedUrlsToRoutes",
213
+ "validateLocalisedUrls"
214
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
215
+ Object.defineProperty(exports, '__esModule', {
216
+ value: true
217
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -57,8 +57,9 @@ var __webpack_exports__ = {};
57
57
  "createWebHeadMarkerStripper",
58
58
  "default",
59
59
  "finishHeadRender",
60
- "abortHeadRender",
60
+ "LATE_HEAD_MESSAGE",
61
61
  "beginHeadRender",
62
+ "abortHeadRender",
62
63
  "completeHeadRender",
63
64
  "createHeadChunkProcessor",
64
65
  "publishHeadRender",
@@ -71,6 +72,7 @@ var __webpack_exports__ = {};
71
72
  const MARKER_SUFFIX = '"></template>';
72
73
  const RECORD_ID_WIDTH = 12;
73
74
  const MARKER_LENGTH = MARKER_PREFIX.length + 1 + 36 + RECORD_ID_WIDTH + MARKER_SUFFIX.length;
75
+ const LATE_HEAD_MESSAGE = "<Helmet> rendered in a boundary that completed after the shell; head tags dropped. Move it above the Suspense boundary or set server.ssrByEntries[entry].mode to 'string'.";
74
76
  const HEAD_STATE = Symbol('modern.rendererHead');
75
77
  const getState = (context)=>{
76
78
  const headContext = context;
@@ -91,7 +93,12 @@ var __webpack_exports__ = {};
91
93
  transaction.nextRecordId += 1;
92
94
  return token;
93
95
  };
94
- const beginHeadRender = (context)=>{
96
+ const dropLateHead = (transaction)=>{
97
+ if (transaction.lateHeadReported) return;
98
+ transaction.lateHeadReported = true;
99
+ transaction.reportLateHead(LATE_HEAD_MESSAGE);
100
+ };
101
+ const beginHeadRender = (context, reportLateHead)=>{
95
102
  const state = getState(context);
96
103
  state.transaction = {
97
104
  recordsByToken: new Map(),
@@ -100,7 +107,9 @@ var __webpack_exports__ = {};
100
107
  nextRecordId: 0,
101
108
  nonce: globalThis.crypto.randomUUID(),
102
109
  previousRecords: state.publishedRecords,
103
- sealed: false
110
+ sealed: false,
111
+ reportLateHead,
112
+ lateHeadReported: false
104
113
  };
105
114
  state.publish?.([]);
106
115
  };
@@ -111,7 +120,6 @@ var __webpack_exports__ = {};
111
120
  const hadPublisher = void 0 !== state.publish;
112
121
  state.publish = (records)=>publish(records);
113
122
  if (!hadPublisher) state.publish([]);
114
- if (transaction.sealed) return null;
115
123
  const token = createToken(transaction);
116
124
  transaction.recordsByToken.set(token, createRecord());
117
125
  return {
@@ -141,7 +149,9 @@ var __webpack_exports__ = {};
141
149
  const token = html.slice(tokenStart, end);
142
150
  if (transaction.recordsByToken.has(token)) {
143
151
  stripped += html.slice(cursor, start);
144
- if (!transaction.sealed && !transaction.committedTokens.has(token)) {
152
+ if (transaction.sealed) {
153
+ if (!transaction.committedTokens.has(token)) dropLateHead(transaction);
154
+ } else if (!transaction.committedTokens.has(token)) {
145
155
  transaction.committedTokens.add(token);
146
156
  transaction.committedRecords.push(transaction.recordsByToken.get(token));
147
157
  }
@@ -227,6 +237,7 @@ var __webpack_exports__ = {};
227
237
  });
228
238
  };
229
239
  __webpack_require__.d(__webpack_exports__, {}, {
240
+ LATE_HEAD_MESSAGE: LATE_HEAD_MESSAGE,
230
241
  abortHeadRender: abortHeadRender,
231
242
  beginHeadRender: beginHeadRender,
232
243
  collectHeadRecord: collectHeadRecord,
@@ -238,6 +249,7 @@ var __webpack_exports__ = {};
238
249
  publishHeadRender: publishHeadRender
239
250
  });
240
251
  })();
252
+ exports.LATE_HEAD_MESSAGE = __webpack_exports__.LATE_HEAD_MESSAGE;
241
253
  exports.abortHeadRender = __webpack_exports__.abortHeadRender;
242
254
  exports.beginHeadRender = __webpack_exports__.beginHeadRender;
243
255
  exports.collectHeadRecord = __webpack_exports__.collectHeadRecord;
@@ -248,6 +260,7 @@ exports.createWebHeadMarkerStripper = __webpack_exports__.createWebHeadMarkerStr
248
260
  exports.finishHeadRender = __webpack_exports__.finishHeadRender;
249
261
  exports.publishHeadRender = __webpack_exports__.publishHeadRender;
250
262
  for(var __rspack_i in __webpack_exports__)if (-1 === [
263
+ "LATE_HEAD_MESSAGE",
251
264
  "abortHeadRender",
252
265
  "beginHeadRender",
253
266
  "collectHeadRecord",
@@ -81,7 +81,7 @@ const toOrigin = (value)=>{
81
81
  if (!value) return;
82
82
  try {
83
83
  return new URL(value).origin;
84
- } catch (error) {
84
+ } catch {
85
85
  return;
86
86
  }
87
87
  };
@@ -87,7 +87,7 @@ const shouldRetryWithDefaults = (method, statusCode, error, retryableStatusCodes
87
87
  const shouldRetry = (retryOptions, context, retryableStatusCodes)=>{
88
88
  if ('function' == typeof retryOptions?.shouldRetry) try {
89
89
  return retryOptions.shouldRetry(context);
90
- } catch (error) {
90
+ } catch {
91
91
  return false;
92
92
  }
93
93
  return shouldRetryWithDefaults(context.method, context.statusCode, context.error, retryableStatusCodes);
@@ -104,7 +104,7 @@ const emitDegradedEvent = (transport, event)=>{
104
104
  if ('function' != typeof transport?.onDegraded) return;
105
105
  try {
106
106
  transport.onDegraded(event);
107
- } catch (error) {}
107
+ } catch {}
108
108
  };
109
109
  const withTimeout = async (promise, timeoutMs, signalBuilder)=>{
110
110
  if (!timeoutMs || timeoutMs <= 0) {