/
githubmirror
/
client
Обзор
Документация
Войти
/
githubmirror
/
client
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
rnmodules/react-native-kb/src/index.tsx
176 строк
5 KB
chrisnojima
unify video trim + compression across share extension and in-chat attach. misc share fixes (#29485)
06 авг 2026, 18:54
Не верифицирован
06 авг 2026, 18:54
400178f
Код
Авторство
О чём код?
import {Platform} from 'react-native' import type {EventSubscription} from 'react-native' import KbNative from './NativeKb' const Kb = KbNative export const logSend = ( status: string, feedback: string, sendLogs: boolean, sendMaxBytes: boolean, traceDir: string, cpuProfileDir: string ): Promise<string> => { return Kb.logSend(status, feedback, sendLogs, sendMaxBytes, traceDir, cpuProfileDir) } export const iosGetHasShownPushPrompt = (): Promise<boolean> => { if (Platform.OS === 'ios') { return Kb.iosGetHasShownPushPrompt() } return Promise.resolve(false) } // iOS only. The native Android method rejects, so short-circuit and hand the // path back untouched instead. export const processMedia = ( path: string, isVideo: boolean, compress: boolean, startMs = 0, endMs = 0, removeAudio = false ): Promise<string> => { if (Platform.OS === 'ios') { return Kb.processMedia(path, isVideo, compress, startMs, endMs, removeAudio) } return Promise.resolve(path) } export const androidShareText = (text: string, mimeType: string): Promise<boolean> => { if (Platform.OS === 'android') { return Kb.androidShareText(text, mimeType) } return Promise.resolve(false) } export const androidShare = (text: string, mimeType: string): Promise<boolean> => { if (Platform.OS === 'android') { return Kb.androidShare(text, mimeType) } return Promise.resolve(false) } export const androidAddCompleteDownload = (o: { description: string mime: string path: string showNotification: boolean title: string }): Promise<void> => { if (Platform.OS === 'android') { return Kb.androidAddCompleteDownload(o) } return Promise.reject(new Error('wrong platform')) } export const androidAppColorSchemeChanged = (mode: 'system' | 'alwaysDark' | 'alwaysLight' | ''): void => { if (Platform.OS === 'android') { Kb.androidAppColorSchemeChanged(mode) } } export const checkPushPermissions = (): Promise<boolean> => { return Kb.checkPushPermissions() } export const requestPushPermissions = (): Promise<boolean> => { return Kb.requestPushPermissions() } export const getRegistrationToken = (): Promise<string> => { return Kb.getRegistrationToken() } export const setApplicationIconBadgeNumber = (n: number): void => { Kb.setApplicationIconBadgeNumber(n) } export const getInitialNotification = (): Promise<object | null> => { return Kb.getInitialNotification() } export const removeAllPendingNotificationRequests = (): void => { Kb.removeAllPendingNotificationRequests() } export const addNotificationRequest = (config: {body: string; id: string}): Promise<void> => { return Kb.addNotificationRequest(config) } // Hardware keyboard events const hwKeyPressedListeners: Array<EventSubscription> = [] export const onHWKeyPressed = (callback: (event: {pressedKey: string}) => void): void => { const listener = Kb.onHardwareKeyPressed(pressedKey => callback({pressedKey})) hwKeyPressedListeners.push(listener) } export const removeOnHWKeyPressed = (): void => { hwKeyPressedListeners.forEach(listener => listener.remove()) hwKeyPressedListeners.length = 0 } // Paste image events (iOS) let pasteImageListenerCount = 0 export const registerPasteImage = (callback: (uris: Array<string>) => void): (() => void) => { if (Platform.OS !== 'ios') return () => {} const listener = Kb.onPasteImage(uris => callback(uris)) pasteImageListenerCount++ Kb.setEnablePasteImage(true) return () => { listener.remove() pasteImageListenerCount-- Kb.setEnablePasteImage(pasteImageListenerCount > 0) } } // Engine meta events (e.g. 'kb-engine-reset') export const onMetaEvent = (callback: (payload: string) => void): EventSubscription => { return Kb.onMetaEvent(callback) } // Push events export const onPushNotification = (callback: (notification: object) => void): EventSubscription => { return Kb.onPushNotification(n => callback(n)) } export const onPushToken = (callback: (token: string) => void): EventSubscription => { return Kb.onPushToken(callback) } // Android share-into-app intents export const onShareData = ( callback: (evt: {text?: string; localPaths?: Array<string>}) => void ): EventSubscription => { return Kb.onShareData(callback) } export const engineReset = (): void => { return Kb.engineReset() } export const notifyJSReady = (): void => { return Kb.notifyJSReady() } export const shareListenersRegistered = (): void => { return Kb.shareListenersRegistered() } export const clearLocalLogs = (): Promise<void> => { return Kb.clearLocalLogs() } const KBC = Kb.getTypedConstants() export const androidIsDeviceSecure: boolean = KBC.androidIsDeviceSecure export const androidIsTestDevice: boolean = KBC.androidIsTestDevice export const appVersionCode: string = KBC.appVersionCode export const appVersionName: string = KBC.appVersionName export const darkModeSupported: boolean = KBC.darkModeSupported export const fsCacheDir: string = KBC.fsCacheDir export const fsDownloadDir: string = KBC.fsDownloadDir export const guiConfig: string = KBC.guiConfig export const serverConfig: string = KBC.serverConfig export const uses24HourClock: boolean = KBC.uses24HourClock export const version: string = KBC.version