react-signalr
Advanced tools
Comparing version
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.2.23](https://github.com/hosseinmd/react-signalr/compare/v0.2.22...v0.2.23) (2024-09-11) | ||
### Features | ||
* support react-native headers for websocket ([9048654](https://github.com/hosseinmd/react-signalr/commit/9048654b73f751472083f4c24406ee3e8f07b99a)) | ||
### [0.2.22](https://github.com/hosseinmd/react-signalr/compare/v0.2.21...v0.2.22) (2024-05-26) | ||
@@ -7,0 +14,0 @@ |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { ProviderProps } from "./types"; | ||
@@ -3,0 +2,0 @@ import { Context, Hub } from "../types"; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { Context, Hub } from "../types"; | ||
@@ -3,0 +2,0 @@ import { ProviderProps } from "./types"; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { ProviderProps } from "./types"; | ||
@@ -3,0 +2,0 @@ import { Context, Hub } from "../types"; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { Context, Hub } from "../types"; | ||
@@ -3,0 +2,0 @@ import { ProviderProps } from "./types"; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { ProviderProps } from "./types"; | ||
@@ -3,0 +2,0 @@ import { Context } from "../types"; |
@@ -1,6 +0,5 @@ | ||
/// <reference types="react" /> | ||
import { Context } from "../types"; | ||
import { ProviderProps } from "./types"; | ||
declare function providerNativeFactory(context: Context): ({ url, connectEnabled, children, dependencies, onError, onOpen, onClose, logger, }: ProviderProps) => JSX.Element; | ||
declare function providerNativeFactory(context: Context): ({ url, connectEnabled, children, dependencies, onError, onOpen, onClose, logger, headers, }: ProviderProps) => JSX.Element; | ||
export { providerNativeFactory }; | ||
//# sourceMappingURL=providerNativeFactory.d.ts.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
function providerNativeFactory(context) { | ||
const Provider = ({ url, connectEnabled = true, children, dependencies = [], onError, onOpen, onClose, logger = console, }) => { | ||
const Provider = ({ url, connectEnabled = true, children, dependencies = [], onError, onOpen, onClose, logger = console, headers, }) => { | ||
const onErrorRef = (0, utils_1.useEvent)(onError); | ||
@@ -26,2 +26,3 @@ // eslint-disable-next-line @typescript-eslint/no-empty-function | ||
onErrorRef, | ||
headers, | ||
}); | ||
@@ -28,0 +29,0 @@ } |
@@ -15,3 +15,7 @@ import { DependencyList, ReactNode } from "react"; | ||
} | null; | ||
/** | ||
* react-native only | ||
*/ | ||
headers?: any; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import { ProviderProps } from "./provider"; | ||
@@ -3,0 +2,0 @@ export interface Context { |
import { ProviderProps } from "./provider/types"; | ||
import { Context } from "./types"; | ||
declare function isConnectionConnecting(connection: WebSocket | null): boolean | null; | ||
declare function createConnection(context: Context, { url, onOpen, onClose, onErrorRef, logger, }: Pick<ProviderProps, "url" | "onOpen" | "logger" | "onClose"> & { | ||
declare function createConnection(context: Context, { url, onOpen, onClose, onErrorRef, logger, headers, }: Pick<ProviderProps, "url" | "onOpen" | "logger" | "onClose" | "headers"> & { | ||
onErrorRef: any; | ||
@@ -6,0 +6,0 @@ }): WebSocket; |
@@ -11,4 +11,13 @@ "use strict"; | ||
exports.isConnectionConnecting = isConnectionConnecting; | ||
function createConnection(context, { url, onOpen, onClose, onErrorRef, logger, }) { | ||
const connection = new WebSocket(url); | ||
function createConnection(context, { url, onOpen, onClose, onErrorRef, logger, headers, }) { | ||
let connection; | ||
if (headers) { | ||
//@ts-ignore | ||
connection = new WebSocket(url, null, { | ||
headers, | ||
}); | ||
} | ||
else { | ||
connection = new WebSocket(url); | ||
} | ||
connection.onopen = () => { | ||
@@ -15,0 +24,0 @@ onOpen === null || onOpen === void 0 ? void 0 : onOpen(connection); |
{ | ||
"name": "react-signalr", | ||
"version": "0.2.22", | ||
"version": "0.2.23", | ||
"description": "React-signalr is a tools for using signalr web socket in react/react-native apps", | ||
@@ -54,2 +54,4 @@ "main": "lib/index.js", | ||
"@types/react": "^18.0.15", | ||
"@types/react-native": "0.73.0", | ||
"@react-native/typescript-config": "0.75.2", | ||
"@types/uuid": "^8.3.1", | ||
@@ -56,0 +58,0 @@ "@typescript-eslint/eslint-plugin": "^6.6.0", |
@@ -17,2 +17,3 @@ import { useEffect, useRef, useState } from "react"; | ||
logger = console, | ||
headers, | ||
}: ProviderProps) => { | ||
@@ -37,2 +38,3 @@ const onErrorRef = useEvent(onError); | ||
onErrorRef, | ||
headers, | ||
}); | ||
@@ -39,0 +41,0 @@ } catch (err) { |
@@ -16,2 +16,6 @@ import { DependencyList, ReactNode } from "react"; | ||
} | null; | ||
/** | ||
* react-native only | ||
*/ | ||
headers?: any; | ||
} |
@@ -21,7 +21,19 @@ import { sendWithHermes } from "../utils"; | ||
logger, | ||
}: Pick<ProviderProps, "url" | "onOpen" | "logger" | "onClose"> & { | ||
headers, | ||
}: Pick< | ||
ProviderProps, | ||
"url" | "onOpen" | "logger" | "onClose" | "headers" | ||
> & { | ||
onErrorRef: any; | ||
}, | ||
) { | ||
const connection = new WebSocket(url); | ||
let connection: WebSocket; | ||
if (headers) { | ||
//@ts-ignore | ||
connection = new WebSocket(url, null, { | ||
headers, | ||
}); | ||
} else { | ||
connection = new WebSocket(url); | ||
} | ||
@@ -28,0 +40,0 @@ connection.onopen = () => { |
{ | ||
"compilerOptions": { | ||
"types": ["react-native", "jest"], | ||
"jsx": "react", | ||
@@ -4,0 +5,0 @@ /* Basic Options */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
347388
0.28%3229
0.81%31
6.9%