@relax.js/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +188 -0
- package/dist/DataLoader.d.ts +51 -0
- package/dist/DependencyInjection.d.ts +271 -0
- package/dist/DependencyInjectionOld.d.ts +35 -0
- package/dist/Metadata.d.ts +8 -0
- package/dist/SequentialId.d.ts +47 -0
- package/dist/_alt/src/MustardEngine.d.ts +30 -0
- package/dist/_alt/src/MustardParser.d.ts +63 -0
- package/dist/_alt/src/MustardParser2.d.ts +35 -0
- package/dist/_alt/src/pipes.d.ts +93 -0
- package/dist/_alt/src/template.d.ts +166 -0
- package/dist/_alt/src/tools.d.ts +4 -0
- package/dist/_alt/tests/pipes.tests.d.ts +1 -0
- package/dist/_alt/tests/template.tests.d.ts +1 -0
- package/dist/_alt/vitest.config.d.ts +2 -0
- package/dist/collections/Index.d.ts +1 -0
- package/dist/collections/LinkedList.d.ts +75 -0
- package/dist/collections/Pager.d.ts +15 -0
- package/dist/collections/index.js +2 -0
- package/dist/collections/index.js.map +7 -0
- package/dist/collections/index.mjs +2 -0
- package/dist/collections/index.mjs.map +7 -0
- package/dist/components/Table.d.ts +13 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +128 -0
- package/dist/components/index.js.map +7 -0
- package/dist/components/index.mjs +128 -0
- package/dist/components/index.mjs.map +7 -0
- package/dist/components/lists/Table.d.ts +59 -0
- package/dist/components/lists/TreeView.d.ts +67 -0
- package/dist/components/lists/index.d.ts +2 -0
- package/dist/components/loader.d.ts +60 -0
- package/dist/components/menus/MenuItem.d.ts +30 -0
- package/dist/components/menus/TopMenu.d.ts +16 -0
- package/dist/components/menus/index.d.ts +2 -0
- package/dist/components/panels/tabs.d.ts +15 -0
- package/dist/di/index.d.ts +1 -0
- package/dist/di/index.js +2 -0
- package/dist/di/index.js.map +7 -0
- package/dist/di/index.mjs +2 -0
- package/dist/di/index.mjs.map +7 -0
- package/dist/elements/CopyAttributes.d.ts +2 -0
- package/dist/elements/dom.d.ts +18 -0
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +2 -0
- package/dist/elements/index.js.map +7 -0
- package/dist/elements/index.mjs +2 -0
- package/dist/elements/index.mjs.map +7 -0
- package/dist/errors.d.ts +71 -0
- package/dist/forms/FormReader.d.ts +182 -0
- package/dist/forms/FormValidator.d.ts +114 -0
- package/dist/forms/ValidationRules.d.ts +103 -0
- package/dist/forms/index.d.ts +4 -0
- package/dist/forms/index.js +2 -0
- package/dist/forms/index.js.map +7 -0
- package/dist/forms/index.mjs +2 -0
- package/dist/forms/index.mjs.map +7 -0
- package/dist/forms/setFormData.d.ts +49 -0
- package/dist/getParentComponent.d.ts +43 -0
- package/dist/html/TableRenderer.d.ts +44 -0
- package/dist/html/TreeBinder.d.ts +9 -0
- package/dist/html/html.d.ts +55 -0
- package/dist/html/index.d.ts +5 -0
- package/dist/html/index.js +2 -0
- package/dist/html/index.js.map +7 -0
- package/dist/html/index.mjs +2 -0
- package/dist/html/index.mjs.map +7 -0
- package/dist/html/template.d.ts +167 -0
- package/dist/http/ServerSentEvents.d.ts +116 -0
- package/dist/http/SimpleWebSocket.d.ts +153 -0
- package/dist/http/http.d.ts +177 -0
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.js +2 -0
- package/dist/http/index.js.map +7 -0
- package/dist/http/index.mjs +2 -0
- package/dist/http/index.mjs.map +7 -0
- package/dist/i18n/i18n.d.ts +105 -0
- package/dist/i18n/icu.d.ts +64 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +7 -0
- package/dist/i18n/index.mjs +2 -0
- package/dist/i18n/index.mjs.map +7 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +7 -0
- package/dist/lib/DataLoader.d.ts +51 -0
- package/dist/lib/DependencyInjection.d.ts +271 -0
- package/dist/lib/InvokeParent.d.ts +10 -0
- package/dist/lib/Pipes.d.ts +236 -0
- package/dist/lib/SequentialId.d.ts +47 -0
- package/dist/lib/collections/Index.d.ts +1 -0
- package/dist/lib/collections/LinkedList.d.ts +75 -0
- package/dist/lib/collections/Pager.d.ts +15 -0
- package/dist/lib/collections/TableRenderer.d.ts +44 -0
- package/dist/lib/di/index.d.ts +1 -0
- package/dist/lib/elements/CopyAttributes.d.ts +2 -0
- package/dist/lib/elements/dom.d.ts +18 -0
- package/dist/lib/elements/index.d.ts +2 -0
- package/dist/lib/errors.d.ts +71 -0
- package/dist/lib/forms/FormReader.d.ts +182 -0
- package/dist/lib/forms/FormValidator.d.ts +114 -0
- package/dist/lib/forms/ValidationRules.d.ts +103 -0
- package/dist/lib/forms/index.d.ts +4 -0
- package/dist/lib/forms/setFormData.d.ts +49 -0
- package/dist/lib/getParentComponent.d.ts +43 -0
- package/dist/lib/html/TableRenderer.d.ts +44 -0
- package/dist/lib/html/TreeBinder.d.ts +9 -0
- package/dist/lib/html/html.d.ts +55 -0
- package/dist/lib/html/html2.d.ts +55 -0
- package/dist/lib/html/index.d.ts +5 -0
- package/dist/lib/html/m.d.ts +167 -0
- package/dist/lib/html/m2.d.ts +8 -0
- package/dist/lib/html/m3.d.ts +0 -0
- package/dist/lib/html/template.d.ts +167 -0
- package/dist/lib/http/HttpClient.d.ts +153 -0
- package/dist/lib/http/ServerSentEvents.d.ts +116 -0
- package/dist/lib/http/SimpleWebSocket.d.ts +153 -0
- package/dist/lib/http/http.d.ts +177 -0
- package/dist/lib/http/index.d.ts +3 -0
- package/dist/lib/i18n/i18n.d.ts +105 -0
- package/dist/lib/i18n/icu.d.ts +64 -0
- package/dist/lib/i18n/index.d.ts +2 -0
- package/dist/lib/index.d.ts +16 -0
- package/dist/lib/routing/NavigateRouteEvent.d.ts +52 -0
- package/dist/lib/routing/RouteLink.d.ts +7 -0
- package/dist/lib/routing/Routing.d.ts +270 -0
- package/dist/lib/routing/RoutingTarget.d.ts +22 -0
- package/dist/lib/routing/index.d.ts +7 -0
- package/dist/lib/routing/navigation.d.ts +70 -0
- package/dist/lib/routing/routeMatching.d.ts +21 -0
- package/dist/lib/routing/routeTargetRegistry.d.ts +23 -0
- package/dist/lib/routing/types.d.ts +130 -0
- package/dist/lib/templates/NodeTemplate.d.ts +38 -0
- package/dist/lib/templates/accessorParser.d.ts +87 -0
- package/dist/lib/templates/parseTemplate.d.ts +6 -0
- package/dist/lib/templates/tokenizer.d.ts +76 -0
- package/dist/lib/tools.d.ts +30 -0
- package/dist/lib/utils/index.d.ts +4 -0
- package/dist/pipes.d.ts +236 -0
- package/dist/routing/NavigateRouteEvent.d.ts +52 -0
- package/dist/routing/RouteLink.d.ts +7 -0
- package/dist/routing/RoutingTarget.d.ts +22 -0
- package/dist/routing/index.d.ts +7 -0
- package/dist/routing/index.js +5 -0
- package/dist/routing/index.js.map +7 -0
- package/dist/routing/index.mjs +5 -0
- package/dist/routing/index.mjs.map +7 -0
- package/dist/routing/navigation.d.ts +70 -0
- package/dist/routing/routeMatching.d.ts +21 -0
- package/dist/routing/routeTargetRegistry.d.ts +23 -0
- package/dist/routing/types.d.ts +130 -0
- package/dist/templates/NodeTemplate.d.ts +38 -0
- package/dist/templates/accessorParser.d.ts +87 -0
- package/dist/templates/parseTemplate.d.ts +6 -0
- package/dist/templates/tokenizer.d.ts +76 -0
- package/dist/tools.d.ts +30 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/index.mjs +2 -0
- package/dist/utils/index.mjs.map +7 -0
- package/docs/Architecture.md +333 -0
- package/docs/DependencyInjection.md +237 -0
- package/docs/Errors.md +87 -0
- package/docs/GettingStarted.md +231 -0
- package/docs/Pipes.md +211 -0
- package/docs/Translations.md +312 -0
- package/docs/WhyRelaxjs.md +336 -0
- package/docs/elements/dom.md +102 -0
- package/docs/forms/creating-form-components.md +924 -0
- package/docs/forms/form-api.md +94 -0
- package/docs/forms/forms.md +99 -0
- package/docs/forms/patterns.md +311 -0
- package/docs/forms/reading-writing.md +365 -0
- package/docs/forms/validation.md +351 -0
- package/docs/html/TableRenderer.md +292 -0
- package/docs/html/html.md +175 -0
- package/docs/html/index.md +54 -0
- package/docs/html/template.md +422 -0
- package/docs/http/HttpClient.md +459 -0
- package/docs/http/ServerSentEvents.md +184 -0
- package/docs/http/index.md +109 -0
- package/docs/i18n/i18n.md +309 -0
- package/docs/i18n/intl-standard.md +178 -0
- package/docs/routing/RouteLink.md +98 -0
- package/docs/routing/Routing.md +332 -0
- package/docs/routing/RoutingTarget.md +136 -0
- package/docs/routing/layouts.md +207 -0
- package/docs/utilities.md +143 -0
- package/package.json +93 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,IAAA,eAKAA,IAAA,uBAKAA,IAAA,eAnBQA,OAAA,IAgICC,EAAN,cAAyB,KAAM,CAAC,EAC1BC,EAAN,cAA8BD,CAAW,CAEhD,EChIO,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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e,EACxDd,EAASc,EAAgB,UAAW,CAChC,OAAQA,EAAgB,MAC5B,CAAC,EAEM,EACX,OAASG,EAAO,CACZ,sBAAe,WAAW,kBAAkB,EAC5CC,EAAY,0CAA2C,CACnD,MAAOD,CACX,CAAC,EACM,EACX,CACJ,CAEA,SAASR,EACLR,EACAkB,EACAC,EACM,CACN,IAAIC,EAAY,GACZF,EACAE,GAAa,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", "getLayout", "path", "internalRoutes", "printRoutes", "internalRoutes", "defineRoutes", "appRoutes", "initRouteTargetListener", "RouteTarget", "RouteLink", "errs", "route", "startRouting", "newPage", "currentLayout", "match", "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
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single Page Application routing system with multiple target support.
|
|
3
|
+
* Designed for scenarios where you need:
|
|
4
|
+
* - Multiple navigation targets (main content, modals, sidebars)
|
|
5
|
+
* - Strongly typed route parameters
|
|
6
|
+
* - History management with back/forward support
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Configure routes
|
|
10
|
+
* const routes = [
|
|
11
|
+
* { name: 'user', path: '/users/:id' }, // String parameter
|
|
12
|
+
* { name: 'order', path: '/orders/;orderId' }, // Number parameter
|
|
13
|
+
* { name: 'modal', path: '/detail/:id', target: 'modal' } // Custom target
|
|
14
|
+
* ];
|
|
15
|
+
*/
|
|
16
|
+
import { type Route, type NavigateOptions } from './types';
|
|
17
|
+
export declare const internalRoutes: Route[];
|
|
18
|
+
export declare const MyData: {
|
|
19
|
+
routes: any[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Debug helper to print all registered routes to console.
|
|
23
|
+
*/
|
|
24
|
+
export declare function printRoutes(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Registers application routes with the router.
|
|
27
|
+
* Call this at application startup before routing begins.
|
|
28
|
+
*
|
|
29
|
+
* @param appRoutes - Array of route configurations
|
|
30
|
+
* @throws Error if referenced components are not registered
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const routes: Route[] = [
|
|
34
|
+
* { name: 'home', path: '/', componentTagName: 'app-home' },
|
|
35
|
+
* { name: 'user', path: '/users/:id', componentTagName: 'user-profile' },
|
|
36
|
+
* { name: 'login', path: '/auth/', componentTagName: 'login-form', layout: 'noauth' }
|
|
37
|
+
* ];
|
|
38
|
+
* defineRoutes(routes);
|
|
39
|
+
*/
|
|
40
|
+
export declare function defineRoutes(appRoutes: Route[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Initializes routing and navigates to the current URL.
|
|
43
|
+
* Call this after DOM is ready and routes are defined.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // In your main application component
|
|
47
|
+
* connectedCallback() {
|
|
48
|
+
* defineRoutes(routes);
|
|
49
|
+
* startRouting();
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
export declare function startRouting(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Navigates to a route by name or URL.
|
|
55
|
+
* Updates browser history and dispatches navigation events.
|
|
56
|
+
*
|
|
57
|
+
* @param routeNameOrUrl - Route name or URL path to navigate to
|
|
58
|
+
* @param options - Navigation options including params and target
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Navigate by route name
|
|
62
|
+
* navigate('user', { params: { id: '123' } });
|
|
63
|
+
*
|
|
64
|
+
* // Navigate by URL
|
|
65
|
+
* navigate('/users/123');
|
|
66
|
+
*
|
|
67
|
+
* // Navigate to specific target
|
|
68
|
+
* navigate('detail', { params: { id: '42' }, target: 'modal' });
|
|
69
|
+
*/
|
|
70
|
+
export declare function navigate(routeNameOrUrl: string, options?: NavigateOptions): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Route, RouteMatchResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Match route by either name or URL pattern
|
|
4
|
+
* @param routes Available routes
|
|
5
|
+
* @param routeNameOrUrl Route name or URL to match
|
|
6
|
+
* @param routeData Optional parameters for named routes
|
|
7
|
+
*/
|
|
8
|
+
export declare function matchRoute(routes: Route[], routeNameOrUrl: string, routeData?: Record<string, string | any>): RouteMatchResult | null;
|
|
9
|
+
/**
|
|
10
|
+
* Find route by name and apply parameters
|
|
11
|
+
* @param routes Available routes
|
|
12
|
+
* @param name Route name to find
|
|
13
|
+
* @param routeData Parameters to apply
|
|
14
|
+
*/
|
|
15
|
+
export declare function findRouteByName(routes: Route[], name: string, routeData?: Record<string, string | any>): RouteMatchResult | null;
|
|
16
|
+
/**
|
|
17
|
+
* Find route matching URL pattern
|
|
18
|
+
* @param routes Available routes
|
|
19
|
+
* @param path URL to match
|
|
20
|
+
*/
|
|
21
|
+
export declare function findRouteByUrl(routes: Route[], path: string): RouteMatchResult | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NavigateRouteEvent } from './NavigateRouteEvent';
|
|
2
|
+
type RouteTargetHandler = (evt: NavigateRouteEvent) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Registers a route target handler.
|
|
5
|
+
* When a navigation event targets this name, the handler is called directly.
|
|
6
|
+
* If a pending event exists for this target, it is replayed immediately.
|
|
7
|
+
*
|
|
8
|
+
* @param name - Target name, or `undefined` for the default (unnamed) target
|
|
9
|
+
* @param handler - Callback that receives the `NavigateRouteEvent`
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* registerRouteTarget('sidebar', (evt) => renderComponent(evt));
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerRouteTarget(name: string | undefined, handler: RouteTargetHandler): void;
|
|
15
|
+
/**
|
|
16
|
+
* Unregisters a previously registered route target handler.
|
|
17
|
+
*
|
|
18
|
+
* @param name - Target name that was passed to `registerRouteTarget`
|
|
19
|
+
*/
|
|
20
|
+
export declare function unregisterRouteTarget(name: string | undefined): void;
|
|
21
|
+
export declare function clearPendingNavigations(): void;
|
|
22
|
+
export declare function initRouteTargetListener(): void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
type WebComponentConstructor = new (...args: any[]) => HTMLElement;
|
|
2
|
+
export declare enum GuardResult {
|
|
3
|
+
/**
|
|
4
|
+
* Handle route without checking more guards.
|
|
5
|
+
*/
|
|
6
|
+
Allow = 0,
|
|
7
|
+
/**
|
|
8
|
+
* Throw a RouteGuardError.
|
|
9
|
+
*/
|
|
10
|
+
Deny = 1,
|
|
11
|
+
/**
|
|
12
|
+
* Resume and check other guards.
|
|
13
|
+
*/
|
|
14
|
+
Continue = 2,
|
|
15
|
+
/**
|
|
16
|
+
* Do not invoke the rooute nor other guards.
|
|
17
|
+
*/
|
|
18
|
+
Stop = 3
|
|
19
|
+
}
|
|
20
|
+
export interface RouteGuard {
|
|
21
|
+
check(route: RouteMatchResult): GuardResult;
|
|
22
|
+
}
|
|
23
|
+
export interface Route {
|
|
24
|
+
name?: string;
|
|
25
|
+
target?: string;
|
|
26
|
+
path: string;
|
|
27
|
+
/**
|
|
28
|
+
* HTML file name (without extension).
|
|
29
|
+
*
|
|
30
|
+
* Define for instance if you have a route that requires a more limited layout. The library
|
|
31
|
+
* will automatically load that HTML file and rewrite URL history so that the correct url is displayed.
|
|
32
|
+
*/
|
|
33
|
+
layout?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Name of the tag for your web component.
|
|
36
|
+
*/
|
|
37
|
+
componentTagName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Guards used to check if this route can be visited.
|
|
40
|
+
*/
|
|
41
|
+
guards?: RouteGuard[];
|
|
42
|
+
component?: WebComponentConstructor;
|
|
43
|
+
}
|
|
44
|
+
export type RouteParamType = string | number;
|
|
45
|
+
export type RouteData = Record<string, RouteParamType>;
|
|
46
|
+
/**
|
|
47
|
+
* Implement to receive typed route parameters via a `routeData` property.
|
|
48
|
+
* RouteTarget assigns `routeData` after element creation but before DOM insertion.
|
|
49
|
+
* Optional since it's not available at construction time.
|
|
50
|
+
*
|
|
51
|
+
* For convention-based usage without undefined checks, skip the interface
|
|
52
|
+
* and declare `routeData` directly on your component.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* class UserProfile extends HTMLElement implements Routable<{ userName: string }> {
|
|
56
|
+
* routeData?: { userName: string };
|
|
57
|
+
* }
|
|
58
|
+
*/
|
|
59
|
+
export interface Routable<T extends RouteData = RouteData> {
|
|
60
|
+
routeData?: T;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Implement to run async initialization before the component is added to the DOM.
|
|
64
|
+
* RouteTarget calls `loadRoute()` and awaits it before inserting the element.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* class OrderDetail extends HTMLElement implements LoadRoute<{ orderId: number }> {
|
|
68
|
+
* async loadRoute(data: { orderId: number }) {
|
|
69
|
+
* this.order = await fetchOrder(data.orderId);
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
73
|
+
export interface LoadRoute<T extends RouteData = RouteData> {
|
|
74
|
+
loadRoute(data: T): void | Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Result from route matching operations.
|
|
78
|
+
* Contains all information needed for navigation and rendering.
|
|
79
|
+
*/
|
|
80
|
+
export type RouteMatchResult = {
|
|
81
|
+
/**
|
|
82
|
+
* Matched route configuration
|
|
83
|
+
*/
|
|
84
|
+
route: Route;
|
|
85
|
+
/**
|
|
86
|
+
* URL segments used for history state
|
|
87
|
+
*/
|
|
88
|
+
urlSegments: string[];
|
|
89
|
+
/**
|
|
90
|
+
* Extracted and type-converted parameters
|
|
91
|
+
*/
|
|
92
|
+
params: RouteData;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Supported types of route segments
|
|
96
|
+
*/
|
|
97
|
+
export type RouteSegmentType = 'string' | 'number' | 'path' | 'regex';
|
|
98
|
+
/**
|
|
99
|
+
* Strongly typed route segment value
|
|
100
|
+
*/
|
|
101
|
+
export interface RouteValue {
|
|
102
|
+
/**
|
|
103
|
+
* Type of parameter for validation
|
|
104
|
+
*/
|
|
105
|
+
type: RouteSegmentType;
|
|
106
|
+
/**
|
|
107
|
+
* Actual parameter value
|
|
108
|
+
*/
|
|
109
|
+
value: any;
|
|
110
|
+
}
|
|
111
|
+
export declare class RouteError extends Error {
|
|
112
|
+
}
|
|
113
|
+
export declare class RouteGuardError extends RouteError {
|
|
114
|
+
isGuard: any;
|
|
115
|
+
}
|
|
116
|
+
export interface NavigateOptions {
|
|
117
|
+
/**
|
|
118
|
+
* Optional parameters when using route name
|
|
119
|
+
*/
|
|
120
|
+
params?: Record<string, string | number>;
|
|
121
|
+
/**
|
|
122
|
+
* override for route's default target
|
|
123
|
+
*/
|
|
124
|
+
target?: string;
|
|
125
|
+
/**
|
|
126
|
+
* When you want to override routes from the globally registered ones.
|
|
127
|
+
*/
|
|
128
|
+
routes?: Route[];
|
|
129
|
+
}
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ArgToken } from "./tokenizer";
|
|
2
|
+
type ClickBinding = {
|
|
3
|
+
path: number[];
|
|
4
|
+
methodName: string;
|
|
5
|
+
argTokens: ArgToken[];
|
|
6
|
+
};
|
|
7
|
+
type BoundBinding = {
|
|
8
|
+
type: 'text';
|
|
9
|
+
node: Node;
|
|
10
|
+
func: (context: Record<string, any>, node: Node) => void;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'attribute';
|
|
13
|
+
element: HTMLElement;
|
|
14
|
+
name: string;
|
|
15
|
+
func: (context: Record<string, any>, element: HTMLElement) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare class BoundNode {
|
|
18
|
+
private readonly root;
|
|
19
|
+
private readonly bindings;
|
|
20
|
+
private readonly clickBindings;
|
|
21
|
+
private readonly component?;
|
|
22
|
+
constructor(root: HTMLElement, bindings: BoundBinding[], clickBindings: ClickBinding[], component?: Record<string, any>);
|
|
23
|
+
render(data: Record<string, any>): HTMLElement;
|
|
24
|
+
private getNodeAtPath;
|
|
25
|
+
}
|
|
26
|
+
export declare function createBluePrint(html: string): Blueprint;
|
|
27
|
+
export declare class Blueprint {
|
|
28
|
+
private readonly template;
|
|
29
|
+
private readonly bindings;
|
|
30
|
+
private readonly clickBindings;
|
|
31
|
+
constructor(htmlOrTemplate: string | HTMLTemplateElement);
|
|
32
|
+
createInstance(component?: Record<string, any>): BoundNode;
|
|
33
|
+
private getRootElement;
|
|
34
|
+
private collectBindings;
|
|
35
|
+
private collectClickBindings;
|
|
36
|
+
private getNodeAtPath;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single step in a property access path
|
|
3
|
+
* Can be either a property name or an array index access
|
|
4
|
+
* @example { type: "property", key: "user" }
|
|
5
|
+
* @example { type: "index", key: "0" }
|
|
6
|
+
*/
|
|
7
|
+
type PathSegment = {
|
|
8
|
+
type: "property" | "index";
|
|
9
|
+
key: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Represents the result of parsing a dot-notation string into path segments
|
|
13
|
+
* Used internally by the parser to break down property access chains including arrays
|
|
14
|
+
* @example [{ type: "property", key: "users" }, { type: "index", key: "0" }, { type: "property", key: "name" }] for "users[0].name"
|
|
15
|
+
*/
|
|
16
|
+
type PropertyPath = PathSegment[];
|
|
17
|
+
/**
|
|
18
|
+
* Function type that accesses nested properties safely from a record
|
|
19
|
+
* Returns undefined if any property in the chain is missing or null/undefined
|
|
20
|
+
* @example
|
|
21
|
+
* const accessor = createAccessor("user.name");
|
|
22
|
+
* const result = accessor(data); // string | undefined
|
|
23
|
+
*/
|
|
24
|
+
type PropertyAccessor<T = unknown> = (record: Record<string, any>) => T | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Parser configuration options for customizing dot-notation parsing behavior
|
|
27
|
+
* Used to modify how the parser handles property paths and edge cases
|
|
28
|
+
* @example { delimiter: ".", escapeChar: "\\" }
|
|
29
|
+
*/
|
|
30
|
+
interface ParserOptions {
|
|
31
|
+
delimiter?: string;
|
|
32
|
+
escapeChar?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parses a dot-notation string with array support into path segments
|
|
36
|
+
* Handles escaped delimiters, array indices, and validates input format
|
|
37
|
+
* @param notation - Notation string with dots and brackets (e.g., "users[0].profile.name")
|
|
38
|
+
* @param options - Parser configuration options
|
|
39
|
+
* @returns Array of path segments for property and array access
|
|
40
|
+
* @example
|
|
41
|
+
* parsePath("user.profile.name") // [{ type: "property", key: "user" }, { type: "property", key: "profile" }, { type: "property", key: "name" }]
|
|
42
|
+
* parsePath("users[0].name") // [{ type: "property", key: "users" }, { type: "index", key: "0" }, { type: "property", key: "name" }]
|
|
43
|
+
* parsePath("data\\.file[1]", { escapeChar: "\\" }) // [{ type: "property", key: "data.file" }, { type: "index", key: "1" }]
|
|
44
|
+
*/
|
|
45
|
+
declare function parsePath(notation: string, options?: ParserOptions): PropertyPath;
|
|
46
|
+
/**
|
|
47
|
+
* Creates an accessor function from a parsed property path with array support
|
|
48
|
+
* The returned function safely navigates nested objects and arrays using the parsed path
|
|
49
|
+
* @param path - Array of path segments to access in sequence
|
|
50
|
+
* @returns Function that takes a record and returns the nested value or undefined
|
|
51
|
+
* @example
|
|
52
|
+
* const path = [{ type: "property", key: "users" }, { type: "index", key: "0" }, { type: "property", key: "name" }];
|
|
53
|
+
* const accessor = createAccessorFromPath(path);
|
|
54
|
+
* accessor({ users: [{ name: "John" }] }) // "John"
|
|
55
|
+
*/
|
|
56
|
+
declare function createAccessorFromPath<T = unknown>(path: PropertyPath): PropertyAccessor<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Main parser function that creates an accessor from notation string with array support
|
|
59
|
+
* Combines path parsing and accessor creation into a single operation
|
|
60
|
+
* @param notation - Notation string with dots and brackets (e.g., "users[0].profile.name")
|
|
61
|
+
* @param options - Parser configuration options
|
|
62
|
+
* @returns Accessor function for the specified property path
|
|
63
|
+
* @example
|
|
64
|
+
* const accessor = createAccessor("user.profile.name");
|
|
65
|
+
* const name = accessor(userData); // safely gets nested property
|
|
66
|
+
*
|
|
67
|
+
* const arrayAccessor = createAccessor("users[0].name");
|
|
68
|
+
* const userName = arrayAccessor(data); // safely accesses array elements
|
|
69
|
+
*
|
|
70
|
+
* const complexAccessor = createAccessor("items[2].meta\\.data.values[1]", { escapeChar: "\\" });
|
|
71
|
+
* const value = complexAccessor(response); // handles escaped dots and nested arrays
|
|
72
|
+
*/
|
|
73
|
+
declare function createAccessor<T = unknown>(notation: string, options?: ParserOptions): PropertyAccessor<T>;
|
|
74
|
+
/**
|
|
75
|
+
* Utility function to test if a property path exists in a record (with array support)
|
|
76
|
+
* Useful for validation before attempting to access nested properties or array elements
|
|
77
|
+
* @param notation - Notation string with dots and brackets to test
|
|
78
|
+
* @param record - Record to test against
|
|
79
|
+
* @param options - Parser configuration options
|
|
80
|
+
* @returns Boolean indicating if the complete path exists
|
|
81
|
+
* @example
|
|
82
|
+
* hasProperty("user.name", data) // true if data.user.name exists
|
|
83
|
+
* hasProperty("users[0].name", data) // true if data.users[0].name exists
|
|
84
|
+
* hasProperty("missing.path", data) // false if any part is undefined
|
|
85
|
+
*/
|
|
86
|
+
declare function hasProperty(notation: string, record: Record<string, any>, options?: ParserOptions): boolean;
|
|
87
|
+
export { createAccessor, createAccessorFromPath, parsePath, hasProperty, type PropertyAccessor, type PropertyPath, type PathSegment, type ParserOptions, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PipeRegistry } from "../pipes";
|
|
2
|
+
export type RenderTemplate = (data: Record<string, any>, component?: any) => string;
|
|
3
|
+
export interface TemplateParserOptions {
|
|
4
|
+
pipeRegistry?: PipeRegistry;
|
|
5
|
+
}
|
|
6
|
+
export declare function compileMustard(template: string, options?: TemplateParserOptions): RenderTemplate;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents different token types that can be identified by the tokenizer
|
|
3
|
+
* @example
|
|
4
|
+
* // Use to classify what kind of syntax element was found
|
|
5
|
+
* const tokenType = TokenType.Constant;
|
|
6
|
+
*/
|
|
7
|
+
export declare enum TokenType {
|
|
8
|
+
Constant = 0,
|
|
9
|
+
FunctionCall = 1,
|
|
10
|
+
Variable = 2,
|
|
11
|
+
Pipe = 3
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents a token with its type and value
|
|
15
|
+
* @example
|
|
16
|
+
* // Creating a token for a number constant
|
|
17
|
+
* const token: Token = { type: TokenType.Constant, value: '42' };
|
|
18
|
+
*/
|
|
19
|
+
export interface Token {
|
|
20
|
+
type: TokenType;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Tokenizes an input string into constants, function calls, and variables
|
|
25
|
+
* @example
|
|
26
|
+
* // Basic usage
|
|
27
|
+
* const tokens = tokenize('myVar.property + func(42)');
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Handling complex expressions
|
|
31
|
+
* const tokens = tokenize('math.sin(angle) + "hello".length');
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Handling pipes
|
|
35
|
+
* const tokens = tokenize('input | transform | display');
|
|
36
|
+
*/
|
|
37
|
+
export declare function tokenize(input: string): Token[];
|
|
38
|
+
/** Functions */
|
|
39
|
+
export type ArgToken = {
|
|
40
|
+
type: 'number';
|
|
41
|
+
value: number;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'string';
|
|
44
|
+
value: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'identifier';
|
|
47
|
+
value: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function tokenizeArgs(input: string): ArgToken[];
|
|
50
|
+
/** For STRING/MUSTACHE */
|
|
51
|
+
export type MustacheTokenType = 'string' | 'mustache';
|
|
52
|
+
/**
|
|
53
|
+
* Represents a token extracted from a template string
|
|
54
|
+
* @typedef {Object} MustahceToken
|
|
55
|
+
* @property {MustacheTokenType} type - Either 'string' for plain text or 'mustache' for mustache expressions
|
|
56
|
+
* @property {string} value - The actual content of the token
|
|
57
|
+
*/
|
|
58
|
+
export interface MustacheToken {
|
|
59
|
+
type: MustacheTokenType;
|
|
60
|
+
value: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Tokenizes a template string into an array of string and mustache tokens
|
|
64
|
+
* @param {string} template - The template string containing text and mustache expressions
|
|
65
|
+
* @returns {MustacheToken[]} An array of tokens representing the parsed template
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // Returns tokens for a simple greeting template
|
|
69
|
+
* tokenizeTemplate("Hello, {{name}}!");
|
|
70
|
+
* // [
|
|
71
|
+
* // { type: 'string', value: 'Hello, ' },
|
|
72
|
+
* // { type: 'mustache', value: '{{name}}' },
|
|
73
|
+
* // { type: 'string', value: '!' }
|
|
74
|
+
* // ]
|
|
75
|
+
*/
|
|
76
|
+
export declare function tokenizeMustache(template: string): MustacheToken[];
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a deeply nested value from an object using a path array.
|
|
3
|
+
* Safely navigates through the object tree, returning undefined if any
|
|
4
|
+
* segment in the path is null or undefined.
|
|
5
|
+
*
|
|
6
|
+
* Used internally by template engines to access data properties,
|
|
7
|
+
* but also useful for general-purpose deep property access.
|
|
8
|
+
*
|
|
9
|
+
* @param path - Array of property names forming the path to the value
|
|
10
|
+
* @param context - The object to resolve the value from
|
|
11
|
+
* @returns The resolved value, or undefined if path cannot be resolved
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Access nested property
|
|
15
|
+
* const user = { address: { city: 'Stockholm' } };
|
|
16
|
+
* const city = resolveValue(['address', 'city'], user);
|
|
17
|
+
* // Returns: 'Stockholm'
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Safe access with missing properties
|
|
21
|
+
* const data = { user: null };
|
|
22
|
+
* const name = resolveValue(['user', 'name'], data);
|
|
23
|
+
* // Returns: undefined (doesn't throw)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Use with template expression paths
|
|
27
|
+
* const path = 'user.profile.avatar'.split('.');
|
|
28
|
+
* const avatar = resolveValue(path, context);
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveValue(path: string[], context: Record<string, any>): any | undefined;
|
|
@@ -0,0 +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 w=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 u=(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 A=c((Pe,ue)=>{ue.exports={greeting:"Hello, {name}!",items:"{count, plural, one {# item} other {# items}}"}});var M=c((Ie,le)=>{le.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((Ae,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 Se={};se(Se,{RelaxError:()=>p,applyPipes:()=>xe,capitalizePipe:()=>L,createPipeRegistry:()=>Z,currencyPipe:()=>H,datePipe:()=>F,daysAgoPipe:()=>U,defaultPipe:()=>z,defaultPipes:()=>G,firstPipe:()=>X,generateSequentialId:()=>Q,joinPipe:()=>O,keysPipe:()=>q,lastPipe:()=>v,lowercasePipe:()=>_,onError:()=>W,piecesPipe:()=>j,reportError:()=>Y,resolveValue:()=>he,shortenPipe:()=>k,ternaryPipe:()=>V,trimPipe:()=>N,uppercasePipe:()=>$});module.exports=ie(Se);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),S=new RegExp(`${K}\\s*\\{([^{}]*)\\}`).exec(a)||new RegExp("other\\s*\\{([^{}]*)\\}").exec(a);return S?S[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 I=ce;var Ce=w({"./locales/en/r-common.json":()=>Promise.resolve().then(()=>u(A())),"./locales/en/r-pipes.json":()=>Promise.resolve().then(()=>u(M())),"./locales/en/r-validation.json":()=>Promise.resolve().then(()=>u(R())),"./locales/sv/r-common.json":()=>Promise.resolve().then(()=>u(b())),"./locales/sv/r-pipes.json":()=>Promise.resolve().then(()=>u(D())),"./locales/sv/r-validation.json":()=>Promise.resolve().then(()=>u(B()))});var me="en",x=me;var ye={},C=null;function l(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 I(o,t,x)}catch{return e}}function h(){return x}function $(e){return String(e).toUpperCase()}function N(e){return String(e).trimEnd().trimStart()}function _(e){return String(e).toLowerCase()}function L(e){let t=String(e);return t.charAt(0).toUpperCase()+t.slice(1)}function k(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?l("r-pipes:today"):o===1?l("r-pipes:yesterday"):l("r-pipes:daysAgo",{count:o})}function j(e){if(e==null)return"n/a";let t=Number(e);return l("r-pipes:pieces",{count:t})}function O(e,t=","){return Array.isArray(e)?e.join(t):e}function X(e){return!Array.isArray(e)||e.length===0?"":e[0]}function v(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",_),e.set("capitalize",L),e.set("trim",N),e.set("shorten",k),e.set("currency",H),e.set("date",F),e.set("daysAgo",U),e.set("pieces",j),e.set("join",O),e.set("first",X),e.set("last",v),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 Ee=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-Ee;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}},E=null;function W(e){E=e}function Y(e,t){let r=new p(e,t);if(E){let n=!1;if(E(r,{suppress(){n=!0}}),n)return null}return r}
|
|
2
|
+
//# sourceMappingURL=index.js.map
|