@relax.js/core 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -188
- package/dist/DependencyInjection.d.ts +42 -24
- package/dist/di/index.js +1 -1
- package/dist/di/index.js.map +3 -3
- package/dist/di/index.mjs +1 -1
- package/dist/di/index.mjs.map +3 -3
- package/dist/errors.d.ts +20 -0
- package/dist/forms/FormValidator.d.ts +1 -20
- package/dist/forms/ValidationRules.d.ts +2 -0
- package/dist/forms/index.js +1 -1
- package/dist/forms/index.js.map +4 -4
- package/dist/forms/index.mjs +1 -1
- package/dist/forms/index.mjs.map +4 -4
- package/dist/html/TableRenderer.d.ts +1 -0
- package/dist/html/index.js.map +2 -2
- package/dist/html/index.mjs.map +2 -2
- package/dist/html/template.d.ts +4 -0
- package/dist/http/http.d.ts +1 -0
- package/dist/http/index.js.map +2 -2
- package/dist/http/index.mjs.map +2 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +3 -3
- package/dist/routing/index.js +3 -3
- package/dist/routing/index.js.map +3 -3
- package/dist/routing/index.mjs +3 -3
- package/dist/routing/index.mjs.map +3 -3
- package/dist/routing/routeTargetRegistry.d.ts +1 -0
- package/dist/routing/types.d.ts +2 -1
- package/dist/templates/NodeTemplate.d.ts +2 -0
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +2 -2
- package/docs/Architecture.md +333 -333
- package/docs/DependencyInjection.md +277 -237
- package/docs/Errors.md +87 -87
- package/docs/GettingStarted.md +231 -231
- package/docs/Pipes.md +5 -5
- package/docs/Translations.md +167 -312
- package/docs/WhyRelaxjs.md +336 -336
- package/docs/api/.nojekyll +1 -0
- package/docs/api/assets/hierarchy.js +1 -0
- package/docs/api/assets/highlight.css +120 -0
- package/docs/api/assets/icons.js +18 -0
- package/docs/api/assets/icons.svg +1 -0
- package/docs/api/assets/main.js +60 -0
- package/docs/api/assets/navigation.js +1 -0
- package/docs/api/assets/search.js +1 -0
- package/docs/api/assets/style.css +1633 -0
- package/docs/api/classes/http.WebSocketClient.html +26 -0
- package/docs/api/classes/i18n.LocaleChangeEvent.html +66 -0
- package/docs/api/classes/index.Blueprint.html +3 -0
- package/docs/api/classes/index.BoundNode.html +3 -0
- package/docs/api/classes/index.DigitsValidation.html +10 -0
- package/docs/api/classes/index.FormValidator.html +32 -0
- package/docs/api/classes/index.HttpError.html +13 -0
- package/docs/api/classes/index.LinkedList.html +26 -0
- package/docs/api/classes/index.NavigateRouteEvent.html +76 -0
- package/docs/api/classes/index.Node.html +15 -0
- package/docs/api/classes/index.PageSelectedEvent.html +61 -0
- package/docs/api/classes/index.Pager.html +4 -0
- package/docs/api/classes/index.RangeValidation.html +15 -0
- package/docs/api/classes/index.RelaxError.html +17 -0
- package/docs/api/classes/index.RequiredValidation.html +10 -0
- package/docs/api/classes/index.RouteError.html +11 -0
- package/docs/api/classes/index.RouteGuardError.html +12 -0
- package/docs/api/classes/index.RouteLink.html +779 -0
- package/docs/api/classes/index.RouteTarget.html +788 -0
- package/docs/api/classes/index.SSEClient.html +13 -0
- package/docs/api/classes/index.SSEDataEvent.html +63 -0
- package/docs/api/classes/index.ServiceCollection.html +28 -0
- package/docs/api/classes/index.ServiceContainer.html +24 -0
- package/docs/api/classes/index.SortChangeEvent.html +61 -0
- package/docs/api/classes/index.TableRenderer.html +5 -0
- package/docs/api/classes/index.TableSorter.html +4 -0
- package/docs/api/enums/index.GuardResult.html +9 -0
- package/docs/api/functions/elements.formError.html +6 -0
- package/docs/api/functions/elements.selectOne.html +6 -0
- package/docs/api/functions/i18n.getCurrentLocale.html +3 -0
- package/docs/api/functions/i18n.loadNamespace.html +7 -0
- package/docs/api/functions/i18n.loadNamespaces.html +6 -0
- package/docs/api/functions/i18n.onMissingTranslation.html +7 -0
- package/docs/api/functions/i18n.setLocale.html +7 -0
- package/docs/api/functions/i18n.setMessageFormatter.html +7 -0
- package/docs/api/functions/i18n.t.html +9 -0
- package/docs/api/functions/index.BooleanConverter.html +6 -0
- package/docs/api/functions/index.ContainerService.html +13 -0
- package/docs/api/functions/index.DateConverter.html +11 -0
- package/docs/api/functions/index.Inject.html +16 -0
- package/docs/api/functions/index.NumberConverter.html +5 -0
- package/docs/api/functions/index.RegisterValidator.html +7 -0
- package/docs/api/functions/index.applyPipes.html +17 -0
- package/docs/api/functions/index.asyncHandler.html +11 -0
- package/docs/api/functions/index.capitalizePipe.html +4 -0
- package/docs/api/functions/index.clearPendingNavigations.html +1 -0
- package/docs/api/functions/index.compileTemplate.html +26 -0
- package/docs/api/functions/index.configure.html +5 -0
- package/docs/api/functions/index.createBluePrint.html +1 -0
- package/docs/api/functions/index.createConverterFromDataType.html +4 -0
- package/docs/api/functions/index.createConverterFromInputType.html +5 -0
- package/docs/api/functions/index.createPipeRegistry.html +12 -0
- package/docs/api/functions/index.currencyPipe.html +9 -0
- package/docs/api/functions/index.datePipe.html +9 -0
- package/docs/api/functions/index.daysAgoPipe.html +8 -0
- package/docs/api/functions/index.defaultPipe.html +5 -0
- package/docs/api/functions/index.defineRoutes.html +8 -0
- package/docs/api/functions/index.del.html +8 -0
- package/docs/api/functions/index.findRouteByName.html +5 -0
- package/docs/api/functions/index.findRouteByUrl.html +4 -0
- package/docs/api/functions/index.firstPipe.html +4 -0
- package/docs/api/functions/index.generateSequentialId.html +21 -0
- package/docs/api/functions/index.get.html +9 -0
- package/docs/api/functions/index.getDataConverter.html +11 -0
- package/docs/api/functions/index.getParentComponent.html +18 -0
- package/docs/api/functions/index.getValidator.html +4 -0
- package/docs/api/functions/index.html.html +19 -0
- package/docs/api/functions/index.joinPipe.html +5 -0
- package/docs/api/functions/index.keysPipe.html +4 -0
- package/docs/api/functions/index.lastPipe.html +4 -0
- package/docs/api/functions/index.lowercasePipe.html +4 -0
- package/docs/api/functions/index.mapFormToClass.html +17 -0
- package/docs/api/functions/index.matchRoute.html +5 -0
- package/docs/api/functions/index.navigate.html +8 -0
- package/docs/api/functions/index.onError.html +8 -0
- package/docs/api/functions/index.piecesPipe.html +8 -0
- package/docs/api/functions/index.post.html +9 -0
- package/docs/api/functions/index.printRoutes.html +2 -0
- package/docs/api/functions/index.put.html +9 -0
- package/docs/api/functions/index.readData.html +17 -0
- package/docs/api/functions/index.registerRouteTarget.html +9 -0
- package/docs/api/functions/index.reportError.html +10 -0
- package/docs/api/functions/index.request.html +8 -0
- package/docs/api/functions/index.resolveValue.html +18 -0
- package/docs/api/functions/index.setFetch.html +6 -0
- package/docs/api/functions/index.setFormData.html +17 -0
- package/docs/api/functions/index.shortenPipe.html +5 -0
- package/docs/api/functions/index.startRouting.html +6 -0
- package/docs/api/functions/index.ternaryPipe.html +6 -0
- package/docs/api/functions/index.trimPipe.html +4 -0
- package/docs/api/functions/index.unregisterRouteTarget.html +3 -0
- package/docs/api/functions/index.uppercasePipe.html +4 -0
- package/docs/api/hierarchy.html +1 -0
- package/docs/api/index.html +323 -0
- package/docs/api/interfaces/http.SimpleDataEvent.html +3 -0
- package/docs/api/interfaces/http.WebSocketAbstraction.html +9 -0
- package/docs/api/interfaces/http.WebSocketCodec.html +4 -0
- package/docs/api/interfaces/http.WebSocketOptions.html +20 -0
- package/docs/api/interfaces/index.CompiledTemplate.html +10 -0
- package/docs/api/interfaces/index.DataLoader.html +19 -0
- package/docs/api/interfaces/index.EngineConfig.html +11 -0
- package/docs/api/interfaces/index.ErrorContext.html +4 -0
- package/docs/api/interfaces/index.FormReaderOptions.html +8 -0
- package/docs/api/interfaces/index.HttpOptions.html +16 -0
- package/docs/api/interfaces/index.HttpResponse.html +17 -0
- package/docs/api/interfaces/index.LoadRoute.html +7 -0
- package/docs/api/interfaces/index.NavigateOptions.html +7 -0
- package/docs/api/interfaces/index.PipeRegistry.html +12 -0
- package/docs/api/interfaces/index.RegistrationOptions.html +22 -0
- package/docs/api/interfaces/index.RenderTemplate.html +7 -0
- package/docs/api/interfaces/index.RequestOptions.html +11 -0
- package/docs/api/interfaces/index.Routable.html +10 -0
- package/docs/api/interfaces/index.Route.html +13 -0
- package/docs/api/interfaces/index.RouteGuard.html +2 -0
- package/docs/api/interfaces/index.RouteValue.html +6 -0
- package/docs/api/interfaces/index.SSEOptions.html +24 -0
- package/docs/api/interfaces/index.ValidationContext.html +8 -0
- package/docs/api/interfaces/index.ValidatorOptions.html +14 -0
- package/docs/api/media/Architecture.md +333 -0
- package/docs/api/media/DependencyInjection.md +277 -0
- package/docs/api/media/GettingStarted.md +231 -0
- package/docs/api/media/HttpClient.md +459 -0
- package/docs/api/media/Pipes.md +211 -0
- package/docs/api/media/Routing.md +332 -0
- package/docs/api/media/WhyRelaxjs.md +336 -0
- package/docs/api/media/forms.md +99 -0
- package/docs/api/media/html.md +175 -0
- package/docs/api/media/i18n.md +354 -0
- package/docs/api/media/utilities.md +143 -0
- package/docs/api/media/validation.md +351 -0
- package/docs/api/modules/collections_Index.html +1 -0
- package/docs/api/modules/di.html +1 -0
- package/docs/api/modules/elements.html +1 -0
- package/docs/api/modules/forms.html +1 -0
- package/docs/api/modules/html.html +1 -0
- package/docs/api/modules/http.html +1 -0
- package/docs/api/modules/i18n.html +1 -0
- package/docs/api/modules/index.html +1 -0
- package/docs/api/modules/routing.html +1 -0
- package/docs/api/modules/utils.html +1 -0
- package/docs/api/modules.html +1 -0
- package/docs/api/types/http.WebSocketFactory.html +2 -0
- package/docs/api/types/i18n.MessageFormatter.html +3 -0
- package/docs/api/types/i18n.MissingTranslationHandler.html +1 -0
- package/docs/api/types/index.Constructor.html +7 -0
- package/docs/api/types/index.ConverterFunc.html +2 -0
- package/docs/api/types/index.DataType.html +2 -0
- package/docs/api/types/index.InputType.html +2 -0
- package/docs/api/types/index.PipeFunction.html +6 -0
- package/docs/api/types/index.RouteData.html +1 -0
- package/docs/api/types/index.RouteMatchResult.html +9 -0
- package/docs/api/types/index.RouteParamType.html +1 -0
- package/docs/api/types/index.RouteSegmentType.html +2 -0
- package/docs/api/types/index.SSEEventFactory.html +5 -0
- package/docs/api/types/index.ServiceScope.html +10 -0
- package/docs/api/types/index.SortColumn.html +3 -0
- package/docs/api/variables/i18n.formatICU.html +3 -0
- package/docs/api/variables/index.container.html +6 -0
- package/docs/api/variables/index.defaultPipes.html +6 -0
- package/docs/api/variables/index.internalRoutes.html +1 -0
- package/docs/api/variables/index.serviceCollection.html +6 -0
- package/docs/api.json +93171 -0
- package/docs/elements/dom.md +102 -102
- package/docs/forms/creating-form-components.md +924 -924
- package/docs/forms/form-api.md +94 -94
- package/docs/forms/forms.md +99 -99
- package/docs/forms/patterns.md +311 -311
- package/docs/forms/reading-writing.md +365 -365
- package/docs/forms/validation.md +351 -351
- package/docs/html/TableRenderer.md +291 -291
- package/docs/html/html.md +175 -175
- package/docs/html/index.md +54 -54
- package/docs/html/template.md +422 -422
- package/docs/http/HttpClient.md +459 -459
- package/docs/http/ServerSentEvents.md +184 -184
- package/docs/http/index.md +109 -109
- package/docs/i18n/i18n.md +49 -4
- package/docs/i18n/intl-standard.md +178 -178
- package/docs/routing/RouteLink.md +98 -98
- package/docs/routing/Routing.md +332 -332
- package/docs/routing/layouts.md +207 -207
- package/docs/utilities.md +143 -143
- package/package.json +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/routing/types.ts", "../../src/routing/NavigateRouteEvent.ts", "../../src/errors.ts", "../../src/routing/routeTargetRegistry.ts", "../../src/routing/routeMatching.ts", "../../src/routing/RouteLink.ts", "../../src/routing/RoutingTarget.ts", "../../src/routing/navigation.ts"],
|
|
4
|
-
"sourcesContent": ["type WebComponentConstructor = new (...args: any[]) => HTMLElement;\r\n\r\nexport enum GuardResult {\r\n /**\r\n * Handle route without checking more guards.\r\n */\r\n Allow,\r\n\r\n /**\r\n * Throw a RouteGuardError.\r\n */\r\n Deny,\r\n\r\n /**\r\n * Resume and check other guards.\r\n */\r\n Continue,\r\n\r\n /**\r\n * Do not invoke the rooute nor other guards.\r\n */\r\n Stop\r\n}\r\n\r\nexport interface RouteGuard {\r\n check(route: RouteMatchResult): GuardResult;\r\n}\r\n\r\nexport interface Route {\r\n name?: string;\r\n target?: string;\r\n path: string;\r\n\r\n /**\r\n * HTML file name (without extension).\r\n *\r\n * Define for instance if you have a route that requires a more limited layout. The library\r\n * will automatically load that HTML file and rewrite URL history so that the correct url is displayed.\r\n */\r\n layout?: string;\r\n\r\n /**\r\n * Name of the tag for your web component.\r\n */\r\n componentTagName?: string;\r\n\r\n /**\r\n * Guards used to check if this route can be visited.\r\n */\r\n guards?: RouteGuard[];\r\n\r\n component?: WebComponentConstructor;\r\n}\r\n\r\nexport type RouteParamType = string | number;\r\nexport type RouteData = Record<string, RouteParamType>;\r\n\r\n/**\r\n * Implement to receive typed route parameters via a `routeData` property.\r\n * RouteTarget assigns `routeData` after element creation but before DOM insertion.\r\n * Optional since it's not available at construction time.\r\n *\r\n * For convention-based usage without undefined checks, skip the interface\r\n * and declare `routeData` directly on your component.\r\n *\r\n * @example\r\n * class UserProfile extends HTMLElement implements Routable<{ userName: string }> {\r\n * routeData?: { userName: string };\r\n * }\r\n */\r\nexport interface Routable<T extends RouteData = RouteData> {\r\n routeData?: T;\r\n}\r\n\r\n/**\r\n * Implement to run async initialization before the component is added to the DOM.\r\n * RouteTarget calls `loadRoute()` and awaits it before inserting the element.\r\n *\r\n * @example\r\n * class OrderDetail extends HTMLElement implements LoadRoute<{ orderId: number }> {\r\n * async loadRoute(data: { orderId: number }) {\r\n * this.order = await fetchOrder(data.orderId);\r\n * }\r\n * }\r\n */\r\nexport interface LoadRoute<T extends RouteData = RouteData> {\r\n loadRoute(data: T): void | Promise<void>;\r\n}\r\n\r\n/**\r\n * Result from route matching operations.\r\n * Contains all information needed for navigation and rendering.\r\n */\r\nexport type RouteMatchResult = {\r\n /**\r\n * Matched route configuration\r\n */\r\n route: Route;\r\n\r\n /**\r\n * URL segments used for history state\r\n */\r\n urlSegments: string[];\r\n\r\n /**\r\n * Extracted and type-converted parameters\r\n */\r\n params: RouteData;\r\n};\r\n\r\n/**\r\n * Supported types of route segments\r\n */\r\nexport type RouteSegmentType = 'string' | 'number' | 'path' | 'regex';\r\n\r\n/**\r\n * Strongly typed route segment value\r\n */\r\nexport interface RouteValue {\r\n /**\r\n * Type of parameter for validation\r\n */\r\n type: RouteSegmentType;\r\n\r\n /**\r\n * Actual parameter value\r\n */\r\n value: any;\r\n}\r\n\r\nexport class RouteError extends Error {}\r\nexport class RouteGuardError extends RouteError {\r\n isGuard;\r\n}\r\n\r\nexport interface NavigateOptions {\r\n /**\r\n * Optional parameters when using route name\r\n */\r\n params?: Record<string, string | number>;\r\n\r\n /**\r\n * override for route's default target\r\n */\r\n target?: string;\r\n\r\n /**\r\n * When you want to override routes from the globally registered ones.\r\n */\r\n routes?: Route[];\r\n}\r\n", "import type { Route, RouteData } from './types';\r\n\r\n/**\r\n * Event sent to routing targets when a new route should be displayed.\r\n */\r\nexport class NavigateRouteEvent extends Event {\r\n static NAME: string = 'rlx.navigateRoute';\r\n constructor(\r\n /**\r\n * Matched route.\r\n */\r\n public route: Route,\r\n\r\n /**\r\n * The generated url sements which can be used to push the url into the browser history.\r\n */\r\n public urlSegments: string[],\r\n\r\n /**\r\n * Data supplied to the route.\r\n */\r\n public routeData?: RouteData,\r\n\r\n /**\r\n * The target can differ from the default target that is defined in the route.\r\n *\r\n * undefined means that the default (unnamed) target should be used.\r\n */\r\n public routeTarget?: string,\r\n\r\n eventInit?: EventInit\r\n ) {\r\n super(NavigateRouteEvent.NAME, eventInit);\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementEventMap {\r\n 'rlx.navigateRoute': NavigateRouteEvent;\r\n }\r\n interface DocumentEventMap {\r\n 'rlx.navigateRoute': NavigateRouteEvent;\r\n }\r\n}\r\n", "/**\r\n * Global error handling for Relaxjs.\r\n * Register a handler with `onError()` to intercept errors before they throw.\r\n * Call `ctx.suppress()` in the handler to prevent the error from being thrown.\r\n *\r\n * @example\r\n * import { onError } from 'relaxjs';\r\n *\r\n * onError((error, ctx) => {\r\n * logToService(error.message, error.context);\r\n * showToast(error.message);\r\n * ctx.suppress();\r\n * });\r\n */\r\n\r\n/**\r\n * Passed to error handlers to control error behavior.\r\n * Call `suppress()` to prevent the error from being thrown.\r\n */\r\nexport interface ErrorContext {\r\n suppress(): void;\r\n}\r\n\r\n/**\r\n * Error with structured context for debugging.\r\n * The `context` record contains details like route name, component tag, route data.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * console.log(error.context.route);\r\n * console.log(error.context.componentTagName);\r\n * });\r\n */\r\nexport class RelaxError extends Error {\r\n constructor(\r\n message: string,\r\n public context: Record<string, unknown>,\r\n ) {\r\n super(message);\r\n }\r\n}\r\n\r\ntype ErrorHandler = (error: RelaxError, ctx: ErrorContext) => void;\r\n\r\nlet handler: ErrorHandler | null = null;\r\n\r\n/**\r\n * Registers a global error handler for Relaxjs errors.\r\n * The handler receives the error and an `ErrorContext`.\r\n * Call `ctx.suppress()` to prevent the error from being thrown.\r\n * Only one handler can be active at a time; subsequent calls replace the previous handler.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * if (error.context.route === 'optional-panel') {\r\n * ctx.suppress();\r\n * return;\r\n * }\r\n * showErrorDialog(error.message);\r\n * });\r\n */\r\nexport function onError(fn: ErrorHandler) {\r\n handler = fn;\r\n}\r\n\r\n/**\r\n * Reports an error through the global handler.\r\n * Returns the `RelaxError` if it should be thrown, or `null` if the handler suppressed it.\r\n * The caller is responsible for throwing the returned error.\r\n *\r\n * @param message - Human-readable error description\r\n * @param context - Structured data for debugging (route, component, params, cause, etc.)\r\n * @returns The error to throw, or `null` if suppressed\r\n *\r\n * @example\r\n * const error = reportError('Failed to load route component', {\r\n * route: 'user',\r\n * componentTagName: 'user-profile',\r\n * routeData: { id: 123 },\r\n * });\r\n * if (error) throw error;\r\n */\r\nexport function reportError(message: string, context: Record<string, unknown>): RelaxError | null {\r\n const error = new RelaxError(message, context);\r\n if (handler) {\r\n let suppressed = false;\r\n const ctx: ErrorContext = {\r\n suppress() { suppressed = true; },\r\n };\r\n handler(error, ctx);\r\n if (suppressed) {\r\n return null;\r\n }\r\n }\r\n return error;\r\n}\r\n", "import { reportError } from '../errors';\r\nimport { NavigateRouteEvent } from './NavigateRouteEvent';\r\n\r\ntype RouteTargetHandler = (evt: NavigateRouteEvent) => void;\r\nconst targetHandlers = new Map<string | undefined, RouteTargetHandler>();\r\nconst pendingEvents = new Map<string | undefined, NavigateRouteEvent>();\r\n\r\n/**\r\n * Registers a route target handler.\r\n * When a navigation event targets this name, the handler is called directly.\r\n * If a pending event exists for this target, it is replayed immediately.\r\n *\r\n * @param name - Target name, or `undefined` for the default (unnamed) target\r\n * @param handler - Callback that receives the `NavigateRouteEvent`\r\n *\r\n * @example\r\n * registerRouteTarget('sidebar', (evt) => renderComponent(evt));\r\n */\r\nexport function registerRouteTarget(\r\n name: string | undefined,\r\n handler: RouteTargetHandler,\r\n) {\r\n initRouteTargetListener();\r\n if (targetHandlers.has(name)) {\r\n const error = reportError('Duplicate route target', {\r\n target: name ?? 'default',\r\n });\r\n if (error) throw error;\r\n return;\r\n }\r\n targetHandlers.set(name, handler);\r\n\r\n const pending = pendingEvents.get(name);\r\n if (pending) {\r\n pendingEvents.delete(name);\r\n handler(pending);\r\n }\r\n}\r\n\r\n/**\r\n * Unregisters a previously registered route target handler.\r\n *\r\n * @param name - Target name that was passed to `registerRouteTarget`\r\n */\r\nexport function unregisterRouteTarget(name: string | undefined) {\r\n targetHandlers.delete(name);\r\n}\r\n\r\nexport function clearPendingNavigations() {\r\n pendingEvents.clear();\r\n targetHandlers.clear();\r\n}\r\n\r\nfunction dispatchToTarget(evt: NavigateRouteEvent) {\r\n const handler = targetHandlers.get(evt.routeTarget);\r\n if (handler) {\r\n handler(evt);\r\n } else {\r\n pendingEvents.set(evt.routeTarget, evt);\r\n }\r\n}\r\n\r\nlet listenerAttached = false;\r\n\r\nexport function initRouteTargetListener() {\r\n if (listenerAttached) return;\r\n listenerAttached = true;\r\n document.addEventListener(NavigateRouteEvent.NAME, (evt) => {\r\n dispatchToTarget(evt as NavigateRouteEvent);\r\n });\r\n}\r\n", "import type { Route, RouteData, RouteParamType, RouteMatchResult } from './types';\r\n\r\n/**\r\n * Route segment matcher interface.\r\n * Each segment type (string, number, path) implements this\r\n * for parameter extraction and validation.\r\n */\r\ninterface RouteSegment {\r\n /**\r\n * Parameter name when segment is dynamic (:name or ;id)\r\n */\r\n paramName?: string;\r\n\r\n /**\r\n * Validates if URL segment matches pattern\r\n * @param value Segment from URL to validate\r\n */\r\n isMatch(value: string): boolean;\r\n\r\n /**\r\n * Converts URL segment to typed parameter\r\n * @param pathValue Raw value from URL\r\n */\r\n getValue(pathValue: string): RouteParamType;\r\n}\r\n\r\n/**\r\n * Number parameter segment matcher.\r\n * Used for ;id style parameters that must be numbers.\r\n */\r\nclass NumberRouteSegment implements RouteSegment {\r\n constructor(public paramName: string) {}\r\n isMatch(value: string): boolean {\r\n if (/^\\d+$/.test(value)) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(pathValue: string): RouteParamType {\r\n if (/^\\d+$/.test(pathValue) === false) {\r\n throw new Error(\r\n `Path is not a number, parameter name '${this.paramName}', value: '${pathValue}'.`\r\n );\r\n }\r\n return parseInt(pathValue);\r\n }\r\n}\r\n\r\n/**\r\n * String parameter segment matcher.\r\n * Used for :name style parameters.\r\n */\r\nclass StringRouteSegment implements RouteSegment {\r\n constructor(public paramName: string) {}\r\n isMatch(value: string): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n *\r\n * @param pathValue the route data (for route by name) or segment extracted from the url (for url routing).\r\n * @returns\r\n */\r\n getValue(pathValue: string): RouteParamType {\r\n return pathValue;\r\n }\r\n}\r\n\r\n/**\r\n * Static path segment matcher.\r\n * Used for fixed URL parts like 'users' in /users/:id\r\n */\r\nclass PathRouteSegment implements RouteSegment {\r\n constructor(public value: string) {}\r\n isMatch(value: string): boolean {\r\n return value == this.value;\r\n }\r\n\r\n getValue(_pathValue: string): RouteParamType {\r\n return this.value;\r\n }\r\n}\r\n\r\n/**\r\n * Internal route implementation that handles segment matching\r\n * and parameter extraction.\r\n */\r\nclass RouteImp {\r\n constructor(public route: Route, private segments: RouteSegment[]) {}\r\n\r\n /**\r\n * Attempts to match URL segments against route pattern\r\n * @param segments URL parts to match\r\n * @returns Match result with parameters if successful\r\n */\r\n match(segments: string[]): RouteMatchResult | null {\r\n if (segments.length != this.segments.length) {\r\n return null;\r\n }\r\n\r\n const generatedSegments: string[] = [];\r\n var params: RouteData = {};\r\n for (let index = 0; index < segments.length; index++) {\r\n const urlSegment = segments[index];\r\n const ourSegment = this.segments[index];\r\n\r\n if (!ourSegment.isMatch(urlSegment)) {\r\n return null;\r\n }\r\n\r\n if (ourSegment.paramName) {\r\n const value = ourSegment.getValue(urlSegment);\r\n params[ourSegment.paramName] = value;\r\n generatedSegments.push(value.toString());\r\n } else {\r\n generatedSegments.push(urlSegment);\r\n }\r\n }\r\n\r\n return { route: this.route, params, urlSegments: generatedSegments };\r\n }\r\n\r\n /**\r\n * Routing by name and route data, so generate the url segments.\r\n * @param routeData Data to use in the URL.\r\n * @returns Match result with parameters if successful\r\n */\r\n buildUrl(routeData: RouteData): RouteMatchResult | null {\r\n const urlSegments: string[] = [];\r\n for (let index = 0; index < this.segments.length; index++) {\r\n const ourSegment = this.segments[index];\r\n if (ourSegment.paramName) {\r\n var value = routeData[ourSegment.paramName];\r\n if (!value) {\r\n throw new Error(\r\n `Route \"${\r\n this.route.name\r\n }\" did not get value for parameter \"${\r\n ourSegment.paramName\r\n } from the provided routeData: \"${JSON.stringify(\r\n routeData\r\n )}\".`\r\n );\r\n }\r\n\r\n urlSegments.push(value.toString());\r\n } else {\r\n urlSegments.push(ourSegment.getValue('').toString());\r\n }\r\n }\r\n\r\n return { route: this.route, params: routeData, urlSegments };\r\n }\r\n\r\n /**\r\n * Converts string parameters to proper types\r\n * @param routeParams Raw string parameters to convert\r\n */\r\n parseParameters(routeParams: Record<string, string>): RouteData {\r\n const d: Record<string, any> = {};\r\n\r\n this.segments.forEach((segment) => {\r\n if (!segment.paramName) {\r\n return;\r\n }\r\n\r\n if (!segment.isMatch(providedValue)) {\r\n throw new Error(\r\n `Failed to convert parameter ${segment.paramName}, or missing value: ${providedValue}, route: ${this.route.name}.`\r\n );\r\n }\r\n\r\n var providedValue = routeParams[segment.paramName];\r\n if (!providedValue) {\r\n throw new Error(\r\n `Parameter ${segment.paramName} was not provided, route: ${this.route.name}.`\r\n );\r\n }\r\n\r\n var convertedValue = segment.getValue(providedValue);\r\n d[segment.paramName] = convertedValue;\r\n });\r\n\r\n return d;\r\n }\r\n}\r\n\r\n/**\r\n * Match route by either name or URL pattern\r\n * @param routes Available routes\r\n * @param routeNameOrUrl Route name or URL to match\r\n * @param routeData Optional parameters for named routes\r\n */\r\nexport function matchRoute(\r\n routes: Route[],\r\n routeNameOrUrl: string,\r\n routeData?: Record<string, string | any>\r\n): RouteMatchResult | null {\r\n if (routeNameOrUrl === '' || routeNameOrUrl.indexOf('/') >= 0) {\r\n return findRouteByUrl(routes, routeNameOrUrl || '/');\r\n } else {\r\n return findRouteByName(routes, routeNameOrUrl, routeData!);\r\n }\r\n}\r\n\r\n/**\r\n * Find route by name and apply parameters\r\n * @param routes Available routes\r\n * @param name Route name to find\r\n * @param routeData Parameters to apply\r\n */\r\nexport function findRouteByName(\r\n routes: Route[],\r\n name: string,\r\n routeData?: Record<string, string | any>\r\n): RouteMatchResult | null {\r\n var route = routes.find((x) => x.name === name);\r\n if (!route) {\r\n return null;\r\n }\r\n\r\n var imp = generateRouteImp(route);\r\n var result = imp.buildUrl(routeData);\r\n return result;\r\n}\r\n\r\n/**\r\n * Find route matching URL pattern\r\n * @param routes Available routes\r\n * @param path URL to match\r\n */\r\nexport function findRouteByUrl(\r\n routes: Route[],\r\n path: string\r\n): RouteMatchResult | null {\r\n const urlSegments = path.replace(/^\\/|\\/$/g, '').split('/');\r\n const routeImps = generateRouteImps(routes);\r\n\r\n for (let index = 0; index < routeImps.length; index++) {\r\n const element = routeImps[index];\r\n const m = element.match(urlSegments);\r\n if (m) {\r\n return m;\r\n }\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Generate implementations for all routes\r\n */\r\nfunction generateRouteImps(routes: Route[]) {\r\n const routeImps: RouteImp[] = [];\r\n routes.forEach((route) => {\r\n var imp = generateRouteImp(route);\r\n routeImps.push(imp);\r\n });\r\n\r\n return routeImps;\r\n}\r\n\r\n/**\r\n * Generate implementation for single route\r\n * Parses URL pattern into segment matchers\r\n */\r\nfunction generateRouteImp(route: Route): RouteImp {\r\n var impSegments = [];\r\n const segments = route.path.replace(/^\\/|\\/$/g, '').split('/');\r\n segments.forEach((segment) => {\r\n if (segment.substring(0, 1) == ':') {\r\n impSegments.push(new StringRouteSegment(segment.substring(1)));\r\n } else if (segment.substring(0, 1) === ';') {\r\n impSegments.push(new NumberRouteSegment(segment.substring(1)));\r\n } else if (segment.substring(0, 1) === '{') {\r\n } else {\r\n impSegments.push(new PathRouteSegment(segment));\r\n }\r\n });\r\n\r\n var imp = new RouteImp(route, impSegments);\r\n return imp;\r\n}\r\n", "import { navigate, printRoutes } from './navigation';\r\nimport { RelaxError, reportError } from '../errors';\r\n\r\nexport class RouteLink extends HTMLElement {\r\n static get observedAttributes() {\r\n return ['name', 'target', 'params'];\r\n }\r\n\r\n constructor() {\r\n super();\r\n this.addEventListener('click', e => this.handleClick(e));\r\n }\r\n\r\n private handleClick(e: MouseEvent) {\r\n e.preventDefault();\r\n \r\n const name = this.getAttribute('name');\r\n if (!name) return;\r\n\r\n console.log('Calling printRoutes from RouteLink in relaxjs/components');\r\n printRoutes();\r\n \r\n const params: Record<string, string> = {};\r\n for (const attr of Array.from(this.attributes)) {\r\n if (attr.name.startsWith('param-')) {\r\n const paramName = attr.name.substring(6);\r\n params[paramName] = attr.value;\r\n }\r\n }\r\n\r\n const paramsAttr = this.getAttribute('params');\r\n let additionalParams: Record<string, string | number> | undefined;\r\n if (paramsAttr) {\r\n try {\r\n const parsed = JSON.parse(paramsAttr);\r\n additionalParams = parsed as Record<string, string | number>;\r\n } catch (error) {\r\n const err = reportError('Failed to parse route params', {\r\n element: 'r-link',\r\n params: paramsAttr,\r\n cause: error,\r\n });\r\n if (err) throw err;\r\n }\r\n }\r\n\r\n const target = this.getAttribute('target');\r\n if (additionalParams){\r\n Object.assign(params, additionalParams);\r\n }\r\n\r\n try {\r\n navigate(name, { params, target: target || undefined });\r\n } catch (error) {\r\n if (error instanceof RelaxError) throw error;\r\n const reported = reportError('Navigation failed', {\r\n element: 'r-link',\r\n route: name,\r\n params,\r\n target,\r\n cause: error,\r\n });\r\n if (reported) throw reported;\r\n }\r\n }\r\n\r\n connectedCallback() {\r\n if (!this.hasAttribute('tabindex')) {\r\n this.setAttribute('tabindex', '0');\r\n }\r\n \r\n this.style.cursor = 'pointer';\r\n this.role = 'link';\r\n }\r\n\r\n disconnectedCallback() {\r\n this.removeEventListener('click', this.handleClick);\r\n }\r\n}", "import { registerRouteTarget, unregisterRouteTarget } from './routeTargetRegistry';\r\nimport type { NavigateRouteEvent } from './NavigateRouteEvent';\r\nimport type { RouteData, LoadRoute } from './types';\r\nimport { RelaxError, reportError } from '../errors';\r\n\r\n/**\r\n * WebComponent that listens on the `NavigateRouteEvent` event to be able to switch route.\r\n *\r\n * Use the \"name\" attribute to make this non-default target.\r\n * Use the \"dialog\" attribute to render routes inside a native `<dialog>` element\r\n * with built-in focus trapping, backdrop, and Escape-to-close.\r\n *\r\n * @example\r\n * <r-route-target></r-route-target>\r\n * <r-route-target name=\"modal\" dialog></r-route-target>\r\n */\r\nexport class RouteTarget extends HTMLElement {\r\n name?: string = undefined;\r\n private dialog?: HTMLDialogElement;\r\n\r\n connectedCallback() {\r\n this.name = this.getAttribute('name') ?? undefined;\r\n\r\n if (this.hasAttribute('dialog')) {\r\n this.dialog = document.createElement('dialog');\r\n this.dialog.addEventListener('close', () => {\r\n this.dialog!.replaceChildren();\r\n });\r\n this.appendChild(this.dialog);\r\n }\r\n\r\n registerRouteTarget(this.name, (evt) => this.onNavigate(evt));\r\n console.log('registered');\r\n }\r\n\r\n disconnectedCallback() {\r\n unregisterRouteTarget(this.name);\r\n }\r\n\r\n private onNavigate(evt: NavigateRouteEvent) {\r\n console.log('got nav', evt);\r\n this.loadComponent(evt).catch((error) => {\r\n if (!(error instanceof RelaxError)) {\r\n error = reportError('Route navigation failed', {\r\n route: evt.route.name,\r\n routeTarget: evt.routeTarget,\r\n cause: error,\r\n });\r\n }\r\n if (error) {\r\n console.error(error);\r\n }\r\n });\r\n }\r\n\r\n private async loadComponent(evt: NavigateRouteEvent) {\r\n const tagName = evt.route.componentTagName\r\n ?? customElements.getName(evt.route.component);\r\n\r\n if (!tagName) {\r\n const error = reportError('Failed to find component for route', {\r\n route: evt.route.name,\r\n componentTagName: evt.route.componentTagName,\r\n component: evt.route.component?.name,\r\n routeData: evt.routeData,\r\n });\r\n if (error) throw error;\r\n return;\r\n }\r\n\r\n await customElements.whenDefined(tagName);\r\n const element = document.createElement(tagName);\r\n\r\n await this.applyRouteData(element, evt.routeData);\r\n\r\n if (this.dialog) {\r\n this.dialog.replaceChildren(element);\r\n if (!this.dialog.open) {\r\n this.dialog.showModal();\r\n }\r\n } else if (document.startViewTransition) {\r\n document.startViewTransition(() => this.replaceChildren(element));\r\n } else {\r\n this.replaceChildren(element);\r\n }\r\n }\r\n\r\n /** Closes the dialog (only applies to dialog targets). */\r\n close() {\r\n this.dialog?.close();\r\n }\r\n\r\n private async applyRouteData(element: Element, data?: RouteData) {\r\n if ('loadRoute' in element) {\r\n const routeData = data\r\n ?? { error: 'loadRoute function without mapped route data in the routes' };\r\n await (element as unknown as LoadRoute).loadRoute(routeData);\r\n }\r\n\r\n if (data) {\r\n (element as any).routeData = data;\r\n }\r\n }\r\n}\r\n", "/**\r\n * Single Page Application routing system with multiple target support.\r\n * Designed for scenarios where you need:\r\n * - Multiple navigation targets (main content, modals, sidebars)\r\n * - Strongly typed route parameters\r\n * - History management with back/forward support\r\n *\r\n * @example\r\n * // Configure routes\r\n * const routes = [\r\n * { name: 'user', path: '/users/:id' }, // String parameter\r\n * { name: 'order', path: '/orders/;orderId' }, // Number parameter\r\n * { name: 'modal', path: '/detail/:id', target: 'modal' } // Custom target\r\n * ];\r\n */\r\n\r\nimport { reportError } from '../errors';\r\nimport {\r\n GuardResult,\r\n RouteError,\r\n RouteGuardError,\r\n type Route,\r\n type RouteData,\r\n type RouteParamType,\r\n type RouteMatchResult,\r\n type NavigateOptions,\r\n} from './types';\r\nimport { NavigateRouteEvent } from './NavigateRouteEvent';\r\nimport { matchRoute } from './routeMatching';\r\nimport { initRouteTargetListener } from './routeTargetRegistry';\r\nimport { RouteLink } from './RouteLink';\r\nimport { RouteTarget } from './RoutingTarget';\r\n\r\n/**\r\n * Used to keep track of current main HTML file,\r\n * used when different layouts are supported.\r\n *\r\n * The default page is ALWAYS loaded initially,\r\n * which means that we need to switch layout page\r\n * if someone else is configured for the route.\r\n */\r\nvar currentLayout = getLayout() ?? 'default';\r\nfunction getLayout() {\r\n const path = window.location.pathname;\r\n if (path == '/index.html') {\r\n return 'default';\r\n }\r\n\r\n return path.endsWith('.html') ? path.slice(1, -5) : null;\r\n}\r\n\r\nexport const internalRoutes: Route[] = [];\r\n\r\nexport const MyData = {\r\n routes: []\r\n};\r\n\r\n/**\r\n * Debug helper to print all registered routes to console.\r\n */\r\nexport function printRoutes() {\r\n console.log(internalRoutes);\r\n}\r\n\r\n/**\r\n * Registers application routes with the router.\r\n * Call this at application startup before routing begins.\r\n *\r\n * @param appRoutes - Array of route configurations\r\n * @throws Error if referenced components are not registered\r\n *\r\n * @example\r\n * const routes: Route[] = [\r\n * { name: 'home', path: '/', componentTagName: 'app-home' },\r\n * { name: 'user', path: '/users/:id', componentTagName: 'user-profile' },\r\n * { name: 'login', path: '/auth/', componentTagName: 'login-form', layout: 'noauth' }\r\n * ];\r\n * defineRoutes(routes);\r\n */\r\nexport function defineRoutes(appRoutes: Route[]) {\r\n console.log('defining routes1', appRoutes);\r\n initRouteTargetListener();\r\n if (!customElements.get('r-route-target')) {\r\n customElements.define('r-route-target', RouteTarget);\r\n }\r\n if (!customElements.get('r-link')) {\r\n customElements.define('r-link', RouteLink);\r\n }\r\n console.log('defining routes', appRoutes);\r\n internalRoutes.length = 0;\r\n internalRoutes.push(...appRoutes);\r\n\r\n var errs = [];\r\n appRoutes.forEach((route) => {\r\n if (\r\n route.componentTagName &&\r\n !customElements.get(route.componentTagName)\r\n ) {\r\n errs.push(\r\n `Component with tagName '${route.componentTagName}' is not defined in customElements.`\r\n );\r\n }\r\n if (route.component && !customElements.getName(route.component)) {\r\n errs.push(\r\n `Component '${route.component.name}' is not defined in customElements. Used in route '${JSON.stringify(route)}'.`\r\n );\r\n }\r\n if (route.layout === '') {\r\n console.log('should not use empty string layout.', route);\r\n route.layout = undefined;\r\n }\r\n });\r\n\r\n if (errs.length > 0) {\r\n throw new Error(errs.join('\\n'));\r\n }\r\n}\r\n\r\n/**\r\n * Initializes routing and navigates to the current URL.\r\n * Call this after DOM is ready and routes are defined.\r\n *\r\n * @example\r\n * // In your main application component\r\n * connectedCallback() {\r\n * defineRoutes(routes);\r\n * startRouting();\r\n * }\r\n */\r\nexport function startRouting() {\r\n let newPage = false;\r\n if (currentLayout == '') {\r\n const path = window.location.pathname;\r\n const match = path.match(/\\/([^\\/]+)\\.html$/);\r\n if (match && match[1] !== '') {\r\n console.log('setting current layut', match[1]);\r\n currentLayout = match[1];\r\n newPage = true;\r\n } else {\r\n console.log('Setting default layout name');\r\n currentLayout = 'default';\r\n }\r\n }\r\n\r\n if (tryLoadRouteFromLayoutNavigation()) {\r\n return;\r\n }\r\n\r\n const currentUrl = window.location.pathname.replace(/^\\/|\\/$/g, '') || '/';\r\n const routeResult = findRoute(currentUrl, {});\r\n\r\n const searchParams = new URLSearchParams(window.location.search);\r\n if (searchParams.size > 0) {\r\n routeResult.params ??= {};\r\n searchParams.forEach((value, key) => {\r\n routeResult.params[key] = value;\r\n });\r\n }\r\n\r\n if (navigateToLayout(routeResult)) {\r\n return;\r\n }\r\n\r\n history.replaceState(\r\n routeResult.urlSegments,\r\n '',\r\n '/' + routeResult.urlSegments.join('/')\r\n );\r\n\r\n const e = new NavigateRouteEvent(\r\n routeResult.route,\r\n routeResult.urlSegments,\r\n routeResult.params,\r\n routeResult.route.target\r\n );\r\n document.dispatchEvent(e);\r\n}\r\n\r\n/**\r\n * Navigates to a route by name or URL.\r\n * Updates browser history and dispatches navigation events.\r\n *\r\n * @param routeNameOrUrl - Route name or URL path to navigate to\r\n * @param options - Navigation options including params and target\r\n *\r\n * @example\r\n * // Navigate by route name\r\n * navigate('user', { params: { id: '123' } });\r\n *\r\n * // Navigate by URL\r\n * navigate('/users/123');\r\n *\r\n * // Navigate to specific target\r\n * navigate('detail', { params: { id: '42' }, target: 'modal' });\r\n */\r\nexport function navigate(routeNameOrUrl: string, options?: NavigateOptions) {\r\n console.log('navigating to ', routeNameOrUrl, options);\r\n const routeResult = findRoute(routeNameOrUrl, options);\r\n if (navigateToLayout(routeResult)) {\r\n return;\r\n }\r\n\r\n const target = options?.target ?? routeResult.route.target;\r\n const ourUrl = routeResult.urlSegments.join('/');\r\n const currentUrl = window.location.pathname.replace(/^\\/|\\/$/g, '');\r\n if (currentUrl != ourUrl) {\r\n history.pushState(\r\n routeResult.urlSegments,\r\n '',\r\n '/' + routeResult.urlSegments.join('/')\r\n );\r\n }\r\n const e = new NavigateRouteEvent(\r\n routeResult.route,\r\n routeResult.urlSegments,\r\n routeResult.params,\r\n target\r\n );\r\n document.dispatchEvent(e);\r\n}\r\n\r\nfunction findRoute(routeNameOrUrl: string, options?: NavigateOptions) {\r\n const theRoutes = options?.routes ?? internalRoutes;\r\n const params = options?.params;\r\n\r\n const routeResult = matchRoute(theRoutes, routeNameOrUrl, params);\r\n if (!routeResult) {\r\n const errorMsg = generateErrorMessage(\r\n routeNameOrUrl,\r\n params,\r\n theRoutes\r\n );\r\n console.error(errorMsg);\r\n throw new RouteError(errorMsg);\r\n }\r\n\r\n if (!checkRouteGuards(routeResult)) {\r\n throw new RouteGuardError('Route guards stopped navigation for route ' + routeNameOrUrl);\r\n }\r\n\r\n return routeResult;\r\n}\r\n\r\nfunction navigateToLayout(routeResult: RouteMatchResult): boolean {\r\n if (!routeResult) {\r\n console.error('Route result is null, cannot navigate to layout.');\r\n }\r\n\r\n const wantedLayout = (routeResult.route.layout ?? 'default').replace(\r\n /\\.html?$/,\r\n ''\r\n );\r\n if (wantedLayout === currentLayout) {\r\n return false;\r\n }\r\n\r\n console.log(\r\n 'Current layout: ' + currentLayout,\r\n 'Wanted layout: ' + wantedLayout\r\n );\r\n\r\n // The hash means that we attempted to redirect to the same layout once,\r\n // so if it's there and another redirect is requsted, something is wrong.\r\n //\r\n // Because the push history should remove it if everything worked out.\r\n if (window.location.hash) {\r\n throw Error(\r\n 'A redirect failed, does the requsted layout exist? \"' +\r\n wantedLayout +\r\n '\"?'\r\n );\r\n }\r\n\r\n console.log(\r\n `requires layout switch from ${currentLayout} to ${wantedLayout}`\r\n );\r\n const navigationState = {\r\n routeName: routeResult.route.name,\r\n params: routeResult.params || {}\r\n };\r\n\r\n sessionStorage.setItem('layoutNavigation', JSON.stringify(navigationState));\r\n const layoutUrl =\r\n wantedLayout.indexOf('.htm') > -1\r\n ? `/${wantedLayout}#layout`\r\n : `/${wantedLayout}.html#layout`;\r\n console.log('redirecting to ', layoutUrl);\r\n window.location.href = layoutUrl;\r\n return true;\r\n}\r\n/**\r\n * Checks session storage for route information and initiates proper navigation\r\n * Should be called when page loads to handle layout transitions\r\n *\r\n * @returns Whether navigation was initiated from session storage\r\n *\r\n * @example\r\n * // Call on page load\r\n * document.addEventListener('DOMContentLoaded', () => {\r\n * if (handleLayoutNavigation()) {\r\n * console.log('Navigation handled from session storage');\r\n * }\r\n * });\r\n */\r\nfunction tryLoadRouteFromLayoutNavigation(): boolean {\r\n try {\r\n const navigationStateJson = sessionStorage.getItem('layoutNavigation');\r\n if (!navigationStateJson) {\r\n return false;\r\n }\r\n\r\n const navigationState = JSON.parse(navigationStateJson);\r\n sessionStorage.removeItem('layoutNavigation');\r\n console.log('session store navigation ', navigationState);\r\n navigate(navigationState.routeName, {\r\n params: navigationState.params\r\n });\r\n\r\n return true;\r\n } catch (error) {\r\n sessionStorage.removeItem('layoutNavigation');\r\n reportError('Failed to navigate from session storage', {\r\n cause: error,\r\n });\r\n return false;\r\n }\r\n}\r\n\r\nfunction generateErrorMessage(\r\n routeNameOrUrl: string,\r\n routeParams: Record<string, RouteParamType>,\r\n allRoutes: Route[]\r\n): string {\r\n var routeData = '';\r\n if (routeParams) {\r\n routeData += Object.entries(routeParams)\r\n .map(([key, value]) => `${key}=${value}`)\r\n .join(', ');\r\n } else {\r\n routeData = '.';\r\n }\r\n\r\n var routesStr = allRoutes.map(\r\n (x) =>\r\n ` * Name: '${x.name}', path: '${x.path}', target: ${\r\n x.target ?? 'default'\r\n }\\n`\r\n );\r\n return `No route matched '${routeNameOrUrl}${routeData}'. Available routes:\\n${routesStr}`;\r\n}\r\n\r\nfunction checkRouteGuards(routeResult: RouteMatchResult): boolean {\r\n if (\r\n !routeResult ||\r\n !routeResult.route.guards ||\r\n routeResult.route.guards.length == 0\r\n ) {\r\n return true;\r\n }\r\n\r\n for (let index = 0; index < routeResult.route.guards.length; index++) {\r\n const element = routeResult.route.guards[index];\r\n var result = element.check(routeResult);\r\n if (result == GuardResult.Allow) {\r\n return true;\r\n }\r\n\r\n if (result == GuardResult.Stop) {\r\n return false;\r\n }\r\n\r\n if (result == GuardResult.Deny) {\r\n throw new RouteGuardError(\r\n `Guard ${element.constructor.name} said 'Deny' for ${routeResult.route.name}`\r\n );\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n"],
|
|
5
|
-
"mappings": "AAEO,IAAKA,OAIRA,IAAA,iBAKAA,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M,IAAId,EACN,SAASa,EAAQ,YAAY,IAAI,oBAAoBjC,EAAY,MAAM,IAAI,EAC/E,CAER,CAEA,MAAO,EACX",
|
|
6
|
-
"names": ["GuardResult", "RouteError", "RouteGuardError", "NavigateRouteEvent", "_NavigateRouteEvent", "route", "urlSegments", "routeData", "routeTarget", "eventInit", "RelaxError", "message", "context", "handler", "reportError", "message", "context", "error", "RelaxError", "handler", "suppressed", "targetHandlers", "pendingEvents", "registerRouteTarget", "name", "handler", "initRouteTargetListener", "error", "reportError", "pending", "unregisterRouteTarget", "clearPendingNavigations", "dispatchToTarget", "evt", "listenerAttached", "NavigateRouteEvent", "NumberRouteSegment", "paramName", "value", "pathValue", "StringRouteSegment", "PathRouteSegment", "_pathValue", "RouteImp", "route", "segments", "generatedSegments", "params", "index", "urlSegment", "ourSegment", "routeData", "urlSegments", "routeParams", "d", "segment", "providedValue", "convertedValue", "matchRoute", "routes", "routeNameOrUrl", "findRouteByUrl", "findRouteByName", "name", "x", "imp", "generateRouteImp", "result", "path", "routeImps", "generateRouteImps", "m", "impSegments", "RouteLink", "name", "printRoutes", "params", "attr", "paramName", "paramsAttr", "additionalParams", "error", "err", "reportError", "target", "navigate", "RelaxError", "reported", "RouteTarget", "registerRouteTarget", "evt", "unregisterRouteTarget", "error", "RelaxError", "reportError", "tagName", "element", "data", "routeData", "currentLayout", "getLayout", "path", "internalRoutes", "printRoutes", "internalRoutes", "defineRoutes", "appRoutes", "initRouteTargetListener", "RouteTarget", "RouteLink", "errs", "route", "startRouting", "newPage", "
|
|
4
|
+
"sourcesContent": ["/** @internal */\r\ntype WebComponentConstructor = new (...args: any[]) => HTMLElement;\r\n\r\nexport enum GuardResult {\r\n /**\r\n * Handle route without checking more guards.\r\n */\r\n Allow,\r\n\r\n /**\r\n * Throw a RouteGuardError.\r\n */\r\n Deny,\r\n\r\n /**\r\n * Resume and check other guards.\r\n */\r\n Continue,\r\n\r\n /**\r\n * Do not invoke the rooute nor other guards.\r\n */\r\n Stop\r\n}\r\n\r\nexport interface RouteGuard {\r\n check(route: RouteMatchResult): GuardResult;\r\n}\r\n\r\nexport interface Route {\r\n name?: string;\r\n target?: string;\r\n path: string;\r\n\r\n /**\r\n * HTML file name (without extension).\r\n *\r\n * Define for instance if you have a route that requires a more limited layout. The library\r\n * will automatically load that HTML file and rewrite URL history so that the correct url is displayed.\r\n */\r\n layout?: string;\r\n\r\n /**\r\n * Name of the tag for your web component.\r\n */\r\n componentTagName?: string;\r\n\r\n /**\r\n * Guards used to check if this route can be visited.\r\n */\r\n guards?: RouteGuard[];\r\n\r\n component?: WebComponentConstructor;\r\n}\r\n\r\nexport type RouteParamType = string | number;\r\nexport type RouteData = Record<string, RouteParamType>;\r\n\r\n/**\r\n * Implement to receive typed route parameters via a `routeData` property.\r\n * RouteTarget assigns `routeData` after element creation but before DOM insertion.\r\n * Optional since it's not available at construction time.\r\n *\r\n * For convention-based usage without undefined checks, skip the interface\r\n * and declare `routeData` directly on your component.\r\n *\r\n * @example\r\n * class UserProfile extends HTMLElement implements Routable<{ userName: string }> {\r\n * routeData?: { userName: string };\r\n * }\r\n */\r\nexport interface Routable<T extends RouteData = RouteData> {\r\n routeData?: T;\r\n}\r\n\r\n/**\r\n * Implement to run async initialization before the component is added to the DOM.\r\n * RouteTarget calls `loadRoute()` and awaits it before inserting the element.\r\n *\r\n * @example\r\n * class OrderDetail extends HTMLElement implements LoadRoute<{ orderId: number }> {\r\n * async loadRoute(data: { orderId: number }) {\r\n * this.order = await fetchOrder(data.orderId);\r\n * }\r\n * }\r\n */\r\nexport interface LoadRoute<T extends RouteData = RouteData> {\r\n loadRoute(data: T): void | Promise<void>;\r\n}\r\n\r\n/**\r\n * Result from route matching operations.\r\n * Contains all information needed for navigation and rendering.\r\n */\r\nexport type RouteMatchResult = {\r\n /**\r\n * Matched route configuration\r\n */\r\n route: Route;\r\n\r\n /**\r\n * URL segments used for history state\r\n */\r\n urlSegments: string[];\r\n\r\n /**\r\n * Extracted and type-converted parameters\r\n */\r\n params: RouteData;\r\n};\r\n\r\n/**\r\n * Supported types of route segments\r\n */\r\nexport type RouteSegmentType = 'string' | 'number' | 'path' | 'regex';\r\n\r\n/**\r\n * Strongly typed route segment value\r\n */\r\nexport interface RouteValue {\r\n /**\r\n * Type of parameter for validation\r\n */\r\n type: RouteSegmentType;\r\n\r\n /**\r\n * Actual parameter value\r\n */\r\n value: any;\r\n}\r\n\r\nexport class RouteError extends Error {}\r\nexport class RouteGuardError extends RouteError {\r\n isGuard = true;\r\n}\r\n\r\nexport interface NavigateOptions {\r\n /**\r\n * Optional parameters when using route name\r\n */\r\n params?: Record<string, string | number>;\r\n\r\n /**\r\n * override for route's default target\r\n */\r\n target?: string;\r\n\r\n /**\r\n * When you want to override routes from the globally registered ones.\r\n */\r\n routes?: Route[];\r\n}\r\n", "import type { Route, RouteData } from './types';\r\n\r\n/**\r\n * Event sent to routing targets when a new route should be displayed.\r\n */\r\nexport class NavigateRouteEvent extends Event {\r\n static NAME: string = 'rlx.navigateRoute';\r\n constructor(\r\n /**\r\n * Matched route.\r\n */\r\n public route: Route,\r\n\r\n /**\r\n * The generated url sements which can be used to push the url into the browser history.\r\n */\r\n public urlSegments: string[],\r\n\r\n /**\r\n * Data supplied to the route.\r\n */\r\n public routeData?: RouteData,\r\n\r\n /**\r\n * The target can differ from the default target that is defined in the route.\r\n *\r\n * undefined means that the default (unnamed) target should be used.\r\n */\r\n public routeTarget?: string,\r\n\r\n eventInit?: EventInit\r\n ) {\r\n super(NavigateRouteEvent.NAME, eventInit);\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementEventMap {\r\n 'rlx.navigateRoute': NavigateRouteEvent;\r\n }\r\n interface DocumentEventMap {\r\n 'rlx.navigateRoute': NavigateRouteEvent;\r\n }\r\n}\r\n", "/**\r\n * Global error handling for Relaxjs.\r\n * Register a handler with `onError()` to intercept errors before they throw.\r\n * Call `ctx.suppress()` in the handler to prevent the error from being thrown.\r\n *\r\n * @example\r\n * import { onError } from 'relaxjs';\r\n *\r\n * onError((error, ctx) => {\r\n * logToService(error.message, error.context);\r\n * showToast(error.message);\r\n * ctx.suppress();\r\n * });\r\n */\r\n\r\n/**\r\n * Passed to error handlers to control error behavior.\r\n * Call `suppress()` to prevent the error from being thrown.\r\n */\r\nexport interface ErrorContext {\r\n suppress(): void;\r\n}\r\n\r\n/**\r\n * Error with structured context for debugging.\r\n * The `context` record contains details like route name, component tag, route data.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * console.log(error.context.route);\r\n * console.log(error.context.componentTagName);\r\n * });\r\n */\r\nexport class RelaxError extends Error {\r\n constructor(\r\n message: string,\r\n public context: Record<string, unknown>,\r\n ) {\r\n super(message);\r\n }\r\n}\r\n\r\n/** @internal */\r\ntype ErrorHandler = (error: RelaxError, ctx: ErrorContext) => void;\r\n\r\nlet handler: ErrorHandler | null = null;\r\n\r\n/**\r\n * Registers a global error handler for Relaxjs errors.\r\n * The handler receives the error and an `ErrorContext`.\r\n * Call `ctx.suppress()` to prevent the error from being thrown.\r\n * Only one handler can be active at a time; subsequent calls replace the previous handler.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * if (error.context.route === 'optional-panel') {\r\n * ctx.suppress();\r\n * return;\r\n * }\r\n * showErrorDialog(error.message);\r\n * });\r\n */\r\nexport function onError(fn: ErrorHandler) {\r\n handler = fn;\r\n}\r\n\r\n/**\r\n * Reports an error through the global handler.\r\n * Returns the `RelaxError` if it should be thrown, or `null` if the handler suppressed it.\r\n * The caller is responsible for throwing the returned error.\r\n *\r\n * @param message - Human-readable error description\r\n * @param context - Structured data for debugging (route, component, params, cause, etc.)\r\n * @returns The error to throw, or `null` if suppressed\r\n *\r\n * @example\r\n * const error = reportError('Failed to load route component', {\r\n * route: 'user',\r\n * componentTagName: 'user-profile',\r\n * routeData: { id: 123 },\r\n * });\r\n * if (error) throw error;\r\n */\r\nexport function reportError(message: string, context: Record<string, unknown>): RelaxError | null {\r\n const error = new RelaxError(message, context);\r\n if (handler) {\r\n let suppressed = false;\r\n const ctx: ErrorContext = {\r\n suppress() { suppressed = true; },\r\n };\r\n handler(error, ctx);\r\n if (suppressed) {\r\n return null;\r\n }\r\n }\r\n return error;\r\n}\r\n\r\n/**\r\n * Wraps an async function into a synchronous callback suitable for addEventListener.\r\n * Catches promise rejections and reports them through the global error handler.\r\n *\r\n * @param fn - Async function to wrap\r\n * @returns Synchronous function that can be passed to addEventListener\r\n *\r\n * @example\r\n * button.addEventListener('click', asyncHandler(async (e) => {\r\n * await saveData();\r\n * }));\r\n *\r\n * @example\r\n * form.addEventListener('submit', asyncHandler(async (e) => {\r\n * e.preventDefault();\r\n * await submitForm();\r\n * }));\r\n */\r\nexport function asyncHandler<TArgs extends unknown[]>(\r\n fn: (...args: TArgs) => Promise<void>,\r\n): (...args: TArgs) => void {\r\n return function (this: any, ...args: TArgs) {\r\n fn.call(this, ...args).catch((cause: unknown) => {\r\n const error = reportError('Async callback failed', { cause });\r\n if (error) throw error;\r\n });\r\n };\r\n}\r\n", "import { reportError } from '../errors';\r\nimport { NavigateRouteEvent } from './NavigateRouteEvent';\r\n\r\n/** @internal */\r\ntype RouteTargetHandler = (evt: NavigateRouteEvent) => void;\r\nconst targetHandlers = new Map<string | undefined, RouteTargetHandler>();\r\nconst pendingEvents = new Map<string | undefined, NavigateRouteEvent>();\r\n\r\n/**\r\n * Registers a route target handler.\r\n * When a navigation event targets this name, the handler is called directly.\r\n * If a pending event exists for this target, it is replayed immediately.\r\n *\r\n * @param name - Target name, or `undefined` for the default (unnamed) target\r\n * @param handler - Callback that receives the `NavigateRouteEvent`\r\n *\r\n * @example\r\n * registerRouteTarget('sidebar', (evt) => renderComponent(evt));\r\n */\r\nexport function registerRouteTarget(\r\n name: string | undefined,\r\n handler: RouteTargetHandler,\r\n) {\r\n initRouteTargetListener();\r\n if (targetHandlers.has(name)) {\r\n const error = reportError('Duplicate route target', {\r\n target: name ?? 'default',\r\n });\r\n if (error) throw error;\r\n return;\r\n }\r\n targetHandlers.set(name, handler);\r\n\r\n const pending = pendingEvents.get(name);\r\n if (pending) {\r\n pendingEvents.delete(name);\r\n handler(pending);\r\n }\r\n}\r\n\r\n/**\r\n * Unregisters a previously registered route target handler.\r\n *\r\n * @param name - Target name that was passed to `registerRouteTarget`\r\n */\r\nexport function unregisterRouteTarget(name: string | undefined) {\r\n targetHandlers.delete(name);\r\n}\r\n\r\nexport function clearPendingNavigations() {\r\n pendingEvents.clear();\r\n targetHandlers.clear();\r\n}\r\n\r\nfunction dispatchToTarget(evt: NavigateRouteEvent) {\r\n const handler = targetHandlers.get(evt.routeTarget);\r\n if (handler) {\r\n handler(evt);\r\n } else {\r\n pendingEvents.set(evt.routeTarget, evt);\r\n }\r\n}\r\n\r\nlet listenerAttached = false;\r\n\r\nexport function initRouteTargetListener() {\r\n if (listenerAttached) return;\r\n listenerAttached = true;\r\n document.addEventListener(NavigateRouteEvent.NAME, (evt) => {\r\n dispatchToTarget(evt as NavigateRouteEvent);\r\n });\r\n}\r\n", "import type { Route, RouteData, RouteParamType, RouteMatchResult } from './types';\r\n\r\n/**\r\n * Route segment matcher interface.\r\n * Each segment type (string, number, path) implements this\r\n * for parameter extraction and validation.\r\n */\r\ninterface RouteSegment {\r\n /**\r\n * Parameter name when segment is dynamic (:name or ;id)\r\n */\r\n paramName?: string;\r\n\r\n /**\r\n * Validates if URL segment matches pattern\r\n * @param value Segment from URL to validate\r\n */\r\n isMatch(value: string): boolean;\r\n\r\n /**\r\n * Converts URL segment to typed parameter\r\n * @param pathValue Raw value from URL\r\n */\r\n getValue(pathValue: string): RouteParamType;\r\n}\r\n\r\n/**\r\n * Number parameter segment matcher.\r\n * Used for ;id style parameters that must be numbers.\r\n */\r\nclass NumberRouteSegment implements RouteSegment {\r\n constructor(public paramName: string) {}\r\n isMatch(value: string): boolean {\r\n if (/^\\d+$/.test(value)) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(pathValue: string): RouteParamType {\r\n if (/^\\d+$/.test(pathValue) === false) {\r\n throw new Error(\r\n `Path is not a number, parameter name '${this.paramName}', value: '${pathValue}'.`\r\n );\r\n }\r\n return parseInt(pathValue);\r\n }\r\n}\r\n\r\n/**\r\n * String parameter segment matcher.\r\n * Used for :name style parameters.\r\n */\r\nclass StringRouteSegment implements RouteSegment {\r\n constructor(public paramName: string) {}\r\n isMatch(value: string): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n *\r\n * @param pathValue the route data (for route by name) or segment extracted from the url (for url routing).\r\n * @returns\r\n */\r\n getValue(pathValue: string): RouteParamType {\r\n return pathValue;\r\n }\r\n}\r\n\r\n/**\r\n * Static path segment matcher.\r\n * Used for fixed URL parts like 'users' in /users/:id\r\n */\r\nclass PathRouteSegment implements RouteSegment {\r\n constructor(public value: string) {}\r\n isMatch(value: string): boolean {\r\n return value == this.value;\r\n }\r\n\r\n getValue(_pathValue: string): RouteParamType {\r\n return this.value;\r\n }\r\n}\r\n\r\n/**\r\n * Internal route implementation that handles segment matching\r\n * and parameter extraction.\r\n */\r\nclass RouteImp {\r\n constructor(public route: Route, private segments: RouteSegment[]) {}\r\n\r\n /**\r\n * Attempts to match URL segments against route pattern\r\n * @param segments URL parts to match\r\n * @returns Match result with parameters if successful\r\n */\r\n match(segments: string[]): RouteMatchResult | null {\r\n if (segments.length != this.segments.length) {\r\n return null;\r\n }\r\n\r\n const generatedSegments: string[] = [];\r\n var params: RouteData = {};\r\n for (let index = 0; index < segments.length; index++) {\r\n const urlSegment = segments[index];\r\n const ourSegment = this.segments[index];\r\n\r\n if (!ourSegment.isMatch(urlSegment)) {\r\n return null;\r\n }\r\n\r\n if (ourSegment.paramName) {\r\n const value = ourSegment.getValue(urlSegment);\r\n params[ourSegment.paramName] = value;\r\n generatedSegments.push(value.toString());\r\n } else {\r\n generatedSegments.push(urlSegment);\r\n }\r\n }\r\n\r\n return { route: this.route, params, urlSegments: generatedSegments };\r\n }\r\n\r\n /**\r\n * Routing by name and route data, so generate the url segments.\r\n * @param routeData Data to use in the URL.\r\n * @returns Match result with parameters if successful\r\n */\r\n buildUrl(routeData: RouteData): RouteMatchResult | null {\r\n const urlSegments: string[] = [];\r\n for (let index = 0; index < this.segments.length; index++) {\r\n const ourSegment = this.segments[index];\r\n if (ourSegment.paramName) {\r\n var value = routeData[ourSegment.paramName];\r\n if (!value) {\r\n throw new Error(\r\n `Route \"${\r\n this.route.name\r\n }\" did not get value for parameter \"${\r\n ourSegment.paramName\r\n } from the provided routeData: \"${JSON.stringify(\r\n routeData\r\n )}\".`\r\n );\r\n }\r\n\r\n urlSegments.push(value.toString());\r\n } else {\r\n urlSegments.push(ourSegment.getValue('').toString());\r\n }\r\n }\r\n\r\n return { route: this.route, params: routeData, urlSegments };\r\n }\r\n\r\n /**\r\n * Converts string parameters to proper types\r\n * @param routeParams Raw string parameters to convert\r\n */\r\n parseParameters(routeParams: Record<string, string>): RouteData {\r\n const d: Record<string, any> = {};\r\n\r\n this.segments.forEach((segment) => {\r\n if (!segment.paramName) {\r\n return;\r\n }\r\n\r\n if (!segment.isMatch(providedValue)) {\r\n throw new Error(\r\n `Failed to convert parameter ${segment.paramName}, or missing value: ${providedValue}, route: ${this.route.name}.`\r\n );\r\n }\r\n\r\n var providedValue = routeParams[segment.paramName];\r\n if (!providedValue) {\r\n throw new Error(\r\n `Parameter ${segment.paramName} was not provided, route: ${this.route.name}.`\r\n );\r\n }\r\n\r\n var convertedValue = segment.getValue(providedValue);\r\n d[segment.paramName] = convertedValue;\r\n });\r\n\r\n return d;\r\n }\r\n}\r\n\r\n/**\r\n * Match route by either name or URL pattern\r\n * @param routes Available routes\r\n * @param routeNameOrUrl Route name or URL to match\r\n * @param routeData Optional parameters for named routes\r\n */\r\nexport function matchRoute(\r\n routes: Route[],\r\n routeNameOrUrl: string,\r\n routeData?: Record<string, string | any>\r\n): RouteMatchResult | null {\r\n if (routeNameOrUrl === '' || routeNameOrUrl.indexOf('/') >= 0) {\r\n return findRouteByUrl(routes, routeNameOrUrl || '/');\r\n } else {\r\n return findRouteByName(routes, routeNameOrUrl, routeData!);\r\n }\r\n}\r\n\r\n/**\r\n * Find route by name and apply parameters\r\n * @param routes Available routes\r\n * @param name Route name to find\r\n * @param routeData Parameters to apply\r\n */\r\nexport function findRouteByName(\r\n routes: Route[],\r\n name: string,\r\n routeData?: Record<string, string | any>\r\n): RouteMatchResult | null {\r\n var route = routes.find((x) => x.name === name);\r\n if (!route) {\r\n return null;\r\n }\r\n\r\n var imp = generateRouteImp(route);\r\n var result = imp.buildUrl(routeData);\r\n return result;\r\n}\r\n\r\n/**\r\n * Find route matching URL pattern\r\n * @param routes Available routes\r\n * @param path URL to match\r\n */\r\nexport function findRouteByUrl(\r\n routes: Route[],\r\n path: string\r\n): RouteMatchResult | null {\r\n const urlSegments = path.replace(/^\\/|\\/$/g, '').split('/');\r\n const routeImps = generateRouteImps(routes);\r\n\r\n for (let index = 0; index < routeImps.length; index++) {\r\n const element = routeImps[index];\r\n const m = element.match(urlSegments);\r\n if (m) {\r\n return m;\r\n }\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Generate implementations for all routes\r\n */\r\nfunction generateRouteImps(routes: Route[]) {\r\n const routeImps: RouteImp[] = [];\r\n routes.forEach((route) => {\r\n var imp = generateRouteImp(route);\r\n routeImps.push(imp);\r\n });\r\n\r\n return routeImps;\r\n}\r\n\r\n/**\r\n * Generate implementation for single route\r\n * Parses URL pattern into segment matchers\r\n */\r\nfunction generateRouteImp(route: Route): RouteImp {\r\n var impSegments = [];\r\n const segments = route.path.replace(/^\\/|\\/$/g, '').split('/');\r\n segments.forEach((segment) => {\r\n if (segment.substring(0, 1) == ':') {\r\n impSegments.push(new StringRouteSegment(segment.substring(1)));\r\n } else if (segment.substring(0, 1) === ';') {\r\n impSegments.push(new NumberRouteSegment(segment.substring(1)));\r\n } else if (segment.substring(0, 1) === '{') {\r\n } else {\r\n impSegments.push(new PathRouteSegment(segment));\r\n }\r\n });\r\n\r\n var imp = new RouteImp(route, impSegments);\r\n return imp;\r\n}\r\n", "import { navigate, printRoutes } from './navigation';\r\nimport { RelaxError, reportError } from '../errors';\r\n\r\nexport class RouteLink extends HTMLElement {\r\n static get observedAttributes() {\r\n return ['name', 'target', 'params'];\r\n }\r\n\r\n constructor() {\r\n super();\r\n this.addEventListener('click', e => this.handleClick(e));\r\n }\r\n\r\n private handleClick(e: MouseEvent) {\r\n e.preventDefault();\r\n \r\n const name = this.getAttribute('name');\r\n if (!name) return;\r\n\r\n console.log('Calling printRoutes from RouteLink in relaxjs/components');\r\n printRoutes();\r\n \r\n const params: Record<string, string> = {};\r\n for (const attr of Array.from(this.attributes)) {\r\n if (attr.name.startsWith('param-')) {\r\n const paramName = attr.name.substring(6);\r\n params[paramName] = attr.value;\r\n }\r\n }\r\n\r\n const paramsAttr = this.getAttribute('params');\r\n let additionalParams: Record<string, string | number> | undefined;\r\n if (paramsAttr) {\r\n try {\r\n const parsed = JSON.parse(paramsAttr);\r\n additionalParams = parsed as Record<string, string | number>;\r\n } catch (error) {\r\n const err = reportError('Failed to parse route params', {\r\n element: 'r-link',\r\n params: paramsAttr,\r\n cause: error,\r\n });\r\n if (err) throw err;\r\n }\r\n }\r\n\r\n const target = this.getAttribute('target');\r\n if (additionalParams){\r\n Object.assign(params, additionalParams);\r\n }\r\n\r\n try {\r\n navigate(name, { params, target: target || undefined });\r\n } catch (error) {\r\n if (error instanceof RelaxError) throw error;\r\n const reported = reportError('Navigation failed', {\r\n element: 'r-link',\r\n route: name,\r\n params,\r\n target,\r\n cause: error,\r\n });\r\n if (reported) throw reported;\r\n }\r\n }\r\n\r\n connectedCallback() {\r\n if (!this.hasAttribute('tabindex')) {\r\n this.setAttribute('tabindex', '0');\r\n }\r\n \r\n this.style.cursor = 'pointer';\r\n this.role = 'link';\r\n }\r\n\r\n disconnectedCallback() {\r\n this.removeEventListener('click', this.handleClick);\r\n }\r\n}", "import { registerRouteTarget, unregisterRouteTarget } from './routeTargetRegistry';\r\nimport type { NavigateRouteEvent } from './NavigateRouteEvent';\r\nimport type { RouteData, LoadRoute } from './types';\r\nimport { RelaxError, reportError } from '../errors';\r\n\r\n/**\r\n * WebComponent that listens on the `NavigateRouteEvent` event to be able to switch route.\r\n *\r\n * Use the \"name\" attribute to make this non-default target.\r\n * Use the \"dialog\" attribute to render routes inside a native `<dialog>` element\r\n * with built-in focus trapping, backdrop, and Escape-to-close.\r\n *\r\n * @example\r\n * <r-route-target></r-route-target>\r\n * <r-route-target name=\"modal\" dialog></r-route-target>\r\n */\r\nexport class RouteTarget extends HTMLElement {\r\n name?: string = undefined;\r\n private dialog?: HTMLDialogElement;\r\n\r\n connectedCallback() {\r\n this.name = this.getAttribute('name') ?? undefined;\r\n\r\n if (this.hasAttribute('dialog')) {\r\n this.dialog = document.createElement('dialog');\r\n this.dialog.addEventListener('close', () => {\r\n this.dialog!.replaceChildren();\r\n });\r\n this.appendChild(this.dialog);\r\n }\r\n\r\n registerRouteTarget(this.name, (evt) => this.onNavigate(evt));\r\n console.log('registered');\r\n }\r\n\r\n disconnectedCallback() {\r\n unregisterRouteTarget(this.name);\r\n }\r\n\r\n private onNavigate(evt: NavigateRouteEvent) {\r\n console.log('got nav', evt);\r\n this.loadComponent(evt).catch((error) => {\r\n if (!(error instanceof RelaxError)) {\r\n error = reportError('Route navigation failed', {\r\n route: evt.route.name,\r\n routeTarget: evt.routeTarget,\r\n cause: error,\r\n });\r\n }\r\n if (error) {\r\n console.error(error);\r\n }\r\n });\r\n }\r\n\r\n private async loadComponent(evt: NavigateRouteEvent) {\r\n const tagName = evt.route.componentTagName\r\n ?? customElements.getName(evt.route.component);\r\n\r\n if (!tagName) {\r\n const error = reportError('Failed to find component for route', {\r\n route: evt.route.name,\r\n componentTagName: evt.route.componentTagName,\r\n component: evt.route.component?.name,\r\n routeData: evt.routeData,\r\n });\r\n if (error) throw error;\r\n return;\r\n }\r\n\r\n await customElements.whenDefined(tagName);\r\n const element = document.createElement(tagName);\r\n\r\n await this.applyRouteData(element, evt.routeData);\r\n\r\n if (this.dialog) {\r\n this.dialog.replaceChildren(element);\r\n if (!this.dialog.open) {\r\n this.dialog.showModal();\r\n }\r\n } else if (document.startViewTransition) {\r\n document.startViewTransition(() => this.replaceChildren(element));\r\n } else {\r\n this.replaceChildren(element);\r\n }\r\n }\r\n\r\n /** Closes the dialog (only applies to dialog targets). */\r\n close() {\r\n this.dialog?.close();\r\n }\r\n\r\n private async applyRouteData(element: Element, data?: RouteData) {\r\n if ('loadRoute' in element) {\r\n const routeData = data\r\n ?? { error: 'loadRoute function without mapped route data in the routes' };\r\n await (element as unknown as LoadRoute).loadRoute(routeData);\r\n }\r\n\r\n if (data) {\r\n (element as any).routeData = data;\r\n }\r\n }\r\n}\r\n", "/**\r\n * Single Page Application routing system with multiple target support.\r\n * Designed for scenarios where you need:\r\n * - Multiple navigation targets (main content, modals, sidebars)\r\n * - Strongly typed route parameters\r\n * - History management with back/forward support\r\n *\r\n * @example\r\n * // Configure routes\r\n * const routes = [\r\n * { name: 'user', path: '/users/:id' }, // String parameter\r\n * { name: 'order', path: '/orders/;orderId' }, // Number parameter\r\n * { name: 'modal', path: '/detail/:id', target: 'modal' } // Custom target\r\n * ];\r\n */\r\n\r\nimport { reportError } from '../errors';\r\nimport {\r\n GuardResult,\r\n RouteError,\r\n RouteGuardError,\r\n type Route,\r\n type RouteData,\r\n type RouteParamType,\r\n type RouteMatchResult,\r\n type NavigateOptions,\r\n} from './types';\r\nimport { NavigateRouteEvent } from './NavigateRouteEvent';\r\nimport { matchRoute } from './routeMatching';\r\nimport { initRouteTargetListener } from './routeTargetRegistry';\r\nimport { RouteLink } from './RouteLink';\r\nimport { RouteTarget } from './RoutingTarget';\r\n\r\n/**\r\n * Used to keep track of current main HTML file,\r\n * used when different layouts are supported.\r\n *\r\n * The default page is ALWAYS loaded initially,\r\n * which means that we need to switch layout page\r\n * if someone else is configured for the route.\r\n */\r\nvar currentLayout: string | undefined;\r\n\r\nfunction getCurrentLayout(): string {\r\n if (currentLayout === undefined) {\r\n currentLayout = getLayout() ?? 'default';\r\n }\r\n return currentLayout;\r\n}\r\n\r\nfunction getLayout() {\r\n const path = window.location.pathname;\r\n if (path == '/index.html') {\r\n return 'default';\r\n }\r\n\r\n return path.endsWith('.html') ? path.slice(1, -5) : null;\r\n}\r\n\r\nexport const internalRoutes: Route[] = [];\r\n\r\nexport const MyData = {\r\n routes: []\r\n};\r\n\r\n/**\r\n * Debug helper to print all registered routes to console.\r\n */\r\nexport function printRoutes() {\r\n console.log(internalRoutes);\r\n}\r\n\r\n/**\r\n * Registers application routes with the router.\r\n * Call this at application startup before routing begins.\r\n *\r\n * @param appRoutes - Array of route configurations\r\n * @throws Error if referenced components are not registered\r\n *\r\n * @example\r\n * const routes: Route[] = [\r\n * { name: 'home', path: '/', componentTagName: 'app-home' },\r\n * { name: 'user', path: '/users/:id', componentTagName: 'user-profile' },\r\n * { name: 'login', path: '/auth/', componentTagName: 'login-form', layout: 'noauth' }\r\n * ];\r\n * defineRoutes(routes);\r\n */\r\nexport function defineRoutes(appRoutes: Route[]) {\r\n console.log('defining routes1', appRoutes);\r\n initRouteTargetListener();\r\n if (!customElements.get('r-route-target')) {\r\n customElements.define('r-route-target', RouteTarget);\r\n }\r\n if (!customElements.get('r-link')) {\r\n customElements.define('r-link', RouteLink);\r\n }\r\n console.log('defining routes', appRoutes);\r\n internalRoutes.length = 0;\r\n internalRoutes.push(...appRoutes);\r\n\r\n var errs = [];\r\n appRoutes.forEach((route) => {\r\n if (\r\n route.componentTagName &&\r\n !customElements.get(route.componentTagName)\r\n ) {\r\n errs.push(\r\n `Component with tagName '${route.componentTagName}' is not defined in customElements.`\r\n );\r\n }\r\n if (route.component && !customElements.getName(route.component)) {\r\n errs.push(\r\n `Component '${route.component.name}' is not defined in customElements. Used in route '${JSON.stringify(route)}'.`\r\n );\r\n }\r\n if (route.layout === '') {\r\n console.log('should not use empty string layout.', route);\r\n route.layout = undefined;\r\n }\r\n });\r\n\r\n if (errs.length > 0) {\r\n throw new Error(errs.join('\\n'));\r\n }\r\n}\r\n\r\n/**\r\n * Initializes routing and navigates to the current URL.\r\n * Call this after DOM is ready and routes are defined.\r\n *\r\n * @example\r\n * // In your main application component\r\n * connectedCallback() {\r\n * defineRoutes(routes);\r\n * startRouting();\r\n * }\r\n */\r\nexport function startRouting() {\r\n let newPage = false;\r\n if (getCurrentLayout() == '') {\r\n const path = window.location.pathname;\r\n const match = path.match(/\\/([^\\/]+)\\.html$/);\r\n if (match && match[1] !== '') {\r\n console.log('setting current layut', match[1]);\r\n currentLayout = match[1];\r\n newPage = true;\r\n } else {\r\n console.log('Setting default layout name');\r\n currentLayout = 'default';\r\n }\r\n }\r\n\r\n if (tryLoadRouteFromLayoutNavigation()) {\r\n return;\r\n }\r\n\r\n const currentUrl = window.location.pathname.replace(/^\\/|\\/$/g, '') || '/';\r\n const routeResult = findRoute(currentUrl, {});\r\n\r\n const searchParams = new URLSearchParams(window.location.search);\r\n if (searchParams.size > 0) {\r\n routeResult.params ??= {};\r\n searchParams.forEach((value, key) => {\r\n routeResult.params[key] = value;\r\n });\r\n }\r\n\r\n if (navigateToLayout(routeResult)) {\r\n return;\r\n }\r\n\r\n history.replaceState(\r\n routeResult.urlSegments,\r\n '',\r\n '/' + routeResult.urlSegments.join('/')\r\n );\r\n\r\n const e = new NavigateRouteEvent(\r\n routeResult.route,\r\n routeResult.urlSegments,\r\n routeResult.params,\r\n routeResult.route.target\r\n );\r\n document.dispatchEvent(e);\r\n}\r\n\r\n/**\r\n * Navigates to a route by name or URL.\r\n * Updates browser history and dispatches navigation events.\r\n *\r\n * @param routeNameOrUrl - Route name or URL path to navigate to\r\n * @param options - Navigation options including params and target\r\n *\r\n * @example\r\n * // Navigate by route name\r\n * navigate('user', { params: { id: '123' } });\r\n *\r\n * // Navigate by URL\r\n * navigate('/users/123');\r\n *\r\n * // Navigate to specific target\r\n * navigate('detail', { params: { id: '42' }, target: 'modal' });\r\n */\r\nexport function navigate(routeNameOrUrl: string, options?: NavigateOptions) {\r\n console.log('navigating to ', routeNameOrUrl, options);\r\n const routeResult = findRoute(routeNameOrUrl, options);\r\n if (navigateToLayout(routeResult)) {\r\n return;\r\n }\r\n\r\n const target = options?.target ?? routeResult.route.target;\r\n const ourUrl = routeResult.urlSegments.join('/');\r\n const currentUrl = window.location.pathname.replace(/^\\/|\\/$/g, '');\r\n if (currentUrl != ourUrl) {\r\n history.pushState(\r\n routeResult.urlSegments,\r\n '',\r\n '/' + routeResult.urlSegments.join('/')\r\n );\r\n }\r\n const e = new NavigateRouteEvent(\r\n routeResult.route,\r\n routeResult.urlSegments,\r\n routeResult.params,\r\n target\r\n );\r\n document.dispatchEvent(e);\r\n}\r\n\r\nfunction findRoute(routeNameOrUrl: string, options?: NavigateOptions) {\r\n const theRoutes = options?.routes ?? internalRoutes;\r\n const params = options?.params;\r\n\r\n const routeResult = matchRoute(theRoutes, routeNameOrUrl, params);\r\n if (!routeResult) {\r\n const errorMsg = generateErrorMessage(\r\n routeNameOrUrl,\r\n params,\r\n theRoutes\r\n );\r\n console.error(errorMsg);\r\n throw new RouteError(errorMsg);\r\n }\r\n\r\n if (!checkRouteGuards(routeResult)) {\r\n throw new RouteGuardError('Route guards stopped navigation for route ' + routeNameOrUrl);\r\n }\r\n\r\n return routeResult;\r\n}\r\n\r\nfunction navigateToLayout(routeResult: RouteMatchResult): boolean {\r\n if (!routeResult) {\r\n console.error('Route result is null, cannot navigate to layout.');\r\n }\r\n\r\n const wantedLayout = (routeResult.route.layout ?? 'default').replace(\r\n /\\.html?$/,\r\n ''\r\n );\r\n if (wantedLayout === getCurrentLayout()) {\r\n return false;\r\n }\r\n\r\n console.log(\r\n 'Current layout: ' + getCurrentLayout(),\r\n 'Wanted layout: ' + wantedLayout\r\n );\r\n\r\n // The hash means that we attempted to redirect to the same layout once,\r\n // so if it's there and another redirect is requsted, something is wrong.\r\n //\r\n // Because the push history should remove it if everything worked out.\r\n if (window.location.hash) {\r\n throw Error(\r\n 'A redirect failed, does the requsted layout exist? \"' +\r\n wantedLayout +\r\n '\"?'\r\n );\r\n }\r\n\r\n console.log(\r\n `requires layout switch from ${getCurrentLayout()} to ${wantedLayout}`\r\n );\r\n const navigationState = {\r\n routeName: routeResult.route.name,\r\n params: routeResult.params || {}\r\n };\r\n\r\n sessionStorage.setItem('layoutNavigation', JSON.stringify(navigationState));\r\n const layoutUrl =\r\n wantedLayout.indexOf('.htm') > -1\r\n ? `/${wantedLayout}#layout`\r\n : `/${wantedLayout}.html#layout`;\r\n console.log('redirecting to ', layoutUrl);\r\n window.location.href = layoutUrl;\r\n return true;\r\n}\r\n/**\r\n * Checks session storage for route information and initiates proper navigation\r\n * Should be called when page loads to handle layout transitions\r\n *\r\n * @returns Whether navigation was initiated from session storage\r\n *\r\n * @example\r\n * // Call on page load\r\n * document.addEventListener('DOMContentLoaded', () => {\r\n * if (handleLayoutNavigation()) {\r\n * console.log('Navigation handled from session storage');\r\n * }\r\n * });\r\n */\r\nfunction tryLoadRouteFromLayoutNavigation(): boolean {\r\n try {\r\n const navigationStateJson = sessionStorage.getItem('layoutNavigation');\r\n if (!navigationStateJson) {\r\n return false;\r\n }\r\n\r\n const navigationState = JSON.parse(navigationStateJson);\r\n sessionStorage.removeItem('layoutNavigation');\r\n console.log('session store navigation ', navigationState);\r\n navigate(navigationState.routeName, {\r\n params: navigationState.params\r\n });\r\n\r\n return true;\r\n } catch (error) {\r\n sessionStorage.removeItem('layoutNavigation');\r\n reportError('Failed to navigate from session storage', {\r\n cause: error,\r\n });\r\n return false;\r\n }\r\n}\r\n\r\nfunction generateErrorMessage(\r\n routeNameOrUrl: string,\r\n routeParams: Record<string, RouteParamType>,\r\n allRoutes: Route[]\r\n): string {\r\n var routeData = '';\r\n if (routeParams) {\r\n routeData += Object.entries(routeParams)\r\n .map(([key, value]) => `${key}=${value}`)\r\n .join(', ');\r\n } else {\r\n routeData = '.';\r\n }\r\n\r\n var routesStr = allRoutes.map(\r\n (x) =>\r\n ` * Name: '${x.name}', path: '${x.path}', target: ${\r\n x.target ?? 'default'\r\n }\\n`\r\n );\r\n return `No route matched '${routeNameOrUrl}${routeData}'. Available routes:\\n${routesStr}`;\r\n}\r\n\r\nfunction checkRouteGuards(routeResult: RouteMatchResult): boolean {\r\n if (\r\n !routeResult ||\r\n !routeResult.route.guards ||\r\n routeResult.route.guards.length == 0\r\n ) {\r\n return true;\r\n }\r\n\r\n for (let index = 0; index < routeResult.route.guards.length; index++) {\r\n const element = routeResult.route.guards[index];\r\n var result = element.check(routeResult);\r\n if (result == GuardResult.Allow) {\r\n return true;\r\n }\r\n\r\n if (result == GuardResult.Stop) {\r\n return false;\r\n }\r\n\r\n if (result == GuardResult.Deny) {\r\n throw new RouteGuardError(\r\n `Guard ${element.constructor.name} said 'Deny' for ${routeResult.route.name}`\r\n );\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n"],
|
|
5
|
+
"mappings": "AAGO,IAAKA,OAIRA,IAAA,iBAKAA,IAAA,eAKAA,IAAA,uBAKAA,IAAA,eAnBQA,OAAA,IAgICC,EAAN,cAAyB,KAAM,CAAC,EAC1BC,EAAN,cAA8BD,CAAW,CAAzC,kCACH,aAAU,GACd,ECjIO,IAAME,EAAN,MAAMC,UAA2B,KAAM,CAE1C,YAIWC,EAKAC,EAKAC,EAOAC,EAEPC,EACF,CACE,MAAML,EAAmB,KAAMK,CAAS,EArBjC,WAAAJ,EAKA,iBAAAC,EAKA,eAAAC,EAOA,iBAAAC,CAKX,CA3BA,YAAO,KAAe,oBA4B1B,ECDO,IAAME,EAAN,cAAyB,KAAM,CAClC,YACIC,EACOC,EACT,CACE,MAAMD,CAAO,EAFN,aAAAC,CAGX,CACJ,EAKIC,EAA+B,KAsC5B,SAASC,EAAYC,EAAiBC,EAAqD,CAC9F,IAAMC,EAAQ,IAAIC,EAAWH,EAASC,CAAO,EAC7C,GAAIG,EAAS,CACT,IAAIC,EAAa,GAKjB,GADAD,EAAQF,EAHkB,CACtB,UAAW,CAAEG,EAAa,EAAM,CACpC,CACkB,EACdA,EACA,O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a,OAAO,QAAQF,CAAW,EAClC,IAAI,CAAC,CAACvB,EAAKD,CAAK,IAAM,GAAGC,CAAG,IAAID,CAAK,EAAE,EACvC,KAAK,IAAI,EAEd0B,EAAY,IAGhB,IAAIC,EAAYF,EAAU,IACrBG,GACG,aAAaA,EAAE,IAAI,aAAaA,EAAE,IAAI,cAClCA,EAAE,QAAU,SAChB;AAAA,CACR,EACA,MAAO,qBAAqBtB,CAAc,GAAGoB,CAAS;AAAA,EAAyBC,CAAS,EAC5F,CAEA,SAASX,EAAiBnB,EAAwC,CAC9D,GACI,CAACA,GACD,CAACA,EAAY,MAAM,QACnBA,EAAY,MAAM,OAAO,QAAU,EAEnC,MAAO,GAGX,QAASgC,EAAQ,EAAGA,EAAQhC,EAAY,MAAM,OAAO,OAAQgC,IAAS,CAClE,IAAMC,EAAUjC,EAAY,MAAM,OAAOgC,CAAK,EAC9C,IAAIE,EAASD,EAAQ,MAAMjC,CAAW,EACtC,GAAIkC,GAAU,EACV,MAAO,GAGX,GAAIA,GAAU,EACV,MAAO,GAGX,GAAIA,GAAU,EACV,MAAM,IAAId,EACN,SAASa,EAAQ,YAAY,IAAI,oBAAoBjC,EAAY,MAAM,IAAI,EAC/E,CAER,CAEA,MAAO,EACX",
|
|
6
|
+
"names": ["GuardResult", "RouteError", "RouteGuardError", "NavigateRouteEvent", "_NavigateRouteEvent", "route", "urlSegments", "routeData", "routeTarget", "eventInit", "RelaxError", "message", "context", "handler", "reportError", "message", "context", "error", "RelaxError", "handler", "suppressed", "targetHandlers", "pendingEvents", "registerRouteTarget", "name", "handler", "initRouteTargetListener", "error", "reportError", "pending", "unregisterRouteTarget", "clearPendingNavigations", "dispatchToTarget", "evt", "listenerAttached", "NavigateRouteEvent", "NumberRouteSegment", "paramName", "value", "pathValue", "StringRouteSegment", "PathRouteSegment", "_pathValue", "RouteImp", "route", "segments", "generatedSegments", "params", "index", "urlSegment", "ourSegment", "routeData", "urlSegments", "routeParams", "d", "segment", "providedValue", "convertedValue", "matchRoute", "routes", "routeNameOrUrl", "findRouteByUrl", "findRouteByName", "name", "x", "imp", "generateRouteImp", "result", "path", "routeImps", "generateRouteImps", "m", "impSegments", "RouteLink", "name", "printRoutes", "params", "attr", "paramName", "paramsAttr", "additionalParams", "error", "err", "reportError", "target", "navigate", "RelaxError", "reported", "RouteTarget", "registerRouteTarget", "evt", "unregisterRouteTarget", "error", "RelaxError", "reportError", "tagName", "element", "data", "routeData", "currentLayout", "getCurrentLayout", "getLayout", "path", "internalRoutes", "printRoutes", "internalRoutes", "defineRoutes", "appRoutes", "initRouteTargetListener", "RouteTarget", "RouteLink", "errs", "route", "startRouting", "newPage", "getCurrentLayout", "match", "currentLayout", "tryLoadRouteFromLayoutNavigation", "currentUrl", "routeResult", "findRoute", "searchParams", "value", "key", "navigateToLayout", "e", "NavigateRouteEvent", "navigate", "routeNameOrUrl", "options", "target", "ourUrl", "theRoutes", "params", "matchRoute", "errorMsg", "generateErrorMessage", "RouteError", "checkRouteGuards", "RouteGuardError", "wantedLayout", "navigationState", "layoutUrl", "navigationStateJson", "error", "reportError", "routeParams", "allRoutes", "routeData", "routesStr", "x", "index", "element", "result"]
|
|
7
7
|
}
|
package/dist/routing/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
type WebComponentConstructor = new (...args: any[]) => HTMLElement;
|
|
2
3
|
export declare enum GuardResult {
|
|
3
4
|
/**
|
|
@@ -111,7 +112,7 @@ export interface RouteValue {
|
|
|
111
112
|
export declare class RouteError extends Error {
|
|
112
113
|
}
|
|
113
114
|
export declare class RouteGuardError extends RouteError {
|
|
114
|
-
isGuard:
|
|
115
|
+
isGuard: boolean;
|
|
115
116
|
}
|
|
116
117
|
export interface NavigateOptions {
|
|
117
118
|
/**
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ee=Object.create;var d=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var
|
|
1
|
+
var ee=Object.create;var d=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var S=e=>t=>{var r=e[t];if(r)return r();throw new Error("Module not found in bundle: "+t)};var c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),se=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},T=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of re(t))!oe.call(e,o)&&o!==r&&d(e,o,{get:()=>t[o],enumerable:!(n=te(t,o))||n.enumerable});return e};var l=(e,t,r)=>(r=e!=null?ee(ne(e)):{},T(t||!e||!e.__esModule?d(r,"default",{value:e,enumerable:!0}):r,e)),ie=e=>T(d({},"__esModule",{value:!0}),e);var I=c((Pe,le)=>{le.exports={greeting:"Hello, {name}!",items:"{count, plural, one {# item} other {# items}}"}});var M=c((Ae,ue)=>{ue.exports={today:"today",yesterday:"yesterday",daysAgo:"{count, plural, one {# day ago} other {# days ago}}",pieces:"{count, plural, =0 {none} one {one} other {# pcs}}"}});var R=c((Ie,pe)=>{pe.exports={required:"This field is required.",range:"Number must be between {min} and {max}, was {actual}.",digits:"Please enter only digits."}});var b=c((Me,ge)=>{ge.exports={greeting:"Hej, {name}!",items:"{count, plural, one {# sak} other {# saker}}"}});var D=c((Re,de)=>{de.exports={today:"idag",yesterday:"ig\xE5r",daysAgo:"{count, plural, one {# dag sedan} other {# dagar sedan}}",pieces:"{count, plural, =0 {inga} one {en} other {# st}}"}});var B=c((be,fe)=>{fe.exports={required:"Detta f\xE4lt \xE4r obligatoriskt.",range:"Talet m\xE5ste vara mellan {min} och {max}, var {actual}.",digits:"Ange endast siffror."}});var Ee={};se(Ee,{RelaxError:()=>p,applyPipes:()=>xe,capitalizePipe:()=>_,createPipeRegistry:()=>Z,currencyPipe:()=>H,datePipe:()=>F,daysAgoPipe:()=>U,defaultPipe:()=>z,defaultPipes:()=>G,firstPipe:()=>v,generateSequentialId:()=>Q,joinPipe:()=>O,keysPipe:()=>q,lastPipe:()=>X,lowercasePipe:()=>N,onError:()=>W,piecesPipe:()=>j,reportError:()=>Y,resolveValue:()=>he,shortenPipe:()=>L,ternaryPipe:()=>V,trimPipe:()=>k,uppercasePipe:()=>$});module.exports=ie(Ee);var y=new Map;function ae(e){return y.has(e)||y.set(e,new Intl.PluralRules(e)),y.get(e)}function P(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,r="en"){return e.replace(/\{(\w+)(?:, (plural|select),((?:[^{}]*\{[^{}]*\})+))?\}/g,(n,o,i,a)=>{let s=t[o];if(i==="plural"){let g=new RegExp(`=${P(String(s))}\\s*\\{([^{}]*)\\}`).exec(a);if(g)return g[1].replace(`{${o}}`,String(s)).replace("#",String(s));let K=ae(r).select(s),E=new RegExp(`${K}\\s*\\{([^{}]*)\\}`).exec(a)||new RegExp("other\\s*\\{([^{}]*)\\}").exec(a);return E?E[1].replace(`{${o}}`,String(s)).replace("#",String(s)):String(s)}if(i==="select"){let g=P(String(s)),m=new RegExp(`\\b${g}\\s*\\{([^{}]*)\\}`).exec(a)||new RegExp("\\bother\\s*\\{([^{}]*)\\}").exec(a);return m?m[1]:String(s)}return s!==void 0?String(s):`{${o}}`})}var A=ce;var Ce=S({"./locales/en/r-common.json":()=>Promise.resolve().then(()=>l(I())),"./locales/en/r-pipes.json":()=>Promise.resolve().then(()=>l(M())),"./locales/en/r-validation.json":()=>Promise.resolve().then(()=>l(R())),"./locales/sv/r-common.json":()=>Promise.resolve().then(()=>l(b())),"./locales/sv/r-pipes.json":()=>Promise.resolve().then(()=>l(D())),"./locales/sv/r-validation.json":()=>Promise.resolve().then(()=>l(B()))});var me="en",x=me;var ye={},C=null;function u(e,t){let[r,n]=e.includes(":")?e.split(":"):["r-common",e],o=ye[r]?.[n];if(!o)return C&&C(n,r,x),e;try{return A(o,t,x)}catch{return e}}function h(){return x}function $(e){return String(e).toUpperCase()}function k(e){return String(e).trimEnd().trimStart()}function N(e){return String(e).toLowerCase()}function _(e){let t=String(e);return t.charAt(0).toUpperCase()+t.slice(1)}function L(e,t){let r=String(e),n=parseInt(t,10);return r.length>n?r.substring(0,n-3)+"...":r}function H(e,t="USD"){let r=h();return new Intl.NumberFormat(r,{style:"currency",currency:t}).format(e)}function F(e,t){let r=new Date(e),n=h();return t==="short"?r.toLocaleDateString(n):t==="long"?r.toLocaleDateString(n,{weekday:"long",year:"numeric",month:"long",day:"numeric"}):r.toISOString()}function U(e){if(!e)return"n/a";let t=new Date(e),r=new Date;t.setHours(0,0,0,0),r.setHours(0,0,0,0);let n=r.getTime()-t.getTime(),o=Math.round(n/(1e3*60*60*24));return o===0?u("r-pipes:today"):o===1?u("r-pipes:yesterday"):u("r-pipes:daysAgo",{count:o})}function j(e){if(e==null)return"n/a";let t=Number(e);return u("r-pipes:pieces",{count:t})}function O(e,t=","){return Array.isArray(e)?e.join(t):e}function v(e){return!Array.isArray(e)||e.length===0?"":e[0]}function X(e){return!Array.isArray(e)||e.length===0?"":e[e.length-1]}function q(e){return typeof e!="object"||e===null?[]:Object.keys(e)}function z(e,t){return e||t}function V(e,t,r){return e?t:r}function Z(){let e=new Map;return e.set("uppercase",$),e.set("lowercase",N),e.set("capitalize",_),e.set("trim",k),e.set("shorten",L),e.set("currency",H),e.set("date",F),e.set("daysAgo",U),e.set("pieces",j),e.set("join",O),e.set("first",v),e.set("last",X),e.set("keys",q),e.set("default",z),e.set("ternary",V),{lookup(t){return e.get(t)},get(t){var r=e.get(t);if(!r)throw Error("Pipe '"+t+"' not found.");return r},has(t){return e.has(t)}}}var G=Z();function xe(e,t,r=G){return t.reduce((n,o)=>{let[i,...a]=o.split(":").map(s=>s.trim());if(!r.has(i))return`[Pipe ${i} not found]`;try{return r.get(i)(n,...a)}catch(s){return`[Pipe ${i}, value: ${e}, error: ${s}]`}},e)}function he(e,t){let r=t;for(let n of e){if(r==null)return;r=r[n]}return r??void 0}var we=Math.floor(new Date("2025-01-01T00:00:00Z").getTime()/1e3),J=0,f=0;function Q(e){if(e<0||e>1048575)throw new Error("baseId must be between 0 and 1048575");let t=Math.floor(Date.now()/1e3);if(t===J){if(f++,f>255)throw new Error("Too many IDs generated in one second")}else J=t,f=0;let r=t-we;if(r>1073741823)throw new Error("Timestamp exceeds allowed range (beyond 2045-01-01)");let n=BigInt(r),o=BigInt(f),i=BigInt(e);return(n<<BigInt(28)|o<<BigInt(20)|i).toString(36).toLowerCase()}var p=class extends Error{constructor(r,n){super(r);this.context=n}},w=null;function W(e){w=e}function Y(e,t){let r=new p(e,t);if(w){let n=!1;if(w(r,{suppress(){n=!0}}),n)return null}return r}
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/i18n/locales/en/r-common.json", "../../src/i18n/locales/en/r-pipes.json", "../../src/i18n/locales/en/r-validation.json", "../../src/i18n/locales/sv/r-common.json", "../../src/i18n/locales/sv/r-pipes.json", "../../src/i18n/locales/sv/r-validation.json", "../../src/utils/index.ts", "../../src/i18n/icu.ts", "../../src/i18n/i18n.ts", "../../src/pipes.ts", "../../src/tools.ts", "../../src/SequentialId.ts", "../../src/errors.ts"],
|
|
4
|
-
"sourcesContent": ["{\r\n \"greeting\": \"Hello, {name}!\",\r\n \"items\": \"{count, plural, one {# item} other {# items}}\"\r\n}\r\n", "{\r\n \"today\": \"today\",\r\n \"yesterday\": \"yesterday\",\r\n \"daysAgo\": \"{count, plural, one {# day ago} other {# days ago}}\",\r\n \"pieces\": \"{count, plural, =0 {none} one {one} other {# pcs}}\"\r\n}\r\n", "{\r\n \"required\": \"This field is required.\",\r\n \"range\": \"Number must be between {min} and {max}, was {actual}.\",\r\n \"digits\": \"Please enter only digits.\"\r\n}\r\n", "{\r\n \"greeting\": \"Hej, {name}!\",\r\n \"items\": \"{count, plural, one {# sak} other {# saker}}\"\r\n}\r\n", "{\r\n \"today\": \"idag\",\r\n \"yesterday\": \"ig\u00E5r\",\r\n \"daysAgo\": \"{count, plural, one {# dag sedan} other {# dagar sedan}}\",\r\n \"pieces\": \"{count, plural, =0 {inga} one {en} other {# st}}\"\r\n}\r\n", "{\r\n \"required\": \"Detta f\u00E4lt \u00E4r obligatoriskt.\",\r\n \"range\": \"Talet m\u00E5ste vara mellan {min} och {max}, var {actual}.\",\r\n \"digits\": \"Ange endast siffror.\"\r\n}\r\n", "export * from '../pipes';\r\nexport * from '../tools';\r\nexport { generateSequentialId } from '../SequentialId';\r\nexport { onError, reportError, RelaxError } from '../errors';\r\n", "/**\r\n * @module icu\r\n * ICU message format support for internationalization.\r\n * Provides pluralization, select, and value interpolation.\r\n *\r\n * @example\r\n * // Simple interpolation\r\n * formatICU('Hello, {name}!', { name: 'World' });\r\n * // Returns: 'Hello, World!'\r\n *\r\n * @example\r\n * // Pluralization\r\n * formatICU('{count, plural, one {# item} other {# items}}', { count: 5 });\r\n * // Returns: '5 items'\r\n *\r\n * @example\r\n * // Select\r\n * formatICU('{gender, select, male {He} female {She} other {They}}', { gender: 'female' });\r\n * // Returns: 'She'\r\n */\r\n\r\nconst pluralRulesCache = new Map<string, Intl.PluralRules>();\r\n\r\n/**\r\n * Function type for message formatters.\r\n * Implement this to provide custom message formatting.\r\n */\r\nexport type MessageFormatter = (\r\n message: string,\r\n values?: Record<string, any>,\r\n locale?: string\r\n) => string;\r\n\r\n\r\nfunction getPluralRule(locale: string): Intl.PluralRules {\r\n if (!pluralRulesCache.has(locale)) {\r\n pluralRulesCache.set(locale, new Intl.PluralRules(locale));\r\n }\r\n return pluralRulesCache.get(locale)!;\r\n}\r\n\r\nfunction escapeRegex(s: string): string {\r\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\r\n}\r\n\r\n/**\r\n * Default ICU message formatter implementation.\r\n * Supports simple interpolation, pluralization with exact matches, and select.\r\n *\r\n * @param message - ICU format message string\r\n * @param values - Values to interpolate\r\n * @param locale - Locale for plural rules (default: 'en')\r\n * @returns Formatted message string\r\n *\r\n * @example\r\n * defaultFormatICU('{n, plural, =0 {none} one {# item} other {# items}}', { n: 0 }, 'en');\r\n * // Returns: 'none'\r\n *\r\n * @example\r\n * defaultFormatICU('{role, select, admin {Full access} other {Limited access}}', { role: 'admin' });\r\n * // Returns: 'Full access'\r\n */\r\nexport function defaultFormatICU(\r\n message: string,\r\n values: Record<string, any>,\r\n locale: string = 'en'\r\n): string {\r\n return message.replace(\r\n /\\{(\\w+)(?:, (plural|select),((?:[^{}]*\\{[^{}]*\\})+))?\\}/g,\r\n (_, key, type, categoriesPart) => {\r\n const value = values[key];\r\n\r\n if (type === 'plural') {\r\n const exact = new RegExp(\r\n `=${escapeRegex(String(value))}\\\\s*\\\\{([^{}]*)\\\\}`\r\n ).exec(categoriesPart);\r\n if (exact) {\r\n return exact[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n\r\n const rules = getPluralRule(locale);\r\n const category = rules.select(value);\r\n const match =\r\n new RegExp(`${category}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`other\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n if (match) {\r\n return match[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n return String(value);\r\n }\r\n\r\n if (type === 'select') {\r\n const escaped = escapeRegex(String(value));\r\n const match =\r\n new RegExp(`\\\\b${escaped}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`\\\\bother\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n return match ? match[1] : String(value);\r\n }\r\n\r\n return value !== undefined ? String(value) : `{${key}}`;\r\n },\r\n );\r\n}\r\n\r\n/**\r\n * The active message formatter. Defaults to `defaultFormatICU`.\r\n * Can be replaced with `setMessageFormatter` for custom formatting.\r\n */\r\nexport let formatICU: MessageFormatter = defaultFormatICU;\r\n\r\n/**\r\n * Replaces the default message formatter with a custom implementation.\r\n * Use this to integrate with external i18n libraries like FormatJS.\r\n *\r\n * @param formatter - The custom formatter function\r\n *\r\n * @example\r\n * // Use FormatJS IntlMessageFormat\r\n * import { IntlMessageFormat } from 'intl-messageformat';\r\n *\r\n * setMessageFormatter((message, values, locale) => {\r\n * const fmt = new IntlMessageFormat(message, locale);\r\n * return fmt.format(values);\r\n * });\r\n */\r\nexport function setMessageFormatter(formatter: MessageFormatter) {\r\n formatICU = formatter;\r\n}", "/**\r\n * @module i18n\r\n * Internationalization support with namespace-based translations.\r\n * Uses ICU message format for pluralization, select, and formatting.\r\n *\r\n * @example\r\n * // Initialize locale\r\n * await setLocale('sv');\r\n *\r\n * // Use translations\r\n * const greeting = t('r-common:greeting', { name: 'John' });\r\n * const items = t('shop:items', { count: 5 });\r\n */\r\n\r\nimport { formatICU } from './icu';\r\n\r\ntype Locale = string;\r\ntype Namespace = string;\r\ntype TranslationMap = Record<string, string>;\r\ntype Translations = Record<Namespace, TranslationMap>;\r\n\r\nexport type MissingTranslationHandler = (\r\n key: string,\r\n namespace: string,\r\n locale: string,\r\n) => void;\r\n\r\n/**\r\n * Dispatched on `document` after `setLocale()` completes.\r\n * The `locale` property contains the new normalized locale code.\r\n *\r\n * @example\r\n * document.addEventListener('localechange', (e) => {\r\n * console.log(`Locale changed to ${e.locale}`);\r\n * this.render();\r\n * });\r\n */\r\nexport class LocaleChangeEvent extends Event {\r\n readonly locale: string;\r\n constructor(locale: string) {\r\n super('localechange', { bubbles: false });\r\n this.locale = locale;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface DocumentEventMap {\r\n localechange: LocaleChangeEvent;\r\n }\r\n}\r\n\r\nconst fallbackLocale: Locale = 'en';\r\nlet currentLocale: Locale = fallbackLocale;\r\nconst loadedNamespaces = new Set<Namespace>();\r\nconst translations: Translations = {};\r\nlet missingHandler: MissingTranslationHandler | null = null;\r\n\r\nfunction normalizeLocale(locale: string): string {\r\n return locale.toLowerCase().split('-')[0];\r\n}\r\n\r\n/**\r\n * Sets the current locale and loads the common namespace.\r\n * Clears previously loaded translations and dispatches a `localechange` event.\r\n *\r\n * @param locale - The locale code (e.g., 'en', 'sv', 'en-US')\r\n *\r\n * @example\r\n * await setLocale('sv');\r\n */\r\nexport async function setLocale(locale: string): Promise<void> {\r\n const normalized = normalizeLocale(locale);\r\n currentLocale = normalized;\r\n loadedNamespaces.clear();\r\n Object.keys(translations).forEach(ns => delete translations[ns]);\r\n await loadNamespace('r-common');\r\n if (typeof document !== 'undefined') {\r\n document.dispatchEvent(new LocaleChangeEvent(normalized));\r\n }\r\n}\r\n\r\n/**\r\n * Loads a translation namespace on demand.\r\n * Falls back to the default locale if translations are not found.\r\n *\r\n * @param namespace - The namespace to load (e.g., 'shop', 'errors')\r\n *\r\n * @example\r\n * await loadNamespace('shop');\r\n * const price = t('shop:priceLabel');\r\n */\r\nexport async function loadNamespace(namespace: Namespace): Promise<void> {\r\n if (loadedNamespaces.has(namespace)) return;\r\n\r\n try {\r\n const module = await import(`./locales/${currentLocale}/${namespace}.json`);\r\n translations[namespace] = module.default;\r\n loadedNamespaces.add(namespace);\r\n } catch (err) {\r\n if (currentLocale !== fallbackLocale) {\r\n const fallback = await import(`./locales/${fallbackLocale}/${namespace}.json`);\r\n translations[namespace] = fallback.default;\r\n loadedNamespaces.add(namespace);\r\n } else {\r\n console.warn(`i18n: Failed to load namespace '${namespace}' for locale '${currentLocale}'`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Loads multiple translation namespaces in parallel.\r\n *\r\n * @param namespaces - Array of namespace names to load\r\n *\r\n * @example\r\n * await loadNamespaces(['r-pipes', 'r-validation']);\r\n */\r\nexport async function loadNamespaces(namespaces: Namespace[]): Promise<void> {\r\n await Promise.all(namespaces.map(ns => loadNamespace(ns)));\r\n}\r\n\r\n/**\r\n * Translates a key with optional value interpolation.\r\n * Supports ICU message format for pluralization and select.\r\n *\r\n * @param fullKey - Translation key in format 'namespace:key' or just 'key' (uses 'r-common')\r\n * @param values - Values to interpolate into the message\r\n * @returns The translated string, or the key if not found\r\n *\r\n * @example\r\n * // Simple translation\r\n * t('greeting'); // Uses r-common:greeting\r\n *\r\n * // With namespace\r\n * t('errors:notFound');\r\n *\r\n * // With interpolation\r\n * t('welcome', { name: 'John' }); // \"Welcome, John!\"\r\n *\r\n * // With pluralization (ICU format)\r\n * t('items', { count: 5 }); // \"5 items\" or \"5 f\u00F6rem\u00E5l\"\r\n */\r\nexport function t(fullKey: string, values?: Record<string, any>): string {\r\n const [namespace, key] = fullKey.includes(':')\r\n ? fullKey.split(':')\r\n : ['r-common', fullKey];\r\n const message = translations[namespace]?.[key];\r\n if (!message) {\r\n if (missingHandler) missingHandler(key, namespace, currentLocale);\r\n return fullKey;\r\n }\r\n try {\r\n return formatICU(message, values, currentLocale) as string;\r\n } catch {\r\n return fullKey;\r\n }\r\n}\r\n\r\n/**\r\n * Returns the current locale code.\r\n *\r\n * @returns The normalized locale code (e.g., 'en', 'sv')\r\n */\r\nexport function getCurrentLocale(): string {\r\n return currentLocale;\r\n}\r\n\r\n/**\r\n * Registers a handler called when `t()` encounters a missing translation key.\r\n * Pass `null` to remove the handler.\r\n *\r\n * @param handler - Callback receiving the key, namespace, and locale\r\n *\r\n * @example\r\n * onMissingTranslation((key, ns, locale) => {\r\n * console.warn(`Missing: ${ns}:${key} [${locale}]`);\r\n * });\r\n */\r\nexport function onMissingTranslation(handler: MissingTranslationHandler | null): void {\r\n missingHandler = handler;\r\n}\r\n", "/**\r\n * @module pipes\r\n * Data transformation functions (pipes) for use in template expressions.\r\n * Pipes transform values for display, like formatting dates, currencies, or text.\r\n *\r\n * Locale-aware pipes (currency, date, daysAgo, pieces) use the i18n system\r\n * for formatting and translations. Call `setLocale()` before using these pipes.\r\n *\r\n * Pipes can be chained in templates: `{{value | uppercase | shorten:20}}`\r\n *\r\n * @example\r\n * // In templates\r\n * <span>{{user.name | uppercase}}</span>\r\n * <span>{{price | currency}}</span>\r\n * <span>{{createdAt | daysAgo}}</span>\r\n *\r\n * @example\r\n * // Programmatic usage\r\n * import { applyPipes, defaultPipes } from 'relaxjs';\r\n * const result = applyPipes('hello world', ['uppercase', 'shorten:8']);\r\n * // Returns: 'HELLO...'\r\n */\r\n\r\nimport { getCurrentLocale, t } from './i18n/i18n';\r\n\r\n/**\r\n * Type definition for pipe transformation functions.\r\n * Pipes take a value and optional arguments, returning a transformed value.\r\n *\r\n * @example\r\n * // Define a custom pipe\r\n * const reversePipe: PipeFunction = (value: string) => {\r\n * return value.split('').reverse().join('');\r\n * };\r\n */\r\nexport type PipeFunction = (value: any, ...args: any[]) => any;\r\n\r\n\r\n// =============================== Text manipulation pipes ===========================\r\n\r\n\r\n\r\n/**\r\n * Converts a string to uppercase\r\n * @param value The string to convert\r\n * @returns The uppercase string\r\n */\r\nexport function uppercasePipe(value: string): string {\r\n return String(value).toUpperCase();\r\n}\r\n\r\n/**\r\n * Converts a string to uppercase\r\n * @param value The string to convert\r\n * @returns The uppercase string\r\n */\r\nexport function trimPipe(value: string): string {\r\n return String(value).trimEnd().trimStart();\r\n}\r\n\r\n\r\n/**\r\n * Converts a string to lowercase\r\n * @param value The string to convert\r\n * @returns The lowercase string\r\n */\r\nexport function lowercasePipe(value: string): string {\r\n return String(value).toLowerCase();\r\n}\r\n\r\n/**\r\n * Capitalizes the first character of a string\r\n * @param value The string to capitalize\r\n * @returns The capitalized string\r\n */\r\nexport function capitalizePipe(value: string): string {\r\n const str = String(value);\r\n return str.charAt(0).toUpperCase() + str.slice(1);\r\n}\r\n\r\n/**\r\n * Shortens a string to a specified length and adds ellipsis.\r\n * @param value The string to shorten\r\n * @param length Maximum length including ellipsis\r\n * @returns The shortened string with ellipsis if needed\r\n */\r\nexport function shortenPipe(value: string, length: string): string {\r\n const str = String(value);\r\n const maxLength = parseInt(length, 10);\r\n return str.length > maxLength\r\n ? str.substring(0, maxLength - 3) + '...'\r\n : str;\r\n}\r\n\r\n// Formatting pipes\r\n/**\r\n * Formats a number as currency using the current locale.\r\n * Uses the i18n system's current locale for formatting.\r\n *\r\n * @param value The number to format\r\n * @param currency Currency code (defaults to USD)\r\n * @returns Formatted currency string\r\n *\r\n * @example\r\n * // In template: {{price | currency}} or {{price | currency:EUR}}\r\n * currencyPipe(1234.56); // \"$1,234.56\" (en) or \"1 234,56 $\" (sv)\r\n * currencyPipe(1234.56, 'SEK'); // \"SEK 1,234.56\" (en) or \"1 234,56 kr\" (sv)\r\n */\r\nexport function currencyPipe(value: number, currency: string = 'USD'): string {\r\n const locale = getCurrentLocale();\r\n return new Intl.NumberFormat(locale, {\r\n style: 'currency',\r\n currency\r\n }).format(value);\r\n}\r\n\r\n/**\r\n * Formats a date value according to the specified format.\r\n * Uses the i18n system's current locale for formatting.\r\n *\r\n * @param value Date value (string, number, or Date object)\r\n * @param format Format type: 'short', 'long', or default (ISO)\r\n * @returns Formatted date string\r\n *\r\n * @example\r\n * // In template: {{date | date:short}} or {{date | date:long}}\r\n * datePipe(new Date(), 'short'); // \"1/15/2024\" (en) or \"2024-01-15\" (sv)\r\n * datePipe(new Date(), 'long'); // \"Monday, January 15, 2024\" (en) or \"m\u00E5ndag 15 januari 2024\" (sv)\r\n */\r\nexport function datePipe(value: string | number | Date, format?: string): string {\r\n const date = new Date(value);\r\n const locale = getCurrentLocale();\r\n if (format === 'short') {\r\n return date.toLocaleDateString(locale);\r\n } else if (format === 'long') {\r\n return date.toLocaleDateString(locale, {\r\n weekday: 'long',\r\n year: 'numeric',\r\n month: 'long',\r\n day: 'numeric'\r\n });\r\n }\r\n return date.toISOString();\r\n}\r\n\r\n/**\r\n * Prints today, yesterday or X days ago.\r\n * Uses the i18n system for translations (requires pipes namespace loaded).\r\n *\r\n * @param value Date value (string, number, or Date object)\r\n * @returns Formatted relative date string\r\n *\r\n * @example\r\n * // In template: {{createdAt | daysAgo}}\r\n * // English: \"today\", \"yesterday\", \"3 days ago\"\r\n * // Swedish: \"idag\", \"ig\u00E5r\", \"3 dagar sedan\"\r\n */\r\nexport function daysAgoPipe(value: string | number | Date): string {\r\n if (!value) {\r\n return 'n/a';\r\n }\r\n\r\n const inputDate = new Date(value);\r\n const today = new Date();\r\n\r\n // Normalize times to midnight to compare only dates\r\n inputDate.setHours(0, 0, 0, 0);\r\n today.setHours(0, 0, 0, 0);\r\n\r\n const diffTime = today.getTime() - inputDate.getTime();\r\n const diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));\r\n\r\n if (diffDays === 0) return t('r-pipes:today');\r\n if (diffDays === 1) return t('r-pipes:yesterday');\r\n return t('r-pipes:daysAgo', { count: diffDays });\r\n}\r\n\r\n/**\r\n * Formats a count as pieces/items.\r\n * Uses the i18n system for translations (requires pipes namespace loaded).\r\n *\r\n * @param value Count value\r\n * @returns Formatted piece count string\r\n *\r\n * @example\r\n * // In template: {{quantity | pieces}}\r\n * // English: \"none\", \"one\", \"3 pcs\"\r\n * // Swedish: \"inga\", \"en\", \"3 st\"\r\n */\r\nexport function piecesPipe(value: string | number): string {\r\n if (value === null || value === undefined) {\r\n return 'n/a';\r\n }\r\n\r\n const count = Number(value);\r\n return t('r-pipes:pieces', { count });\r\n}\r\n\r\n\r\n\r\n// =============================== Array operation pipes ===========================\r\n\r\n\r\n\r\n/**\r\n * Joins array elements with the specified separator\r\n * @param value Array to join\r\n * @param separator Character(s) to use between elements (defaults to comma)\r\n * @returns Joined string or original value if not an array\r\n */\r\nexport function joinPipe(value: any[], separator: string = ','): string | any {\r\n if (!Array.isArray(value)) return value;\r\n return value.join(separator);\r\n}\r\n\r\n/**\r\n * Returns the first element of an array\r\n * @param value Array to extract from\r\n * @returns First element or empty string if array is empty/invalid\r\n */\r\nexport function firstPipe(value: any[]): any {\r\n if (!Array.isArray(value) || value.length === 0) return '';\r\n return value[0];\r\n}\r\n\r\n/**\r\n * Returns the last element of an array\r\n * @param value Array to extract from\r\n * @returns Last element or empty string if array is empty/invalid\r\n */\r\nexport function lastPipe(value: any[]): any {\r\n if (!Array.isArray(value) || value.length === 0) return '';\r\n return value[value.length - 1];\r\n}\r\n\r\n// Object operation pipes\r\n/**\r\n * Returns the keys of an object\r\n * @param value Object to extract keys from\r\n * @returns Array of object keys or empty array if not an object\r\n */\r\nexport function keysPipe(value: object): string[] {\r\n if (typeof value !== 'object' || value === null) return [];\r\n return Object.keys(value);\r\n}\r\n\r\n// Conditional pipes\r\n/**\r\n * Returns a default value if the input is falsy\r\n * @param value Input value to check\r\n * @param defaultValue Value to return if input is falsy\r\n * @returns Original value or default value\r\n */\r\nexport function defaultPipe(value: any, defaultValue: string): any {\r\n return value || defaultValue;\r\n}\r\n\r\n/**\r\n * Implements ternary operator as a pipe\r\n * @param value Condition to evaluate\r\n * @param trueValue Value to return if condition is truthy\r\n * @param falseValue Value to return if condition is falsy\r\n * @returns Selected value based on condition\r\n */\r\nexport function ternaryPipe(value: any, trueValue: string, falseValue: string): string {\r\n return value ? trueValue : falseValue;\r\n}\r\n\r\n\r\n\r\n// =============================== Pipe registry and application ===========================\r\n\r\n\r\n/**\r\n * Interface for a collection of pipe functions.\r\n * Use this to look up pipes by name for template processing.\r\n *\r\n * @example\r\n * // Check if a pipe exists before using\r\n * if (registry.has('currency')) {\r\n * const formatted = registry.get('currency')(price);\r\n * }\r\n */\r\nexport interface PipeRegistry {\r\n /**\r\n * Looks up a pipe by name, returning null if not found.\r\n */\r\n lookup(name: string): PipeFunction | null;\r\n\r\n /**\r\n * Gets a pipe by name, throwing if not found.\r\n */\r\n get(name: string): PipeFunction;\r\n\r\n /**\r\n * Checks if a pipe with the given name exists.\r\n */\r\n has(name: string): boolean;\r\n}\r\n\r\n\r\n/**\r\n * Creates a new pipe registry with all built-in pipes registered.\r\n * Built-in pipes include:\r\n *\r\n * **Text:** uppercase, lowercase, capitalize, trim, shorten\r\n * **Formatting:** currency, date, daysAgo, pieces\r\n * **Arrays:** join, first, last\r\n * **Objects:** keys\r\n * **Conditionals:** default, ternary\r\n *\r\n * @returns A new pipe registry instance\r\n *\r\n * @example\r\n * const registry = createPipeRegistry();\r\n * const upperPipe = registry.get('uppercase');\r\n * console.log(upperPipe('hello')); // 'HELLO'\r\n */\r\nexport function createPipeRegistry(): PipeRegistry {\r\n const pipes = new Map<string, PipeFunction>();\r\n\r\n // Text manipulation\r\n pipes.set('uppercase', uppercasePipe);\r\n pipes.set('lowercase', lowercasePipe);\r\n pipes.set('capitalize', capitalizePipe);\r\n pipes.set('trim', trimPipe);\r\n pipes.set('shorten', shortenPipe);\r\n\r\n // Formatting\r\n pipes.set('currency', currencyPipe);\r\n pipes.set('date', datePipe);\r\n pipes.set('daysAgo', daysAgoPipe);\r\n pipes.set('pieces', piecesPipe);\r\n\r\n // Array operations\r\n pipes.set('join', joinPipe);\r\n pipes.set('first', firstPipe);\r\n pipes.set('last', lastPipe);\r\n\r\n // Object operations\r\n pipes.set('keys', keysPipe);\r\n\r\n // Conditional formatting\r\n pipes.set('default', defaultPipe);\r\n pipes.set('ternary', ternaryPipe);\r\n\r\n return {\r\n lookup(name) {\r\n return pipes.get(name);\r\n },\r\n get(name) {\r\n var pipe = pipes.get(name);\r\n if (!pipe) {\r\n throw Error(\"Pipe '\" + name + \"' not found.\");\r\n }\r\n return pipe;\r\n },\r\n has(name) {\r\n return pipes.has(name);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Default pipe registry instance with all built-in pipes.\r\n * Used by template engines unless a custom registry is provided.\r\n *\r\n * @example\r\n * import { defaultPipes } from 'relaxjs';\r\n *\r\n * if (defaultPipes.has('uppercase')) {\r\n * const result = defaultPipes.get('uppercase')('hello');\r\n * }\r\n */\r\nexport const defaultPipes = createPipeRegistry();\r\n\r\n/**\r\n * Applies a series of pipes to a value sequentially.\r\n * Each pipe transforms the output of the previous pipe.\r\n *\r\n * Pipe arguments are specified after a colon: `shorten:20`\r\n *\r\n * @param value - Initial value to transform\r\n * @param pipes - Array of pipe strings (name and optional arguments separated by ':')\r\n * @param registry - Optional custom pipe registry (uses defaultPipes if not provided)\r\n * @returns The transformed value after applying all pipes\r\n *\r\n * @example\r\n * // Apply single pipe\r\n * applyPipes('hello', ['uppercase']); // 'HELLO'\r\n *\r\n * @example\r\n * // Chain multiple pipes\r\n * applyPipes('hello world', ['uppercase', 'shorten:8']); // 'HELLO...'\r\n *\r\n * @example\r\n * // With pipe arguments\r\n * applyPipes(1234.56, ['currency']); // '$1,234.56'\r\n */\r\nexport function applyPipes(\r\n value: any,\r\n pipes: string[],\r\n registry: PipeRegistry = defaultPipes\r\n): any {\r\n\r\n return pipes.reduce((currentValue, pipe) => {\r\n const [pipeName, ...args] = pipe.split(':').map((p) => p.trim());\r\n\r\n if (!registry.has(pipeName)) {\r\n return `[Pipe ${pipeName} not found]`;\r\n }\r\n\r\n try {\r\n return registry.get(pipeName)(currentValue, ...args);\r\n } catch (error) {\r\n return `[Pipe ${pipeName}, value: ${value}, error: ${error}]`;\r\n }\r\n }, value);\r\n}", "/**\r\n * Resolves a deeply nested value from an object using a path array.\r\n * Safely navigates through the object tree, returning undefined if any\r\n * segment in the path is null or undefined.\r\n *\r\n * Used internally by template engines to access data properties,\r\n * but also useful for general-purpose deep property access.\r\n *\r\n * @param path - Array of property names forming the path to the value\r\n * @param context - The object to resolve the value from\r\n * @returns The resolved value, or undefined if path cannot be resolved\r\n *\r\n * @example\r\n * // Access nested property\r\n * const user = { address: { city: 'Stockholm' } };\r\n * const city = resolveValue(['address', 'city'], user);\r\n * // Returns: 'Stockholm'\r\n *\r\n * @example\r\n * // Safe access with missing properties\r\n * const data = { user: null };\r\n * const name = resolveValue(['user', 'name'], data);\r\n * // Returns: undefined (doesn't throw)\r\n *\r\n * @example\r\n * // Use with template expression paths\r\n * const path = 'user.profile.avatar'.split('.');\r\n * const avatar = resolveValue(path, context);\r\n */\r\nexport function resolveValue(\r\n path: string[],\r\n context: Record<string, any>\r\n): any | undefined {\r\n let value = context;\r\n\r\n for (const key of path) {\r\n if (value === undefined || value === null) {\r\n return undefined;\r\n }\r\n\r\n value = value[key];\r\n }\r\n\r\n return value !== undefined && value !== null ? value : undefined;\r\n}\r\n ", "/**\r\n * @module SequentialId\r\n * Generates compact, time-ordered unique identifiers suitable for distributed systems.\r\n *\r\n * IDs are structured to be:\r\n * - Unique across multiple clients (via baseId)\r\n * - Time-sortable (timestamp is the most significant bits)\r\n * - Compact (Base36 encoding produces short strings)\r\n *\r\n * Bit allocation (58 bits total):\r\n * - 30 bits for timestamp (seconds since January 1, 2025)\r\n * - 8 bits for per-second counter (supports 256 IDs/second)\r\n * - 20 bits for client/endpoint identifier (supports ~1M unique sources)\r\n */\r\n\r\nconst TIMESTAMP_BITS = 30;\r\nconst COUNTER_BITS = 8;\r\nconst BASEID_BITS = 20;\r\n\r\nconst MAX_TIMESTAMP = (1 << TIMESTAMP_BITS) - 1;\r\nconst MAX_COUNTER = (1 << COUNTER_BITS) - 1;\r\nconst MAX_BASEID = (1 << BASEID_BITS) - 1;\r\n\r\nconst EPOCH = Math.floor(new Date('2025-01-01T00:00:00Z').getTime() / 1000);\r\n\r\nlet lastTimestamp = 0;\r\nlet counter = 0;\r\n\r\n/**\r\n * Generates a unique, time-ordered sequential ID.\r\n *\r\n * The ID combines a timestamp, per-second counter, and client identifier\r\n * into a compact Base36 string. IDs generated later will sort after earlier IDs,\r\n * making them suitable for ordered collections.\r\n *\r\n * @param baseId - Unique identifier for the client/endpoint (0 to 1,048,575).\r\n * Use different baseIds for different servers or processes to\r\n * avoid collisions.\r\n * @returns Base36 encoded string representing the unique ID\r\n * @throws Error if baseId is out of valid range\r\n * @throws Error if more than 256 IDs are generated in a single second\r\n * @throws Error if timestamp exceeds range (after year 2045)\r\n *\r\n * @example\r\n * // Generate ID for server instance 1\r\n * const id1 = generateSequentialId(1);\r\n * // Returns something like: 'k2j8m3n5p'\r\n *\r\n * @example\r\n * // Different servers use different baseIds\r\n * const SERVER_ID = parseInt(process.env.SERVER_ID || '0');\r\n * const orderId = generateSequentialId(SERVER_ID);\r\n *\r\n * @example\r\n * // IDs are time-sortable\r\n * const id1 = generateSequentialId(0);\r\n * await delay(1000);\r\n * const id2 = generateSequentialId(0);\r\n * console.log(id1 < id2); // true (lexicographic comparison works)\r\n */\r\nexport function generateSequentialId(baseId: number): string {\r\n if (baseId < 0 || baseId > MAX_BASEID) {\r\n throw new Error(`baseId must be between 0 and ${MAX_BASEID}`);\r\n }\r\n\r\n const now = Math.floor(Date.now() / 1000);\r\n if (now === lastTimestamp) {\r\n counter++;\r\n if (counter > MAX_COUNTER) {\r\n throw new Error('Too many IDs generated in one second');\r\n }\r\n } else {\r\n lastTimestamp = now;\r\n counter = 0;\r\n }\r\n\r\n const timestamp = now - EPOCH;\r\n if (timestamp > MAX_TIMESTAMP) {\r\n throw new Error('Timestamp exceeds allowed range (beyond 2045-01-01)');\r\n }\r\n\r\n const ts = BigInt(timestamp);\r\n const cnt = BigInt(counter);\r\n const uid = BigInt(baseId);\r\n\r\n // [ timestamp (30 bits) | counter (8 bits) | baseId (20 bits) ]\r\n const id =\r\n (ts << BigInt(COUNTER_BITS + BASEID_BITS)) |\r\n (cnt << BigInt(BASEID_BITS)) |\r\n uid;\r\n\r\n return id.toString(36).toLowerCase();\r\n}\r\n", "/**\r\n * Global error handling for Relaxjs.\r\n * Register a handler with `onError()` to intercept errors before they throw.\r\n * Call `ctx.suppress()` in the handler to prevent the error from being thrown.\r\n *\r\n * @example\r\n * import { onError } from 'relaxjs';\r\n *\r\n * onError((error, ctx) => {\r\n * logToService(error.message, error.context);\r\n * showToast(error.message);\r\n * ctx.suppress();\r\n * });\r\n */\r\n\r\n/**\r\n * Passed to error handlers to control error behavior.\r\n * Call `suppress()` to prevent the error from being thrown.\r\n */\r\nexport interface ErrorContext {\r\n suppress(): void;\r\n}\r\n\r\n/**\r\n * Error with structured context for debugging.\r\n * The `context` record contains details like route name, component tag, route data.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * console.log(error.context.route);\r\n * console.log(error.context.componentTagName);\r\n * });\r\n */\r\nexport class RelaxError extends Error {\r\n constructor(\r\n message: string,\r\n public context: Record<string, unknown>,\r\n ) {\r\n super(message);\r\n }\r\n}\r\n\r\ntype ErrorHandler = (error: RelaxError, ctx: ErrorContext) => void;\r\n\r\nlet handler: ErrorHandler | null = null;\r\n\r\n/**\r\n * Registers a global error handler for Relaxjs errors.\r\n * The handler receives the error and an `ErrorContext`.\r\n * Call `ctx.suppress()` to prevent the error from being thrown.\r\n * Only one handler can be active at a time; subsequent calls replace the previous handler.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * if (error.context.route === 'optional-panel') {\r\n * ctx.suppress();\r\n * return;\r\n * }\r\n * showErrorDialog(error.message);\r\n * });\r\n */\r\nexport function onError(fn: ErrorHandler) {\r\n handler = fn;\r\n}\r\n\r\n/**\r\n * Reports an error through the global handler.\r\n * Returns the `RelaxError` if it should be thrown, or `null` if the handler suppressed it.\r\n * The caller is responsible for throwing the returned error.\r\n *\r\n * @param message - Human-readable error description\r\n * @param context - Structured data for debugging (route, component, params, cause, etc.)\r\n * @returns The error to throw, or `null` if suppressed\r\n *\r\n * @example\r\n * const error = reportError('Failed to load route component', {\r\n * route: 'user',\r\n * componentTagName: 'user-profile',\r\n * routeData: { id: 123 },\r\n * });\r\n * if (error) throw error;\r\n */\r\nexport function reportError(message: string, context: Record<string, unknown>): RelaxError | null {\r\n const error = new RelaxError(message, context);\r\n if (handler) {\r\n let suppressed = false;\r\n const ctx: ErrorContext = {\r\n suppress() { suppressed = true; },\r\n };\r\n handler(error, ctx);\r\n if (suppressed) {\r\n return null;\r\n }\r\n }\r\n return error;\r\n}\r\n"],
|
|
5
|
-
"mappings": "8sBAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,SAAY,iBACZ,MAAS,+CACb,ICHA,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,M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,EAAQD,EAEZ,QAAWE,KAAOH,EAAM,CACpB,GAA2BE,GAAU,KACjC,OAGJA,EAAQA,EAAMC,CAAG,CACrB,CAEA,OAA8BD,GAAyB,MAC3D,CCrBA,IAAME,GAAQ,KAAK,MAAM,IAAI,KAAK,sBAAsB,EAAE,QAAQ,EAAI,GAAI,EAEtEC,EAAgB,EAChBC,EAAU,EAkCP,SAASC,EAAqBC,EAAwB,CACzD,GAAIA,EAAS,GAAKA,EAAS,QACvB,MAAM,IAAI,MAAM,sCAA4C,EAGhE,IAAMC,EAAM,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EACxC,GAAIA,IAAQJ,GAER,GADAC,IACIA,EAAU,IACV,MAAM,IAAI,MAAM,sCAAsC,OAG1DD,EAAgBI,EAChBH,EAAU,EAGd,IAAMI,EAAYD,EAAML,GACxB,GAAIM,EAAY,WACZ,MAAM,IAAI,MAAM,qDAAqD,EAGzE,IAAMC,EAAK,OAAOD,CAAS,EACrBE,EAAM,OAAON,CAAO,EACpBO,EAAM,OAAOL,CAAM,EAQzB,OAJKG,GAAM,OAAO,EAA0B,EACvCC,GAAO,OAAO,EAAW,EAC1BC,GAEM,SAAS,EAAE,EAAE,YAAY,CACvC,CC3DO,IAAMC,EAAN,cAAyB,KAAM,CAClC,YACIC,EACOC,EACT,CACE,MAAMD,CAAO,EAFN,aAAAC,CAGX,CACJ,
|
|
4
|
+
"sourcesContent": ["{\r\n \"greeting\": \"Hello, {name}!\",\r\n \"items\": \"{count, plural, one {# item} other {# items}}\"\r\n}\r\n", "{\r\n \"today\": \"today\",\r\n \"yesterday\": \"yesterday\",\r\n \"daysAgo\": \"{count, plural, one {# day ago} other {# days ago}}\",\r\n \"pieces\": \"{count, plural, =0 {none} one {one} other {# pcs}}\"\r\n}\r\n", "{\r\n \"required\": \"This field is required.\",\r\n \"range\": \"Number must be between {min} and {max}, was {actual}.\",\r\n \"digits\": \"Please enter only digits.\"\r\n}\r\n", "{\r\n \"greeting\": \"Hej, {name}!\",\r\n \"items\": \"{count, plural, one {# sak} other {# saker}}\"\r\n}\r\n", "{\r\n \"today\": \"idag\",\r\n \"yesterday\": \"ig\u00E5r\",\r\n \"daysAgo\": \"{count, plural, one {# dag sedan} other {# dagar sedan}}\",\r\n \"pieces\": \"{count, plural, =0 {inga} one {en} other {# st}}\"\r\n}\r\n", "{\r\n \"required\": \"Detta f\u00E4lt \u00E4r obligatoriskt.\",\r\n \"range\": \"Talet m\u00E5ste vara mellan {min} och {max}, var {actual}.\",\r\n \"digits\": \"Ange endast siffror.\"\r\n}\r\n", "export * from '../pipes';\r\nexport * from '../tools';\r\nexport { generateSequentialId } from '../SequentialId';\r\nexport { onError, reportError, RelaxError } from '../errors';\r\n", "/**\r\n * @module icu\r\n * ICU message format support for internationalization.\r\n * Provides pluralization, select, and value interpolation.\r\n *\r\n * @example\r\n * // Simple interpolation\r\n * formatICU('Hello, {name}!', { name: 'World' });\r\n * // Returns: 'Hello, World!'\r\n *\r\n * @example\r\n * // Pluralization\r\n * formatICU('{count, plural, one {# item} other {# items}}', { count: 5 });\r\n * // Returns: '5 items'\r\n *\r\n * @example\r\n * // Select\r\n * formatICU('{gender, select, male {He} female {She} other {They}}', { gender: 'female' });\r\n * // Returns: 'She'\r\n */\r\n\r\nconst pluralRulesCache = new Map<string, Intl.PluralRules>();\r\n\r\n/**\r\n * Function type for message formatters.\r\n * Implement this to provide custom message formatting.\r\n */\r\nexport type MessageFormatter = (\r\n message: string,\r\n values?: Record<string, any>,\r\n locale?: string\r\n) => string;\r\n\r\n\r\nfunction getPluralRule(locale: string): Intl.PluralRules {\r\n if (!pluralRulesCache.has(locale)) {\r\n pluralRulesCache.set(locale, new Intl.PluralRules(locale));\r\n }\r\n return pluralRulesCache.get(locale)!;\r\n}\r\n\r\nfunction escapeRegex(s: string): string {\r\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\r\n}\r\n\r\n/**\r\n * Default ICU message formatter implementation.\r\n * Supports simple interpolation, pluralization with exact matches, and select.\r\n *\r\n * @param message - ICU format message string\r\n * @param values - Values to interpolate\r\n * @param locale - Locale for plural rules (default: 'en')\r\n * @returns Formatted message string\r\n *\r\n * @example\r\n * defaultFormatICU('{n, plural, =0 {none} one {# item} other {# items}}', { n: 0 }, 'en');\r\n * // Returns: 'none'\r\n *\r\n * @example\r\n * defaultFormatICU('{role, select, admin {Full access} other {Limited access}}', { role: 'admin' });\r\n * // Returns: 'Full access'\r\n */\r\nexport function defaultFormatICU(\r\n message: string,\r\n values: Record<string, any>,\r\n locale: string = 'en'\r\n): string {\r\n return message.replace(\r\n /\\{(\\w+)(?:, (plural|select),((?:[^{}]*\\{[^{}]*\\})+))?\\}/g,\r\n (_, key, type, categoriesPart) => {\r\n const value = values[key];\r\n\r\n if (type === 'plural') {\r\n const exact = new RegExp(\r\n `=${escapeRegex(String(value))}\\\\s*\\\\{([^{}]*)\\\\}`\r\n ).exec(categoriesPart);\r\n if (exact) {\r\n return exact[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n\r\n const rules = getPluralRule(locale);\r\n const category = rules.select(value);\r\n const match =\r\n new RegExp(`${category}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`other\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n if (match) {\r\n return match[1]\r\n .replace(`{${key}}`, String(value))\r\n .replace('#', String(value));\r\n }\r\n return String(value);\r\n }\r\n\r\n if (type === 'select') {\r\n const escaped = escapeRegex(String(value));\r\n const match =\r\n new RegExp(`\\\\b${escaped}\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart) ||\r\n new RegExp(`\\\\bother\\\\s*\\\\{([^{}]*)\\\\}`).exec(categoriesPart);\r\n return match ? match[1] : String(value);\r\n }\r\n\r\n return value !== undefined ? String(value) : `{${key}}`;\r\n },\r\n );\r\n}\r\n\r\n/**\r\n * The active message formatter. Defaults to `defaultFormatICU`.\r\n * Can be replaced with `setMessageFormatter` for custom formatting.\r\n */\r\nexport let formatICU: MessageFormatter = defaultFormatICU;\r\n\r\n/**\r\n * Replaces the default message formatter with a custom implementation.\r\n * Use this to integrate with external i18n libraries like FormatJS.\r\n *\r\n * @param formatter - The custom formatter function\r\n *\r\n * @example\r\n * // Use FormatJS IntlMessageFormat\r\n * import { IntlMessageFormat } from 'intl-messageformat';\r\n *\r\n * setMessageFormatter((message, values, locale) => {\r\n * const fmt = new IntlMessageFormat(message, locale);\r\n * return fmt.format(values);\r\n * });\r\n */\r\nexport function setMessageFormatter(formatter: MessageFormatter) {\r\n formatICU = formatter;\r\n}", "/**\r\n * @module i18n\r\n * Internationalization support with namespace-based translations.\r\n * Uses ICU message format for pluralization, select, and formatting.\r\n *\r\n * @example\r\n * // Initialize locale\r\n * await setLocale('sv');\r\n *\r\n * // Use translations\r\n * const greeting = t('r-common:greeting', { name: 'John' });\r\n * const items = t('shop:items', { count: 5 });\r\n */\r\n\r\nimport { formatICU } from './icu';\r\n\r\ntype Locale = string;\r\ntype Namespace = string;\r\ntype TranslationMap = Record<string, string>;\r\ntype Translations = Record<Namespace, TranslationMap>;\r\n\r\nexport type MissingTranslationHandler = (\r\n key: string,\r\n namespace: string,\r\n locale: string,\r\n) => void;\r\n\r\n/**\r\n * Dispatched on `document` after `setLocale()` completes.\r\n * The `locale` property contains the new normalized locale code.\r\n *\r\n * @example\r\n * document.addEventListener('localechange', (e) => {\r\n * console.log(`Locale changed to ${e.locale}`);\r\n * this.render();\r\n * });\r\n */\r\nexport class LocaleChangeEvent extends Event {\r\n readonly locale: string;\r\n constructor(locale: string) {\r\n super('localechange', { bubbles: false });\r\n this.locale = locale;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface DocumentEventMap {\r\n localechange: LocaleChangeEvent;\r\n }\r\n}\r\n\r\nconst fallbackLocale: Locale = 'en';\r\nlet currentLocale: Locale = fallbackLocale;\r\nconst loadedNamespaces = new Set<Namespace>();\r\nconst translations: Translations = {};\r\nlet missingHandler: MissingTranslationHandler | null = null;\r\n\r\nfunction normalizeLocale(locale: string): string {\r\n return locale.toLowerCase().split('-')[0];\r\n}\r\n\r\n/**\r\n * Sets the current locale and loads the common namespace.\r\n * Clears previously loaded translations and dispatches a `localechange` event.\r\n *\r\n * @param locale - The locale code (e.g., 'en', 'sv', 'en-US')\r\n *\r\n * @example\r\n * await setLocale('sv');\r\n */\r\nexport async function setLocale(locale: string): Promise<void> {\r\n const normalized = normalizeLocale(locale);\r\n currentLocale = normalized;\r\n loadedNamespaces.clear();\r\n Object.keys(translations).forEach(ns => delete translations[ns]);\r\n await loadNamespace('r-common');\r\n if (typeof document !== 'undefined') {\r\n document.dispatchEvent(new LocaleChangeEvent(normalized));\r\n }\r\n}\r\n\r\n/**\r\n * Loads a translation namespace on demand.\r\n * Falls back to the default locale if translations are not found.\r\n *\r\n * @param namespace - The namespace to load (e.g., 'shop', 'errors')\r\n *\r\n * @example\r\n * await loadNamespace('shop');\r\n * const price = t('shop:priceLabel');\r\n */\r\nexport async function loadNamespace(namespace: Namespace): Promise<void> {\r\n if (loadedNamespaces.has(namespace)) return;\r\n\r\n try {\r\n const module = await import(`./locales/${currentLocale}/${namespace}.json`);\r\n translations[namespace] = module.default;\r\n loadedNamespaces.add(namespace);\r\n } catch (err) {\r\n if (currentLocale !== fallbackLocale) {\r\n const fallback = await import(`./locales/${fallbackLocale}/${namespace}.json`);\r\n translations[namespace] = fallback.default;\r\n loadedNamespaces.add(namespace);\r\n } else {\r\n console.warn(`i18n: Failed to load namespace '${namespace}' for locale '${currentLocale}'`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Loads multiple translation namespaces in parallel.\r\n *\r\n * @param namespaces - Array of namespace names to load\r\n *\r\n * @example\r\n * await loadNamespaces(['r-pipes', 'r-validation']);\r\n */\r\nexport async function loadNamespaces(namespaces: Namespace[]): Promise<void> {\r\n await Promise.all(namespaces.map(ns => loadNamespace(ns)));\r\n}\r\n\r\n/**\r\n * Translates a key with optional value interpolation.\r\n * Supports ICU message format for pluralization and select.\r\n *\r\n * @param fullKey - Translation key in format 'namespace:key' or just 'key' (uses 'r-common')\r\n * @param values - Values to interpolate into the message\r\n * @returns The translated string, or the key if not found\r\n *\r\n * @example\r\n * // Simple translation\r\n * t('greeting'); // Uses r-common:greeting\r\n *\r\n * // With namespace\r\n * t('errors:notFound');\r\n *\r\n * // With interpolation\r\n * t('welcome', { name: 'John' }); // \"Welcome, John!\"\r\n *\r\n * // With pluralization (ICU format)\r\n * t('items', { count: 5 }); // \"5 items\" or \"5 f\u00F6rem\u00E5l\"\r\n */\r\nexport function t(fullKey: string, values?: Record<string, any>): string {\r\n const [namespace, key] = fullKey.includes(':')\r\n ? fullKey.split(':')\r\n : ['r-common', fullKey];\r\n const message = translations[namespace]?.[key];\r\n if (!message) {\r\n if (missingHandler) missingHandler(key, namespace, currentLocale);\r\n return fullKey;\r\n }\r\n try {\r\n return formatICU(message, values, currentLocale) as string;\r\n } catch {\r\n return fullKey;\r\n }\r\n}\r\n\r\n/**\r\n * Returns the current locale code.\r\n *\r\n * @returns The normalized locale code (e.g., 'en', 'sv')\r\n */\r\nexport function getCurrentLocale(): string {\r\n return currentLocale;\r\n}\r\n\r\n/**\r\n * Registers a handler called when `t()` encounters a missing translation key.\r\n * Pass `null` to remove the handler.\r\n *\r\n * @param handler - Callback receiving the key, namespace, and locale\r\n *\r\n * @example\r\n * onMissingTranslation((key, ns, locale) => {\r\n * console.warn(`Missing: ${ns}:${key} [${locale}]`);\r\n * });\r\n */\r\nexport function onMissingTranslation(handler: MissingTranslationHandler | null): void {\r\n missingHandler = handler;\r\n}\r\n", "/**\r\n * @module pipes\r\n * Data transformation functions (pipes) for use in template expressions.\r\n * Pipes transform values for display, like formatting dates, currencies, or text.\r\n *\r\n * Locale-aware pipes (currency, date, daysAgo, pieces) use the i18n system\r\n * for formatting and translations. Call `setLocale()` before using these pipes.\r\n *\r\n * Pipes can be chained in templates: `{{value | uppercase | shorten:20}}`\r\n *\r\n * @example\r\n * // In templates\r\n * <span>{{user.name | uppercase}}</span>\r\n * <span>{{price | currency}}</span>\r\n * <span>{{createdAt | daysAgo}}</span>\r\n *\r\n * @example\r\n * // Programmatic usage\r\n * import { applyPipes, defaultPipes } from 'relaxjs';\r\n * const result = applyPipes('hello world', ['uppercase', 'shorten:8']);\r\n * // Returns: 'HELLO...'\r\n */\r\n\r\nimport { getCurrentLocale, t } from './i18n/i18n';\r\n\r\n/**\r\n * Type definition for pipe transformation functions.\r\n * Pipes take a value and optional arguments, returning a transformed value.\r\n *\r\n * @example\r\n * // Define a custom pipe\r\n * const reversePipe: PipeFunction = (value: string) => {\r\n * return value.split('').reverse().join('');\r\n * };\r\n */\r\nexport type PipeFunction = (value: any, ...args: any[]) => any;\r\n\r\n\r\n// =============================== Text manipulation pipes ===========================\r\n\r\n\r\n\r\n/**\r\n * Converts a string to uppercase\r\n * @param value The string to convert\r\n * @returns The uppercase string\r\n */\r\nexport function uppercasePipe(value: string): string {\r\n return String(value).toUpperCase();\r\n}\r\n\r\n/**\r\n * Converts a string to uppercase\r\n * @param value The string to convert\r\n * @returns The uppercase string\r\n */\r\nexport function trimPipe(value: string): string {\r\n return String(value).trimEnd().trimStart();\r\n}\r\n\r\n\r\n/**\r\n * Converts a string to lowercase\r\n * @param value The string to convert\r\n * @returns The lowercase string\r\n */\r\nexport function lowercasePipe(value: string): string {\r\n return String(value).toLowerCase();\r\n}\r\n\r\n/**\r\n * Capitalizes the first character of a string\r\n * @param value The string to capitalize\r\n * @returns The capitalized string\r\n */\r\nexport function capitalizePipe(value: string): string {\r\n const str = String(value);\r\n return str.charAt(0).toUpperCase() + str.slice(1);\r\n}\r\n\r\n/**\r\n * Shortens a string to a specified length and adds ellipsis.\r\n * @param value The string to shorten\r\n * @param length Maximum length including ellipsis\r\n * @returns The shortened string with ellipsis if needed\r\n */\r\nexport function shortenPipe(value: string, length: string): string {\r\n const str = String(value);\r\n const maxLength = parseInt(length, 10);\r\n return str.length > maxLength\r\n ? str.substring(0, maxLength - 3) + '...'\r\n : str;\r\n}\r\n\r\n// Formatting pipes\r\n/**\r\n * Formats a number as currency using the current locale.\r\n * Uses the i18n system's current locale for formatting.\r\n *\r\n * @param value The number to format\r\n * @param currency Currency code (defaults to USD)\r\n * @returns Formatted currency string\r\n *\r\n * @example\r\n * // In template: {{price | currency}} or {{price | currency:EUR}}\r\n * currencyPipe(1234.56); // \"$1,234.56\" (en) or \"1 234,56 $\" (sv)\r\n * currencyPipe(1234.56, 'SEK'); // \"SEK 1,234.56\" (en) or \"1 234,56 kr\" (sv)\r\n */\r\nexport function currencyPipe(value: number, currency: string = 'USD'): string {\r\n const locale = getCurrentLocale();\r\n return new Intl.NumberFormat(locale, {\r\n style: 'currency',\r\n currency\r\n }).format(value);\r\n}\r\n\r\n/**\r\n * Formats a date value according to the specified format.\r\n * Uses the i18n system's current locale for formatting.\r\n *\r\n * @param value Date value (string, number, or Date object)\r\n * @param format Format type: 'short', 'long', or default (ISO)\r\n * @returns Formatted date string\r\n *\r\n * @example\r\n * // In template: {{date | date:short}} or {{date | date:long}}\r\n * datePipe(new Date(), 'short'); // \"1/15/2024\" (en) or \"2024-01-15\" (sv)\r\n * datePipe(new Date(), 'long'); // \"Monday, January 15, 2024\" (en) or \"m\u00E5ndag 15 januari 2024\" (sv)\r\n */\r\nexport function datePipe(value: string | number | Date, format?: string): string {\r\n const date = new Date(value);\r\n const locale = getCurrentLocale();\r\n if (format === 'short') {\r\n return date.toLocaleDateString(locale);\r\n } else if (format === 'long') {\r\n return date.toLocaleDateString(locale, {\r\n weekday: 'long',\r\n year: 'numeric',\r\n month: 'long',\r\n day: 'numeric'\r\n });\r\n }\r\n return date.toISOString();\r\n}\r\n\r\n/**\r\n * Prints today, yesterday or X days ago.\r\n * Uses the i18n system for translations (requires pipes namespace loaded).\r\n *\r\n * @param value Date value (string, number, or Date object)\r\n * @returns Formatted relative date string\r\n *\r\n * @example\r\n * // In template: {{createdAt | daysAgo}}\r\n * // English: \"today\", \"yesterday\", \"3 days ago\"\r\n * // Swedish: \"idag\", \"ig\u00E5r\", \"3 dagar sedan\"\r\n */\r\nexport function daysAgoPipe(value: string | number | Date): string {\r\n if (!value) {\r\n return 'n/a';\r\n }\r\n\r\n const inputDate = new Date(value);\r\n const today = new Date();\r\n\r\n // Normalize times to midnight to compare only dates\r\n inputDate.setHours(0, 0, 0, 0);\r\n today.setHours(0, 0, 0, 0);\r\n\r\n const diffTime = today.getTime() - inputDate.getTime();\r\n const diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));\r\n\r\n if (diffDays === 0) return t('r-pipes:today');\r\n if (diffDays === 1) return t('r-pipes:yesterday');\r\n return t('r-pipes:daysAgo', { count: diffDays });\r\n}\r\n\r\n/**\r\n * Formats a count as pieces/items.\r\n * Uses the i18n system for translations (requires pipes namespace loaded).\r\n *\r\n * @param value Count value\r\n * @returns Formatted piece count string\r\n *\r\n * @example\r\n * // In template: {{quantity | pieces}}\r\n * // English: \"none\", \"one\", \"3 pcs\"\r\n * // Swedish: \"inga\", \"en\", \"3 st\"\r\n */\r\nexport function piecesPipe(value: string | number): string {\r\n if (value === null || value === undefined) {\r\n return 'n/a';\r\n }\r\n\r\n const count = Number(value);\r\n return t('r-pipes:pieces', { count });\r\n}\r\n\r\n\r\n\r\n// =============================== Array operation pipes ===========================\r\n\r\n\r\n\r\n/**\r\n * Joins array elements with the specified separator\r\n * @param value Array to join\r\n * @param separator Character(s) to use between elements (defaults to comma)\r\n * @returns Joined string or original value if not an array\r\n */\r\nexport function joinPipe(value: any[], separator: string = ','): string | any {\r\n if (!Array.isArray(value)) return value;\r\n return value.join(separator);\r\n}\r\n\r\n/**\r\n * Returns the first element of an array\r\n * @param value Array to extract from\r\n * @returns First element or empty string if array is empty/invalid\r\n */\r\nexport function firstPipe(value: any[]): any {\r\n if (!Array.isArray(value) || value.length === 0) return '';\r\n return value[0];\r\n}\r\n\r\n/**\r\n * Returns the last element of an array\r\n * @param value Array to extract from\r\n * @returns Last element or empty string if array is empty/invalid\r\n */\r\nexport function lastPipe(value: any[]): any {\r\n if (!Array.isArray(value) || value.length === 0) return '';\r\n return value[value.length - 1];\r\n}\r\n\r\n// Object operation pipes\r\n/**\r\n * Returns the keys of an object\r\n * @param value Object to extract keys from\r\n * @returns Array of object keys or empty array if not an object\r\n */\r\nexport function keysPipe(value: object): string[] {\r\n if (typeof value !== 'object' || value === null) return [];\r\n return Object.keys(value);\r\n}\r\n\r\n// Conditional pipes\r\n/**\r\n * Returns a default value if the input is falsy\r\n * @param value Input value to check\r\n * @param defaultValue Value to return if input is falsy\r\n * @returns Original value or default value\r\n */\r\nexport function defaultPipe(value: any, defaultValue: string): any {\r\n return value || defaultValue;\r\n}\r\n\r\n/**\r\n * Implements ternary operator as a pipe\r\n * @param value Condition to evaluate\r\n * @param trueValue Value to return if condition is truthy\r\n * @param falseValue Value to return if condition is falsy\r\n * @returns Selected value based on condition\r\n */\r\nexport function ternaryPipe(value: any, trueValue: string, falseValue: string): string {\r\n return value ? trueValue : falseValue;\r\n}\r\n\r\n\r\n\r\n// =============================== Pipe registry and application ===========================\r\n\r\n\r\n/**\r\n * Interface for a collection of pipe functions.\r\n * Use this to look up pipes by name for template processing.\r\n *\r\n * @example\r\n * // Check if a pipe exists before using\r\n * if (registry.has('currency')) {\r\n * const formatted = registry.get('currency')(price);\r\n * }\r\n */\r\nexport interface PipeRegistry {\r\n /**\r\n * Looks up a pipe by name, returning null if not found.\r\n */\r\n lookup(name: string): PipeFunction | null;\r\n\r\n /**\r\n * Gets a pipe by name, throwing if not found.\r\n */\r\n get(name: string): PipeFunction;\r\n\r\n /**\r\n * Checks if a pipe with the given name exists.\r\n */\r\n has(name: string): boolean;\r\n}\r\n\r\n\r\n/**\r\n * Creates a new pipe registry with all built-in pipes registered.\r\n * Built-in pipes include:\r\n *\r\n * **Text:** uppercase, lowercase, capitalize, trim, shorten\r\n * **Formatting:** currency, date, daysAgo, pieces\r\n * **Arrays:** join, first, last\r\n * **Objects:** keys\r\n * **Conditionals:** default, ternary\r\n *\r\n * @returns A new pipe registry instance\r\n *\r\n * @example\r\n * const registry = createPipeRegistry();\r\n * const upperPipe = registry.get('uppercase');\r\n * console.log(upperPipe('hello')); // 'HELLO'\r\n */\r\nexport function createPipeRegistry(): PipeRegistry {\r\n const pipes = new Map<string, PipeFunction>();\r\n\r\n // Text manipulation\r\n pipes.set('uppercase', uppercasePipe);\r\n pipes.set('lowercase', lowercasePipe);\r\n pipes.set('capitalize', capitalizePipe);\r\n pipes.set('trim', trimPipe);\r\n pipes.set('shorten', shortenPipe);\r\n\r\n // Formatting\r\n pipes.set('currency', currencyPipe);\r\n pipes.set('date', datePipe);\r\n pipes.set('daysAgo', daysAgoPipe);\r\n pipes.set('pieces', piecesPipe);\r\n\r\n // Array operations\r\n pipes.set('join', joinPipe);\r\n pipes.set('first', firstPipe);\r\n pipes.set('last', lastPipe);\r\n\r\n // Object operations\r\n pipes.set('keys', keysPipe);\r\n\r\n // Conditional formatting\r\n pipes.set('default', defaultPipe);\r\n pipes.set('ternary', ternaryPipe);\r\n\r\n return {\r\n lookup(name) {\r\n return pipes.get(name);\r\n },\r\n get(name) {\r\n var pipe = pipes.get(name);\r\n if (!pipe) {\r\n throw Error(\"Pipe '\" + name + \"' not found.\");\r\n }\r\n return pipe;\r\n },\r\n has(name) {\r\n return pipes.has(name);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Default pipe registry instance with all built-in pipes.\r\n * Used by template engines unless a custom registry is provided.\r\n *\r\n * @example\r\n * import { defaultPipes } from 'relaxjs';\r\n *\r\n * if (defaultPipes.has('uppercase')) {\r\n * const result = defaultPipes.get('uppercase')('hello');\r\n * }\r\n */\r\nexport const defaultPipes = createPipeRegistry();\r\n\r\n/**\r\n * Applies a series of pipes to a value sequentially.\r\n * Each pipe transforms the output of the previous pipe.\r\n *\r\n * Pipe arguments are specified after a colon: `shorten:20`\r\n *\r\n * @param value - Initial value to transform\r\n * @param pipes - Array of pipe strings (name and optional arguments separated by ':')\r\n * @param registry - Optional custom pipe registry (uses defaultPipes if not provided)\r\n * @returns The transformed value after applying all pipes\r\n *\r\n * @example\r\n * // Apply single pipe\r\n * applyPipes('hello', ['uppercase']); // 'HELLO'\r\n *\r\n * @example\r\n * // Chain multiple pipes\r\n * applyPipes('hello world', ['uppercase', 'shorten:8']); // 'HELLO...'\r\n *\r\n * @example\r\n * // With pipe arguments\r\n * applyPipes(1234.56, ['currency']); // '$1,234.56'\r\n */\r\nexport function applyPipes(\r\n value: any,\r\n pipes: string[],\r\n registry: PipeRegistry = defaultPipes\r\n): any {\r\n\r\n return pipes.reduce((currentValue, pipe) => {\r\n const [pipeName, ...args] = pipe.split(':').map((p) => p.trim());\r\n\r\n if (!registry.has(pipeName)) {\r\n return `[Pipe ${pipeName} not found]`;\r\n }\r\n\r\n try {\r\n return registry.get(pipeName)(currentValue, ...args);\r\n } catch (error) {\r\n return `[Pipe ${pipeName}, value: ${value}, error: ${error}]`;\r\n }\r\n }, value);\r\n}", "/**\r\n * Resolves a deeply nested value from an object using a path array.\r\n * Safely navigates through the object tree, returning undefined if any\r\n * segment in the path is null or undefined.\r\n *\r\n * Used internally by template engines to access data properties,\r\n * but also useful for general-purpose deep property access.\r\n *\r\n * @param path - Array of property names forming the path to the value\r\n * @param context - The object to resolve the value from\r\n * @returns The resolved value, or undefined if path cannot be resolved\r\n *\r\n * @example\r\n * // Access nested property\r\n * const user = { address: { city: 'Stockholm' } };\r\n * const city = resolveValue(['address', 'city'], user);\r\n * // Returns: 'Stockholm'\r\n *\r\n * @example\r\n * // Safe access with missing properties\r\n * const data = { user: null };\r\n * const name = resolveValue(['user', 'name'], data);\r\n * // Returns: undefined (doesn't throw)\r\n *\r\n * @example\r\n * // Use with template expression paths\r\n * const path = 'user.profile.avatar'.split('.');\r\n * const avatar = resolveValue(path, context);\r\n */\r\nexport function resolveValue(\r\n path: string[],\r\n context: Record<string, any>\r\n): any | undefined {\r\n let value = context;\r\n\r\n for (const key of path) {\r\n if (value === undefined || value === null) {\r\n return undefined;\r\n }\r\n\r\n value = value[key];\r\n }\r\n\r\n return value !== undefined && value !== null ? value : undefined;\r\n}\r\n ", "/**\r\n * @module SequentialId\r\n * Generates compact, time-ordered unique identifiers suitable for distributed systems.\r\n *\r\n * IDs are structured to be:\r\n * - Unique across multiple clients (via baseId)\r\n * - Time-sortable (timestamp is the most significant bits)\r\n * - Compact (Base36 encoding produces short strings)\r\n *\r\n * Bit allocation (58 bits total):\r\n * - 30 bits for timestamp (seconds since January 1, 2025)\r\n * - 8 bits for per-second counter (supports 256 IDs/second)\r\n * - 20 bits for client/endpoint identifier (supports ~1M unique sources)\r\n */\r\n\r\nconst TIMESTAMP_BITS = 30;\r\nconst COUNTER_BITS = 8;\r\nconst BASEID_BITS = 20;\r\n\r\nconst MAX_TIMESTAMP = (1 << TIMESTAMP_BITS) - 1;\r\nconst MAX_COUNTER = (1 << COUNTER_BITS) - 1;\r\nconst MAX_BASEID = (1 << BASEID_BITS) - 1;\r\n\r\nconst EPOCH = Math.floor(new Date('2025-01-01T00:00:00Z').getTime() / 1000);\r\n\r\nlet lastTimestamp = 0;\r\nlet counter = 0;\r\n\r\n/**\r\n * Generates a unique, time-ordered sequential ID.\r\n *\r\n * The ID combines a timestamp, per-second counter, and client identifier\r\n * into a compact Base36 string. IDs generated later will sort after earlier IDs,\r\n * making them suitable for ordered collections.\r\n *\r\n * @param baseId - Unique identifier for the client/endpoint (0 to 1,048,575).\r\n * Use different baseIds for different servers or processes to\r\n * avoid collisions.\r\n * @returns Base36 encoded string representing the unique ID\r\n * @throws Error if baseId is out of valid range\r\n * @throws Error if more than 256 IDs are generated in a single second\r\n * @throws Error if timestamp exceeds range (after year 2045)\r\n *\r\n * @example\r\n * // Generate ID for server instance 1\r\n * const id1 = generateSequentialId(1);\r\n * // Returns something like: 'k2j8m3n5p'\r\n *\r\n * @example\r\n * // Different servers use different baseIds\r\n * const SERVER_ID = parseInt(process.env.SERVER_ID || '0');\r\n * const orderId = generateSequentialId(SERVER_ID);\r\n *\r\n * @example\r\n * // IDs are time-sortable\r\n * const id1 = generateSequentialId(0);\r\n * await delay(1000);\r\n * const id2 = generateSequentialId(0);\r\n * console.log(id1 < id2); // true (lexicographic comparison works)\r\n */\r\nexport function generateSequentialId(baseId: number): string {\r\n if (baseId < 0 || baseId > MAX_BASEID) {\r\n throw new Error(`baseId must be between 0 and ${MAX_BASEID}`);\r\n }\r\n\r\n const now = Math.floor(Date.now() / 1000);\r\n if (now === lastTimestamp) {\r\n counter++;\r\n if (counter > MAX_COUNTER) {\r\n throw new Error('Too many IDs generated in one second');\r\n }\r\n } else {\r\n lastTimestamp = now;\r\n counter = 0;\r\n }\r\n\r\n const timestamp = now - EPOCH;\r\n if (timestamp > MAX_TIMESTAMP) {\r\n throw new Error('Timestamp exceeds allowed range (beyond 2045-01-01)');\r\n }\r\n\r\n const ts = BigInt(timestamp);\r\n const cnt = BigInt(counter);\r\n const uid = BigInt(baseId);\r\n\r\n // [ timestamp (30 bits) | counter (8 bits) | baseId (20 bits) ]\r\n const id =\r\n (ts << BigInt(COUNTER_BITS + BASEID_BITS)) |\r\n (cnt << BigInt(BASEID_BITS)) |\r\n uid;\r\n\r\n return id.toString(36).toLowerCase();\r\n}\r\n", "/**\r\n * Global error handling for Relaxjs.\r\n * Register a handler with `onError()` to intercept errors before they throw.\r\n * Call `ctx.suppress()` in the handler to prevent the error from being thrown.\r\n *\r\n * @example\r\n * import { onError } from 'relaxjs';\r\n *\r\n * onError((error, ctx) => {\r\n * logToService(error.message, error.context);\r\n * showToast(error.message);\r\n * ctx.suppress();\r\n * });\r\n */\r\n\r\n/**\r\n * Passed to error handlers to control error behavior.\r\n * Call `suppress()` to prevent the error from being thrown.\r\n */\r\nexport interface ErrorContext {\r\n suppress(): void;\r\n}\r\n\r\n/**\r\n * Error with structured context for debugging.\r\n * The `context` record contains details like route name, component tag, route data.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * console.log(error.context.route);\r\n * console.log(error.context.componentTagName);\r\n * });\r\n */\r\nexport class RelaxError extends Error {\r\n constructor(\r\n message: string,\r\n public context: Record<string, unknown>,\r\n ) {\r\n super(message);\r\n }\r\n}\r\n\r\n/** @internal */\r\ntype ErrorHandler = (error: RelaxError, ctx: ErrorContext) => void;\r\n\r\nlet handler: ErrorHandler | null = null;\r\n\r\n/**\r\n * Registers a global error handler for Relaxjs errors.\r\n * The handler receives the error and an `ErrorContext`.\r\n * Call `ctx.suppress()` to prevent the error from being thrown.\r\n * Only one handler can be active at a time; subsequent calls replace the previous handler.\r\n *\r\n * @example\r\n * onError((error, ctx) => {\r\n * if (error.context.route === 'optional-panel') {\r\n * ctx.suppress();\r\n * return;\r\n * }\r\n * showErrorDialog(error.message);\r\n * });\r\n */\r\nexport function onError(fn: ErrorHandler) {\r\n handler = fn;\r\n}\r\n\r\n/**\r\n * Reports an error through the global handler.\r\n * Returns the `RelaxError` if it should be thrown, or `null` if the handler suppressed it.\r\n * The caller is responsible for throwing the returned error.\r\n *\r\n * @param message - Human-readable error description\r\n * @param context - Structured data for debugging (route, component, params, cause, etc.)\r\n * @returns The error to throw, or `null` if suppressed\r\n *\r\n * @example\r\n * const error = reportError('Failed to load route component', {\r\n * route: 'user',\r\n * componentTagName: 'user-profile',\r\n * routeData: { id: 123 },\r\n * });\r\n * if (error) throw error;\r\n */\r\nexport function reportError(message: string, context: Record<string, unknown>): RelaxError | null {\r\n const error = new RelaxError(message, context);\r\n if (handler) {\r\n let suppressed = false;\r\n const ctx: ErrorContext = {\r\n suppress() { suppressed = true; },\r\n };\r\n handler(error, ctx);\r\n if (suppressed) {\r\n return null;\r\n }\r\n }\r\n return error;\r\n}\r\n\r\n/**\r\n * Wraps an async function into a synchronous callback suitable for addEventListener.\r\n * Catches promise rejections and reports them through the global error handler.\r\n *\r\n * @param fn - Async function to wrap\r\n * @returns Synchronous function that can be passed to addEventListener\r\n *\r\n * @example\r\n * button.addEventListener('click', asyncHandler(async (e) => {\r\n * await saveData();\r\n * }));\r\n *\r\n * @example\r\n * form.addEventListener('submit', asyncHandler(async (e) => {\r\n * e.preventDefault();\r\n * await submitForm();\r\n * }));\r\n */\r\nexport function asyncHandler<TArgs extends unknown[]>(\r\n fn: (...args: TArgs) => Promise<void>,\r\n): (...args: TArgs) => void {\r\n return function (this: any, ...args: TArgs) {\r\n fn.call(this, ...args).catch((cause: unknown) => {\r\n const error = reportError('Async callback failed', { cause });\r\n if (error) throw error;\r\n });\r\n };\r\n}\r\n"],
|
|
5
|
+
"mappings": "8sBAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,SAAY,iBACZ,MAAS,+CACb,ICHA,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,MAAS,QACT,UAAa,YACb,QAAW,sDACX,OAAU,oDACd,ICLA,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,SAAY,0BACZ,MAAS,wDACT,OAAU,2BACd,ICJA,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,SAAY,eACZ,MAAS,8CACb,ICHA,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,MAAS,OACT,UAAa,UACb,QAAW,2DACX,OAAU,kDACd,ICLA,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACI,SAAY,qCACZ,MAAS,4DACT,OAAU,sBACd,ICJA,IAAAC,GAAA,GAAAC,GAAAD,GAAA,gBAAAE,EAAA,eAAAC,GAAA,mBAAAC,EAAA,uBAAAC,EAAA,iBAAAC,EAAA,aAAAC,EAAA,gBAAAC,EAAA,gBAAAC,EAAA,iBAAAC,EAAA,cAAAC,EAAA,yBAAAC,EAAA,aAAAC,EAAA,aAAAC,EAAA,aAAAC,EAAA,kBAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,gBAAAC,EAAA,iBAAAC,GAAA,g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,CC3DO,IAAMC,EAAN,cAAyB,KAAM,CAClC,YACIC,EACOC,EACT,CACE,MAAMD,CAAO,EAFN,aAAAC,CAGX,CACJ,EAKIC,EAA+B,KAiB5B,SAASC,EAAQC,EAAkB,CACtCF,EAAUE,CACd,CAmBO,SAASC,EAAYL,EAAiBC,EAAqD,CAC9F,IAAMK,EAAQ,IAAIP,EAAWC,EAASC,CAAO,EAC7C,GAAIC,EAAS,CACT,IAAIK,EAAa,GAKjB,GADAL,EAAQI,EAHkB,CACtB,UAAW,CAAEC,EAAa,EAAM,CACpC,CACkB,EACdA,EACA,OAAO,IAEf,CACA,OAAOD,CACX",
|
|
6
6
|
"names": ["require_r_common", "__commonJSMin", "exports", "module", "require_r_pipes", "__commonJSMin", "exports", "module", "require_r_validation", "__commonJSMin", "exports", "module", "require_r_common", "__commonJSMin", "exports", "module", "require_r_pipes", "__commonJSMin", "exports", "module", "require_r_validation", "__commonJSMin", "exports", "module", "index_exports", "__export", "RelaxError", "applyPipes", "capitalizePipe", "createPipeRegistry", "currencyPipe", "datePipe", "daysAgoPipe", "defaultPipe", "defaultPipes", "firstPipe", "generateSequentialId", "joinPipe", "keysPipe", "lastPipe", "lowercasePipe", "onError", "piecesPipe", "reportError", "resolveValue", "shortenPipe", "ternaryPipe", "trimPipe", "uppercasePipe", "__toCommonJS", "pluralRulesCache", "getPluralRule", "locale", "escapeRegex", "s", "defaultFormatICU", "message", "values", "_", "key", "type", "categoriesPart", "value", "exact", "category", "match", "escaped", "formatICU", "fallbackLocale", "currentLocale", "translations", "missingHandler", "t", "fullKey", "values", "namespace", "key", "message", "translations", "missingHandler", "currentLocale", "formatICU", "getCurrentLocale", "uppercasePipe", "value", "trimPipe", "lowercasePipe", "capitalizePipe", "str", "shortenPipe", "length", "maxLength", "currencyPipe", "currency", "locale", "getCurrentLocale", "datePipe", "format", "date", "daysAgoPipe", "inputDate", "today", "diffTime", "diffDays", "t", "piecesPipe", "count", "joinPipe", "separator", "firstPipe", "lastPipe", "keysPipe", "defaultPipe", "defaultValue", "ternaryPipe", "trueValue", "falseValue", "createPipeRegistry", "pipes", "name", "pipe", "defaultPipes", "applyPipes", "registry", "currentValue", "pipeName", "args", "p", "error", "resolveValue", "path", "context", "value", "key", "EPOCH", "lastTimestamp", "counter", "generateSequentialId", "baseId", "now", "timestamp", "ts", "cnt", "uid", "RelaxError", "message", "context", "handler", "onError", "fn", "reportError", "error", "suppressed"]
|
|
7
7
|
}
|