@jsenv/navi 0.16.34 → 0.16.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsenv_navi.js +68 -5
- package/dist/jsenv_navi.js.map +4 -4
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -8264,6 +8264,57 @@ const createRoutePattern = (pattern) => {
|
|
|
8264
8264
|
}
|
|
8265
8265
|
}
|
|
8266
8266
|
|
|
8267
|
+
// CRITICAL: Block child routes that have literal segments requiring specific parameter values
|
|
8268
|
+
// that aren't available. Only check literal segments that replace parameter positions.
|
|
8269
|
+
// Example: /map/flow/ replaces /:panel/ with "flow", so panel must equal "flow"
|
|
8270
|
+
let hasIncompatibleLiterals = false;
|
|
8271
|
+
let hasMatchingNonDefaultLiterals = false;
|
|
8272
|
+
|
|
8273
|
+
for (let i = 0; i < childPatternObj.pattern.segments.length; i++) {
|
|
8274
|
+
const childSegment = childPatternObj.pattern.segments[i];
|
|
8275
|
+
const parentSegment = parsedPattern.segments[i];
|
|
8276
|
+
|
|
8277
|
+
if (
|
|
8278
|
+
childSegment.type === "literal" &&
|
|
8279
|
+
parentSegment &&
|
|
8280
|
+
parentSegment.type === "param"
|
|
8281
|
+
) {
|
|
8282
|
+
// This literal segment replaces a parameter in the parent
|
|
8283
|
+
const paramName = parentSegment.name;
|
|
8284
|
+
const explicitValue = params[paramName];
|
|
8285
|
+
const connection = connectionMap.get(paramName);
|
|
8286
|
+
const signalValue = connection ? connection.signal.value : undefined;
|
|
8287
|
+
|
|
8288
|
+
// Check if the parameter has the required value
|
|
8289
|
+
if (
|
|
8290
|
+
explicitValue !== childSegment.value &&
|
|
8291
|
+
signalValue !== childSegment.value
|
|
8292
|
+
) {
|
|
8293
|
+
hasIncompatibleLiterals = true;
|
|
8294
|
+
if (DEBUG$2) {
|
|
8295
|
+
console.debug(
|
|
8296
|
+
`[${pattern}] Blocking child route ${childPatternObj.originalPattern} because parameter "${paramName}" must be "${childSegment.value}" but current values are explicit="${explicitValue}" signal="${signalValue}"`,
|
|
8297
|
+
);
|
|
8298
|
+
}
|
|
8299
|
+
break;
|
|
8300
|
+
}
|
|
8301
|
+
|
|
8302
|
+
// Check if this matching literal represents a non-default parameter value
|
|
8303
|
+
// (for forcing child route selection later)
|
|
8304
|
+
if (explicitValue === childSegment.value && connection) {
|
|
8305
|
+
const defaultValue = connection.getDefaultValue();
|
|
8306
|
+
if (explicitValue !== defaultValue) {
|
|
8307
|
+
hasMatchingNonDefaultLiterals = true;
|
|
8308
|
+
}
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
}
|
|
8312
|
+
|
|
8313
|
+
// Block incompatible child routes immediately
|
|
8314
|
+
if (hasIncompatibleLiterals) {
|
|
8315
|
+
return false;
|
|
8316
|
+
}
|
|
8317
|
+
|
|
8267
8318
|
// Check if child has active non-default signal values
|
|
8268
8319
|
let hasActiveParams = false;
|
|
8269
8320
|
const childParams = { ...compatibility.childParams };
|
|
@@ -8335,11 +8386,25 @@ const createRoutePattern = (pattern) => {
|
|
|
8335
8386
|
|
|
8336
8387
|
// Use child route if:
|
|
8337
8388
|
// 1. Child has active non-default parameters, OR
|
|
8338
|
-
// 2. User provided non-default params AND child can be built completely
|
|
8389
|
+
// 2. User provided non-default params AND child can be built completely, OR
|
|
8390
|
+
// 3. User provided params that match child literal segments AND are non-default values
|
|
8339
8391
|
// EXCEPT: Don't use child if parent can produce cleaner URL by omitting defaults
|
|
8340
8392
|
let shouldUse =
|
|
8341
8393
|
hasActiveParams ||
|
|
8342
|
-
(hasNonDefaultProvidedParams && canBuildChildCompletely)
|
|
8394
|
+
(hasNonDefaultProvidedParams && canBuildChildCompletely) ||
|
|
8395
|
+
(hasMatchingNonDefaultLiterals && canBuildChildCompletely);
|
|
8396
|
+
|
|
8397
|
+
if (DEBUG$2) {
|
|
8398
|
+
console.debug(
|
|
8399
|
+
`[${pattern}] shouldUseChildRoute decision for ${childPatternObj.originalPattern}:`,
|
|
8400
|
+
{
|
|
8401
|
+
hasActiveParams,
|
|
8402
|
+
hasNonDefaultProvidedParams,
|
|
8403
|
+
canBuildChildCompletely,
|
|
8404
|
+
shouldUse,
|
|
8405
|
+
},
|
|
8406
|
+
);
|
|
8407
|
+
}
|
|
8343
8408
|
|
|
8344
8409
|
// Optimization: Check if child would include literal segments that represent default values
|
|
8345
8410
|
if (shouldUse) {
|
|
@@ -8716,7 +8781,7 @@ const createRoutePattern = (pattern) => {
|
|
|
8716
8781
|
let finalParams = removeDefaultValues(resolvedParams);
|
|
8717
8782
|
|
|
8718
8783
|
// Step 4: Try descendants - find the deepest descendant that works
|
|
8719
|
-
const childPatternObjs = patternObject.children
|
|
8784
|
+
const childPatternObjs = patternObject.children;
|
|
8720
8785
|
|
|
8721
8786
|
let bestDescendantUrl = null;
|
|
8722
8787
|
for (const childPatternObj of childPatternObjs) {
|
|
@@ -10780,8 +10845,6 @@ const registerRoute = (routePattern) => {
|
|
|
10780
10845
|
if (mostSpecificRoute !== route) {
|
|
10781
10846
|
return mostSpecificRoute.redirectTo(newParams);
|
|
10782
10847
|
}
|
|
10783
|
-
|
|
10784
|
-
// This route is the most specific, handle the redirect ourselves
|
|
10785
10848
|
return route.redirectTo(newParams);
|
|
10786
10849
|
};
|
|
10787
10850
|
route.buildRelativeUrl = (params) => {
|