@idealyst/navigation 1.2.3 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/navigation",
3
- "version": "1.2.3",
3
+ "version": "1.2.6",
4
4
  "description": "Cross-platform navigation library for React and React Native",
5
5
  "readme": "README.md",
6
6
  "main": "src/index.ts",
@@ -44,9 +44,9 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@idealyst/camera": "^1.1.6",
47
- "@idealyst/components": "^1.2.3",
47
+ "@idealyst/components": "^1.2.6",
48
48
  "@idealyst/microphone": "^1.1.7",
49
- "@idealyst/theme": "^1.2.3",
49
+ "@idealyst/theme": "^1.2.6",
50
50
  "@react-navigation/bottom-tabs": ">=7.0.0",
51
51
  "@react-navigation/drawer": ">=7.0.0",
52
52
  "@react-navigation/native": ">=7.0.0",
@@ -71,11 +71,11 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@idealyst/camera": "^1.1.6",
74
- "@idealyst/components": "^1.2.3",
74
+ "@idealyst/components": "^1.2.6",
75
75
  "@idealyst/datagrid": "^1.0.93",
76
76
  "@idealyst/datepicker": "^1.0.93",
77
77
  "@idealyst/microphone": "^1.1.7",
78
- "@idealyst/theme": "^1.2.3",
78
+ "@idealyst/theme": "^1.2.6",
79
79
  "@types/react": "^19.1.8",
80
80
  "@types/react-dom": "^19.1.6",
81
81
  "react": "^19.1.0",
@@ -92,7 +92,28 @@ function hasNotFoundComponent(route: NavigatorParam): boolean {
92
92
  /**
93
93
  * Normalize a path and substitute variables
94
94
  */
95
- function normalizePath(path: string, vars?: Record<string, string>): string {
95
+ function normalizePath(path: string | undefined | null, vars?: Record<string, string>): string {
96
+ // Handle invalid path input
97
+ if (path === undefined || path === null) {
98
+ console.error(
99
+ 'Navigation Error: navigate() was called with an invalid path.\n' +
100
+ 'Expected: navigate({ path: "/your-route" })\n' +
101
+ 'Received: path is ' + String(path) + '\n' +
102
+ 'Make sure you are passing an object with a "path" property, not a string directly.'
103
+ );
104
+ return '/';
105
+ }
106
+
107
+ if (typeof path !== 'string') {
108
+ console.error(
109
+ 'Navigation Error: navigate() path must be a string.\n' +
110
+ 'Expected: navigate({ path: "/your-route" })\n' +
111
+ 'Received: ' + typeof path + '\n' +
112
+ 'Make sure you are passing an object with a "path" property, not a string directly.'
113
+ );
114
+ return '/';
115
+ }
116
+
96
117
  let normalizedPath = path;
97
118
 
98
119
  // Convert empty string to '/'
@@ -188,6 +209,25 @@ const UnwrappedNavigatorProvider = ({ route }: NavigatorProviderProps) => {
188
209
  const navigation = useNavigation();
189
210
 
190
211
  const navigate = (params: NavigateParams, _redirectCount = 0) => {
212
+ // Validate params - catch common mistake of passing string directly
213
+ if (typeof params === 'string') {
214
+ console.error(
215
+ 'Navigation Error: navigate() expects an object, not a string.\n' +
216
+ 'Expected: navigate({ path: "' + params + '" })\n' +
217
+ 'Received: navigate("' + params + '")\n' +
218
+ 'Please pass an object with a "path" property.'
219
+ );
220
+ return;
221
+ }
222
+
223
+ if (!params || typeof params !== 'object') {
224
+ console.error(
225
+ 'Navigation Error: navigate() expects an object with a "path" property.\n' +
226
+ 'Received: ' + typeof params
227
+ );
228
+ return;
229
+ }
230
+
191
231
  // Prevent infinite redirect loops
192
232
  if (_redirectCount > 10) {
193
233
  console.error('Navigation: Maximum redirect count exceeded. Check onInvalidRoute handlers.');
@@ -310,6 +350,25 @@ const NavigatorProvider = ({ route }: NavigatorProviderProps) => {
310
350
  const DrawerNavigatorProvider = ({ navigation, route, children }: { navigation: any, route: any, children: React.ReactNode }) => {
311
351
 
312
352
  const navigate = (params: NavigateParams, _redirectCount = 0) => {
353
+ // Validate params - catch common mistake of passing string directly
354
+ if (typeof params === 'string') {
355
+ console.error(
356
+ 'Navigation Error: navigate() expects an object, not a string.\n' +
357
+ 'Expected: navigate({ path: "' + params + '" })\n' +
358
+ 'Received: navigate("' + params + '")\n' +
359
+ 'Please pass an object with a "path" property.'
360
+ );
361
+ return;
362
+ }
363
+
364
+ if (!params || typeof params !== 'object') {
365
+ console.error(
366
+ 'Navigation Error: navigate() expects an object with a "path" property.\n' +
367
+ 'Received: ' + typeof params
368
+ );
369
+ return;
370
+ }
371
+
313
372
  // Prevent infinite redirect loops
314
373
  if (_redirectCount > 10) {
315
374
  console.error('Navigation: Maximum redirect count exceeded. Check onInvalidRoute handlers.');
@@ -14,7 +14,28 @@ const NavigatorContext = createContext<NavigatorContextValue>({
14
14
  /**
15
15
  * Normalize a path and substitute variables
16
16
  */
17
- function normalizePath(path: string, vars?: Record<string, string>): string {
17
+ function normalizePath(path: string | undefined | null, vars?: Record<string, string>): string {
18
+ // Handle invalid path input
19
+ if (path === undefined || path === null) {
20
+ console.error(
21
+ 'Navigation Error: navigate() was called with an invalid path.\n' +
22
+ 'Expected: navigate({ path: "/your-route" })\n' +
23
+ 'Received: path is ' + String(path) + '\n' +
24
+ 'Make sure you are passing an object with a "path" property, not a string directly.'
25
+ );
26
+ return '/';
27
+ }
28
+
29
+ if (typeof path !== 'string') {
30
+ console.error(
31
+ 'Navigation Error: navigate() path must be a string.\n' +
32
+ 'Expected: navigate({ path: "/your-route" })\n' +
33
+ 'Received: ' + typeof path + '\n' +
34
+ 'Make sure you are passing an object with a "path" property, not a string directly.'
35
+ );
36
+ return '/';
37
+ }
38
+
18
39
  let normalizedPath = path;
19
40
 
20
41
  // Convert empty string to '/'