@hkdigital/lib-core 0.5.56 → 0.5.57

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.
@@ -195,8 +195,17 @@ export default class PageMachine {
195
195
  this.#data = initialData;
196
196
  this.#onEnterHooks = this.#normalizeOnEnterHooks(onEnterHooks);
197
197
 
198
- // Build reverse map (path -> state)
198
+ // Build reverse map (path -> state) and validate no duplicates
199
199
  for (const [state, path] of Object.entries(routeMap)) {
200
+ // Check if this path is already mapped to a different state
201
+ const existingState = this.#pathToStateMap[path];
202
+ if (existingState && existingState !== state) {
203
+ throw new Error(
204
+ `PageMachine: Duplicate route mapping detected. ` +
205
+ `Path "${path}" is mapped to both "${existingState}" and "${state}". ` +
206
+ `Each route path must map to exactly one state.`
207
+ );
208
+ }
200
209
  this.#pathToStateMap[path] = state;
201
210
  }
202
211
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.5.56",
3
+ "version": "0.5.57",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"