From 973daf3816bc0eaaf7a9620c83d28a4fba1c39c6 Mon Sep 17 00:00:00 2001 From: RNEvok <81921589+RNEvok@users.noreply.github.com> Date: Fri, 14 Jun 2024 02:53:20 +0300 Subject: [PATCH] Attempt #1 to improve types declaration --- index.d.ts | 183 ++++++++++++++++++----------------------------------- 1 file changed, 62 insertions(+), 121 deletions(-) diff --git a/index.d.ts b/index.d.ts index 877a02c..333884f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,36 +1,69 @@ -declare module '@appklaar/codebud' { - export type ObjectT = {[key: string]: T}; +declare type ObjectT = {[key: string]: T}; + +declare type StackTraceCallData = { + sourceLine?: string; + beforeParse: string; + callee: string; + calleeShort?: string; + native: boolean; + file?: string; + fileRelative?: string; + fileShort?: string; + fileName?: string; + line?: number; +}; + +declare type StackTraceData = { + stack?: StackTraceCallData[]; +}; + +declare type GetStackTraceFunctionOptions = { + calleeExclude?: string[]; + fileNameExclude?: string[]; +}; + +declare type GetStackTraceFunction = (errorOrStack: Error | string | undefined, options?: GetStackTraceFunctionOptions) => Promise; + +declare type SpecialInstructionId = "condition" | "delay" | "forwardData"; + +declare type RemoteEvent = { + id: string; + eventType: "default" | "special"; + instructionId: string | SpecialInstructionId; + args?: any[]; +}; + +declare type RemoteSettingsEnv = "dev" | "stg" | "prod"; + +declare type _RemoteSettings = {[env in RemoteSettingsEnv]: ObjectT}; + +declare class Component { + static contextType?: any | undefined; + context: unknown; + + constructor(props: Readonly

| P); + + setState( + state: ((prevState: Readonly, props: Readonly

) => (Pick | S | null)) | (Pick | S | null), + callback?: () => void + ): void; + forceUpdate(callback?: () => void): void; + render(): any; + readonly props: Readonly

; + state: Readonly; + + refs: {[key: string]: any}; +} + +declare type ReactFunctionalComponent = (props: T) => any | null; +declare module '@appklaar/codebud' { export type ProjectInfo = { projectId: string; }; export type PackageMode = "dev" | "prod"; - export type StackTraceCallData = { - sourceLine?: string; - beforeParse: string; - callee: string; - calleeShort?: string; - native: boolean; - file?: string; - fileRelative?: string; - fileShort?: string; - fileName?: string; - line?: number; - }; - - export type StackTraceData = { - stack?: StackTraceCallData[]; - }; - - export type GetStackTraceFunctionOptions = { - calleeExclude?: string[]; - fileNameExclude?: string[]; - }; - - export type GetStackTraceFunction = (errorOrStack: Error | string | undefined, options?: GetStackTraceFunctionOptions) => Promise; - export type PackageConfig = { mode?: PackageMode; Interceptor?: any; @@ -110,17 +143,8 @@ declare module '@appklaar/codebud' { export type InstructionsTable = {[key: string]: Instruction}; - export type SpecialInstructionId = "condition" | "delay" | "forwardData"; - export type SpecialInstructionsTable = {[id in SpecialInstructionId]: Instruction}; - export type RemoteEvent = { - id: string; - eventType: "default" | "special"; - instructionId: string | SpecialInstructionId; - args?: any[]; - }; - export type OnEventUsersCustomCallback = (event: RemoteEvent) => void; export type ClientType = "CLIENT" | "ADMIN_PANEL"; @@ -142,10 +166,8 @@ declare module '@appklaar/codebud' { export type EventListenersTable = ListenersTable; export type SelectFn = (state: any) => any; - - export type RemoteSettingsEnv = "dev" | "stg" | "prod"; - export type RemoteSettings = {[env in RemoteSettingsEnv]: ObjectT}; + export type RemoteSettings = _RemoteSettings; export type RemoteSettingsListenersTable = ListenersTable; @@ -260,19 +282,6 @@ declare module '@appklaar/codebud' { } declare module '@appklaar/codebud/react' { - export type ObjectT = {[key: string]: T}; - - export type RemoteEvent = { - id: string; - eventType: "default" | "special"; - instructionId: string; - args?: any[]; - }; - - export type RemoteSettingsEnv = "dev" | "stg" | "prod"; - - export type RemoteSettings = {[env in RemoteSettingsEnv]: ObjectT}; - export function useEvent( handler: (event: RemoteEvent) => any, instructionIds: ReadonlyArray @@ -286,24 +295,6 @@ declare module '@appklaar/codebud/react' { waitMs?: number ): void; - class Component { - static contextType?: any | undefined; - context: unknown; - - constructor(props: Readonly

| P); - - setState( - state: ((prevState: Readonly, props: Readonly

) => (Pick | S | null)) | (Pick | S | null), - callback?: () => void - ): void; - forceUpdate(callback?: () => void): void; - render(): any; - readonly props: Readonly

; - state: Readonly; - - refs: {[key: string]: any}; - } - export type ErrorBoundaryProps = { fallback?: any; children: any; @@ -334,8 +325,6 @@ declare module '@appklaar/codebud/Network/NetworkInterceptorXHR' { } declare module '@appklaar/codebud/rn' { - type ReactFunctionalComponent = (props: T) => any | null; - export type InitModalProps = { animationType?: "fade" | "none" | "slide"; onInit: (apiKey: string) => void; @@ -360,58 +349,10 @@ declare module '@appklaar/codebud/encryption' { export class EncryptionPlugin {} } -declare module '@appklaar/codebud/StackTracing/getStackTraceStackTracey' { - export type StackTraceCallData = { - sourceLine?: string; - beforeParse: string; - callee: string; - calleeShort?: string; - native: boolean; - file?: string; - fileRelative?: string; - fileShort?: string; - fileName?: string; - line?: number; - }; - - export type StackTraceData = { - stack?: StackTraceCallData[]; - }; - - export type GetStackTraceFunctionOptions = { - calleeExclude?: string[]; - fileNameExclude?: string[]; - }; - - export type GetStackTraceFunction = (errorOrStack: Error | string | undefined, options?: GetStackTraceFunctionOptions) => Promise; - +declare module '@appklaar/codebud/StackTracing/getStackTraceStackTracey' { export const getStackTraceStackTracey: GetStackTraceFunction; } -declare module '@appklaar/codebud/StackTracing/getStackTraceSimple' { - export type StackTraceCallData = { - sourceLine?: string; - beforeParse: string; - callee: string; - calleeShort?: string; - native: boolean; - file?: string; - fileRelative?: string; - fileShort?: string; - fileName?: string; - line?: number; - }; - - export type StackTraceData = { - stack?: StackTraceCallData[]; - }; - - export type GetStackTraceFunctionOptions = { - calleeExclude?: string[]; - fileNameExclude?: string[]; - }; - - export type GetStackTraceFunction = (errorOrStack: Error | string | undefined, options?: GetStackTraceFunctionOptions) => Promise; - +declare module '@appklaar/codebud/StackTracing/getStackTraceSimple' { export const getStackTraceSimple: GetStackTraceFunction; } \ No newline at end of file