@vielzeug/wayfinder 2.0.0 → 2.2.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.
Files changed (58) hide show
  1. package/README.md +2 -2
  2. package/dist/_dev.cjs.map +1 -1
  3. package/dist/_dev.js.map +1 -1
  4. package/dist/compile.cjs +1 -1
  5. package/dist/compile.cjs.map +1 -1
  6. package/dist/compile.d.ts.map +1 -1
  7. package/dist/compile.js +1 -1
  8. package/dist/compile.js.map +1 -1
  9. package/dist/context.cjs +1 -1
  10. package/dist/context.cjs.map +1 -1
  11. package/dist/context.d.ts +4 -4
  12. package/dist/context.d.ts.map +1 -1
  13. package/dist/context.js +2 -2
  14. package/dist/context.js.map +1 -1
  15. package/dist/errors.cjs +1 -1
  16. package/dist/errors.cjs.map +1 -1
  17. package/dist/errors.d.ts +0 -1
  18. package/dist/errors.d.ts.map +1 -1
  19. package/dist/errors.js +1 -4
  20. package/dist/errors.js.map +1 -1
  21. package/dist/guards.cjs.map +1 -1
  22. package/dist/guards.d.ts +1 -1
  23. package/dist/guards.js.map +1 -1
  24. package/dist/history.cjs +1 -1
  25. package/dist/history.cjs.map +1 -1
  26. package/dist/history.d.ts.map +1 -1
  27. package/dist/history.js +3 -1
  28. package/dist/history.js.map +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -3
  33. package/dist/path.cjs +1 -1
  34. package/dist/path.cjs.map +1 -1
  35. package/dist/path.d.ts.map +1 -1
  36. package/dist/path.js +6 -2
  37. package/dist/path.js.map +1 -1
  38. package/dist/router.cjs +1 -1
  39. package/dist/router.cjs.map +1 -1
  40. package/dist/router.d.ts +3 -4
  41. package/dist/router.d.ts.map +1 -1
  42. package/dist/router.js +100 -96
  43. package/dist/router.js.map +1 -1
  44. package/dist/types.d.ts +13 -14
  45. package/dist/types.d.ts.map +1 -1
  46. package/dist/wayfinder.cjs +1 -1
  47. package/dist/wayfinder.cjs.map +1 -1
  48. package/dist/wayfinder.iife.js +1 -1
  49. package/dist/wayfinder.iife.js.map +1 -1
  50. package/dist/wayfinder.js +1 -1
  51. package/dist/wayfinder.js.map +1 -1
  52. package/package.json +22 -28
  53. package/dist/devtools.cjs +0 -2
  54. package/dist/devtools.cjs.map +0 -1
  55. package/dist/devtools.d.ts +0 -47
  56. package/dist/devtools.d.ts.map +0 -1
  57. package/dist/devtools.js +0 -13
  58. package/dist/devtools.js.map +0 -1
@@ -1,47 +0,0 @@
1
- /**
2
- * @vielzeug/wayfinder — debug utilities for router navigation visualisation.
3
- *
4
- * Import from the dedicated sub-path so it is tree-shaken from production bundles:
5
- * ```ts
6
- * import { debugRouter } from '@vielzeug/wayfinder/devtools';
7
- * ```
8
- */
9
- import type { Router, RouterOptions, RouteTable } from './index';
10
- /** Options for {@link debugRouter}. Extends {@link RouterOptions} with debug-specific settings. */
11
- export interface DebugRouterOptions<TRoutes extends RouteTable, TMeta = unknown, TComponent = unknown> extends RouterOptions<TRoutes, TMeta, TComponent> {
12
- /**
13
- * Label used in log prefixes. Defaults to `'nav'`, producing `[wayfinder:nav]`.
14
- * Useful when running multiple routers (e.g. a main router and a modal router)
15
- * so their log output can be distinguished:
16
- * ```ts
17
- * debugRouter({ label: 'modal', routes });
18
- * // [wayfinder:modal] loading /confirm
19
- * ```
20
- */
21
- label?: string;
22
- }
23
- /**
24
- * Creates a {@link Router} with navigation lifecycle logging pre-wired to `console.debug`.
25
- *
26
- * Equivalent to `createRouter(options)` with a `subscribe` listener attached, but imported
27
- * from a dedicated sub-path so `console.debug` references are tree-shaken from production
28
- * bundles when this sub-path is not imported.
29
- *
30
- * Logs every navigation state change with `[wayfinder:<label>]` prefixes showing the pathname,
31
- * status (`loading` → `idle` / `error`), and matched route names.
32
- *
33
- * @example
34
- * ```ts
35
- * import { debugRouter } from '@vielzeug/wayfinder/devtools';
36
- *
37
- * const router = debugRouter({ routes });
38
- * // [wayfinder:nav] loading /users
39
- * // [wayfinder:nav] idle /users [users]
40
- *
41
- * // Multi-router setup:
42
- * const modal = debugRouter({ label: 'modal', routes: modalRoutes });
43
- * // [wayfinder:modal] loading /confirm
44
- * ```
45
- */
46
- export declare function debugRouter<const TRoutes extends RouteTable, TMeta = unknown, TComponent = unknown>(options: DebugRouterOptions<TRoutes, TMeta, TComponent>): Router<TRoutes, TMeta, TComponent>;
47
- //# sourceMappingURL=devtools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAc,UAAU,EAAE,MAAM,SAAS,CAAC;AAI7E,mGAAmG;AACnG,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,UAAU,EAC1B,KAAK,GAAG,OAAO,EACf,UAAU,GAAG,OAAO,CACpB,SAAQ,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC;IACjD;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,EAAE,KAAK,GAAG,OAAO,EAAE,UAAU,GAAG,OAAO,EACjG,OAAO,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,GACtD,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,CAsBpC"}
package/dist/devtools.js DELETED
@@ -1,13 +0,0 @@
1
- import { createRouter as e } from "./router.js";
2
- //#region src/devtools.ts
3
- function t(t) {
4
- let { label: n = "nav", ...r } = t, i = e(r), a = `[wayfinder:${n}]`;
5
- return i.subscribe((e) => {
6
- let t = e.matches.map((e) => e.name).filter(Boolean).join(", "), n = t ? ` [${t}]` : "";
7
- e.status === "error" ? console.debug(`${a} error ${e.location.pathname}${n}`, e.error) : console.debug(`${a} ${e.status.padEnd(8)} ${e.location.pathname}${n}`);
8
- }), i;
9
- }
10
- //#endregion
11
- export { t as debugRouter };
12
-
13
- //# sourceMappingURL=devtools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.js","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["/**\n * @vielzeug/wayfinder — debug utilities for router navigation visualisation.\n *\n * Import from the dedicated sub-path so it is tree-shaken from production bundles:\n * ```ts\n * import { debugRouter } from '@vielzeug/wayfinder/devtools';\n * ```\n */\n\nimport type { Router, RouterOptions, RouteState, RouteTable } from './index';\n\nimport { createRouter } from './router';\n\n/** Options for {@link debugRouter}. Extends {@link RouterOptions} with debug-specific settings. */\nexport interface DebugRouterOptions<\n TRoutes extends RouteTable,\n TMeta = unknown,\n TComponent = unknown,\n> extends RouterOptions<TRoutes, TMeta, TComponent> {\n /**\n * Label used in log prefixes. Defaults to `'nav'`, producing `[wayfinder:nav]`.\n * Useful when running multiple routers (e.g. a main router and a modal router)\n * so their log output can be distinguished:\n * ```ts\n * debugRouter({ label: 'modal', routes });\n * // [wayfinder:modal] loading /confirm\n * ```\n */\n label?: string;\n}\n\n/**\n * Creates a {@link Router} with navigation lifecycle logging pre-wired to `console.debug`.\n *\n * Equivalent to `createRouter(options)` with a `subscribe` listener attached, but imported\n * from a dedicated sub-path so `console.debug` references are tree-shaken from production\n * bundles when this sub-path is not imported.\n *\n * Logs every navigation state change with `[wayfinder:<label>]` prefixes showing the pathname,\n * status (`loading` → `idle` / `error`), and matched route names.\n *\n * @example\n * ```ts\n * import { debugRouter } from '@vielzeug/wayfinder/devtools';\n *\n * const router = debugRouter({ routes });\n * // [wayfinder:nav] loading /users\n * // [wayfinder:nav] idle /users [users]\n *\n * // Multi-router setup:\n * const modal = debugRouter({ label: 'modal', routes: modalRoutes });\n * // [wayfinder:modal] loading /confirm\n * ```\n */\nexport function debugRouter<const TRoutes extends RouteTable, TMeta = unknown, TComponent = unknown>(\n options: DebugRouterOptions<TRoutes, TMeta, TComponent>,\n): Router<TRoutes, TMeta, TComponent> {\n const { label = 'nav', ...routerOptions } = options;\n const router = createRouter<TRoutes, TMeta, TComponent>(routerOptions);\n const prefix = `[wayfinder:${label}]`;\n\n const log = (state: RouteState<TMeta, TComponent>): void => {\n const names = state.matches\n .map((m) => m.name)\n .filter(Boolean)\n .join(', ');\n const suffix = names ? ` [${names}]` : '';\n\n if (state.status === 'error') {\n console.debug(`${prefix} error ${state.location.pathname}${suffix}`, state.error);\n } else {\n console.debug(`${prefix} ${state.status.padEnd(8)} ${state.location.pathname}${suffix}`);\n }\n };\n\n router.subscribe(log);\n\n return router;\n}\n"],"mappings":";;AAsDA,SAAgB,EACd,GACoC;CACpC,IAAM,EAAE,WAAQ,OAAO,GAAG,MAAkB,GACtC,IAAS,EAAyC,CAAa,GAC/D,IAAS,cAAc,EAAM;CAkBnC,OAFA,EAAO,WAdM,MAA+C;EAC1D,IAAM,IAAQ,EAAM,QACjB,KAAK,MAAM,EAAE,IAAI,CAAC,CAClB,OAAO,OAAO,CAAC,CACf,KAAK,IAAI,GACN,IAAS,IAAQ,MAAM,EAAM,KAAK;EAExC,AAAI,EAAM,WAAW,UACnB,QAAQ,MAAM,GAAG,EAAO,YAAY,EAAM,SAAS,WAAW,KAAU,EAAM,KAAK,IAEnF,QAAQ,MAAM,GAAG,EAAO,GAAG,EAAM,OAAO,OAAO,CAAC,EAAE,GAAG,EAAM,SAAS,WAAW,GAAQ;CAE3F,CAEoB,GAEb;AACT"}