@jsenv/navi 0.16.2 → 0.16.3
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 +33 -74
- package/dist/jsenv_navi.js.map +3 -3
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -7522,7 +7522,6 @@ setBaseUrl(
|
|
|
7522
7522
|
// Pattern registry for building relationships before routes are created
|
|
7523
7523
|
const patternRegistry = new Map(); // pattern -> patternData
|
|
7524
7524
|
const patternRelationships = new Map(); // pattern -> relationships
|
|
7525
|
-
let patternsRegistered = false;
|
|
7526
7525
|
|
|
7527
7526
|
// Function to detect signals in route patterns and connect them
|
|
7528
7527
|
const detectSignals = (routePattern) => {
|
|
@@ -8433,8 +8432,6 @@ const setupPatterns = (patternDefinitions) => {
|
|
|
8433
8432
|
originalPattern: currentPattern,
|
|
8434
8433
|
});
|
|
8435
8434
|
}
|
|
8436
|
-
|
|
8437
|
-
patternsRegistered = true;
|
|
8438
8435
|
};
|
|
8439
8436
|
|
|
8440
8437
|
/**
|
|
@@ -8444,25 +8441,12 @@ const getPatternData = (urlPatternRaw) => {
|
|
|
8444
8441
|
return patternRegistry.get(urlPatternRaw);
|
|
8445
8442
|
};
|
|
8446
8443
|
|
|
8447
|
-
/**
|
|
8448
|
-
* Get pattern relationships for route creation
|
|
8449
|
-
*/
|
|
8450
|
-
const getPatternRelationships = () => {
|
|
8451
|
-
if (!patternsRegistered) {
|
|
8452
|
-
throw new Error(
|
|
8453
|
-
"Patterns must be registered before accessing relationships",
|
|
8454
|
-
);
|
|
8455
|
-
}
|
|
8456
|
-
return patternRelationships;
|
|
8457
|
-
};
|
|
8458
|
-
|
|
8459
8444
|
/**
|
|
8460
8445
|
* Clear all registered patterns
|
|
8461
8446
|
*/
|
|
8462
8447
|
const clearPatterns = () => {
|
|
8463
8448
|
patternRegistry.clear();
|
|
8464
8449
|
patternRelationships.clear();
|
|
8465
|
-
patternsRegistered = false;
|
|
8466
8450
|
};
|
|
8467
8451
|
|
|
8468
8452
|
const resolveRouteUrl = (relativeUrl) => {
|
|
@@ -8679,41 +8663,6 @@ const getRoutePrivateProperties = (route) => {
|
|
|
8679
8663
|
return routePrivatePropertiesMap.get(route);
|
|
8680
8664
|
};
|
|
8681
8665
|
|
|
8682
|
-
/**
|
|
8683
|
-
* Get child routes of a given route
|
|
8684
|
-
*/
|
|
8685
|
-
const getRouteChildren = (route) => {
|
|
8686
|
-
const children = [];
|
|
8687
|
-
const routePrivateProperties = getRoutePrivateProperties(route);
|
|
8688
|
-
if (!routePrivateProperties) {
|
|
8689
|
-
return children;
|
|
8690
|
-
}
|
|
8691
|
-
|
|
8692
|
-
const { originalPattern } = routePrivateProperties;
|
|
8693
|
-
const relationships = getPatternRelationships();
|
|
8694
|
-
const relationshipData = relationships.get(originalPattern);
|
|
8695
|
-
|
|
8696
|
-
if (!relationshipData || !relationshipData.children) {
|
|
8697
|
-
return children;
|
|
8698
|
-
}
|
|
8699
|
-
|
|
8700
|
-
// Find child routes
|
|
8701
|
-
for (const childPattern of relationshipData.children) {
|
|
8702
|
-
for (const otherRoute of routeSet) {
|
|
8703
|
-
const otherRoutePrivateProperties = getRoutePrivateProperties(otherRoute);
|
|
8704
|
-
if (
|
|
8705
|
-
otherRoutePrivateProperties &&
|
|
8706
|
-
otherRoutePrivateProperties.originalPattern === childPattern
|
|
8707
|
-
) {
|
|
8708
|
-
children.push(otherRoute);
|
|
8709
|
-
break;
|
|
8710
|
-
}
|
|
8711
|
-
}
|
|
8712
|
-
}
|
|
8713
|
-
|
|
8714
|
-
return children;
|
|
8715
|
-
};
|
|
8716
|
-
|
|
8717
8666
|
const registerRoute = (routePattern) => {
|
|
8718
8667
|
const urlPatternRaw = routePattern.originalPattern;
|
|
8719
8668
|
const patternData = getPatternData(urlPatternRaw);
|
|
@@ -8866,38 +8815,48 @@ const registerRoute = (routePattern) => {
|
|
|
8866
8815
|
return null;
|
|
8867
8816
|
}
|
|
8868
8817
|
|
|
8869
|
-
//
|
|
8870
|
-
|
|
8871
|
-
let mostSpecificRoute;
|
|
8818
|
+
// Find all matching routes and update their actions, then delegate to most specific
|
|
8819
|
+
const allMatchingRoutes = Array.from(routeSet).filter((r) => r.matching);
|
|
8872
8820
|
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
const currentRoutePrivateProperties =
|
|
8883
|
-
getRoutePrivateProperties(currentRoute);
|
|
8884
|
-
if (currentRoutePrivateProperties) {
|
|
8885
|
-
const { routePattern: currentRoutePattern } =
|
|
8886
|
-
currentRoutePrivateProperties;
|
|
8887
|
-
const currentResolvedParams = currentRoutePattern.resolveParams();
|
|
8821
|
+
// Update action params on all matching routes
|
|
8822
|
+
for (const matchingRoute of allMatchingRoutes) {
|
|
8823
|
+
if (matchingRoute.action) {
|
|
8824
|
+
const matchingRoutePrivateProperties =
|
|
8825
|
+
getRoutePrivateProperties(matchingRoute);
|
|
8826
|
+
if (matchingRoutePrivateProperties) {
|
|
8827
|
+
const { routePattern: matchingRoutePattern } =
|
|
8828
|
+
matchingRoutePrivateProperties;
|
|
8829
|
+
const currentResolvedParams = matchingRoutePattern.resolveParams();
|
|
8888
8830
|
const updatedActionParams = {
|
|
8889
8831
|
...currentResolvedParams,
|
|
8890
8832
|
...newParams,
|
|
8891
8833
|
};
|
|
8892
|
-
|
|
8834
|
+
matchingRoute.action.replaceParams(updatedActionParams);
|
|
8893
8835
|
}
|
|
8894
8836
|
}
|
|
8837
|
+
}
|
|
8895
8838
|
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
|
|
8839
|
+
// Find the most specific route (the one with the longest pattern path)
|
|
8840
|
+
let mostSpecificRoute = route;
|
|
8841
|
+
let maxSegments = route.pattern.split("/").filter((s) => s !== "").length;
|
|
8842
|
+
|
|
8843
|
+
for (const matchingRoute of allMatchingRoutes) {
|
|
8844
|
+
const segments = matchingRoute.pattern
|
|
8845
|
+
.split("/")
|
|
8846
|
+
.filter((s) => s !== "").length;
|
|
8847
|
+
if (segments > maxSegments) {
|
|
8848
|
+
maxSegments = segments;
|
|
8849
|
+
mostSpecificRoute = matchingRoute;
|
|
8850
|
+
}
|
|
8851
|
+
}
|
|
8852
|
+
|
|
8853
|
+
// If we found a more specific route, delegate to it; otherwise handle it ourselves
|
|
8854
|
+
if (mostSpecificRoute !== route) {
|
|
8855
|
+
return mostSpecificRoute.redirectTo(newParams);
|
|
8899
8856
|
}
|
|
8900
|
-
|
|
8857
|
+
|
|
8858
|
+
// This route is the most specific, handle the redirect ourselves
|
|
8859
|
+
return route.redirectTo(newParams);
|
|
8901
8860
|
};
|
|
8902
8861
|
route.buildRelativeUrl = (params) => {
|
|
8903
8862
|
// buildMostPreciseUrl now handles parameter resolution internally
|