@real-router/types 0.3.0 → 0.5.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.
@@ -294,6 +294,55 @@ interface Params {
294
294
  [key: string]: string | string[] | number | number[] | boolean | boolean[] | Params | Params[] | Record<string, string | number | boolean> | null | undefined;
295
295
  }
296
296
 
297
+ /**
298
+ * Configuration for router resource limits.
299
+ * Controls maximum allowed values for various router operations to prevent resource exhaustion.
300
+ */
301
+ interface LimitsConfig {
302
+ /**
303
+ * Maximum number of route dependencies allowed.
304
+ * Prevents circular dependency chains and excessive dependency graphs.
305
+ *
306
+ * @default 100
307
+ */
308
+ maxDependencies: number;
309
+ /**
310
+ * Maximum number of plugins that can be registered.
311
+ * Limits plugin stack depth to prevent performance degradation.
312
+ *
313
+ * @default 50
314
+ */
315
+ maxPlugins: number;
316
+ /**
317
+ * Maximum number of middleware functions in the navigation pipeline.
318
+ * Controls middleware chain length to prevent stack overflow and performance issues.
319
+ *
320
+ * @default 50
321
+ */
322
+ maxMiddleware: number;
323
+ /**
324
+ * Maximum number of event listeners per event type.
325
+ * Prevents memory leaks from excessive listener registration.
326
+ *
327
+ * @default 10000
328
+ */
329
+ maxListeners: number;
330
+ /**
331
+ * Maximum depth of nested event propagation.
332
+ * Prevents infinite recursion in event handling chains.
333
+ *
334
+ * @default 5
335
+ */
336
+ maxEventDepth: number;
337
+ /**
338
+ * Maximum number of lifecycle handlers (canActivate/canDeactivate) per route.
339
+ * Controls guard function stack to prevent excessive validation overhead.
340
+ *
341
+ * @default 200
342
+ */
343
+ maxLifecycleHandlers: number;
344
+ }
345
+
297
346
  /**
298
347
  * Base router types without Router class dependency.
299
348
  *
@@ -387,6 +436,13 @@ interface Options {
387
436
  * @default undefined
388
437
  */
389
438
  logger?: Partial<LoggerConfig>;
439
+ /**
440
+ * Router resource limits configuration.
441
+ * Controls maximum allowed values for various router operations.
442
+ *
443
+ * @default DEFAULT_LIMITS (from LimitsNamespace)
444
+ */
445
+ limits?: Partial<LimitsConfig>;
390
446
  /**
391
447
  * Disables argument validation in public router methods.
392
448
  * Use in production for performance. Keep false in development for early error detection.
@@ -427,6 +483,21 @@ interface Listener {
427
483
  interface Subscription {
428
484
  unsubscribe: Unsubscribe;
429
485
  }
486
+ /**
487
+ * Navigator interface - a minimal, safe subset of Router methods.
488
+ *
489
+ * Provides only the essential navigation and state inspection methods.
490
+ * Excludes lifecycle methods (start, stop), plugin management, and internal APIs.
491
+ * Use this when you need to pass a limited router interface to components.
492
+ *
493
+ * For full router access, use the Router interface directly or the useRouter() hook.
494
+ */
495
+ interface Navigator {
496
+ navigate: (routeName: string, routeParamsOrDone?: Params | DoneFn, optionsOrDone?: NavigationOptions | DoneFn, done?: DoneFn) => CancelFn;
497
+ getState: () => State | undefined;
498
+ isActiveRoute: (name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean) => boolean;
499
+ subscribe: (listener: SubscribeFn) => Unsubscribe;
500
+ }
430
501
 
431
502
  /**
432
503
  * Plugin lifecycle method names
@@ -485,4 +556,4 @@ interface ErrorCodeToValueMap {
485
556
  TRANSITION_CANCELLED: "CANCELLED";
486
557
  }
487
558
 
488
- export type { ActivationFn, CancelFn, Config, DefaultDependencies, DoneFn, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, Listener, Middleware, NavigationOptions, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteTreeState, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, Unsubscribe };
559
+ export type { ActivationFn, CancelFn, Config, DefaultDependencies, DoneFn, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, LimitsConfig, Listener, Middleware, NavigationOptions, Navigator, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteTreeState, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, Unsubscribe };
@@ -1 +1 @@
1
- {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/index.ts":{"bytes":1084,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
1
+ {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/index.ts":{"bytes":1168,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
@@ -294,6 +294,55 @@ interface Params {
294
294
  [key: string]: string | string[] | number | number[] | boolean | boolean[] | Params | Params[] | Record<string, string | number | boolean> | null | undefined;
295
295
  }
296
296
 
297
+ /**
298
+ * Configuration for router resource limits.
299
+ * Controls maximum allowed values for various router operations to prevent resource exhaustion.
300
+ */
301
+ interface LimitsConfig {
302
+ /**
303
+ * Maximum number of route dependencies allowed.
304
+ * Prevents circular dependency chains and excessive dependency graphs.
305
+ *
306
+ * @default 100
307
+ */
308
+ maxDependencies: number;
309
+ /**
310
+ * Maximum number of plugins that can be registered.
311
+ * Limits plugin stack depth to prevent performance degradation.
312
+ *
313
+ * @default 50
314
+ */
315
+ maxPlugins: number;
316
+ /**
317
+ * Maximum number of middleware functions in the navigation pipeline.
318
+ * Controls middleware chain length to prevent stack overflow and performance issues.
319
+ *
320
+ * @default 50
321
+ */
322
+ maxMiddleware: number;
323
+ /**
324
+ * Maximum number of event listeners per event type.
325
+ * Prevents memory leaks from excessive listener registration.
326
+ *
327
+ * @default 10000
328
+ */
329
+ maxListeners: number;
330
+ /**
331
+ * Maximum depth of nested event propagation.
332
+ * Prevents infinite recursion in event handling chains.
333
+ *
334
+ * @default 5
335
+ */
336
+ maxEventDepth: number;
337
+ /**
338
+ * Maximum number of lifecycle handlers (canActivate/canDeactivate) per route.
339
+ * Controls guard function stack to prevent excessive validation overhead.
340
+ *
341
+ * @default 200
342
+ */
343
+ maxLifecycleHandlers: number;
344
+ }
345
+
297
346
  /**
298
347
  * Base router types without Router class dependency.
299
348
  *
@@ -387,6 +436,13 @@ interface Options {
387
436
  * @default undefined
388
437
  */
389
438
  logger?: Partial<LoggerConfig>;
439
+ /**
440
+ * Router resource limits configuration.
441
+ * Controls maximum allowed values for various router operations.
442
+ *
443
+ * @default DEFAULT_LIMITS (from LimitsNamespace)
444
+ */
445
+ limits?: Partial<LimitsConfig>;
390
446
  /**
391
447
  * Disables argument validation in public router methods.
392
448
  * Use in production for performance. Keep false in development for early error detection.
@@ -427,6 +483,21 @@ interface Listener {
427
483
  interface Subscription {
428
484
  unsubscribe: Unsubscribe;
429
485
  }
486
+ /**
487
+ * Navigator interface - a minimal, safe subset of Router methods.
488
+ *
489
+ * Provides only the essential navigation and state inspection methods.
490
+ * Excludes lifecycle methods (start, stop), plugin management, and internal APIs.
491
+ * Use this when you need to pass a limited router interface to components.
492
+ *
493
+ * For full router access, use the Router interface directly or the useRouter() hook.
494
+ */
495
+ interface Navigator {
496
+ navigate: (routeName: string, routeParamsOrDone?: Params | DoneFn, optionsOrDone?: NavigationOptions | DoneFn, done?: DoneFn) => CancelFn;
497
+ getState: () => State | undefined;
498
+ isActiveRoute: (name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean) => boolean;
499
+ subscribe: (listener: SubscribeFn) => Unsubscribe;
500
+ }
430
501
 
431
502
  /**
432
503
  * Plugin lifecycle method names
@@ -485,4 +556,4 @@ interface ErrorCodeToValueMap {
485
556
  TRANSITION_CANCELLED: "CANCELLED";
486
557
  }
487
558
 
488
- export type { ActivationFn, CancelFn, Config, DefaultDependencies, DoneFn, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, Listener, Middleware, NavigationOptions, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteTreeState, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, Unsubscribe };
559
+ export type { ActivationFn, CancelFn, Config, DefaultDependencies, DoneFn, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, LimitsConfig, Listener, Middleware, NavigationOptions, Navigator, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteTreeState, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, Unsubscribe };
@@ -1 +1 @@
1
- {"inputs":{"src/index.ts":{"bytes":1084,"imports":[],"format":"esm"}},"outputs":{"dist/esm/index.mjs":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
1
+ {"inputs":{"src/index.ts":{"bytes":1168,"imports":[],"format":"esm"}},"outputs":{"dist/esm/index.mjs":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/types",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "type": "commonjs",
5
5
  "description": "Shared TypeScript types for Real Router ecosystem",
6
6
  "types": "./dist/esm/index.d.mts",