@pithyjs/router 0.1.0-beta.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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +621 -0
  3. package/dist/index.d.ts +29 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +49 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/router/core/config.d.ts +22 -0
  8. package/dist/router/core/config.d.ts.map +1 -0
  9. package/dist/router/core/config.js +54 -0
  10. package/dist/router/core/config.js.map +1 -0
  11. package/dist/router/core/constants.d.ts +89 -0
  12. package/dist/router/core/constants.d.ts.map +1 -0
  13. package/dist/router/core/constants.js +95 -0
  14. package/dist/router/core/constants.js.map +1 -0
  15. package/dist/router/core/history.d.ts +54 -0
  16. package/dist/router/core/history.d.ts.map +1 -0
  17. package/dist/router/core/history.js +89 -0
  18. package/dist/router/core/history.js.map +1 -0
  19. package/dist/router/core/matcher.d.ts +43 -0
  20. package/dist/router/core/matcher.d.ts.map +1 -0
  21. package/dist/router/core/matcher.js +242 -0
  22. package/dist/router/core/matcher.js.map +1 -0
  23. package/dist/router/core/params.d.ts +88 -0
  24. package/dist/router/core/params.d.ts.map +1 -0
  25. package/dist/router/core/params.js +150 -0
  26. package/dist/router/core/params.js.map +1 -0
  27. package/dist/router/core/pipeline.d.ts +90 -0
  28. package/dist/router/core/pipeline.d.ts.map +1 -0
  29. package/dist/router/core/pipeline.js +323 -0
  30. package/dist/router/core/pipeline.js.map +1 -0
  31. package/dist/router/core/route-tree.d.ts +76 -0
  32. package/dist/router/core/route-tree.d.ts.map +1 -0
  33. package/dist/router/core/route-tree.js +143 -0
  34. package/dist/router/core/route-tree.js.map +1 -0
  35. package/dist/router/core/router.d.ts +229 -0
  36. package/dist/router/core/router.d.ts.map +1 -0
  37. package/dist/router/core/router.js +762 -0
  38. package/dist/router/core/router.js.map +1 -0
  39. package/dist/router/core/types.d.ts +387 -0
  40. package/dist/router/core/types.d.ts.map +1 -0
  41. package/dist/router/core/types.js +22 -0
  42. package/dist/router/core/types.js.map +1 -0
  43. package/dist/router/core/utils.d.ts +66 -0
  44. package/dist/router/core/utils.d.ts.map +1 -0
  45. package/dist/router/core/utils.js +152 -0
  46. package/dist/router/core/utils.js.map +1 -0
  47. package/dist/router/features/coordinator.d.ts +75 -0
  48. package/dist/router/features/coordinator.d.ts.map +1 -0
  49. package/dist/router/features/coordinator.js +203 -0
  50. package/dist/router/features/coordinator.js.map +1 -0
  51. package/dist/router/features/errors/error-codes.d.ts +107 -0
  52. package/dist/router/features/errors/error-codes.d.ts.map +1 -0
  53. package/dist/router/features/errors/error-codes.js +247 -0
  54. package/dist/router/features/errors/error-codes.js.map +1 -0
  55. package/dist/router/features/errors/error-resolution.d.ts +31 -0
  56. package/dist/router/features/errors/error-resolution.d.ts.map +1 -0
  57. package/dist/router/features/errors/error-resolution.js +47 -0
  58. package/dist/router/features/errors/error-resolution.js.map +1 -0
  59. package/dist/router/features/errors/error-types.d.ts +60 -0
  60. package/dist/router/features/errors/error-types.d.ts.map +1 -0
  61. package/dist/router/features/errors/error-types.js +57 -0
  62. package/dist/router/features/errors/error-types.js.map +1 -0
  63. package/dist/router/features/errors/global-error-fallback.d.ts +33 -0
  64. package/dist/router/features/errors/global-error-fallback.d.ts.map +1 -0
  65. package/dist/router/features/errors/global-error-fallback.js +182 -0
  66. package/dist/router/features/errors/global-error-fallback.js.map +1 -0
  67. package/dist/router/features/errors/index.d.ts +15 -0
  68. package/dist/router/features/errors/index.d.ts.map +1 -0
  69. package/dist/router/features/errors/index.js +18 -0
  70. package/dist/router/features/errors/index.js.map +1 -0
  71. package/dist/router/features/errors/router-errors.d.ts +44 -0
  72. package/dist/router/features/errors/router-errors.d.ts.map +1 -0
  73. package/dist/router/features/errors/router-errors.js +53 -0
  74. package/dist/router/features/errors/router-errors.js.map +1 -0
  75. package/dist/router/features/guards/engine.d.ts +40 -0
  76. package/dist/router/features/guards/engine.d.ts.map +1 -0
  77. package/dist/router/features/guards/engine.js +67 -0
  78. package/dist/router/features/guards/engine.js.map +1 -0
  79. package/dist/router/features/guards/index.d.ts +52 -0
  80. package/dist/router/features/guards/index.d.ts.map +1 -0
  81. package/dist/router/features/guards/index.js +95 -0
  82. package/dist/router/features/guards/index.js.map +1 -0
  83. package/dist/router/features/loaders/cache.d.ts +60 -0
  84. package/dist/router/features/loaders/cache.d.ts.map +1 -0
  85. package/dist/router/features/loaders/cache.js +80 -0
  86. package/dist/router/features/loaders/cache.js.map +1 -0
  87. package/dist/router/features/loaders/engine.d.ts +17 -0
  88. package/dist/router/features/loaders/engine.d.ts.map +1 -0
  89. package/dist/router/features/loaders/engine.js +27 -0
  90. package/dist/router/features/loaders/engine.js.map +1 -0
  91. package/dist/router/features/loaders/index.d.ts +49 -0
  92. package/dist/router/features/loaders/index.d.ts.map +1 -0
  93. package/dist/router/features/loaders/index.js +112 -0
  94. package/dist/router/features/loaders/index.js.map +1 -0
  95. package/dist/router/features/loading-ui-manager.d.ts +69 -0
  96. package/dist/router/features/loading-ui-manager.d.ts.map +1 -0
  97. package/dist/router/features/loading-ui-manager.js +209 -0
  98. package/dist/router/features/loading-ui-manager.js.map +1 -0
  99. package/dist/router/features/module-loader.d.ts +50 -0
  100. package/dist/router/features/module-loader.d.ts.map +1 -0
  101. package/dist/router/features/module-loader.js +121 -0
  102. package/dist/router/features/module-loader.js.map +1 -0
  103. package/dist/router/features/outlet/errors.d.ts +24 -0
  104. package/dist/router/features/outlet/errors.d.ts.map +1 -0
  105. package/dist/router/features/outlet/errors.js +96 -0
  106. package/dist/router/features/outlet/errors.js.map +1 -0
  107. package/dist/router/features/outlet/index.d.ts +45 -0
  108. package/dist/router/features/outlet/index.d.ts.map +1 -0
  109. package/dist/router/features/outlet/index.js +95 -0
  110. package/dist/router/features/outlet/index.js.map +1 -0
  111. package/dist/router/features/outlet/mount.d.ts +38 -0
  112. package/dist/router/features/outlet/mount.d.ts.map +1 -0
  113. package/dist/router/features/outlet/mount.js +301 -0
  114. package/dist/router/features/outlet/mount.js.map +1 -0
  115. package/dist/router/features/outlet/segment-chain.d.ts +16 -0
  116. package/dist/router/features/outlet/segment-chain.d.ts.map +1 -0
  117. package/dist/router/features/outlet/segment-chain.js +62 -0
  118. package/dist/router/features/outlet/segment-chain.js.map +1 -0
  119. package/dist/router/features/prefetch/index.d.ts +97 -0
  120. package/dist/router/features/prefetch/index.d.ts.map +1 -0
  121. package/dist/router/features/prefetch/index.js +345 -0
  122. package/dist/router/features/prefetch/index.js.map +1 -0
  123. package/dist/router/features/ux/focus.d.ts +62 -0
  124. package/dist/router/features/ux/focus.d.ts.map +1 -0
  125. package/dist/router/features/ux/focus.js +136 -0
  126. package/dist/router/features/ux/focus.js.map +1 -0
  127. package/dist/router/features/ux/live-region.d.ts +81 -0
  128. package/dist/router/features/ux/live-region.d.ts.map +1 -0
  129. package/dist/router/features/ux/live-region.js +166 -0
  130. package/dist/router/features/ux/live-region.js.map +1 -0
  131. package/dist/router/features/ux/scroll-focus.d.ts +105 -0
  132. package/dist/router/features/ux/scroll-focus.d.ts.map +1 -0
  133. package/dist/router/features/ux/scroll-focus.js +111 -0
  134. package/dist/router/features/ux/scroll-focus.js.map +1 -0
  135. package/dist/router/features/ux/scroll.d.ts +71 -0
  136. package/dist/router/features/ux/scroll.d.ts.map +1 -0
  137. package/dist/router/features/ux/scroll.js +137 -0
  138. package/dist/router/features/ux/scroll.js.map +1 -0
  139. package/dist/router/features/ux/transitions.d.ts +120 -0
  140. package/dist/router/features/ux/transitions.d.ts.map +1 -0
  141. package/dist/router/features/ux/transitions.js +235 -0
  142. package/dist/router/features/ux/transitions.js.map +1 -0
  143. package/dist/router/integration/directive-binder.d.ts +20 -0
  144. package/dist/router/integration/directive-binder.d.ts.map +1 -0
  145. package/dist/router/integration/directive-binder.js +139 -0
  146. package/dist/router/integration/directive-binder.js.map +1 -0
  147. package/dist/router/integration/directives.d.ts +42 -0
  148. package/dist/router/integration/directives.d.ts.map +1 -0
  149. package/dist/router/integration/directives.js +109 -0
  150. package/dist/router/integration/directives.js.map +1 -0
  151. package/dist/router/integration/history-adapter.d.ts +76 -0
  152. package/dist/router/integration/history-adapter.d.ts.map +1 -0
  153. package/dist/router/integration/history-adapter.js +157 -0
  154. package/dist/router/integration/history-adapter.js.map +1 -0
  155. package/dist/router/integration/hmr.d.ts +83 -0
  156. package/dist/router/integration/hmr.d.ts.map +1 -0
  157. package/dist/router/integration/hmr.js +160 -0
  158. package/dist/router/integration/hmr.js.map +1 -0
  159. package/dist/router/integration/link-interceptor.d.ts +49 -0
  160. package/dist/router/integration/link-interceptor.d.ts.map +1 -0
  161. package/dist/router/integration/link-interceptor.js +94 -0
  162. package/dist/router/integration/link-interceptor.js.map +1 -0
  163. package/package.json +47 -0
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router",
4
+ "title": "PithyJS Router Core",
5
+ "category": "feature"
6
+ }
7
+ */
8
+ // Export core types
9
+ export * from './router/core/types';
10
+ // Export matcher utilities
11
+ export * from './router/core/matcher';
12
+ // Export route tree utilities
13
+ export * from './router/core/route-tree';
14
+ // Export parameter utilities
15
+ export * from './router/core/params';
16
+ // Export utility functions
17
+ export * from './router/core/utils';
18
+ // Export router core
19
+ export * from './router/core/router';
20
+ // Export configuration utilities
21
+ export * from './router/core/config';
22
+ // Export history management
23
+ export * from './router/core/history';
24
+ // Export router directives
25
+ export * from './router/integration/directives';
26
+ // Export directive binder for core integration
27
+ export { setGlobalRouter, getGlobalRouter, } from './router/integration/directive-binder';
28
+ // Export loader system
29
+ export * from './router/features/loaders';
30
+ // Export guards system
31
+ export * from './router/features/guards';
32
+ // Export prefetch system
33
+ export * from './router/features/prefetch';
34
+ // Export HMR system
35
+ export * from './router/integration/hmr';
36
+ // Export link interceptor
37
+ export * from './router/integration/link-interceptor';
38
+ // Export scroll and focus management
39
+ export * from './router/features/ux/scroll-focus';
40
+ // Export view transitions
41
+ export * from './router/features/ux/transitions';
42
+ // Export error handling system
43
+ export * from './router/features/errors';
44
+ // Export outlet system
45
+ export { OutletManager } from './router/features/outlet';
46
+ export { buildSegmentChain } from './router/features/outlet/segment-chain';
47
+ // Export history adapters
48
+ export { BrowserHistoryAdapter, MemoryHistoryAdapter, } from './router/integration/history-adapter';
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,oBAAoB;AACpB,cAAc,qBAAqB,CAAC;AAEpC,2BAA2B;AAC3B,cAAc,uBAAuB,CAAC;AAEtC,8BAA8B;AAC9B,cAAc,0BAA0B,CAAC;AAEzC,6BAA6B;AAC7B,cAAc,sBAAsB,CAAC;AAErC,2BAA2B;AAC3B,cAAc,qBAAqB,CAAC;AAEpC,qBAAqB;AACrB,cAAc,sBAAsB,CAAC;AAErC,iCAAiC;AACjC,cAAc,sBAAsB,CAAC;AAErC,4BAA4B;AAC5B,cAAc,uBAAuB,CAAC;AAEtC,2BAA2B;AAC3B,cAAc,iCAAiC,CAAC;AAEhD,+CAA+C;AAC/C,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,uCAAuC,CAAC;AAE/C,uBAAuB;AACvB,cAAc,2BAA2B,CAAC;AAE1C,uBAAuB;AACvB,cAAc,0BAA0B,CAAC;AAEzC,yBAAyB;AACzB,cAAc,4BAA4B,CAAC;AAE3C,oBAAoB;AACpB,cAAc,0BAA0B,CAAC;AAEzC,0BAA0B;AAC1B,cAAc,uCAAuC,CAAC;AAEtD,qCAAqC;AACrC,cAAc,mCAAmC,CAAC;AAElD,0BAA0B;AAC1B,cAAc,kCAAkC,CAAC;AAEjD,+BAA+B;AAC/B,cAAc,0BAA0B,CAAC;AAEzC,uBAAuB;AACvB,OAAO,EAAE,aAAa,EAAuB,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,0BAA0B;AAC1B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router.core.config",
4
+ "title": "Router Configuration Normalization",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ import type { RouterConfig } from './types';
9
+ /** @codexApi {"parent":"pithy.router.core.config","name":"normalizeConfig","stability":"stable","signature":"(config?: RouterConfig) => RouterConfig"} */
10
+ /**
11
+ * Normalize and merge user-provided router configuration with defaults
12
+ * @param config - User-provided router configuration
13
+ * @returns Normalized router configuration with all required fields
14
+ */
15
+ export declare function normalizeConfig(config?: RouterConfig): RouterConfig;
16
+ /** @codexApi {"parent":"pithy.router.core.config","name":"initializeScrollRestoration","stability":"stable","signature":"() => void"} */
17
+ /**
18
+ * Initialize manual scroll restoration to disable browser's automatic behavior
19
+ * This is a side effect that should be called once during router initialization
20
+ */
21
+ export declare function initializeScrollRestoration(): void;
22
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/router/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA+B5C,0JAA0J;AAC1J;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,YAAiB,GAAG,YAAY,CAKvE;AAED,yIAAyI;AACzI;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAQlD"}
@@ -0,0 +1,54 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router.core.config",
4
+ "title": "Router Configuration Normalization",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ /**
9
+ * Default router configuration values
10
+ */
11
+ const DEFAULT_CONFIG = {
12
+ basePath: '',
13
+ trailingSlash: 'never',
14
+ decodeParams: true,
15
+ viewTransitions: false,
16
+ a11y: true,
17
+ interceptLinks: true,
18
+ linkIgnoreAttr: 'data-router-ignore',
19
+ loadingPolicy: 'replace',
20
+ popstateLoading: 'none',
21
+ setAsGlobal: true,
22
+ // exposeToWindow will be set dynamically in Router constructor based on env
23
+ exposeToWindow: false,
24
+ windowKey: 'router',
25
+ outletSelector: '[data-router-outlet]',
26
+ };
27
+ /** @codexApi {"parent":"pithy.router.core.config","name":"normalizeConfig","stability":"stable","signature":"(config?: RouterConfig) => RouterConfig"} */
28
+ /**
29
+ * Normalize and merge user-provided router configuration with defaults
30
+ * @param config - User-provided router configuration
31
+ * @returns Normalized router configuration with all required fields
32
+ */
33
+ export function normalizeConfig(config = {}) {
34
+ return {
35
+ ...DEFAULT_CONFIG,
36
+ ...config,
37
+ };
38
+ }
39
+ /** @codexApi {"parent":"pithy.router.core.config","name":"initializeScrollRestoration","stability":"stable","signature":"() => void"} */
40
+ /**
41
+ * Initialize manual scroll restoration to disable browser's automatic behavior
42
+ * This is a side effect that should be called once during router initialization
43
+ */
44
+ export function initializeScrollRestoration() {
45
+ try {
46
+ if (typeof history !== 'undefined' && 'scrollRestoration' in history) {
47
+ history.scrollRestoration = 'manual';
48
+ }
49
+ }
50
+ catch (e) {
51
+ console.warn('[Router] Failed to set scroll restoration to manual:', e);
52
+ }
53
+ }
54
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/router/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAaF;;GAEG;AACH,MAAM,cAAc,GAAoC;IACtD,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,OAAO;IACtB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,KAAK;IACtB,IAAI,EAAE,IAAI;IACV,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,oBAAoB;IACpC,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,IAAI;IACjB,4EAA4E;IAC5E,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,QAAQ;IACnB,cAAc,EAAE,sBAAsB;CACvC,CAAC;AAEF,0JAA0J;AAC1J;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB,EAAE;IACvD,OAAO;QACL,GAAG,cAAc;QACjB,GAAG,MAAM;KACM,CAAC;AACpB,CAAC;AAED,yIAAyI;AACzI;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC;QACH,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,mBAAmB,IAAI,OAAO,EAAE,CAAC;YACrE,OAAO,CAAC,iBAAiB,GAAG,QAAQ,CAAC;QACvC,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,sDAAsD,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,89 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router.constants",
4
+ "title": "Router Configuration Constants",
5
+ "category": "config"
6
+ }
7
+ */
8
+ /**
9
+ * Router package constants
10
+ *
11
+ * Centralized location for all magic numbers and configuration defaults
12
+ * used throughout the router package.
13
+ */
14
+ /**
15
+ * Prefetch configuration defaults
16
+ */
17
+ export declare const PREFETCH_DEFAULTS: {
18
+ /** Default hover delay before prefetching (ms) */
19
+ readonly HOVER_DELAY: 150;
20
+ /** Default cache TTL for prefetched resources (ms) - 5 minutes */
21
+ readonly CACHE_TTL: 300000;
22
+ /** Intent velocity threshold for mouse movement (pixels/second) */
23
+ readonly INTENT_VELOCITY_THRESHOLD: 100;
24
+ /** Number of samples for direction detection */
25
+ readonly INTENT_DIRECTION_SAMPLES: 3;
26
+ /** Maximum cache size for prefetched resources */
27
+ readonly MAX_CACHE_SIZE: 100;
28
+ };
29
+ /**
30
+ * Scroll and focus management defaults
31
+ */
32
+ export declare const SCROLL_FOCUS_DEFAULTS: {
33
+ /** Delay before attempting to scroll to anchor (ms) */
34
+ readonly ANCHOR_DELAY: 100;
35
+ /** Number of retries for anchor scrolling */
36
+ readonly ANCHOR_RETRIES: 3;
37
+ /** Maximum age for scroll positions (ms) - 5 minutes */
38
+ readonly SCROLL_POSITION_MAX_AGE: number;
39
+ /** Clean old positions interval (ms) - 1 second */
40
+ readonly CLEAN_POSITIONS_INTERVAL: 1000;
41
+ /** Default max age for cleanup (ms) - 30 minutes */
42
+ readonly DEFAULT_CLEANUP_MAX_AGE: number;
43
+ /** Announcer element offset (for accessibility) */
44
+ readonly ANNOUNCER_OFFSET: -10000;
45
+ };
46
+ /**
47
+ * Loader configuration defaults
48
+ */
49
+ export declare const LOADER_DEFAULTS: {
50
+ /** Default cache TTL for loader data (ms) - 5 minutes */
51
+ readonly CACHE_TTL: 300000;
52
+ /** Default maximum cache size */
53
+ readonly MAX_CACHE_SIZE: 100;
54
+ };
55
+ /**
56
+ * Route matcher scoring weights
57
+ */
58
+ export declare const MATCHER_SCORES: {
59
+ /** Weight for static segments */
60
+ readonly STATIC_SEGMENT_WEIGHT: 3;
61
+ /** Multiplier for segment score calculation */
62
+ readonly SCORE_MULTIPLIER: 100;
63
+ };
64
+ /**
65
+ * Loading UI styling constants
66
+ */
67
+ export declare const LOADING_UI: {
68
+ /** Spinner size (px) */
69
+ readonly SPINNER_SIZE: 36;
70
+ /** Spinner border width (px) */
71
+ readonly SPINNER_BORDER: 4;
72
+ /** Loading overlay z-index */
73
+ readonly OVERLAY_Z_INDEX: 1000;
74
+ /** Spinner animation duration (degrees) */
75
+ readonly SPINNER_ROTATION: 360;
76
+ };
77
+ /**
78
+ * General router configuration
79
+ */
80
+ export declare const ROUTER_CONFIG: {
81
+ /** Default navigation transaction ID for initial mount */
82
+ readonly INITIAL_NAV_ID: 0;
83
+ };
84
+ /**
85
+ * Route module types for cache keys and invalidation
86
+ */
87
+ export declare const ROUTE_MODULE_TYPES: readonly ["page", "layout", "loading", "error", "loader", "config"];
88
+ export type RouteModuleType = (typeof ROUTE_MODULE_TYPES)[number];
89
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/router/core/constants.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC5B,kDAAkD;;IAGlD,kEAAkE;;IAGlE,mEAAmE;;IAGnE,gDAAgD;;IAGhD,kDAAkD;;CAE1C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC,uDAAuD;;IAGvD,6CAA6C;;IAG7C,wDAAwD;;IAGxD,mDAAmD;;IAGnD,oDAAoD;;IAGpD,mDAAmD;;CAE3C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,yDAAyD;;IAGzD,iCAAiC;;CAEzB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB,iCAAiC;;IAGjC,+CAA+C;;CAEvC,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB,wBAAwB;;IAGxB,gCAAgC;;IAGhC,8BAA8B;;IAG9B,2CAA2C;;CAEnC,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB,0DAA0D;;CAElD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB,qEAOrB,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,95 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router.constants",
4
+ "title": "Router Configuration Constants",
5
+ "category": "config"
6
+ }
7
+ */
8
+ /**
9
+ * Router package constants
10
+ *
11
+ * Centralized location for all magic numbers and configuration defaults
12
+ * used throughout the router package.
13
+ */
14
+ /**
15
+ * Prefetch configuration defaults
16
+ */
17
+ export const PREFETCH_DEFAULTS = {
18
+ /** Default hover delay before prefetching (ms) */
19
+ HOVER_DELAY: 150,
20
+ /** Default cache TTL for prefetched resources (ms) - 5 minutes */
21
+ CACHE_TTL: 300000,
22
+ /** Intent velocity threshold for mouse movement (pixels/second) */
23
+ INTENT_VELOCITY_THRESHOLD: 100,
24
+ /** Number of samples for direction detection */
25
+ INTENT_DIRECTION_SAMPLES: 3,
26
+ /** Maximum cache size for prefetched resources */
27
+ MAX_CACHE_SIZE: 100,
28
+ };
29
+ /**
30
+ * Scroll and focus management defaults
31
+ */
32
+ export const SCROLL_FOCUS_DEFAULTS = {
33
+ /** Delay before attempting to scroll to anchor (ms) */
34
+ ANCHOR_DELAY: 100,
35
+ /** Number of retries for anchor scrolling */
36
+ ANCHOR_RETRIES: 3,
37
+ /** Maximum age for scroll positions (ms) - 5 minutes */
38
+ SCROLL_POSITION_MAX_AGE: 5 * 60 * 1000,
39
+ /** Clean old positions interval (ms) - 1 second */
40
+ CLEAN_POSITIONS_INTERVAL: 1000,
41
+ /** Default max age for cleanup (ms) - 30 minutes */
42
+ DEFAULT_CLEANUP_MAX_AGE: 30 * 60 * 1000,
43
+ /** Announcer element offset (for accessibility) */
44
+ ANNOUNCER_OFFSET: -10000,
45
+ };
46
+ /**
47
+ * Loader configuration defaults
48
+ */
49
+ export const LOADER_DEFAULTS = {
50
+ /** Default cache TTL for loader data (ms) - 5 minutes */
51
+ CACHE_TTL: 300000,
52
+ /** Default maximum cache size */
53
+ MAX_CACHE_SIZE: 100,
54
+ };
55
+ /**
56
+ * Route matcher scoring weights
57
+ */
58
+ export const MATCHER_SCORES = {
59
+ /** Weight for static segments */
60
+ STATIC_SEGMENT_WEIGHT: 3,
61
+ /** Multiplier for segment score calculation */
62
+ SCORE_MULTIPLIER: 100,
63
+ };
64
+ /**
65
+ * Loading UI styling constants
66
+ */
67
+ export const LOADING_UI = {
68
+ /** Spinner size (px) */
69
+ SPINNER_SIZE: 36,
70
+ /** Spinner border width (px) */
71
+ SPINNER_BORDER: 4,
72
+ /** Loading overlay z-index */
73
+ OVERLAY_Z_INDEX: 1000,
74
+ /** Spinner animation duration (degrees) */
75
+ SPINNER_ROTATION: 360,
76
+ };
77
+ /**
78
+ * General router configuration
79
+ */
80
+ export const ROUTER_CONFIG = {
81
+ /** Default navigation transaction ID for initial mount */
82
+ INITIAL_NAV_ID: 0,
83
+ };
84
+ /**
85
+ * Route module types for cache keys and invalidation
86
+ */
87
+ export const ROUTE_MODULE_TYPES = [
88
+ 'page',
89
+ 'layout',
90
+ 'loading',
91
+ 'error',
92
+ 'loader',
93
+ 'config',
94
+ ];
95
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/router/core/constants.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,kDAAkD;IAClD,WAAW,EAAE,GAAG;IAEhB,kEAAkE;IAClE,SAAS,EAAE,MAAM;IAEjB,mEAAmE;IACnE,yBAAyB,EAAE,GAAG;IAE9B,gDAAgD;IAChD,wBAAwB,EAAE,CAAC;IAE3B,kDAAkD;IAClD,cAAc,EAAE,GAAG;CACX,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,uDAAuD;IACvD,YAAY,EAAE,GAAG;IAEjB,6CAA6C;IAC7C,cAAc,EAAE,CAAC;IAEjB,wDAAwD;IACxD,uBAAuB,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;IAEtC,mDAAmD;IACnD,wBAAwB,EAAE,IAAI;IAE9B,oDAAoD;IACpD,uBAAuB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAEvC,mDAAmD;IACnD,gBAAgB,EAAE,CAAC,KAAK;CAChB,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,yDAAyD;IACzD,SAAS,EAAE,MAAM;IAEjB,iCAAiC;IACjC,cAAc,EAAE,GAAG;CACX,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,iCAAiC;IACjC,qBAAqB,EAAE,CAAC;IAExB,+CAA+C;IAC/C,gBAAgB,EAAE,GAAG;CACb,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,wBAAwB;IACxB,YAAY,EAAE,EAAE;IAEhB,gCAAgC;IAChC,cAAc,EAAE,CAAC;IAEjB,8BAA8B;IAC9B,eAAe,EAAE,IAAI;IAErB,2CAA2C;IAC3C,gBAAgB,EAAE,GAAG;CACb,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,0DAA0D;IAC1D,cAAc,EAAE,CAAC;CACT,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,QAAQ;IACR,QAAQ;CACA,CAAC"}
@@ -0,0 +1,54 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router.core.history",
4
+ "title": "Browser History Interaction",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ import type { HistoryAdapter } from './types';
9
+ /** @codexApi {"parent":"pithy.router.core.history","name":"HistoryManager","stability":"stable","signature":"class HistoryManager","description":"Centralizes browser history state, scroll restoration, and popstate handling"} */
10
+ /**
11
+ * HistoryManager handles all browser history API interactions
12
+ * Centralizes history state management, scroll restoration, and popstate handling
13
+ * Uses HistoryAdapter for environment-agnostic history operations (enables SSR)
14
+ */
15
+ export declare class HistoryManager {
16
+ private lastCommittedUrl;
17
+ private adapter;
18
+ constructor(adapter: HistoryAdapter);
19
+ /**
20
+ * Get the last committed URL (for snap-back on guard denial)
21
+ * @returns Last committed URL string
22
+ */
23
+ getLastCommittedUrl(): string;
24
+ /**
25
+ * Push a new history entry
26
+ * @param state - State object to associate with the entry
27
+ * @param url - URL for the new entry
28
+ */
29
+ push(state: unknown, url: string): void;
30
+ /**
31
+ * Replace the current history entry
32
+ * @param state - State object to associate with the entry
33
+ * @param url - URL for the replacement entry
34
+ */
35
+ replace(state: unknown, url: string): void;
36
+ /**
37
+ * Snap back to the last committed URL (used when guards block navigation)
38
+ */
39
+ snapBack(): void;
40
+ /**
41
+ * Go back in history (delegates to adapter)
42
+ */
43
+ back(): void;
44
+ /**
45
+ * Go forward in history (delegates to adapter)
46
+ */
47
+ forward(): void;
48
+ /**
49
+ * Save current scroll position to history.state before navigation
50
+ * This captures window scroll and any scrollable containers marked with [data-remember-scroll]
51
+ */
52
+ saveScrollPosition(): void;
53
+ }
54
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/router/core/history.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,oOAAoO;AACpO;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,OAAO,CAAiB;gBAEpB,OAAO,EAAE,cAAc;IAMnC;;;OAGG;IACI,mBAAmB,IAAI,MAAM;IAIpC;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAK9C;;;;OAIG;IACI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAKjD;;OAEG;IACI,QAAQ,IAAI,IAAI;IAQvB;;OAEG;IACI,IAAI,IAAI,IAAI;IAInB;;OAEG;IACI,OAAO,IAAI,IAAI;IAItB;;;OAGG;IACI,kBAAkB,IAAI,IAAI;CAoBlC"}
@@ -0,0 +1,89 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router.core.history",
4
+ "title": "Browser History Interaction",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ import { selectorFor } from './utils';
9
+ /** @codexApi {"parent":"pithy.router.core.history","name":"HistoryManager","stability":"stable","signature":"class HistoryManager","description":"Centralizes browser history state, scroll restoration, and popstate handling"} */
10
+ /**
11
+ * HistoryManager handles all browser history API interactions
12
+ * Centralizes history state management, scroll restoration, and popstate handling
13
+ * Uses HistoryAdapter for environment-agnostic history operations (enables SSR)
14
+ */
15
+ export class HistoryManager {
16
+ constructor(adapter) {
17
+ this.adapter = adapter;
18
+ const location = adapter.getLocation();
19
+ this.lastCommittedUrl = location.path + location.search + location.hash;
20
+ }
21
+ /**
22
+ * Get the last committed URL (for snap-back on guard denial)
23
+ * @returns Last committed URL string
24
+ */
25
+ getLastCommittedUrl() {
26
+ return this.lastCommittedUrl;
27
+ }
28
+ /**
29
+ * Push a new history entry
30
+ * @param state - State object to associate with the entry
31
+ * @param url - URL for the new entry
32
+ */
33
+ push(state, url) {
34
+ this.adapter.push(url, state);
35
+ this.lastCommittedUrl = url;
36
+ }
37
+ /**
38
+ * Replace the current history entry
39
+ * @param state - State object to associate with the entry
40
+ * @param url - URL for the replacement entry
41
+ */
42
+ replace(state, url) {
43
+ this.adapter.replace(url, state);
44
+ this.lastCommittedUrl = url;
45
+ }
46
+ /**
47
+ * Snap back to the last committed URL (used when guards block navigation)
48
+ */
49
+ snapBack() {
50
+ // Get current state from browser (adapter-agnostic way would require extending HistoryAdapter)
51
+ // For now, assume browser environment in snapBack
52
+ if (typeof window !== 'undefined' && window.history) {
53
+ this.adapter.replace(this.lastCommittedUrl, window.history.state);
54
+ }
55
+ }
56
+ /**
57
+ * Go back in history (delegates to adapter)
58
+ */
59
+ back() {
60
+ this.adapter.back();
61
+ }
62
+ /**
63
+ * Go forward in history (delegates to adapter)
64
+ */
65
+ forward() {
66
+ this.adapter.forward();
67
+ }
68
+ /**
69
+ * Save current scroll position to history.state before navigation
70
+ * This captures window scroll and any scrollable containers marked with [data-remember-scroll]
71
+ */
72
+ saveScrollPosition() {
73
+ // Only save scroll in browser environment
74
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
75
+ return;
76
+ }
77
+ const scroll = {
78
+ window: { x: window.scrollX, y: window.scrollY },
79
+ containers: Array.from(document.querySelectorAll('[data-remember-scroll]')).map(el => ({
80
+ sel: selectorFor(el),
81
+ x: el.scrollLeft,
82
+ y: el.scrollTop,
83
+ })),
84
+ ts: Date.now(),
85
+ };
86
+ this.adapter.saveScrollPosition(scroll);
87
+ }
88
+ }
89
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/router/core/history.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,oOAAoO;AACpO;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAIzB,YAAY,OAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACI,mBAAmB;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,KAAc,EAAE,GAAW;QACrC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,KAAc,EAAE,GAAW;QACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,+FAA+F;QAC/F,kDAAkD;QAClD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED;;OAEG;IACI,IAAI;QACT,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,kBAAkB;QACvB,0CAA0C;QAC1C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACrE,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG;YACb,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE;YAChD,UAAU,EAAE,KAAK,CAAC,IAAI,CACpB,QAAQ,CAAC,gBAAgB,CAAc,wBAAwB,CAAC,CACjE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACX,GAAG,EAAE,WAAW,CAAC,EAAE,CAAC;gBACpB,CAAC,EAAE,EAAE,CAAC,UAAU;gBAChB,CAAC,EAAE,EAAE,CAAC,SAAS;aAChB,CAAC,CAAC;YACH,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;SACf,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.router.matcher",
4
+ "title": "Route Path Matching Engine",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ import { RouteMatch, RouteParams, RouteSegment, RouterConfig, TrailingSlashPolicy } from './types';
9
+ /** @codexApi {"parent":"pithy.router.matcher","name":"parseRoutePattern","stability":"stable","signature":"(pattern: string) => RouteSegment[]","description":"Parse a route pattern into typed segments (static, dynamic, catch-all, group)"} */
10
+ /**
11
+ * Parse a route pattern into segments with type information
12
+ * Handles static, dynamic [id], catch-all [...slug], and groups (group)
13
+ */
14
+ export declare function parseRoutePattern(pattern: string): RouteSegment[];
15
+ /** @codexApi {"parent":"pithy.router.matcher","name":"calculateRouteScore","stability":"stable","signature":"(segments: RouteSegment[]) => number","description":"Calculate route precedence score for conflict resolution"} */
16
+ /**
17
+ * Calculate route precedence score for conflict resolution
18
+ * Higher score = higher precedence
19
+ * Rules: Static > Dynamic > CatchAll, Longer > Shorter
20
+ */
21
+ export declare function calculateRouteScore(segments: RouteSegment[]): number;
22
+ /** @codexApi {"parent":"pithy.router.matcher","name":"normalizePath","stability":"stable","signature":"(path: string, policy?: TrailingSlashPolicy) => string","description":"Normalize path according to trailing slash policy"} */
23
+ /**
24
+ * Normalize path according to trailing slash policy
25
+ */
26
+ export declare function normalizePath(path: string, policy?: TrailingSlashPolicy): string;
27
+ /** @codexApi {"parent":"pithy.router.matcher","name":"extractParams","stability":"stable","signature":"(pathSegments: string[], routeSegments: RouteSegment[], decodeParams?: boolean) => RouteParams","description":"Extract parameters from a matched path using route segments"} */
28
+ /**
29
+ * Extract parameters from a matched path using route segments
30
+ */
31
+ export declare function extractParams(pathSegments: string[], routeSegments: RouteSegment[], decodeParams?: boolean): RouteParams;
32
+ /** @codexApi {"parent":"pithy.router.matcher","name":"matchRoute","stability":"stable","signature":"(path: string, pattern: string, config?: RouterConfig) => RouteMatch | null","description":"Check if a path matches a route pattern and return match details"} */
33
+ /**
34
+ * Check if a path matches a route pattern
35
+ */
36
+ export declare function matchRoute(path: string, pattern: string, config?: RouterConfig): RouteMatch | null;
37
+ /** @codexApi {"parent":"pithy.router.matcher","name":"findBestMatch","stability":"stable","signature":"(path: string, patterns: string[], config?: RouterConfig) => RouteMatch | null","description":"Find the best matching route by highest precedence score"} */
38
+ /**
39
+ * Find the best matching route from a list of patterns
40
+ * Returns the route with the highest precedence score
41
+ */
42
+ export declare function findBestMatch(path: string, patterns: string[], config?: RouterConfig): RouteMatch | null;
43
+ //# sourceMappingURL=matcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../../../src/router/core/matcher.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EACL,UAAU,EACV,WAAW,EACX,YAAY,EAEZ,YAAY,EACZ,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAGjB,kPAAkP;AAClP;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAmEjE;AAED,gOAAgO;AAChO;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAqBpE;AAED,qOAAqO;AACrO;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,mBAA6B,GACpC,MAAM,CAeR;AAED,uRAAuR;AACvR;;GAEG;AACH,wBAAgB,aAAa,CAC3B,YAAY,EAAE,MAAM,EAAE,EACtB,aAAa,EAAE,YAAY,EAAE,EAC7B,YAAY,UAAO,GAClB,WAAW,CA4Cb;AAED,sQAAsQ;AACtQ;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,YAAiB,GACxB,UAAU,GAAG,IAAI,CAgCnB;AA0CD,oQAAoQ;AACpQ;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,GAAE,YAAiB,GACxB,UAAU,GAAG,IAAI,CAoBnB"}