@krak-stack/registry 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +29 -0
  2. package/dist/components/ui/alert-dialog.d.ts +18 -0
  3. package/dist/components/ui/app-brand.d.ts +26 -0
  4. package/dist/components/ui/app-brand.js +78 -0
  5. package/dist/components/ui/attachment.d.ts +23 -0
  6. package/dist/components/ui/badge.d.ts +7 -0
  7. package/dist/components/ui/button.d.ts +8 -0
  8. package/dist/components/ui/card.d.ts +11 -0
  9. package/dist/components/ui/checkbox.d.ts +3 -0
  10. package/dist/components/ui/code-block.d.ts +14 -0
  11. package/dist/components/ui/code-block.js +224 -0
  12. package/dist/components/ui/command.d.ts +18 -0
  13. package/dist/components/ui/copy-button.d.ts +18 -0
  14. package/dist/components/ui/copy-button.js +133 -0
  15. package/dist/components/ui/data-table.d.ts +264 -0
  16. package/dist/components/ui/data-table.js +3594 -0
  17. package/dist/components/ui/dialog.d.ts +13 -0
  18. package/dist/components/ui/dropdown-menu.d.ts +29 -0
  19. package/dist/components/ui/editing-locale-switcher.d.ts +7 -0
  20. package/dist/components/ui/editing-locale-switcher.js +626 -0
  21. package/dist/components/ui/effect-form.d.ts +137 -0
  22. package/dist/components/ui/effect-form.js +2330 -0
  23. package/dist/components/ui/field.d.ts +24 -0
  24. package/dist/components/ui/file-picker.d.ts +30 -0
  25. package/dist/components/ui/file-picker.js +811 -0
  26. package/dist/components/ui/form.d.ts +402 -0
  27. package/dist/components/ui/form.js +2245 -0
  28. package/dist/components/ui/google-map.d.ts +103 -0
  29. package/dist/components/ui/google-map.js +754 -0
  30. package/dist/components/ui/icon-input.d.ts +9 -0
  31. package/dist/components/ui/icon-input.js +971 -0
  32. package/dist/components/ui/input-group.d.ts +17 -0
  33. package/dist/components/ui/input.d.ts +3 -0
  34. package/dist/components/ui/label.d.ts +3 -0
  35. package/dist/components/ui/loading.d.ts +7 -0
  36. package/dist/components/ui/loading.js +467 -0
  37. package/dist/components/ui/locale-switcher.d.ts +7 -0
  38. package/dist/components/ui/locale-switcher.js +632 -0
  39. package/dist/components/ui/pagination.d.ts +43 -0
  40. package/dist/components/ui/pagination.js +787 -0
  41. package/dist/components/ui/popover.d.ts +9 -0
  42. package/dist/components/ui/scroll-area.d.ts +4 -0
  43. package/dist/components/ui/search-menu.d.ts +34 -0
  44. package/dist/components/ui/search-menu.js +839 -0
  45. package/dist/components/ui/select.d.ts +15 -0
  46. package/dist/components/ui/separator.d.ts +3 -0
  47. package/dist/components/ui/sheet.d.ts +14 -0
  48. package/dist/components/ui/sidebar-layout.d.ts +29 -0
  49. package/dist/components/ui/sidebar-layout.js +755 -0
  50. package/dist/components/ui/sidebar.d.ts +63 -0
  51. package/dist/components/ui/skeleton.d.ts +2 -0
  52. package/dist/components/ui/stats-card.d.ts +12 -0
  53. package/dist/components/ui/stats-card.js +125 -0
  54. package/dist/components/ui/table.d.ts +10 -0
  55. package/dist/components/ui/textarea.d.ts +3 -0
  56. package/dist/components/ui/theme-switcher.d.ts +29 -0
  57. package/dist/components/ui/theme-switcher.js +775 -0
  58. package/dist/components/ui/tooltip.d.ts +6 -0
  59. package/dist/components/ui/virtualized-combobox.d.ts +54 -0
  60. package/dist/components/ui/virtualized-combobox.js +821 -0
  61. package/dist/hooks/use-mobile.d.ts +1 -0
  62. package/dist/lib/query.d.ts +49 -0
  63. package/dist/lib/utils.d.ts +2 -0
  64. package/dist/paraglide/runtime.d.ts +978 -0
  65. package/dist/services/embedding.d.ts +2 -0
  66. package/dist/services/embedding.js +23 -0
  67. package/dist/services/notification/channels/index.d.ts +22 -0
  68. package/dist/services/notification/channels/index.js +11 -0
  69. package/dist/services/notification/channels/ses/index.d.ts +51 -0
  70. package/dist/services/notification/channels/ses/index.js +145 -0
  71. package/dist/services/notification/channels/ses/schema.d.ts +13 -0
  72. package/dist/services/notification/channels/ses/schema.js +35 -0
  73. package/dist/services/notification/index.d.ts +15 -0
  74. package/dist/services/notification/index.js +67 -0
  75. package/dist/services/notification/schema.d.ts +10 -0
  76. package/dist/services/notification/schema.js +30 -0
  77. package/dist/services/opentelemetry.d.ts +8 -0
  78. package/dist/services/opentelemetry.js +23 -0
  79. package/dist/services/s3/index.d.ts +62 -0
  80. package/dist/services/s3/index.js +208 -0
  81. package/dist/services/s3/schema.d.ts +18 -0
  82. package/dist/services/s3/schema.js +37 -0
  83. package/package.json +218 -0
  84. package/tailwind.css +1 -0
@@ -0,0 +1,978 @@
1
+ import "@inlang/paraglide-js/urlpattern-polyfill";
2
+ /**
3
+ * The project's base locale.
4
+ *
5
+ * @example
6
+ * if (locale === baseLocale) {
7
+ * // do something
8
+ * }
9
+ */
10
+ export declare const baseLocale = "en";
11
+ /**
12
+ * The project's locales that have been specified in the settings.
13
+ *
14
+ * @example
15
+ * if (locales.includes(userSelectedLocale) === false) {
16
+ * throw new Error('Locale is not available');
17
+ * }
18
+ */
19
+ export declare const locales: readonly ["en", "fr"];
20
+ /** @type {string} */
21
+ export declare const cookieName: string;
22
+ /** @type {number} */
23
+ export declare const cookieMaxAge: number;
24
+ /** @type {string} */
25
+ export declare const cookieDomain: string;
26
+ /** @type {string} */
27
+ export declare const localStorageKey: string;
28
+ /**
29
+ * @type {Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>}
30
+ */
31
+ export declare const strategy: Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>;
32
+ /**
33
+ * Route-level strategy overrides.
34
+ *
35
+ * `match` uses URLPattern syntax.
36
+ *
37
+ * @type {Array<{
38
+ * match: string;
39
+ * strategy?: Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>;
40
+ * exclude?: boolean;
41
+ * }>}
42
+ */
43
+ export declare const routeStrategies: Array<{
44
+ match: string;
45
+ strategy?: Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>;
46
+ exclude?: boolean;
47
+ }>;
48
+ /**
49
+ * The used URL patterns.
50
+ *
51
+ * @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>}
52
+ */
53
+ export declare const urlPatterns: Array<{
54
+ pattern: string;
55
+ localized: Array<[Locale, string]>;
56
+ }>;
57
+ /**
58
+ * Returns the strategy to use for a specific URL.
59
+ *
60
+ * If no route strategy matches (or the matching rule is `exclude: true`),
61
+ * the global strategy is returned.
62
+ *
63
+ * @param {string | URL} url
64
+ * @returns {typeof strategy}
65
+ */
66
+ export declare function getStrategyForUrl(url: string | URL): typeof strategy;
67
+ /**
68
+ * Returns whether the given URL is excluded from middleware i18n processing.
69
+ *
70
+ * @param {string | URL} url
71
+ * @returns {boolean}
72
+ */
73
+ export declare function isExcludedByRouteStrategy(url: string | URL): boolean;
74
+ export type ParaglideAsyncLocalStorage = {
75
+ getStore(): {
76
+ locale?: Locale;
77
+ origin?: string;
78
+ messageCalls?: Set<string>;
79
+ } | undefined;
80
+ run: (store: {
81
+ locale?: Locale;
82
+ origin?: string;
83
+ messageCalls?: Set<string>;
84
+ }, cb: any) => any;
85
+ };
86
+ /**
87
+ * @typedef {{
88
+ * getStore(): {
89
+ * locale?: Locale,
90
+ * origin?: string,
91
+ * messageCalls?: Set<string>
92
+ * } | undefined,
93
+ * run: (store: { locale?: Locale, origin?: string, messageCalls?: Set<string>},
94
+ * cb: any) => any
95
+ * }} ParaglideAsyncLocalStorage
96
+ */
97
+ /**
98
+ * Server side async local storage that is set by `serverMiddleware()`.
99
+ *
100
+ * The variable is used to retrieve the locale and origin in a server-side
101
+ * rendering context without effecting other requests.
102
+ *
103
+ * @type {ParaglideAsyncLocalStorage | undefined}
104
+ */
105
+ export declare let serverAsyncLocalStorage: ParaglideAsyncLocalStorage | undefined;
106
+ export declare const disableAsyncLocalStorage = false;
107
+ export declare const experimentalMiddlewareLocaleSplitting = false;
108
+ export declare const isServer: boolean;
109
+ /** @type {Locale | undefined} */
110
+ export declare const experimentalStaticLocale: Locale | undefined;
111
+ /**
112
+ * Sets the server side async local storage.
113
+ *
114
+ * The function is needed because the `runtime.js` file
115
+ * must define the `serverAsyncLocalStorage` variable to
116
+ * avoid a circular import between `runtime.js` and
117
+ * `server.js` files.
118
+ *
119
+ * @param {ParaglideAsyncLocalStorage | undefined} value
120
+ */
121
+ export declare function overwriteServerAsyncLocalStorage(value: ParaglideAsyncLocalStorage | undefined): void;
122
+ /**
123
+ * Get the current locale.
124
+ *
125
+ * The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.)
126
+ * in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage
127
+ * which is set by the `paraglideMiddleware()`.
128
+ *
129
+ * @see https://paraglidejs.com/strategy - Configure locale detection strategies
130
+ *
131
+ * @example
132
+ * if (getLocale() === 'de') {
133
+ * console.log('Germany 🇩🇪');
134
+ * } else if (getLocale() === 'nl') {
135
+ * console.log('Netherlands 🇳🇱');
136
+ * }
137
+ *
138
+ * @returns {Locale} The current locale.
139
+ */
140
+ export declare let getLocale: () => Locale;
141
+ /**
142
+ * Resolve locale for a given URL using route-aware strategies.
143
+ *
144
+ * @param {string | URL} url
145
+ * @returns {Locale}
146
+ */
147
+ export declare function getLocaleForUrl(url: string | URL): Locale;
148
+ /**
149
+ * Overwrite the `getLocale()` function.
150
+ *
151
+ * Use this function to overwrite how the locale is resolved. This is useful
152
+ * for custom locale resolution or advanced use cases like SSG with concurrent rendering.
153
+ *
154
+ * @see https://paraglidejs.com/strategy
155
+ *
156
+ * @example
157
+ * overwriteGetLocale(() => {
158
+ * return Cookies.get('locale') ?? baseLocale
159
+ * });
160
+ *
161
+ * @param {() => Locale} fn - The new implementation for `getLocale()`.
162
+ */
163
+ export declare const overwriteGetLocale: (fn: () => Locale) => void;
164
+ /**
165
+ * Get writing direction for a locale.
166
+ *
167
+ * Uses `Intl.Locale` text info when available and falls back to a
168
+ * language-based RTL check for runtimes without `getTextInfo()`.
169
+ *
170
+ * @example
171
+ * getTextDirection(); // "ltr" or "rtl" for current locale
172
+ * getTextDirection("ar"); // "rtl"
173
+ * getTextDirection("en"); // "ltr"
174
+ *
175
+ * @param {string} [locale] - Target locale. If not provided, uses `getLocale()`
176
+ * @returns {"ltr" | "rtl"}
177
+ */
178
+ export declare function getTextDirection(locale?: string): "ltr" | "rtl";
179
+ export type SetLocaleFn = (newLocale: Locale, options?: {
180
+ reload?: boolean;
181
+ }) => void | Promise<void>;
182
+ /**
183
+ * @typedef {(newLocale: Locale, options?: { reload?: boolean }) => void | Promise<void>} SetLocaleFn
184
+ */
185
+ /**
186
+ * Set the locale.
187
+ *
188
+ * Updates the locale using your configured strategies (cookie, localStorage, URL, etc.).
189
+ * By default, this reloads the page on the client to reflect the new locale. Reloading
190
+ * can be disabled by passing `reload: false` as an option, but you'll need to ensure
191
+ * the UI updates to reflect the new locale.
192
+ *
193
+ * If any custom strategy's `setLocale` function is async, then this function
194
+ * will become async as well.
195
+ *
196
+ * @see https://paraglidejs.com/strategy
197
+ *
198
+ * @example
199
+ * setLocale('en');
200
+ *
201
+ * @example
202
+ * setLocale('en', { reload: false });
203
+ *
204
+ * @type {SetLocaleFn}
205
+ */
206
+ export declare let setLocale: SetLocaleFn;
207
+ /**
208
+ * Overwrite the `setLocale()` function.
209
+ *
210
+ * Use this function to overwrite how the locale is set. For example,
211
+ * modify a cookie, env variable, or a user's preference.
212
+ *
213
+ * @example
214
+ * overwriteSetLocale((newLocale) => {
215
+ * // set the locale in a cookie
216
+ * return Cookies.set('locale', newLocale)
217
+ * });
218
+ *
219
+ * @param {SetLocaleFn} fn
220
+ */
221
+ export declare const overwriteSetLocale: (fn: SetLocaleFn) => void;
222
+ /**
223
+ * The origin of the current URL.
224
+ *
225
+ * Defaults to "http://y.com" in non-browser environments. If this
226
+ * behavior is not desired, the implementation can be overwritten
227
+ * by `overwriteGetUrlOrigin()`.
228
+ *
229
+ * @type {() => string}
230
+ */
231
+ export declare let getUrlOrigin: () => string;
232
+ /**
233
+ * Overwrite the getUrlOrigin function.
234
+ *
235
+ * Use this function in server environments to
236
+ * define how the URL origin is resolved.
237
+ *
238
+ * @param {() => string} fn - The new implementation for `getUrlOrigin()`.
239
+ */
240
+ export declare let overwriteGetUrlOrigin: (fn: () => string) => void;
241
+ /**
242
+ * Coerces a locale-like string to the canonical locale value used by the runtime.
243
+ *
244
+ * @param {unknown} value
245
+ * @returns {Locale | undefined}
246
+ */
247
+ export declare function toLocale(value: unknown): Locale | undefined;
248
+ /**
249
+ * Check if something is an available locale with the canonical project casing.
250
+ *
251
+ * @example
252
+ * if (isLocale(params.locale)) {
253
+ * setLocale(params.locale);
254
+ * } else {
255
+ * setLocale('en');
256
+ * }
257
+ *
258
+ * Use `toLocale()` when you want case-insensitive matching and canonicalization.
259
+ *
260
+ * @param {unknown} locale
261
+ * @returns {locale is Locale}
262
+ */
263
+ export declare function isLocale(locale: unknown): locale is Locale;
264
+ /**
265
+ * Asserts that the input can be normalized to a locale.
266
+ *
267
+ * @param {unknown} input - The input to check.
268
+ * @returns {Locale} The input normalized to a Locale.
269
+ * @throws {Error} If the input is not a locale.
270
+ */
271
+ export declare function assertIsLocale(input: unknown): Locale;
272
+ export type ExtractLocaleFromRequestOptions = {
273
+ /**
274
+ * - Effective request URL to use for route matching and locale detection with the URL strategy.
275
+ */
276
+ effectiveRequestUrl?: string | URL;
277
+ };
278
+ /**
279
+ * @typedef {object} ExtractLocaleFromRequestOptions
280
+ * @property {string | URL} [effectiveRequestUrl] - Effective request URL to use for route matching and locale detection with the URL strategy.
281
+ */
282
+ /**
283
+ * Extracts a locale from a request.
284
+ *
285
+ * Use the function on the server to extract the locale
286
+ * from a request.
287
+ *
288
+ * The function goes through the strategies in the order
289
+ * they are defined. If a strategy returns an invalid locale,
290
+ * it will fall back to the next strategy.
291
+ *
292
+ * Note: Custom server strategies are not supported in this synchronous version.
293
+ * Use `extractLocaleFromRequestAsync` if you need custom server strategies with async getLocale methods.
294
+ *
295
+ * @example
296
+ * const locale = extractLocaleFromRequest(request);
297
+ *
298
+ * @param {Request} request
299
+ * @param {ExtractLocaleFromRequestOptions} [options]
300
+ * @returns {Locale}
301
+ */
302
+ export declare const extractLocaleFromRequest: (request: Request, options?: ExtractLocaleFromRequestOptions) => Locale;
303
+ /**
304
+ * Extracts a locale from a request using the provided strategy order.
305
+ *
306
+ * @param {Request} request
307
+ * @param {typeof strategy} strategies
308
+ * @param {string | URL} [url]
309
+ * @returns {Locale}
310
+ */
311
+ export declare const extractLocaleFromRequestWithStrategies: (request: Request, strategies: typeof strategy, url?: string | URL) => Locale;
312
+ /**
313
+ * Asynchronously extracts a locale from a request.
314
+ *
315
+ * This function supports async custom server strategies, unlike the synchronous
316
+ * `extractLocaleFromRequest`. Use this function when you have custom server strategies
317
+ * that need to perform asynchronous operations (like database calls) in their getLocale method.
318
+ *
319
+ * The function first processes any custom server strategies asynchronously, then falls back
320
+ * to the synchronous `extractLocaleFromRequest` for all other strategies.
321
+ *
322
+ * @see {@link https://github.com/opral/inlang-paraglide-js/issues/527#issuecomment-2978151022}
323
+ *
324
+ * @example
325
+ * // Basic usage
326
+ * const locale = await extractLocaleFromRequestAsync(request);
327
+ *
328
+ * @example
329
+ * // With custom async server strategy
330
+ * defineCustomServerStrategy("custom-database", {
331
+ * getLocale: async (request) => {
332
+ * const userId = extractUserIdFromRequest(request);
333
+ * return await getUserLocaleFromDatabase(userId);
334
+ * }
335
+ * });
336
+ *
337
+ * const locale = await extractLocaleFromRequestAsync(request);
338
+ *
339
+ * @param {Request} request - The request object to extract the locale from.
340
+ * @param {{ effectiveRequestUrl?: string | URL }} [options] - Effective request URL to use for route matching and locale detection with the URL strategy.
341
+ * @returns {Promise<Locale>} The extracted locale.
342
+ */
343
+ export declare const extractLocaleFromRequestAsync: (request: Request, options?: {
344
+ effectiveRequestUrl?: string | URL;
345
+ }) => Promise<Locale>;
346
+ /**
347
+ * Extracts a cookie from the document.
348
+ *
349
+ * Will return undefined if the document is not available or if the cookie is not set.
350
+ * The `document` object is not available in server-side rendering, so this function should not be called in that context.
351
+ *
352
+ * @returns {Locale | undefined}
353
+ */
354
+ export declare function extractLocaleFromCookie(): Locale | undefined;
355
+ /**
356
+ * Extracts a locale from the accept-language header.
357
+ *
358
+ * Use the function on the server to extract the locale
359
+ * from the accept-language header that is sent by the client.
360
+ *
361
+ * @example
362
+ * const locale = extractLocaleFromHeader(request);
363
+ *
364
+ * @param {Request} request - The request object to extract the locale from.
365
+ * @returns {Locale | undefined} The negotiated preferred language.
366
+ */
367
+ export declare function extractLocaleFromHeader(request: Request): Locale | undefined;
368
+ /**
369
+ * Negotiates a preferred language from navigator.languages.
370
+ *
371
+ * Use the function on the client to extract the locale
372
+ * from the navigator.languages array.
373
+ *
374
+ * @example
375
+ * const locale = extractLocaleFromNavigator();
376
+ *
377
+ * @returns {Locale | undefined}
378
+ */
379
+ export declare function extractLocaleFromNavigator(): Locale | undefined;
380
+ /**
381
+ * Extracts the locale from a given URL using native URLPattern.
382
+ *
383
+ * The built-in default `/:locale/...` routing is case-insensitive because it
384
+ * canonicalizes the first path segment with `toLocale()`. Custom `urlPatterns`
385
+ * keep URLPattern's normal exact matching semantics for path segments.
386
+ *
387
+ * @param {URL|string} url - The full URL from which to extract the locale.
388
+ * @returns {Locale|undefined} The extracted locale, or undefined if no locale is found.
389
+ */
390
+ export declare function extractLocaleFromUrl(url: URL | string): Locale | undefined;
391
+ /**
392
+ * Lower-level URL localization function, primarily used in server contexts.
393
+ *
394
+ * This function is designed for server-side usage where you need precise control
395
+ * over URL localization, such as in middleware or request handlers. It works with
396
+ * URL objects and always returns absolute URLs.
397
+ *
398
+ * For client-side UI components, use `localizeHref()` instead, which provides
399
+ * a more convenient API with relative paths and automatic locale detection.
400
+ *
401
+ * @see https://paraglidejs.com/i18n-routing
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * // Server middleware example
406
+ * app.use((req, res, next) => {
407
+ * const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);
408
+ * const localized = localizeUrl(url, { locale: "de" });
409
+ *
410
+ * if (localized.href !== url.href) {
411
+ * return res.redirect(localized.href);
412
+ * }
413
+ * next();
414
+ * });
415
+ * ```
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * // Using with URL patterns
420
+ * const url = new URL("https://example.com/about");
421
+ * localizeUrl(url, { locale: "de" });
422
+ * // => URL("https://example.com/de/about")
423
+ *
424
+ * // Using with domain-based localization
425
+ * const url = new URL("https://example.com/store");
426
+ * localizeUrl(url, { locale: "de" });
427
+ * // => URL("https://de.example.com/store")
428
+ * ```
429
+ *
430
+ * @param {string | URL} url - The URL to localize. If string, must be absolute.
431
+ * @param {object} [options] - Options for localization
432
+ * @param {Locale} [options.locale] - Target locale. If not provided, uses getLocale()
433
+ * @returns {URL} The localized URL, always absolute
434
+ */
435
+ export declare function localizeUrl(url: string | URL, options?: {
436
+ locale?: Locale;
437
+ }): URL;
438
+ /**
439
+ * Low-level URL de-localization function, primarily used in server contexts.
440
+ *
441
+ * This function is designed for server-side usage where you need precise control
442
+ * over URL de-localization, such as in middleware or request handlers. It works with
443
+ * URL objects and always returns absolute URLs.
444
+ *
445
+ * For client-side UI components, use `deLocalizeHref()` instead, which provides
446
+ * a more convenient API with relative paths.
447
+ *
448
+ * @see https://paraglidejs.com/i18n-routing
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * // Server middleware example
453
+ * app.use((req, res, next) => {
454
+ * const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);
455
+ * const baseUrl = deLocalizeUrl(url);
456
+ *
457
+ * // Store the base URL for later use
458
+ * req.baseUrl = baseUrl;
459
+ * next();
460
+ * });
461
+ * ```
462
+ *
463
+ * @example
464
+ * ```typescript
465
+ * // Using with URL patterns
466
+ * const url = new URL("https://example.com/de/about");
467
+ * deLocalizeUrl(url); // => URL("https://example.com/about")
468
+ *
469
+ * // Using with domain-based localization
470
+ * const url = new URL("https://de.example.com/store");
471
+ * deLocalizeUrl(url); // => URL("https://example.com/store")
472
+ * ```
473
+ *
474
+ * @param {string | URL} url - The URL to de-localize. If string, must be absolute.
475
+ * @returns {URL} The de-localized URL, always absolute
476
+ */
477
+ export declare function deLocalizeUrl(url: string | URL): URL;
478
+ /**
479
+ * Aggregates named groups from various parts of the URLPattern match result.
480
+ *
481
+ *
482
+ * @param {any} match - The URLPattern match result object.
483
+ * @returns {Record<string, string | null | undefined>} An object containing all named groups from the match.
484
+ */
485
+ export declare function aggregateGroups(match: any): Record<string, string | null | undefined>;
486
+ export type ShouldRedirectServerInput = {
487
+ request: Request;
488
+ /**
489
+ * - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
490
+ */
491
+ effectiveRequestUrl?: string | URL;
492
+ locale?: Locale;
493
+ };
494
+ export type ShouldRedirectClientInput = {
495
+ request?: undefined;
496
+ url?: string | URL;
497
+ locale?: Locale;
498
+ };
499
+ export type ShouldRedirectInput = ShouldRedirectServerInput | ShouldRedirectClientInput;
500
+ export type ShouldRedirectResult = {
501
+ /**
502
+ * - Indicates whether the consumer should perform a redirect.
503
+ */
504
+ shouldRedirect: boolean;
505
+ /**
506
+ * - Locale resolved using the configured strategies.
507
+ */
508
+ locale: Locale;
509
+ /**
510
+ * - Destination URL when a redirect is required.
511
+ */
512
+ redirectUrl: URL | undefined;
513
+ };
514
+ /**
515
+ * @typedef {object} ShouldRedirectServerInput
516
+ * @property {Request} request
517
+ * @property {string | URL} [effectiveRequestUrl] - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
518
+ * @property {Locale} [locale]
519
+ *
520
+ * @typedef {object} ShouldRedirectClientInput
521
+ * @property {undefined} [request]
522
+ * @property {string | URL} [url]
523
+ * @property {Locale} [locale]
524
+ *
525
+ * @typedef {ShouldRedirectServerInput | ShouldRedirectClientInput} ShouldRedirectInput
526
+ *
527
+ * @typedef {object} ShouldRedirectResult
528
+ * @property {boolean} shouldRedirect - Indicates whether the consumer should perform a redirect.
529
+ * @property {Locale} locale - Locale resolved using the configured strategies.
530
+ * @property {URL | undefined} redirectUrl - Destination URL when a redirect is required.
531
+ */
532
+ /**
533
+ * Determines whether a redirect is required to align the current URL with the active locale.
534
+ *
535
+ * This helper mirrors the logic that powers `paraglideMiddleware`, but works in both server
536
+ * and client environments. It evaluates the configured strategies in order, computes the
537
+ * canonical localized URL, and reports when the current URL does not match.
538
+ *
539
+ * When called in the browser without arguments, the current `window.location.href` is used.
540
+ *
541
+ * @see https://paraglidejs.com/i18n-routing#redirects
542
+ *
543
+ * @example
544
+ * // Client side usage (e.g. TanStack Router beforeLoad hook)
545
+ * async function beforeLoad({ location }) {
546
+ * const decision = await shouldRedirect({ url: location.href });
547
+ *
548
+ * if (decision.shouldRedirect) {
549
+ * throw redirect({ to: decision.redirectUrl.href });
550
+ * }
551
+ * }
552
+ *
553
+ * @example
554
+ * // Server side usage with a Request
555
+ * export async function handle(request) {
556
+ * const decision = await shouldRedirect({ request });
557
+ *
558
+ * if (decision.shouldRedirect) {
559
+ * return Response.redirect(decision.redirectUrl, 307);
560
+ * }
561
+ *
562
+ * return render(request, decision.locale);
563
+ * }
564
+ *
565
+ * @example
566
+ * // Server side usage behind a proxy where request.url is not public-facing
567
+ * export async function handle(request) {
568
+ * const effectiveRequestUrl = new URL(request.url);
569
+ * effectiveRequestUrl.protocol = "https:";
570
+ * effectiveRequestUrl.host = "example.com";
571
+ *
572
+ * const decision = await shouldRedirect({
573
+ * request,
574
+ * effectiveRequestUrl,
575
+ * });
576
+ *
577
+ * if (decision.shouldRedirect) {
578
+ * return Response.redirect(decision.redirectUrl, 307);
579
+ * }
580
+ * }
581
+ *
582
+ * @param {ShouldRedirectInput} [input]
583
+ * @returns {Promise<ShouldRedirectResult>}
584
+ */
585
+ export declare function shouldRedirect(input?: ShouldRedirectInput): Promise<ShouldRedirectResult>;
586
+ /**
587
+ * High-level URL localization function optimized for client-side UI usage.
588
+ *
589
+ * This is a convenience wrapper around `localizeUrl()` that provides features
590
+ * needed in UI:
591
+ *
592
+ * - Accepts relative paths (e.g., "/about")
593
+ * - Returns relative paths when possible
594
+ * - Automatically detects current locale if not specified
595
+ * - Handles string input/output instead of URL objects
596
+ *
597
+ * @see https://paraglidejs.com/i18n-routing
598
+ *
599
+ * @example
600
+ * ```typescript
601
+ * // In a React/Vue/Svelte component
602
+ * const NavLink = ({ href }) => {
603
+ * // Automatically uses current locale, keeps path relative
604
+ * return <a href={localizeHref(href)}>...</a>;
605
+ * };
606
+ *
607
+ * // Examples:
608
+ * localizeHref("/about")
609
+ * // => "/de/about" (if current locale is "de")
610
+ * localizeHref("/store", { locale: "fr" })
611
+ * // => "/fr/store" (explicit locale)
612
+ *
613
+ * // Cross-origin links remain absolute
614
+ * localizeHref("https://other-site.com/about")
615
+ * // => "https://other-site.com/de/about"
616
+ * ```
617
+ *
618
+ * For server-side URL localization (e.g., in middleware), use `localizeUrl()`
619
+ * which provides more precise control over URL handling.
620
+ *
621
+ * @param {string} href - The href to localize (can be relative or absolute)
622
+ * @param {object} [options] - Options for localization
623
+ * @param {Locale} [options.locale] - Target locale. If not provided, uses `getLocale()`
624
+ * @returns {string} The localized href, relative if input was relative
625
+ */
626
+ export declare function localizeHref(href: string, options?: {
627
+ locale?: Locale;
628
+ }): string;
629
+ /**
630
+ * High-level URL de-localization function optimized for client-side UI usage.
631
+ *
632
+ * This is a convenience wrapper around `deLocalizeUrl()` that provides features
633
+ * needed in the UI:
634
+ *
635
+ * - Accepts relative paths (e.g., "/de/about")
636
+ * - Returns relative paths when possible
637
+ * - Handles string input/output instead of URL objects
638
+ *
639
+ * @see https://paraglidejs.com/i18n-routing
640
+ *
641
+ * @example
642
+ * ```typescript
643
+ * // In a React/Vue/Svelte component
644
+ * const LocaleSwitcher = ({ href }) => {
645
+ * // Remove locale prefix before switching
646
+ * const baseHref = deLocalizeHref(href);
647
+ * return locales.map(locale =>
648
+ * <a href={localizeHref(baseHref, { locale })}>
649
+ * Switch to {locale}
650
+ * </a>
651
+ * );
652
+ * };
653
+ *
654
+ * // Examples:
655
+ * deLocalizeHref("/de/about") // => "/about"
656
+ * deLocalizeHref("/fr/store") // => "/store"
657
+ *
658
+ * // Cross-origin links remain absolute
659
+ * deLocalizeHref("https://example.com/de/about")
660
+ * // => "https://example.com/about"
661
+ * ```
662
+ *
663
+ * For server-side URL de-localization (e.g., in middleware), use `deLocalizeUrl()`
664
+ * which provides more precise control over URL handling.
665
+ *
666
+ * @param {string} href - The href to de-localize (can be relative or absolute)
667
+ * @returns {string} The de-localized href, relative if input was relative
668
+ */
669
+ export declare function deLocalizeHref(href: string): string;
670
+ /**
671
+ * @param {string} safeModuleId
672
+ * @param {Locale} locale
673
+ */
674
+ export declare function trackMessageCall(safeModuleId: string, locale: Locale): void;
675
+ /**
676
+ * Generates localized URL variants for all provided URLs based on your configured locales and URL patterns.
677
+ *
678
+ * This function is essential for Static Site Generation (SSG) where you need to tell your framework
679
+ * which pages to pre-render at build time. It's also useful for generating sitemaps and
680
+ * `<link rel="alternate" hreflang>` tags for SEO.
681
+ *
682
+ * The function respects your `urlPatterns` configuration - if you have translated pathnames
683
+ * (e.g., `/about` → `/ueber-uns` for German), it will generate the correct localized paths.
684
+ *
685
+ * @see https://paraglidejs.com/static-site-generation
686
+ *
687
+ * @example
688
+ * // Basic usage - generate all locale variants for a list of paths
689
+ * const localizedUrls = generateStaticLocalizedUrls([
690
+ * "/",
691
+ * "/about",
692
+ * "/blog/post-1",
693
+ * ]);
694
+ * // Returns URL objects for each locale:
695
+ * // ["/en/", "/de/", "/en/about", "/de/about", "/en/blog/post-1", "/de/blog/post-1"]
696
+ *
697
+ * @example
698
+ * // Use with framework SSG APIs
699
+ * // SvelteKit
700
+ * export function entries() {
701
+ * const paths = ["/", "/about", "/contact"];
702
+ * return generateStaticLocalizedUrls(paths).map(url => ({
703
+ * locale: extractLocaleFromUrl(url)
704
+ * }));
705
+ * }
706
+ *
707
+ * @example
708
+ * // Sitemap generation
709
+ * const allPages = ["/", "/about", "/blog"];
710
+ * const sitemapUrls = generateStaticLocalizedUrls(allPages);
711
+ *
712
+ * @param {(string | URL)[]} urls - List of canonical URLs or paths to generate localized versions for.
713
+ * Can be absolute URLs (`https://example.com/about`) or paths (`/about`).
714
+ * Paths are resolved against `http://localhost` internally.
715
+ * @returns {URL[]} Array of URL objects representing all localized variants.
716
+ * The order follows each input URL with all its locale variants before moving to the next URL.
717
+ */
718
+ export declare function generateStaticLocalizedUrls(urls: (string | URL)[]): URL[];
719
+ export type BuiltInStrategy = "cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage";
720
+ export type CustomStrategy = `custom_${string}`;
721
+ export type Strategy = BuiltInStrategy | CustomStrategy;
722
+ export type Strategies = Array<Strategy>;
723
+ export type CustomServerStrategyHandler = {
724
+ getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined);
725
+ };
726
+ export type CustomClientStrategyHandler = {
727
+ getLocale: () => Promise<string | undefined> | (string | undefined);
728
+ setLocale: (locale: string) => Promise<void> | void;
729
+ };
730
+ /**
731
+ * @typedef {"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage"} BuiltInStrategy
732
+ */
733
+ /**
734
+ * @typedef {`custom_${string}`} CustomStrategy
735
+ */
736
+ /**
737
+ * @typedef {BuiltInStrategy | CustomStrategy} Strategy
738
+ */
739
+ /**
740
+ * @typedef {Array<Strategy>} Strategies
741
+ */
742
+ /**
743
+ * @typedef {{ getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined) }} CustomServerStrategyHandler
744
+ */
745
+ /**
746
+ * @typedef {{ getLocale: () => Promise<string|undefined> | (string | undefined), setLocale: (locale: string) => Promise<void> | void }} CustomClientStrategyHandler
747
+ */
748
+ /** @type {Map<string, CustomServerStrategyHandler>} */
749
+ export declare const customServerStrategies: Map<string, CustomServerStrategyHandler>;
750
+ /** @type {Map<string, CustomClientStrategyHandler>} */
751
+ export declare const customClientStrategies: Map<string, CustomClientStrategyHandler>;
752
+ /**
753
+ * Checks if the given strategy is a custom strategy.
754
+ *
755
+ * @param {unknown} strategy The name of the custom strategy to validate.
756
+ * Must be a string that starts with "custom-" followed by alphanumeric characters, hyphens, or underscores.
757
+ * @returns {boolean} Returns true if it is a custom strategy, false otherwise.
758
+ */
759
+ export declare function isCustomStrategy(strategy: unknown): boolean;
760
+ /**
761
+ * Defines a custom strategy that is executed on the server.
762
+ *
763
+ * @see https://paraglidejs.com/strategy#write-your-own-strategy
764
+ *
765
+ * @param {string} strategy The name of the custom strategy to define. Must follow the pattern custom-name with alphanumeric characters, hyphens, or underscores.
766
+ * @param {CustomServerStrategyHandler} handler The handler for the custom strategy, which should implement
767
+ * the method getLocale.
768
+ * @returns {void}
769
+ */
770
+ export declare function defineCustomServerStrategy(strategy: string, handler: CustomServerStrategyHandler): void;
771
+ /**
772
+ * Defines a custom strategy that is executed on the client.
773
+ *
774
+ * @see https://paraglidejs.com/strategy#write-your-own-strategy
775
+ *
776
+ * @param {string} strategy The name of the custom strategy to define. Must follow the pattern custom-name with alphanumeric characters, hyphens, or underscores.
777
+ * @param {CustomClientStrategyHandler} handler The handler for the custom strategy, which should implement the
778
+ * methods getLocale and setLocale.
779
+ * @returns {void}
780
+ */
781
+ export declare function defineCustomClientStrategy(strategy: string, handler: CustomClientStrategyHandler): void;
782
+ export {};
783
+ export type Locale = typeof locales[number];
784
+ export type LocalizedString = string & {
785
+ readonly __brand: 'LocalizedString';
786
+ };
787
+ export type MessageMarkupOption = {
788
+ name: string;
789
+ value: unknown;
790
+ };
791
+ export type MessageMarkupAttribute = {
792
+ name: string;
793
+ value: string | true;
794
+ };
795
+ export type MessageMarkupOptions = Record<string, unknown>;
796
+ export type MessageMarkupAttributes = Record<string, string | true>;
797
+ export type MessageMarkupTag = {
798
+ options: MessageMarkupOptions;
799
+ attributes: MessageMarkupAttributes;
800
+ children: boolean;
801
+ };
802
+ export type MessageMarkupSchema = Record<string, MessageMarkupTag>;
803
+ export type MessageMetadata<Inputs, Options, Markup extends MessageMarkupSchema = MessageMarkupSchema> = {
804
+ readonly __paraglide?: {
805
+ inputs: Inputs;
806
+ options: Options;
807
+ markup: Markup;
808
+ };
809
+ };
810
+ export type MessagePart = {
811
+ type: "text";
812
+ value: string;
813
+ } | {
814
+ type: "markup-start";
815
+ name: string;
816
+ options: MessageMarkupOptions;
817
+ attributes: MessageMarkupAttributes;
818
+ } | {
819
+ type: "markup-end";
820
+ name: string;
821
+ options: MessageMarkupOptions;
822
+ attributes: MessageMarkupAttributes;
823
+ } | {
824
+ type: "markup-standalone";
825
+ name: string;
826
+ options: MessageMarkupOptions;
827
+ attributes: MessageMarkupAttributes;
828
+ };
829
+ export type MessageFunction = (inputs?: Record<string, never>) => LocalizedString;
830
+ export type MessageBundleFunction<T extends string> = (params: Record<string, never>, options: {
831
+ locale: T;
832
+ }) => LocalizedString;
833
+ /**
834
+ * A locale that is available in the project.
835
+ *
836
+ * @example
837
+ * setLocale(request.locale as Locale)
838
+ *
839
+ * @typedef {typeof locales[number]} Locale
840
+ */
841
+ /**
842
+ * A branded type representing a localized string.
843
+ *
844
+ * Message functions return this type instead of \`string\`, enabling TypeScript
845
+ * to distinguish translated strings from regular strings at compile time.
846
+ * This allows you to enforce that only properly localized content is used
847
+ * in your UI components.
848
+ *
849
+ * Since \`LocalizedString\` is a branded subtype of \`string\`, it remains fully
850
+ * backward compatible—you can pass it anywhere a \`string\` is expected.
851
+ *
852
+ * @example
853
+ * // Enforce localized strings in your components
854
+ * function PageTitle(props: { title: LocalizedString }) {
855
+ * return <h1>{props.title}</h1>
856
+ * }
857
+ *
858
+ * // ✅ Correct: using a message function
859
+ * <PageTitle title={m.welcome_title()} />
860
+ *
861
+ * // ❌ Type error: raw strings are not LocalizedString
862
+ * <PageTitle title="Welcome" />
863
+ *
864
+ * @example
865
+ * // LocalizedString is assignable to string (backward compatible)
866
+ * const localized: LocalizedString = m.greeting()
867
+ * const str: string = localized // ✅ works fine
868
+ *
869
+ * // But string is not assignable to LocalizedString
870
+ * const raw: LocalizedString = "Hello" // ❌ Type error
871
+ *
872
+ * @example
873
+ * // Catches accidental string concatenation
874
+ * function showMessage(msg: LocalizedString) { ... }
875
+ *
876
+ * showMessage(m.hello()) // ✅
877
+ * showMessage("Hello " + userName) // ❌ Type error
878
+ * showMessage(m.hello_user({ name: userName })) // ✅ use params instead
879
+ *
880
+ * @typedef {string & { readonly __brand: 'LocalizedString' }} LocalizedString
881
+ */
882
+ /**
883
+ * A single markup option passed to a tag instance.
884
+ *
885
+ * @typedef {{
886
+ * name: string;
887
+ * value: unknown;
888
+ * }} MessageMarkupOption
889
+ */
890
+ /**
891
+ * A single static markup attribute attached to a tag instance.
892
+ *
893
+ * @typedef {{
894
+ * name: string;
895
+ * value: string | true;
896
+ * }} MessageMarkupAttribute
897
+ */
898
+ /**
899
+ * Record of markup options for a tag instance.
900
+ *
901
+ * @typedef {Record<string, unknown>} MessageMarkupOptions
902
+ */
903
+ /**
904
+ * Record of markup attributes for a tag instance.
905
+ *
906
+ * @typedef {Record<string, string | true>} MessageMarkupAttributes
907
+ */
908
+ /**
909
+ * Type-level schema for a single markup tag.
910
+ *
911
+ * @typedef {{
912
+ * options: MessageMarkupOptions;
913
+ * attributes: MessageMarkupAttributes;
914
+ * children: boolean;
915
+ * }} MessageMarkupTag
916
+ */
917
+ /**
918
+ * Type-level schema for all markup tags in a message.
919
+ *
920
+ * @typedef {Record<string, MessageMarkupTag>} MessageMarkupSchema
921
+ */
922
+ /**
923
+ * Type-only metadata attached to compiled message functions.
924
+ *
925
+ * @template Inputs
926
+ * @template Options
927
+ * @template {MessageMarkupSchema} [Markup = MessageMarkupSchema]
928
+ * @typedef {{
929
+ * readonly __paraglide?: {
930
+ * inputs: Inputs;
931
+ * options: Options;
932
+ * markup: Markup;
933
+ * };
934
+ * }} MessageMetadata
935
+ */
936
+ /**
937
+ * A compiled, framework-neutral message part.
938
+ *
939
+ * @typedef {{
940
+ * type: "text";
941
+ * value: string;
942
+ * } | {
943
+ * type: "markup-start";
944
+ * name: string;
945
+ * options: MessageMarkupOptions;
946
+ * attributes: MessageMarkupAttributes;
947
+ * } | {
948
+ * type: "markup-end";
949
+ * name: string;
950
+ * options: MessageMarkupOptions;
951
+ * attributes: MessageMarkupAttributes;
952
+ * } | {
953
+ * type: "markup-standalone";
954
+ * name: string;
955
+ * options: MessageMarkupOptions;
956
+ * attributes: MessageMarkupAttributes;
957
+ * }} MessagePart
958
+ */
959
+ /**
960
+ * A message function is a message for a specific locale.
961
+ *
962
+ * @example
963
+ * m.hello({ name: 'world' })
964
+ *
965
+ * @typedef {(inputs?: Record<string, never>) => LocalizedString} MessageFunction
966
+ */
967
+ /**
968
+ * A message bundle function that selects the message to be returned.
969
+ *
970
+ * Uses `getLocale()` under the hood to determine the locale with an option.
971
+ *
972
+ * @template {string} T
973
+ *
974
+ * @example
975
+ * * m.hello({ name: 'world' }, { locale: "en" })
976
+ *
977
+ * @typedef {(params: Record<string, never>, options: { locale: T }) => LocalizedString} MessageBundleFunction
978
+ */