@real-router/core 0.2.3 → 0.3.0

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/README.md CHANGED
@@ -239,6 +239,7 @@ Set up route forwarding (redirect).\
239
239
  `toRoute: string` — target route name\
240
240
  Returns: `void`\
241
241
  [Wiki](https://github.com/greydragon888/real-router/wiki/forward)
242
+
242
243
  ---
243
244
 
244
245
  ### State Utilities
@@ -266,11 +267,29 @@ Build state from route name.\
266
267
  `params?: Params` — route parameters\
267
268
  Returns: `State | undefined`\
268
269
  [Wiki](https://github.com/greydragon888/real-router/wiki/buildState)
270
+ #### `router.buildStateWithSegments(name: string, params?: Params): { state: State; segments: RouteSegment[] } | undefined`
271
+ Build state with route segments for advanced use cases.\
272
+ `name: string` — route name\
273
+ `params?: Params` — route parameters\
274
+ Returns: `{ state, segments } | undefined`\
275
+ [Wiki](https://github.com/greydragon888/real-router/wiki/buildStateWithSegments)
276
+ #### `router.forwardState(name: string, params: Params): { name: string; params: Params }`
277
+ Resolve route forwarding and merge default params.\
278
+ `name: string` — route name\
279
+ `params: Params` — route parameters\
280
+ Returns: `{ name, params }` — resolved route name and merged params\
281
+ [Wiki](https://github.com/greydragon888/real-router/wiki/forwardState)
282
+ #### `router.shouldUpdateNode(nodeName: string): (toState, fromState?) => boolean`
283
+ Create a predicate to check if a route node should update during transition.\
284
+ `nodeName: string` — route node name\
285
+ Returns: predicate function\
286
+ [Wiki](https://github.com/greydragon888/real-router/wiki/shouldUpdateNode)
269
287
  #### `router.areStatesEqual(state1: State, state2: State, ignoreQueryParams?: boolean): boolean`
270
288
  Compare two states for equality.\
271
289
  `state1: State` — first state\
272
290
  `state2: State` — second state\
273
- `ignoreQueryParams?: boolean` — ignore query params (default: true)Returns: `boolean`\
291
+ `ignoreQueryParams?: boolean` — ignore query params (default: true)\
292
+ Returns: `boolean`\
274
293
  [Wiki](https://github.com/greydragon888/real-router/wiki/areStatesEqual)
275
294
  #### `router.areStatesDescendants(parentState: State, childState: State): boolean`
276
295
  Check if child state is descendant of parent.\
@@ -278,6 +297,7 @@ Check if child state is descendant of parent.\
278
297
  `childState: State` — child state\
279
298
  Returns: `boolean`\
280
299
  [Wiki](https://github.com/greydragon888/real-router/wiki/areStatesDescendants)
300
+
281
301
  ---
282
302
 
283
303
  ### Path Operations
@@ -297,7 +317,9 @@ Returns: `State | undefined`\
297
317
  Check if route is currently active.\
298
318
  `name: string` — route name\
299
319
  `params?: Params` — route parameters\
300
- `strictEquality?: boolean` — exact match (default: false)`ignoreQueryParams?: boolean` — ignore query params (default: true)Returns: `boolean`\
320
+ `strictEquality?: boolean` — exact match (default: false)\
321
+ `ignoreQueryParams?: boolean` — ignore query params (default: true)\
322
+ Returns: `boolean`\
301
323
  [Wiki](https://github.com/greydragon888/real-router/wiki/isActiveRoute)
302
324
  #### `router.setRootPath(rootPath: string): void`
303
325
  Set root path prefix for all routes.\
@@ -308,6 +330,7 @@ Returns: `void`\
308
330
  Get root path prefix.\
309
331
  Returns: `string`\
310
332
  [Wiki](https://github.com/greydragon888/real-router/wiki/getRootPath)
333
+
311
334
  ---
312
335
 
313
336
  ### Dependencies
@@ -346,20 +369,27 @@ Returns: `void`\
346
369
  Remove all dependencies.\
347
370
  Returns: `void`\
348
371
  [Wiki](https://github.com/greydragon888/real-router/wiki/resetDependencies)
372
+
349
373
  ---
350
374
 
351
375
  ### Options
352
376
 
353
377
  #### `router.getOptions(): Options`
354
- Get router options.\
378
+ Get all router options.\
355
379
  Returns: `Options`\
356
380
  [Wiki](https://github.com/greydragon888/real-router/wiki/getOptions)
381
+ #### `router.getOption(name: keyof Options): unknown`
382
+ Get a single router option by name.\
383
+ `name: keyof Options` — option name\
384
+ Returns: option value\
385
+ [Wiki](https://github.com/greydragon888/real-router/wiki/getOption)
357
386
  #### `router.setOption(name: string, value: unknown): void`
358
387
  Set a router option. Must be called before `start()`.\
359
388
  `name: string` — option name\
360
389
  `value: unknown` — option value\
361
390
  Returns: `void`\
362
391
  [Wiki](https://github.com/greydragon888/real-router/wiki/setOption)
392
+
363
393
  ---
364
394
 
365
395
  ### Other
@@ -373,12 +403,8 @@ Returns: `Router`\
373
403
  Check if navigation is in progress.\
374
404
  Returns: `boolean`\
375
405
  [Wiki](https://github.com/greydragon888/real-router/wiki/isNavigating)
376
- #### `router.isActive(name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean): boolean`
377
- Alias for `isActiveRoute`.\
378
- `name: string` — route name\
379
- `params?: Params` — route parameters\
380
- `strictEquality?: boolean` — exact match\
381
- `ignoreQueryParams?: boolean` — ignore query params\
406
+ #### `router.isActive(): boolean`
407
+ Check if router is active (started and has current state).\
382
408
  Returns: `boolean`\
383
409
  [Wiki](https://github.com/greydragon888/real-router/wiki/isActive)
384
410
  #### `router.clearCanActivate(name: string): void`
@@ -401,6 +427,7 @@ Remove event listener.\
401
427
  `listener: Function` — listener to remove\
402
428
  Returns: `void`\
403
429
  [Wiki](https://github.com/greydragon888/real-router/wiki/removeEventListener)
430
+
404
431
  ---
405
432
 
406
433
  ## Configuration