@relax.js/core 1.0.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 (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +188 -0
  3. package/dist/DataLoader.d.ts +51 -0
  4. package/dist/DependencyInjection.d.ts +271 -0
  5. package/dist/DependencyInjectionOld.d.ts +35 -0
  6. package/dist/Metadata.d.ts +8 -0
  7. package/dist/SequentialId.d.ts +47 -0
  8. package/dist/_alt/src/MustardEngine.d.ts +30 -0
  9. package/dist/_alt/src/MustardParser.d.ts +63 -0
  10. package/dist/_alt/src/MustardParser2.d.ts +35 -0
  11. package/dist/_alt/src/pipes.d.ts +93 -0
  12. package/dist/_alt/src/template.d.ts +166 -0
  13. package/dist/_alt/src/tools.d.ts +4 -0
  14. package/dist/_alt/tests/pipes.tests.d.ts +1 -0
  15. package/dist/_alt/tests/template.tests.d.ts +1 -0
  16. package/dist/_alt/vitest.config.d.ts +2 -0
  17. package/dist/collections/Index.d.ts +1 -0
  18. package/dist/collections/LinkedList.d.ts +75 -0
  19. package/dist/collections/Pager.d.ts +15 -0
  20. package/dist/collections/index.js +2 -0
  21. package/dist/collections/index.js.map +7 -0
  22. package/dist/collections/index.mjs +2 -0
  23. package/dist/collections/index.mjs.map +7 -0
  24. package/dist/components/Table.d.ts +13 -0
  25. package/dist/components/index.d.ts +4 -0
  26. package/dist/components/index.js +128 -0
  27. package/dist/components/index.js.map +7 -0
  28. package/dist/components/index.mjs +128 -0
  29. package/dist/components/index.mjs.map +7 -0
  30. package/dist/components/lists/Table.d.ts +59 -0
  31. package/dist/components/lists/TreeView.d.ts +67 -0
  32. package/dist/components/lists/index.d.ts +2 -0
  33. package/dist/components/loader.d.ts +60 -0
  34. package/dist/components/menus/MenuItem.d.ts +30 -0
  35. package/dist/components/menus/TopMenu.d.ts +16 -0
  36. package/dist/components/menus/index.d.ts +2 -0
  37. package/dist/components/panels/tabs.d.ts +15 -0
  38. package/dist/di/index.d.ts +1 -0
  39. package/dist/di/index.js +2 -0
  40. package/dist/di/index.js.map +7 -0
  41. package/dist/di/index.mjs +2 -0
  42. package/dist/di/index.mjs.map +7 -0
  43. package/dist/elements/CopyAttributes.d.ts +2 -0
  44. package/dist/elements/dom.d.ts +18 -0
  45. package/dist/elements/index.d.ts +2 -0
  46. package/dist/elements/index.js +2 -0
  47. package/dist/elements/index.js.map +7 -0
  48. package/dist/elements/index.mjs +2 -0
  49. package/dist/elements/index.mjs.map +7 -0
  50. package/dist/errors.d.ts +71 -0
  51. package/dist/forms/FormReader.d.ts +182 -0
  52. package/dist/forms/FormValidator.d.ts +114 -0
  53. package/dist/forms/ValidationRules.d.ts +103 -0
  54. package/dist/forms/index.d.ts +4 -0
  55. package/dist/forms/index.js +2 -0
  56. package/dist/forms/index.js.map +7 -0
  57. package/dist/forms/index.mjs +2 -0
  58. package/dist/forms/index.mjs.map +7 -0
  59. package/dist/forms/setFormData.d.ts +49 -0
  60. package/dist/getParentComponent.d.ts +43 -0
  61. package/dist/html/TableRenderer.d.ts +44 -0
  62. package/dist/html/TreeBinder.d.ts +9 -0
  63. package/dist/html/html.d.ts +55 -0
  64. package/dist/html/index.d.ts +5 -0
  65. package/dist/html/index.js +2 -0
  66. package/dist/html/index.js.map +7 -0
  67. package/dist/html/index.mjs +2 -0
  68. package/dist/html/index.mjs.map +7 -0
  69. package/dist/html/template.d.ts +167 -0
  70. package/dist/http/ServerSentEvents.d.ts +116 -0
  71. package/dist/http/SimpleWebSocket.d.ts +153 -0
  72. package/dist/http/http.d.ts +177 -0
  73. package/dist/http/index.d.ts +3 -0
  74. package/dist/http/index.js +2 -0
  75. package/dist/http/index.js.map +7 -0
  76. package/dist/http/index.mjs +2 -0
  77. package/dist/http/index.mjs.map +7 -0
  78. package/dist/i18n/i18n.d.ts +105 -0
  79. package/dist/i18n/icu.d.ts +64 -0
  80. package/dist/i18n/index.d.ts +2 -0
  81. package/dist/i18n/index.js +2 -0
  82. package/dist/i18n/index.js.map +7 -0
  83. package/dist/i18n/index.mjs +2 -0
  84. package/dist/i18n/index.mjs.map +7 -0
  85. package/dist/index.d.ts +16 -0
  86. package/dist/index.js +5 -0
  87. package/dist/index.js.map +7 -0
  88. package/dist/index.mjs +5 -0
  89. package/dist/index.mjs.map +7 -0
  90. package/dist/lib/DataLoader.d.ts +51 -0
  91. package/dist/lib/DependencyInjection.d.ts +271 -0
  92. package/dist/lib/InvokeParent.d.ts +10 -0
  93. package/dist/lib/Pipes.d.ts +236 -0
  94. package/dist/lib/SequentialId.d.ts +47 -0
  95. package/dist/lib/collections/Index.d.ts +1 -0
  96. package/dist/lib/collections/LinkedList.d.ts +75 -0
  97. package/dist/lib/collections/Pager.d.ts +15 -0
  98. package/dist/lib/collections/TableRenderer.d.ts +44 -0
  99. package/dist/lib/di/index.d.ts +1 -0
  100. package/dist/lib/elements/CopyAttributes.d.ts +2 -0
  101. package/dist/lib/elements/dom.d.ts +18 -0
  102. package/dist/lib/elements/index.d.ts +2 -0
  103. package/dist/lib/errors.d.ts +71 -0
  104. package/dist/lib/forms/FormReader.d.ts +182 -0
  105. package/dist/lib/forms/FormValidator.d.ts +114 -0
  106. package/dist/lib/forms/ValidationRules.d.ts +103 -0
  107. package/dist/lib/forms/index.d.ts +4 -0
  108. package/dist/lib/forms/setFormData.d.ts +49 -0
  109. package/dist/lib/getParentComponent.d.ts +43 -0
  110. package/dist/lib/html/TableRenderer.d.ts +44 -0
  111. package/dist/lib/html/TreeBinder.d.ts +9 -0
  112. package/dist/lib/html/html.d.ts +55 -0
  113. package/dist/lib/html/html2.d.ts +55 -0
  114. package/dist/lib/html/index.d.ts +5 -0
  115. package/dist/lib/html/m.d.ts +167 -0
  116. package/dist/lib/html/m2.d.ts +8 -0
  117. package/dist/lib/html/m3.d.ts +0 -0
  118. package/dist/lib/html/template.d.ts +167 -0
  119. package/dist/lib/http/HttpClient.d.ts +153 -0
  120. package/dist/lib/http/ServerSentEvents.d.ts +116 -0
  121. package/dist/lib/http/SimpleWebSocket.d.ts +153 -0
  122. package/dist/lib/http/http.d.ts +177 -0
  123. package/dist/lib/http/index.d.ts +3 -0
  124. package/dist/lib/i18n/i18n.d.ts +105 -0
  125. package/dist/lib/i18n/icu.d.ts +64 -0
  126. package/dist/lib/i18n/index.d.ts +2 -0
  127. package/dist/lib/index.d.ts +16 -0
  128. package/dist/lib/routing/NavigateRouteEvent.d.ts +52 -0
  129. package/dist/lib/routing/RouteLink.d.ts +7 -0
  130. package/dist/lib/routing/Routing.d.ts +270 -0
  131. package/dist/lib/routing/RoutingTarget.d.ts +22 -0
  132. package/dist/lib/routing/index.d.ts +7 -0
  133. package/dist/lib/routing/navigation.d.ts +70 -0
  134. package/dist/lib/routing/routeMatching.d.ts +21 -0
  135. package/dist/lib/routing/routeTargetRegistry.d.ts +23 -0
  136. package/dist/lib/routing/types.d.ts +130 -0
  137. package/dist/lib/templates/NodeTemplate.d.ts +38 -0
  138. package/dist/lib/templates/accessorParser.d.ts +87 -0
  139. package/dist/lib/templates/parseTemplate.d.ts +6 -0
  140. package/dist/lib/templates/tokenizer.d.ts +76 -0
  141. package/dist/lib/tools.d.ts +30 -0
  142. package/dist/lib/utils/index.d.ts +4 -0
  143. package/dist/pipes.d.ts +236 -0
  144. package/dist/routing/NavigateRouteEvent.d.ts +52 -0
  145. package/dist/routing/RouteLink.d.ts +7 -0
  146. package/dist/routing/RoutingTarget.d.ts +22 -0
  147. package/dist/routing/index.d.ts +7 -0
  148. package/dist/routing/index.js +5 -0
  149. package/dist/routing/index.js.map +7 -0
  150. package/dist/routing/index.mjs +5 -0
  151. package/dist/routing/index.mjs.map +7 -0
  152. package/dist/routing/navigation.d.ts +70 -0
  153. package/dist/routing/routeMatching.d.ts +21 -0
  154. package/dist/routing/routeTargetRegistry.d.ts +23 -0
  155. package/dist/routing/types.d.ts +130 -0
  156. package/dist/templates/NodeTemplate.d.ts +38 -0
  157. package/dist/templates/accessorParser.d.ts +87 -0
  158. package/dist/templates/parseTemplate.d.ts +6 -0
  159. package/dist/templates/tokenizer.d.ts +76 -0
  160. package/dist/tools.d.ts +30 -0
  161. package/dist/utils/index.d.ts +4 -0
  162. package/dist/utils/index.js +2 -0
  163. package/dist/utils/index.js.map +7 -0
  164. package/dist/utils/index.mjs +2 -0
  165. package/dist/utils/index.mjs.map +7 -0
  166. package/docs/Architecture.md +333 -0
  167. package/docs/DependencyInjection.md +237 -0
  168. package/docs/Errors.md +87 -0
  169. package/docs/GettingStarted.md +231 -0
  170. package/docs/Pipes.md +211 -0
  171. package/docs/Translations.md +312 -0
  172. package/docs/WhyRelaxjs.md +336 -0
  173. package/docs/elements/dom.md +102 -0
  174. package/docs/forms/creating-form-components.md +924 -0
  175. package/docs/forms/form-api.md +94 -0
  176. package/docs/forms/forms.md +99 -0
  177. package/docs/forms/patterns.md +311 -0
  178. package/docs/forms/reading-writing.md +365 -0
  179. package/docs/forms/validation.md +351 -0
  180. package/docs/html/TableRenderer.md +292 -0
  181. package/docs/html/html.md +175 -0
  182. package/docs/html/index.md +54 -0
  183. package/docs/html/template.md +422 -0
  184. package/docs/http/HttpClient.md +459 -0
  185. package/docs/http/ServerSentEvents.md +184 -0
  186. package/docs/http/index.md +109 -0
  187. package/docs/i18n/i18n.md +309 -0
  188. package/docs/i18n/intl-standard.md +178 -0
  189. package/docs/routing/RouteLink.md +98 -0
  190. package/docs/routing/Routing.md +332 -0
  191. package/docs/routing/RoutingTarget.md +136 -0
  192. package/docs/routing/layouts.md +207 -0
  193. package/docs/utilities.md +143 -0
  194. package/package.json +93 -0
@@ -0,0 +1,7 @@
1
+ export declare class RouteLink extends HTMLElement {
2
+ static get observedAttributes(): string[];
3
+ constructor();
4
+ private handleClick;
5
+ connectedCallback(): void;
6
+ disconnectedCallback(): void;
7
+ }
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Single Page Application routing system with multiple target support.
3
+ * Designed for scenarios where you need:
4
+ * - Multiple navigation targets (main content, modals, sidebars)
5
+ * - Strongly typed route parameters
6
+ * - History management with back/forward support
7
+ *
8
+ * @example
9
+ * // Configure routes
10
+ * const routes = [
11
+ * { name: 'user', path: '/users/:id' }, // String parameter
12
+ * { name: 'order', path: '/orders/;orderId' }, // Number parameter
13
+ * { name: 'modal', path: '/detail/:id', target: 'modal' } // Custom target
14
+ * ];
15
+ */
16
+ type WebComponentConstructor = new (...args: any[]) => HTMLElement;
17
+ export declare enum GuardResult {
18
+ /**
19
+ * Handle route without checking more guards.
20
+ */
21
+ Allow = 0,
22
+ /**
23
+ * Throw a RouteGuardError.
24
+ */
25
+ Deny = 1,
26
+ /**
27
+ * Resume and check other guards.
28
+ */
29
+ Continue = 2,
30
+ /**
31
+ * Do not invoke the rooute nor other guards.
32
+ */
33
+ Stop = 3
34
+ }
35
+ export interface RouteGuard {
36
+ check(route: RouteMatchResult): GuardResult;
37
+ }
38
+ export interface Route {
39
+ name?: string;
40
+ target?: string;
41
+ path: string;
42
+ /**
43
+ * HTML file name (without extension).
44
+ *
45
+ * Define for instance if you have a route that requires a more limited layout. The library
46
+ * will automatically load that HTML file and rewrite URL history so that the correct url is displayed.
47
+ */
48
+ layout?: string;
49
+ /**
50
+ * Name of the tag for your web component.
51
+ */
52
+ componentTagName?: string;
53
+ /**
54
+ * Guards used to check if this route can be visited.
55
+ */
56
+ guards?: RouteGuard[];
57
+ component?: WebComponentConstructor;
58
+ }
59
+ export declare const internalRoutes: Route[];
60
+ export declare const MyData: {
61
+ routes: any[];
62
+ };
63
+ /**
64
+ * Debug helper to print all registered routes to console.
65
+ */
66
+ export declare function printRoutes(): void;
67
+ /**
68
+ * Registers application routes with the router.
69
+ * Call this at application startup before routing begins.
70
+ *
71
+ * @param appRoutes - Array of route configurations
72
+ * @throws Error if referenced components are not registered
73
+ *
74
+ * @example
75
+ * const routes: Route[] = [
76
+ * { name: 'home', path: '/', componentTagName: 'app-home' },
77
+ * { name: 'user', path: '/users/:id', componentTagName: 'user-profile' },
78
+ * { name: 'login', path: '/auth/', componentTagName: 'login-form', layout: 'noauth' }
79
+ * ];
80
+ * defineRoutes(routes);
81
+ */
82
+ export declare function defineRoutes(appRoutes: Route[]): void;
83
+ export type RouteParamType = string | number;
84
+ export type RouteData = Record<string, RouteParamType>;
85
+ /**
86
+ * Implement to receive typed route parameters via a `routeData` property.
87
+ * RouteTarget assigns `routeData` after element creation but before DOM insertion.
88
+ * Optional since it's not available at construction time.
89
+ *
90
+ * For convention-based usage without undefined checks, skip the interface
91
+ * and declare `routeData` directly on your component.
92
+ *
93
+ * @example
94
+ * class UserProfile extends HTMLElement implements Routable<{ userName: string }> {
95
+ * routeData?: { userName: string };
96
+ * }
97
+ */
98
+ export interface Routable<T extends RouteData = RouteData> {
99
+ routeData?: T;
100
+ }
101
+ /**
102
+ * Implement to run async initialization before the component is added to the DOM.
103
+ * RouteTarget calls `loadRoute()` and awaits it before inserting the element.
104
+ *
105
+ * @example
106
+ * class OrderDetail extends HTMLElement implements LoadRoute<{ orderId: number }> {
107
+ * async loadRoute(data: { orderId: number }) {
108
+ * this.order = await fetchOrder(data.orderId);
109
+ * }
110
+ * }
111
+ */
112
+ export interface LoadRoute<T extends RouteData = RouteData> {
113
+ loadRoute(data: T): void | Promise<void>;
114
+ }
115
+ /**
116
+ * Event sent to routing targets when a new route should be displayed.
117
+ */
118
+ export declare class NavigateRouteEvent extends Event {
119
+ /**
120
+ * Matched route.
121
+ */
122
+ route: Route;
123
+ /**
124
+ * The generated url sements which can be used to push the url into the browser history.
125
+ */
126
+ urlSegments: string[];
127
+ /**
128
+ * Data supplied to the route.
129
+ */
130
+ routeData?: RouteData;
131
+ /**
132
+ * The target can differ from the default target that is defined in the route.
133
+ *
134
+ * undefined means that the default (unnamed) target should be used.
135
+ */
136
+ routeTarget?: string;
137
+ static NAME: string;
138
+ constructor(
139
+ /**
140
+ * Matched route.
141
+ */
142
+ route: Route,
143
+ /**
144
+ * The generated url sements which can be used to push the url into the browser history.
145
+ */
146
+ urlSegments: string[],
147
+ /**
148
+ * Data supplied to the route.
149
+ */
150
+ routeData?: RouteData,
151
+ /**
152
+ * The target can differ from the default target that is defined in the route.
153
+ *
154
+ * undefined means that the default (unnamed) target should be used.
155
+ */
156
+ routeTarget?: string, eventInit?: EventInit);
157
+ }
158
+ declare global {
159
+ interface HTMLElementEventMap {
160
+ 'rlx.navigateRoute': NavigateRouteEvent;
161
+ }
162
+ interface DocumentEventMap {
163
+ 'rlx.navigateRoute': NavigateRouteEvent;
164
+ }
165
+ }
166
+ /**
167
+ * Result from route matching operations.
168
+ * Contains all information needed for navigation and rendering.
169
+ */
170
+ export type RouteMatchResult = {
171
+ /**
172
+ * Matched route configuration
173
+ */
174
+ route: Route;
175
+ /**
176
+ * URL segments used for history state
177
+ */
178
+ urlSegments: string[];
179
+ /**
180
+ * Extracted and type-converted parameters
181
+ */
182
+ params: RouteData;
183
+ };
184
+ /**
185
+ * Supported types of route segments
186
+ */
187
+ export type RouteSegmentType = 'string' | 'number' | 'path' | 'regex';
188
+ /**
189
+ * Strongly typed route segment value
190
+ */
191
+ export interface RouteValue {
192
+ /**
193
+ * Type of parameter for validation
194
+ */
195
+ type: RouteSegmentType;
196
+ /**
197
+ * Actual parameter value
198
+ */
199
+ value: any;
200
+ }
201
+ export declare class RouteError extends Error {
202
+ }
203
+ export declare class RouteGuardError extends RouteError {
204
+ isGuard: any;
205
+ }
206
+ export interface NavigateOptions {
207
+ /**
208
+ * Optional parameters when using route name
209
+ */
210
+ params?: Record<string, string | number>;
211
+ /**
212
+ * override for route's default target
213
+ */
214
+ target?: string;
215
+ /**
216
+ * When you want to override routes from the globally registered ones.
217
+ */
218
+ routes?: Route[];
219
+ }
220
+ /**
221
+ * Initializes routing and navigates to the current URL.
222
+ * Call this after DOM is ready and routes are defined.
223
+ *
224
+ * @example
225
+ * // In your main application component
226
+ * connectedCallback() {
227
+ * defineRoutes(routes);
228
+ * startRouting();
229
+ * }
230
+ */
231
+ export declare function startRouting(): void;
232
+ /**
233
+ * Navigates to a route by name or URL.
234
+ * Updates browser history and dispatches navigation events.
235
+ *
236
+ * @param routeNameOrUrl - Route name or URL path to navigate to
237
+ * @param options - Navigation options including params and target
238
+ *
239
+ * @example
240
+ * // Navigate by route name
241
+ * navigate('user', { params: { id: '123' } });
242
+ *
243
+ * // Navigate by URL
244
+ * navigate('/users/123');
245
+ *
246
+ * // Navigate to specific target
247
+ * navigate('detail', { params: { id: '42' }, target: 'modal' });
248
+ */
249
+ export declare function navigate(routeNameOrUrl: string, options?: NavigateOptions): void;
250
+ /**
251
+ * Match route by either name or URL pattern
252
+ * @param routes Available routes
253
+ * @param routeNameOrUrl Route name or URL to match
254
+ * @param routeData Optional parameters for named routes
255
+ */
256
+ export declare function matchRoute(routes: Route[], routeNameOrUrl: string, routeData?: Record<string, string | any>): RouteMatchResult | null;
257
+ /**
258
+ * Find route by name and apply parameters
259
+ * @param routes Available routes
260
+ * @param name Route name to find
261
+ * @param routeData Parameters to apply
262
+ */
263
+ export declare function findRouteByName(routes: Route[], name: string, routeData?: Record<string, string | any>): RouteMatchResult | null;
264
+ /**
265
+ * Find route matching URL pattern
266
+ * @param routes Available routes
267
+ * @param path URL to match
268
+ */
269
+ export declare function findRouteByUrl(routes: Route[], path: string): RouteMatchResult | null;
270
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * WebComponent that listens on the `NavigateRouteEvent` event to be able to switch route.
3
+ *
4
+ * Use the "name" attribute to make this non-default target.
5
+ * Use the "dialog" attribute to render routes inside a native `<dialog>` element
6
+ * with built-in focus trapping, backdrop, and Escape-to-close.
7
+ *
8
+ * @example
9
+ * <r-route-target></r-route-target>
10
+ * <r-route-target name="modal" dialog></r-route-target>
11
+ */
12
+ export declare class RouteTarget extends HTMLElement {
13
+ name?: string;
14
+ private dialog?;
15
+ connectedCallback(): void;
16
+ disconnectedCallback(): void;
17
+ private onNavigate;
18
+ private loadComponent;
19
+ /** Closes the dialog (only applies to dialog targets). */
20
+ close(): void;
21
+ private applyRouteData;
22
+ }
@@ -0,0 +1,7 @@
1
+ export { GuardResult, RouteGuard, Route, RouteParamType, RouteData, Routable, LoadRoute, RouteError, RouteGuardError, NavigateOptions, RouteMatchResult, RouteSegmentType, RouteValue, } from './types';
2
+ export { NavigateRouteEvent } from './NavigateRouteEvent';
3
+ export { registerRouteTarget, unregisterRouteTarget, clearPendingNavigations, } from './routeTargetRegistry';
4
+ export { matchRoute, findRouteByName, findRouteByUrl, } from './routeMatching';
5
+ export { internalRoutes, defineRoutes, startRouting, navigate, printRoutes, } from './navigation';
6
+ export { RouteLink } from './RouteLink';
7
+ export { RouteTarget } from './RoutingTarget';
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Single Page Application routing system with multiple target support.
3
+ * Designed for scenarios where you need:
4
+ * - Multiple navigation targets (main content, modals, sidebars)
5
+ * - Strongly typed route parameters
6
+ * - History management with back/forward support
7
+ *
8
+ * @example
9
+ * // Configure routes
10
+ * const routes = [
11
+ * { name: 'user', path: '/users/:id' }, // String parameter
12
+ * { name: 'order', path: '/orders/;orderId' }, // Number parameter
13
+ * { name: 'modal', path: '/detail/:id', target: 'modal' } // Custom target
14
+ * ];
15
+ */
16
+ import { type Route, type NavigateOptions } from './types';
17
+ export declare const internalRoutes: Route[];
18
+ export declare const MyData: {
19
+ routes: any[];
20
+ };
21
+ /**
22
+ * Debug helper to print all registered routes to console.
23
+ */
24
+ export declare function printRoutes(): void;
25
+ /**
26
+ * Registers application routes with the router.
27
+ * Call this at application startup before routing begins.
28
+ *
29
+ * @param appRoutes - Array of route configurations
30
+ * @throws Error if referenced components are not registered
31
+ *
32
+ * @example
33
+ * const routes: Route[] = [
34
+ * { name: 'home', path: '/', componentTagName: 'app-home' },
35
+ * { name: 'user', path: '/users/:id', componentTagName: 'user-profile' },
36
+ * { name: 'login', path: '/auth/', componentTagName: 'login-form', layout: 'noauth' }
37
+ * ];
38
+ * defineRoutes(routes);
39
+ */
40
+ export declare function defineRoutes(appRoutes: Route[]): void;
41
+ /**
42
+ * Initializes routing and navigates to the current URL.
43
+ * Call this after DOM is ready and routes are defined.
44
+ *
45
+ * @example
46
+ * // In your main application component
47
+ * connectedCallback() {
48
+ * defineRoutes(routes);
49
+ * startRouting();
50
+ * }
51
+ */
52
+ export declare function startRouting(): void;
53
+ /**
54
+ * Navigates to a route by name or URL.
55
+ * Updates browser history and dispatches navigation events.
56
+ *
57
+ * @param routeNameOrUrl - Route name or URL path to navigate to
58
+ * @param options - Navigation options including params and target
59
+ *
60
+ * @example
61
+ * // Navigate by route name
62
+ * navigate('user', { params: { id: '123' } });
63
+ *
64
+ * // Navigate by URL
65
+ * navigate('/users/123');
66
+ *
67
+ * // Navigate to specific target
68
+ * navigate('detail', { params: { id: '42' }, target: 'modal' });
69
+ */
70
+ export declare function navigate(routeNameOrUrl: string, options?: NavigateOptions): void;
@@ -0,0 +1,21 @@
1
+ import type { Route, RouteMatchResult } from './types';
2
+ /**
3
+ * Match route by either name or URL pattern
4
+ * @param routes Available routes
5
+ * @param routeNameOrUrl Route name or URL to match
6
+ * @param routeData Optional parameters for named routes
7
+ */
8
+ export declare function matchRoute(routes: Route[], routeNameOrUrl: string, routeData?: Record<string, string | any>): RouteMatchResult | null;
9
+ /**
10
+ * Find route by name and apply parameters
11
+ * @param routes Available routes
12
+ * @param name Route name to find
13
+ * @param routeData Parameters to apply
14
+ */
15
+ export declare function findRouteByName(routes: Route[], name: string, routeData?: Record<string, string | any>): RouteMatchResult | null;
16
+ /**
17
+ * Find route matching URL pattern
18
+ * @param routes Available routes
19
+ * @param path URL to match
20
+ */
21
+ export declare function findRouteByUrl(routes: Route[], path: string): RouteMatchResult | null;
@@ -0,0 +1,23 @@
1
+ import { NavigateRouteEvent } from './NavigateRouteEvent';
2
+ type RouteTargetHandler = (evt: NavigateRouteEvent) => void;
3
+ /**
4
+ * Registers a route target handler.
5
+ * When a navigation event targets this name, the handler is called directly.
6
+ * If a pending event exists for this target, it is replayed immediately.
7
+ *
8
+ * @param name - Target name, or `undefined` for the default (unnamed) target
9
+ * @param handler - Callback that receives the `NavigateRouteEvent`
10
+ *
11
+ * @example
12
+ * registerRouteTarget('sidebar', (evt) => renderComponent(evt));
13
+ */
14
+ export declare function registerRouteTarget(name: string | undefined, handler: RouteTargetHandler): void;
15
+ /**
16
+ * Unregisters a previously registered route target handler.
17
+ *
18
+ * @param name - Target name that was passed to `registerRouteTarget`
19
+ */
20
+ export declare function unregisterRouteTarget(name: string | undefined): void;
21
+ export declare function clearPendingNavigations(): void;
22
+ export declare function initRouteTargetListener(): void;
23
+ export {};
@@ -0,0 +1,130 @@
1
+ type WebComponentConstructor = new (...args: any[]) => HTMLElement;
2
+ export declare enum GuardResult {
3
+ /**
4
+ * Handle route without checking more guards.
5
+ */
6
+ Allow = 0,
7
+ /**
8
+ * Throw a RouteGuardError.
9
+ */
10
+ Deny = 1,
11
+ /**
12
+ * Resume and check other guards.
13
+ */
14
+ Continue = 2,
15
+ /**
16
+ * Do not invoke the rooute nor other guards.
17
+ */
18
+ Stop = 3
19
+ }
20
+ export interface RouteGuard {
21
+ check(route: RouteMatchResult): GuardResult;
22
+ }
23
+ export interface Route {
24
+ name?: string;
25
+ target?: string;
26
+ path: string;
27
+ /**
28
+ * HTML file name (without extension).
29
+ *
30
+ * Define for instance if you have a route that requires a more limited layout. The library
31
+ * will automatically load that HTML file and rewrite URL history so that the correct url is displayed.
32
+ */
33
+ layout?: string;
34
+ /**
35
+ * Name of the tag for your web component.
36
+ */
37
+ componentTagName?: string;
38
+ /**
39
+ * Guards used to check if this route can be visited.
40
+ */
41
+ guards?: RouteGuard[];
42
+ component?: WebComponentConstructor;
43
+ }
44
+ export type RouteParamType = string | number;
45
+ export type RouteData = Record<string, RouteParamType>;
46
+ /**
47
+ * Implement to receive typed route parameters via a `routeData` property.
48
+ * RouteTarget assigns `routeData` after element creation but before DOM insertion.
49
+ * Optional since it's not available at construction time.
50
+ *
51
+ * For convention-based usage without undefined checks, skip the interface
52
+ * and declare `routeData` directly on your component.
53
+ *
54
+ * @example
55
+ * class UserProfile extends HTMLElement implements Routable<{ userName: string }> {
56
+ * routeData?: { userName: string };
57
+ * }
58
+ */
59
+ export interface Routable<T extends RouteData = RouteData> {
60
+ routeData?: T;
61
+ }
62
+ /**
63
+ * Implement to run async initialization before the component is added to the DOM.
64
+ * RouteTarget calls `loadRoute()` and awaits it before inserting the element.
65
+ *
66
+ * @example
67
+ * class OrderDetail extends HTMLElement implements LoadRoute<{ orderId: number }> {
68
+ * async loadRoute(data: { orderId: number }) {
69
+ * this.order = await fetchOrder(data.orderId);
70
+ * }
71
+ * }
72
+ */
73
+ export interface LoadRoute<T extends RouteData = RouteData> {
74
+ loadRoute(data: T): void | Promise<void>;
75
+ }
76
+ /**
77
+ * Result from route matching operations.
78
+ * Contains all information needed for navigation and rendering.
79
+ */
80
+ export type RouteMatchResult = {
81
+ /**
82
+ * Matched route configuration
83
+ */
84
+ route: Route;
85
+ /**
86
+ * URL segments used for history state
87
+ */
88
+ urlSegments: string[];
89
+ /**
90
+ * Extracted and type-converted parameters
91
+ */
92
+ params: RouteData;
93
+ };
94
+ /**
95
+ * Supported types of route segments
96
+ */
97
+ export type RouteSegmentType = 'string' | 'number' | 'path' | 'regex';
98
+ /**
99
+ * Strongly typed route segment value
100
+ */
101
+ export interface RouteValue {
102
+ /**
103
+ * Type of parameter for validation
104
+ */
105
+ type: RouteSegmentType;
106
+ /**
107
+ * Actual parameter value
108
+ */
109
+ value: any;
110
+ }
111
+ export declare class RouteError extends Error {
112
+ }
113
+ export declare class RouteGuardError extends RouteError {
114
+ isGuard: any;
115
+ }
116
+ export interface NavigateOptions {
117
+ /**
118
+ * Optional parameters when using route name
119
+ */
120
+ params?: Record<string, string | number>;
121
+ /**
122
+ * override for route's default target
123
+ */
124
+ target?: string;
125
+ /**
126
+ * When you want to override routes from the globally registered ones.
127
+ */
128
+ routes?: Route[];
129
+ }
130
+ export {};
@@ -0,0 +1,38 @@
1
+ import { ArgToken } from "./tokenizer";
2
+ type ClickBinding = {
3
+ path: number[];
4
+ methodName: string;
5
+ argTokens: ArgToken[];
6
+ };
7
+ type BoundBinding = {
8
+ type: 'text';
9
+ node: Node;
10
+ func: (context: Record<string, any>, node: Node) => void;
11
+ } | {
12
+ type: 'attribute';
13
+ element: HTMLElement;
14
+ name: string;
15
+ func: (context: Record<string, any>, element: HTMLElement) => void;
16
+ };
17
+ export declare class BoundNode {
18
+ private readonly root;
19
+ private readonly bindings;
20
+ private readonly clickBindings;
21
+ private readonly component?;
22
+ constructor(root: HTMLElement, bindings: BoundBinding[], clickBindings: ClickBinding[], component?: Record<string, any>);
23
+ render(data: Record<string, any>): HTMLElement;
24
+ private getNodeAtPath;
25
+ }
26
+ export declare function createBluePrint(html: string): Blueprint;
27
+ export declare class Blueprint {
28
+ private readonly template;
29
+ private readonly bindings;
30
+ private readonly clickBindings;
31
+ constructor(htmlOrTemplate: string | HTMLTemplateElement);
32
+ createInstance(component?: Record<string, any>): BoundNode;
33
+ private getRootElement;
34
+ private collectBindings;
35
+ private collectClickBindings;
36
+ private getNodeAtPath;
37
+ }
38
+ export {};
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Represents a single step in a property access path
3
+ * Can be either a property name or an array index access
4
+ * @example { type: "property", key: "user" }
5
+ * @example { type: "index", key: "0" }
6
+ */
7
+ type PathSegment = {
8
+ type: "property" | "index";
9
+ key: string;
10
+ };
11
+ /**
12
+ * Represents the result of parsing a dot-notation string into path segments
13
+ * Used internally by the parser to break down property access chains including arrays
14
+ * @example [{ type: "property", key: "users" }, { type: "index", key: "0" }, { type: "property", key: "name" }] for "users[0].name"
15
+ */
16
+ type PropertyPath = PathSegment[];
17
+ /**
18
+ * Function type that accesses nested properties safely from a record
19
+ * Returns undefined if any property in the chain is missing or null/undefined
20
+ * @example
21
+ * const accessor = createAccessor("user.name");
22
+ * const result = accessor(data); // string | undefined
23
+ */
24
+ type PropertyAccessor<T = unknown> = (record: Record<string, any>) => T | undefined;
25
+ /**
26
+ * Parser configuration options for customizing dot-notation parsing behavior
27
+ * Used to modify how the parser handles property paths and edge cases
28
+ * @example { delimiter: ".", escapeChar: "\\" }
29
+ */
30
+ interface ParserOptions {
31
+ delimiter?: string;
32
+ escapeChar?: string;
33
+ }
34
+ /**
35
+ * Parses a dot-notation string with array support into path segments
36
+ * Handles escaped delimiters, array indices, and validates input format
37
+ * @param notation - Notation string with dots and brackets (e.g., "users[0].profile.name")
38
+ * @param options - Parser configuration options
39
+ * @returns Array of path segments for property and array access
40
+ * @example
41
+ * parsePath("user.profile.name") // [{ type: "property", key: "user" }, { type: "property", key: "profile" }, { type: "property", key: "name" }]
42
+ * parsePath("users[0].name") // [{ type: "property", key: "users" }, { type: "index", key: "0" }, { type: "property", key: "name" }]
43
+ * parsePath("data\\.file[1]", { escapeChar: "\\" }) // [{ type: "property", key: "data.file" }, { type: "index", key: "1" }]
44
+ */
45
+ declare function parsePath(notation: string, options?: ParserOptions): PropertyPath;
46
+ /**
47
+ * Creates an accessor function from a parsed property path with array support
48
+ * The returned function safely navigates nested objects and arrays using the parsed path
49
+ * @param path - Array of path segments to access in sequence
50
+ * @returns Function that takes a record and returns the nested value or undefined
51
+ * @example
52
+ * const path = [{ type: "property", key: "users" }, { type: "index", key: "0" }, { type: "property", key: "name" }];
53
+ * const accessor = createAccessorFromPath(path);
54
+ * accessor({ users: [{ name: "John" }] }) // "John"
55
+ */
56
+ declare function createAccessorFromPath<T = unknown>(path: PropertyPath): PropertyAccessor<T>;
57
+ /**
58
+ * Main parser function that creates an accessor from notation string with array support
59
+ * Combines path parsing and accessor creation into a single operation
60
+ * @param notation - Notation string with dots and brackets (e.g., "users[0].profile.name")
61
+ * @param options - Parser configuration options
62
+ * @returns Accessor function for the specified property path
63
+ * @example
64
+ * const accessor = createAccessor("user.profile.name");
65
+ * const name = accessor(userData); // safely gets nested property
66
+ *
67
+ * const arrayAccessor = createAccessor("users[0].name");
68
+ * const userName = arrayAccessor(data); // safely accesses array elements
69
+ *
70
+ * const complexAccessor = createAccessor("items[2].meta\\.data.values[1]", { escapeChar: "\\" });
71
+ * const value = complexAccessor(response); // handles escaped dots and nested arrays
72
+ */
73
+ declare function createAccessor<T = unknown>(notation: string, options?: ParserOptions): PropertyAccessor<T>;
74
+ /**
75
+ * Utility function to test if a property path exists in a record (with array support)
76
+ * Useful for validation before attempting to access nested properties or array elements
77
+ * @param notation - Notation string with dots and brackets to test
78
+ * @param record - Record to test against
79
+ * @param options - Parser configuration options
80
+ * @returns Boolean indicating if the complete path exists
81
+ * @example
82
+ * hasProperty("user.name", data) // true if data.user.name exists
83
+ * hasProperty("users[0].name", data) // true if data.users[0].name exists
84
+ * hasProperty("missing.path", data) // false if any part is undefined
85
+ */
86
+ declare function hasProperty(notation: string, record: Record<string, any>, options?: ParserOptions): boolean;
87
+ export { createAccessor, createAccessorFromPath, parsePath, hasProperty, type PropertyAccessor, type PropertyPath, type PathSegment, type ParserOptions, };
@@ -0,0 +1,6 @@
1
+ import { PipeRegistry } from "../pipes";
2
+ export type RenderTemplate = (data: Record<string, any>, component?: any) => string;
3
+ export interface TemplateParserOptions {
4
+ pipeRegistry?: PipeRegistry;
5
+ }
6
+ export declare function compileMustard(template: string, options?: TemplateParserOptions): RenderTemplate;