router-kit 1.2.5 → 1.2.6

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,7 +1,22 @@
1
1
  import { useParams } from "./useParams";
2
2
  export const useDynamicComponents = (dynamicComponentsObject, variationParam) => {
3
- var _a, _b;
4
3
  const params = useParams();
5
- const variation = (_a = params[variationParam]) !== null && _a !== void 0 ? _a : "";
6
- return (_b = dynamicComponentsObject[variation]) !== null && _b !== void 0 ? _b : dynamicComponentsObject;
4
+ const variation = params[variationParam];
5
+ if (variation == null) {
6
+ throw new Error(`[router-kit] Parameter "${variationParam}" is not defined in route params`);
7
+ }
8
+ if (typeof variation !== "string") {
9
+ throw new Error(`[router-kit] Parameter "${variationParam}" must be a string, got ${typeof variation}`);
10
+ }
11
+ if (variation.trim() === "") {
12
+ throw new Error(`[router-kit] Parameter "${variationParam}" cannot be an empty string`);
13
+ }
14
+ if (!variation) {
15
+ throw new Error(`[router-kit] Parameter "${variationParam}" is required but not found in route params`);
16
+ }
17
+ const component = dynamicComponentsObject[variation];
18
+ if (!component) {
19
+ throw new Error(`[router-kit] Component not found for variation "${variation}". Available variations: ${Object.keys(dynamicComponentsObject).join(", ")}`);
20
+ }
21
+ return component;
7
22
  };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "mohammed.bencheikh.dev@gmail.com",
6
6
  "url": "https://mohammedbencheikh.com/"
7
7
  },
8
- "version": "1.2.5",
8
+ "version": "1.2.6",
9
9
  "description": "A small React routing provider library",
10
10
  "main": "dist/index.js",
11
11
  "types": "dist/index.d.ts",