// Copyright 2018 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { IntlShape } from 'react-intl'; import type { AciString } from './ServiceId.std.js'; import type { LocaleDirection } from '../../app/locale.node.js'; import type { ICUJSXMessageParamsByKeyType, ICUStringMessageParamsByKeyType, } from '../../build/ICUMessageParams.d.ts'; import type { HourCyclePreference, LocaleMessagesType } from './I18N.std.js'; export type StoryContextType = { authorAci?: AciString; timestamp: number; }; export type RenderTextCallbackType = (options: { text: string; key: number; }) => React.JSX.Element | string; export { ICUJSXMessageParamsByKeyType, ICUStringMessageParamsByKeyType }; export type LocalizerOptions = { /** * - 'default' will fence all string parameters with unicode bidi isolates * and balance the control characters within them * - 'strip' should only be used when all of the parameters are not * user-generated and should not contain any control characters. */ bidi?: 'default' | 'strip'; }; export type LocalizerType = { ( key: Key, ...values: ICUStringMessageParamsByKeyType[Key] extends undefined ? [params?: undefined, options?: LocalizerOptions] : [ params: ICUStringMessageParamsByKeyType[Key], options?: LocalizerOptions, ] ): string; getIntl(): IntlShape; getLocale(): string; getLocaleMessages(): LocaleMessagesType; getLocaleDirection(): LocaleDirection; getHourCyclePreference(): HourCyclePreference; // Storybook trackUsage(): void; stopTrackingUsage(): Array<[string, string]>; }; export enum SentMediaQualityType { 'standard' = 'standard', 'high' = 'high', } export enum ThemeType { 'light' = 'light', 'dark' = 'dark', } export enum SystemThemeType { light = 'light', dark = 'dark', } // These are strings so they can be interpolated into class names. export enum ScrollBehavior { Default = 'default', Hard = 'hard', } type InternalAssertProps< Result, Value, Missing = Omit, > = keyof Missing extends never ? Result : Result & { [key in keyof Required]: [ never, 'AssertProps: missing property', ]; }; export type AssertProps = InternalAssertProps; export type UnwrapPromise = Value extends Promise ? T : Value; export type BytesToStrings = Value extends Uint8Array ? string : { [Key in keyof Value]: BytesToStrings }; export type JSONWithUnknownFields = Value extends Record ? Readonly< { [Key in keyof Value]: JSONWithUnknownFields; } & { // Make sure that rest property is required to handle. __rest: never; } > : Value extends Array ? ReadonlyArray> : Value; export type WithRequiredProperties = Omit & Required>; export type WithOptionalProperties = Omit & Partial>; // Check that two const arrays do not have overlapping values export type ErrorIfOverlapping< T1 extends ReadonlyArray, T2 extends ReadonlyArray, > = T1[number] & T2[number] extends never ? void : 'Error: Arrays have overlapping values'; // Check that T has all the fields (and only those fields) from K export type ExactKeys> = Exclude extends never ? Exclude extends never ? T : 'Error: Array has fields not present in object type' : 'Error: Object type has keys not present in array'; export type StripPrefix< T extends string, Prefix extends string, > = T extends `${Prefix}${infer Rest}` ? Rest : T; export type AddPrefix< T extends string, Prefix extends string, > = `${Prefix}${T}`; type Missing = Exclude; type Extra = Exclude; export type AssertSameMembers = [ Missing, ] extends [never] ? [Extra] extends [never] ? true : { error: 'Extra keys'; extra: Extra; } : { error: 'Missing keys'; missing: Missing; }; export type ArrayValues> = T[number];