From 6685fca48d3392fdc3e2579e2111dd1697aba472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Enr=C3=ADquez=20Jaime?= Date: Wed, 27 Aug 2025 13:39:33 -0700 Subject: [PATCH 1/3] feat(types): Refactor + add minor types for functions --- package.json | 1 + src/Meteor.d.ts | 74 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index e16489cc..4138b175 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@meteorrn/core", "version": "2.9.0", "description": "Full Meteor Client for React Native", + "types": "src/Meteor.d.ts", "main": "src/index.js", "repository": { "type": "git", diff --git a/src/Meteor.d.ts b/src/Meteor.d.ts index 56c7b0dc..c193dfd6 100644 --- a/src/Meteor.d.ts +++ b/src/Meteor.d.ts @@ -1,9 +1,8 @@ +import { AsyncStorageStatic } from "@react-native-async-storage/async-storage"; + declare module '@meteorrn/core' { type Callback = (...args: unknown[]) => void; - - function connect(endpoint: string, options?: any): void; - function disconnect(): void; - function reconnect(): void; + type Status = | 'change' | 'connected' @@ -11,15 +10,7 @@ declare module '@meteorrn/core' { | 'loggingIn' | 'loggingOut'; - function call(...args: any[]): void; - function status(): { - connected: boolean; - status: Status; - }; - - function logout(cb: Callback): void; - function loggingOut(): boolean; - function loggingIn(): boolean; + type useTracker = (cb: () => T) => T interface Data { getUrl(): string; @@ -35,7 +26,12 @@ declare module '@meteorrn/core' { socket: unknown; }; } - function getData(): Data; + + interface MeteorError { + error: string + reason?: string + details?: string + } interface User { _id: string; @@ -45,15 +41,53 @@ declare module '@meteorrn/core' { settings: {}; }; } - function user(): User | undefined; + + interface ConnectOptions { + suppressUrlErrors: boolean + AsyncStorage: AsyncStorageStatic + reachabilityUrl: string + } + + interface Meteor { + connect(endpoint: string, options?: ConnectOptions): void; + disconnect(): void; + reconnect(): void; + + call(...args: any[]): void; + status(): { + connected: boolean; + status: Status; + }; + + logout(cb: Callback): void; + loggingOut(): boolean; + loggingIn(): boolean; + + getData(): Data; + user(): User | undefined; + getAuthToken(): string; + + readonly isVerbose: boolean; + enableVerbose(): void; + + useTracker(): useTracker; + + ddp: Data; + + _handleLoginCallback(err?: MeteorError, res: { token: string, id: string }): void; + } + interface Accounts { onLogin(cb: Callback): void; } - function getAuthToken(): string; - const ddp: Data; - let isVerbose: boolean; - function _handleLoginCallback(err: any, res: any): void; + // Export default Meteor object + const Meteor: Meteor; + export default Meteor; - function useTracker(cb: () => T): T; + // Export other members + export { + useTracker, + Accounts, + } } From 340d9c9d14aecf1f14d43d46dad7a3d2b2d3cd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Enr=C3=ADquez=20Jaime?= Date: Wed, 27 Aug 2025 14:44:08 -0700 Subject: [PATCH 2/3] fix: Fixes warning TS1016 --- src/Meteor.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Meteor.d.ts b/src/Meteor.d.ts index c193dfd6..8c8a3e9c 100644 --- a/src/Meteor.d.ts +++ b/src/Meteor.d.ts @@ -74,7 +74,7 @@ declare module '@meteorrn/core' { ddp: Data; - _handleLoginCallback(err?: MeteorError, res: { token: string, id: string }): void; + _handleLoginCallback(err: MeteorError | null | undefined, res: { token: string, id: string }): void; } interface Accounts { From 7c060918ab5547b69be6432bb0f7cee440ca3df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Enr=C3=ADquez=20Jaime?= Date: Fri, 19 Sep 2025 15:55:53 -0700 Subject: [PATCH 3/3] fix: Fixes lint warnings --- src/Meteor.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Meteor.d.ts b/src/Meteor.d.ts index 8c8a3e9c..0437f49e 100644 --- a/src/Meteor.d.ts +++ b/src/Meteor.d.ts @@ -1,8 +1,8 @@ -import { AsyncStorageStatic } from "@react-native-async-storage/async-storage"; +import { AsyncStorageStatic } from '@react-native-async-storage/async-storage'; declare module '@meteorrn/core' { type Callback = (...args: unknown[]) => void; - + type Status = | 'change' | 'connected' @@ -10,7 +10,7 @@ declare module '@meteorrn/core' { | 'loggingIn' | 'loggingOut'; - type useTracker = (cb: () => T) => T + type useTracker = (cb: () => T) => T; interface Data { getUrl(): string; @@ -28,9 +28,9 @@ declare module '@meteorrn/core' { } interface MeteorError { - error: string - reason?: string - details?: string + error: string; + reason?: string; + details?: string; } interface User { @@ -43,9 +43,9 @@ declare module '@meteorrn/core' { } interface ConnectOptions { - suppressUrlErrors: boolean - AsyncStorage: AsyncStorageStatic - reachabilityUrl: string + suppressUrlErrors: boolean; + AsyncStorage: AsyncStorageStatic; + reachabilityUrl: string; } interface Meteor { @@ -72,9 +72,12 @@ declare module '@meteorrn/core' { useTracker(): useTracker; - ddp: Data; + ddp: Data; - _handleLoginCallback(err: MeteorError | null | undefined, res: { token: string, id: string }): void; + _handleLoginCallback( + err: MeteorError | null | undefined, + res: { token: string; id: string } + ): void; } interface Accounts { @@ -86,8 +89,5 @@ declare module '@meteorrn/core' { export default Meteor; // Export other members - export { - useTracker, - Accounts, - } + export { useTracker, Accounts }; }