@jsenv/navi 0.16.28 → 0.16.29
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 +60 -19
- package/dist/jsenv_navi.js.map +3 -3
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -10373,19 +10373,7 @@ const updateRoutes = (
|
|
|
10373
10373
|
const params = routePrivateProperties.rawParamsSignal.value;
|
|
10374
10374
|
const urlParamValue = params[paramName];
|
|
10375
10375
|
|
|
10376
|
-
if (newMatching) {
|
|
10377
|
-
// When route matches, sync signal with URL parameter value
|
|
10378
|
-
// This ensures URL is the source of truth
|
|
10379
|
-
const currentValue = stateSignal.peek();
|
|
10380
|
-
if (currentValue !== urlParamValue) {
|
|
10381
|
-
if (debug) {
|
|
10382
|
-
console.debug(
|
|
10383
|
-
`[route] Route matching: setting ${paramName} signal to URL value: ${urlParamValue}`,
|
|
10384
|
-
);
|
|
10385
|
-
}
|
|
10386
|
-
stateSignal.value = urlParamValue;
|
|
10387
|
-
}
|
|
10388
|
-
} else {
|
|
10376
|
+
if (!newMatching) {
|
|
10389
10377
|
// Route doesn't match - check if any matching route extracts this parameter
|
|
10390
10378
|
let parameterExtractedByMatchingRoute = false;
|
|
10391
10379
|
let matchingRouteInSameFamily = false;
|
|
@@ -10488,7 +10476,39 @@ const updateRoutes = (
|
|
|
10488
10476
|
);
|
|
10489
10477
|
}
|
|
10490
10478
|
}
|
|
10479
|
+
continue;
|
|
10480
|
+
}
|
|
10481
|
+
|
|
10482
|
+
// URL -> Signal sync: When route matches, ensure signal matches URL state
|
|
10483
|
+
// URL is the source of truth for explicit parameters
|
|
10484
|
+
const value = stateSignal.peek();
|
|
10485
|
+
if (urlParamValue === undefined) {
|
|
10486
|
+
// No URL parameter - reset signal to its current default value
|
|
10487
|
+
// (handles both static fallback and dynamic default cases)
|
|
10488
|
+
const defaultValue = options.getDefaultValue();
|
|
10489
|
+
if (value === defaultValue) {
|
|
10490
|
+
// Signal already has correct default value, no sync needed
|
|
10491
|
+
continue;
|
|
10492
|
+
}
|
|
10493
|
+
if (debug) {
|
|
10494
|
+
console.debug(
|
|
10495
|
+
`[route] URL->Signal: ${paramName} not in URL, reset signal to default (${defaultValue})`,
|
|
10496
|
+
);
|
|
10497
|
+
}
|
|
10498
|
+
stateSignal.value = defaultValue;
|
|
10499
|
+
continue;
|
|
10500
|
+
}
|
|
10501
|
+
if (urlParamValue === value) {
|
|
10502
|
+
// Values already match, no sync needed
|
|
10503
|
+
continue;
|
|
10504
|
+
}
|
|
10505
|
+
if (debug) {
|
|
10506
|
+
console.debug(
|
|
10507
|
+
`[route] URL->Signal: ${paramName}=${urlParamValue} in url, sync signal with url`,
|
|
10508
|
+
);
|
|
10491
10509
|
}
|
|
10510
|
+
stateSignal.value = urlParamValue;
|
|
10511
|
+
continue;
|
|
10492
10512
|
}
|
|
10493
10513
|
}
|
|
10494
10514
|
});
|
|
@@ -10687,28 +10707,49 @@ const registerRoute = (routePattern) => {
|
|
|
10687
10707
|
|
|
10688
10708
|
if (debug) {
|
|
10689
10709
|
console.debug(
|
|
10690
|
-
`[route] connecting param "${paramName}" to signal`,
|
|
10710
|
+
`[route] connecting url param "${paramName}" to signal`,
|
|
10691
10711
|
stateSignal,
|
|
10692
10712
|
);
|
|
10693
10713
|
}
|
|
10694
10714
|
|
|
10695
10715
|
// URL -> Signal synchronization now handled in updateRoutes() to eliminate circular dependency
|
|
10696
10716
|
|
|
10697
|
-
// Signal -> URL
|
|
10717
|
+
// Signal -> URL sync: When signal changes, update URL to reflect meaningful state
|
|
10718
|
+
// Only sync non-default values to keep URLs clean (static fallbacks stay invisible)
|
|
10698
10719
|
effect(() => {
|
|
10699
10720
|
const value = stateSignal.value;
|
|
10700
10721
|
const params = rawParamsSignal.value;
|
|
10701
10722
|
const urlParamValue = params[paramName];
|
|
10702
10723
|
const matching = matchingSignal.value;
|
|
10703
10724
|
|
|
10704
|
-
if (!matching
|
|
10725
|
+
if (!matching) {
|
|
10726
|
+
// Route not matching, no URL sync needed
|
|
10727
|
+
return;
|
|
10728
|
+
}
|
|
10729
|
+
if (urlParamValue === undefined) {
|
|
10730
|
+
// No URL parameter exists - check if signal has meaningful value to add
|
|
10731
|
+
const defaultValue = options.getDefaultValue();
|
|
10732
|
+
if (value === defaultValue) {
|
|
10733
|
+
// Signal using default value, keep URL clean (no parameter needed)
|
|
10734
|
+
return;
|
|
10735
|
+
}
|
|
10736
|
+
if (debug) {
|
|
10737
|
+
console.debug(
|
|
10738
|
+
`[route] Signal->URL: ${paramName} adding custom value ${value} to URL (default: ${defaultValue})`,
|
|
10739
|
+
);
|
|
10740
|
+
}
|
|
10741
|
+
route.replaceParams({ [paramName]: value });
|
|
10742
|
+
return;
|
|
10743
|
+
}
|
|
10744
|
+
if (value === urlParamValue) {
|
|
10745
|
+
// Values already match, no sync needed
|
|
10705
10746
|
return;
|
|
10706
10747
|
}
|
|
10707
|
-
|
|
10708
10748
|
if (debug) {
|
|
10709
|
-
console.debug(
|
|
10749
|
+
console.debug(
|
|
10750
|
+
`[route] Signal->URL: ${paramName} updating URL ${urlParamValue} -> ${value}`,
|
|
10751
|
+
);
|
|
10710
10752
|
}
|
|
10711
|
-
|
|
10712
10753
|
route.replaceParams({ [paramName]: value });
|
|
10713
10754
|
});
|
|
10714
10755
|
}
|