@xmachines/play-solid-router 1.0.0-beta.5 → 1.0.0-beta.51

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.
@@ -1,75 +0,0 @@
1
- /**
2
- * RouteMap for bidirectional state ID ↔ path mapping
3
- *
4
- * Provides efficient lookup between XMachines state IDs and SolidJS Router paths.
5
- * Supports pattern matching for dynamic routes with parameters.
6
- */
7
- import type { RouteMapping } from "./types.js";
8
- export declare class RouteMap {
9
- private stateToPath;
10
- private pathToState;
11
- /**
12
- * Create a RouteMap with bidirectional mappings
13
- *
14
- * @param mappings - Array of state ID to path mappings
15
- *
16
- * @example
17
- * ```typescript
18
- * const routeMap = new RouteMap([
19
- * { stateId: '#home', path: '/' },
20
- * { stateId: '#profile', path: '/profile/:userId' },
21
- * { stateId: '#settings', path: '/settings/:section?' }
22
- * ]);
23
- * ```
24
- */
25
- constructor(mappings: RouteMapping[]);
26
- /**
27
- * Get path pattern for a state ID
28
- *
29
- * @param stateId - XMachines state ID (e.g., '#profile')
30
- * @returns Path pattern or undefined if not found
31
- *
32
- * @example
33
- * ```typescript
34
- * routeMap.getPath('#profile'); // '/profile/:userId'
35
- * ```
36
- */
37
- getPath(stateId: string): string | undefined;
38
- /**
39
- * Get state ID for a path, with pattern matching support
40
- *
41
- * Performs exact match first, then fuzzy pattern matching for dynamic routes.
42
- * Supports both required (:param) and optional (:param?) parameters.
43
- *
44
- * @param path - Actual URL path (e.g., '/profile/123')
45
- * @returns State ID or undefined if no match found
46
- *
47
- * @example
48
- * ```typescript
49
- * routeMap.getStateIdByPath('/profile/123'); // '#profile'
50
- * routeMap.getStateIdByPath('/settings'); // '#settings'
51
- * routeMap.getStateIdByPath('/settings/account'); // '#settings'
52
- * ```
53
- */
54
- getStateIdByPath(path: string): string | undefined;
55
- /**
56
- * Check if a path matches a pattern
57
- *
58
- * Supports:
59
- * - Required parameters: :param
60
- * - Optional parameters: :param?
61
- *
62
- * @param path - Actual URL path
63
- * @param pattern - Route pattern with :param syntax
64
- * @returns true if path matches pattern
65
- *
66
- * @example
67
- * ```typescript
68
- * matchesPattern('/profile/123', '/profile/:userId'); // true
69
- * matchesPattern('/settings', '/settings/:section?'); // true
70
- * matchesPattern('/settings/account', '/settings/:section?'); // true
71
- * ```
72
- */
73
- private matchesPattern;
74
- }
75
- //# sourceMappingURL=route-map.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"route-map.d.ts","sourceRoot":"","sources":["../src/route-map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,qBAAa,QAAQ;IACpB,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,WAAW,CAA6B;IAEhD;;;;;;;;;;;;;OAaG;gBACS,QAAQ,EAAE,YAAY,EAAE;IAOpC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI5C;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAmBlD;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,cAAc;CAetB"}
package/dist/route-map.js DELETED
@@ -1,107 +0,0 @@
1
- /**
2
- * RouteMap for bidirectional state ID ↔ path mapping
3
- *
4
- * Provides efficient lookup between XMachines state IDs and SolidJS Router paths.
5
- * Supports pattern matching for dynamic routes with parameters.
6
- */
7
- export class RouteMap {
8
- stateToPath = new Map();
9
- pathToState = new Map();
10
- /**
11
- * Create a RouteMap with bidirectional mappings
12
- *
13
- * @param mappings - Array of state ID to path mappings
14
- *
15
- * @example
16
- * ```typescript
17
- * const routeMap = new RouteMap([
18
- * { stateId: '#home', path: '/' },
19
- * { stateId: '#profile', path: '/profile/:userId' },
20
- * { stateId: '#settings', path: '/settings/:section?' }
21
- * ]);
22
- * ```
23
- */
24
- constructor(mappings) {
25
- mappings.forEach(({ stateId, path }) => {
26
- this.stateToPath.set(stateId, path);
27
- this.pathToState.set(path, stateId);
28
- });
29
- }
30
- /**
31
- * Get path pattern for a state ID
32
- *
33
- * @param stateId - XMachines state ID (e.g., '#profile')
34
- * @returns Path pattern or undefined if not found
35
- *
36
- * @example
37
- * ```typescript
38
- * routeMap.getPath('#profile'); // '/profile/:userId'
39
- * ```
40
- */
41
- getPath(stateId) {
42
- return this.stateToPath.get(stateId);
43
- }
44
- /**
45
- * Get state ID for a path, with pattern matching support
46
- *
47
- * Performs exact match first, then fuzzy pattern matching for dynamic routes.
48
- * Supports both required (:param) and optional (:param?) parameters.
49
- *
50
- * @param path - Actual URL path (e.g., '/profile/123')
51
- * @returns State ID or undefined if no match found
52
- *
53
- * @example
54
- * ```typescript
55
- * routeMap.getStateIdByPath('/profile/123'); // '#profile'
56
- * routeMap.getStateIdByPath('/settings'); // '#settings'
57
- * routeMap.getStateIdByPath('/settings/account'); // '#settings'
58
- * ```
59
- */
60
- getStateIdByPath(path) {
61
- // Strip query string and hash fragment for matching
62
- const cleanPath = path.split("?")[0].split("#")[0];
63
- // Direct lookup first (exact match)
64
- if (this.pathToState.has(cleanPath)) {
65
- return this.pathToState.get(cleanPath);
66
- }
67
- // Fuzzy match for dynamic routes
68
- for (const [pattern, stateId] of this.pathToState) {
69
- if (this.matchesPattern(cleanPath, pattern)) {
70
- return stateId;
71
- }
72
- }
73
- return undefined;
74
- }
75
- /**
76
- * Check if a path matches a pattern
77
- *
78
- * Supports:
79
- * - Required parameters: :param
80
- * - Optional parameters: :param?
81
- *
82
- * @param path - Actual URL path
83
- * @param pattern - Route pattern with :param syntax
84
- * @returns true if path matches pattern
85
- *
86
- * @example
87
- * ```typescript
88
- * matchesPattern('/profile/123', '/profile/:userId'); // true
89
- * matchesPattern('/settings', '/settings/:section?'); // true
90
- * matchesPattern('/settings/account', '/settings/:section?'); // true
91
- * ```
92
- */
93
- matchesPattern(path, pattern) {
94
- // Convert route pattern to regex
95
- // Process replacements in correct order: optional params first, then required
96
- let regexPattern = pattern
97
- // Replace /:param? with optional segment (matches both /value and nothing)
98
- .replace(/\/:(\w+)\?/g, "(?:/([^/]+))?")
99
- // Replace /:param with required segment
100
- .replace(/\/:(\w+)/g, "/([^/]+)");
101
- // Add anchors for exact match
102
- regexPattern = "^" + regexPattern + "$";
103
- const regex = new RegExp(regexPattern);
104
- return regex.test(path);
105
- }
106
- }
107
- //# sourceMappingURL=route-map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"route-map.js","sourceRoot":"","sources":["../src/route-map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,OAAO,QAAQ;IACZ,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEhD;;;;;;;;;;;;;OAaG;IACH,YAAY,QAAwB;QACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACpC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAC,OAAe;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CAAC,IAAY;QAC5B,oDAAoD;QACpD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnD,oCAAoC;QACpC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC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