@inlang/paraglide-js
Version:
[](https://www.npmjs.com/package/@inlang/paraglide-js) [ => Promise<string | undefined> | (string | undefined);
};
export type CustomClientStrategyHandler = {
getLocale: () => Promise<string | undefined> | (string | undefined);
setLocale: (locale: string) => Promise<void> | void;
};
/**
* @typedef {`custom_${string}`} CustomStrategy
*/
/**
* @typedef {BuiltInStrategy | CustomStrategy} Strategy
*/
/**
* @typedef {Array<Strategy>} Strategies
*/
/**
* @typedef {{ getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined) }} CustomServerStrategyHandler
*/
/**
* @typedef {{ getLocale: () => Promise<string|undefined> | (string | undefined), setLocale: (locale: string) => Promise<void> | void }} CustomClientStrategyHandler
*/
/** @type {Map<string, CustomServerStrategyHandler>} */
export declare const customServerStrategies: Map<string, CustomServerStrategyHandler>;
/** @type {Map<string, CustomClientStrategyHandler>} */
export declare const customClientStrategies: Map<string, CustomClientStrategyHandler>;
/**
* Checks if the given strategy is a custom strategy.
*
* @param {unknown} strategy The name of the custom strategy to validate.
* Must be a string that starts with "custom-" followed by alphanumeric characters, hyphens, or underscores.
* @returns {boolean} Returns true if it is a custom strategy, false otherwise.
*/
export declare function isCustomStrategy(strategy: unknown): boolean;
/**
* Defines a custom strategy that is executed on the server.
*
* @see https://paraglidejs.com/strategy#write-your-own-strategy
*
* @param {string} strategy The name of the custom strategy to define. Must follow the pattern custom-name with alphanumeric characters, hyphens, or underscores.
* @param {CustomServerStrategyHandler} handler The handler for the custom strategy, which should implement
* the method getLocale.
* @returns {void}
*/
export declare function defineCustomServerStrategy(strategy: string, handler: CustomServerStrategyHandler): void;
/**
* Defines a custom strategy that is executed on the client.
*
* @see https://paraglidejs.com/strategy#write-your-own-strategy
*
* @param {string} strategy The name of the custom strategy to define. Must follow the pattern custom-name with alphanumeric characters, hyphens, or underscores.
* @param {CustomClientStrategyHandler} handler The handler for the custom strategy, which should implement the
* methods getLocale and setLocale.
* @returns {void}
*/
export declare function defineCustomClientStrategy(strategy: string, handler: CustomClientStrategyHandler): void;
//# sourceMappingURL=strategy.d.ts.map