Skip to content

Commit dec4ad9

Browse files
authored
Support node@22 (#24)
* support node22 * bump "connectycube": ">=4.2.1" as "peerDependencies" * updated CHANGELOG.md * fixed ts issues * upgraded "connectycube" as "peerDependencies" to v4.2.2 * updated CHANGELOG.md * added "engines" to package.json * added @types/node
1 parent 23f5247 commit dec4ad9

9 files changed

+160
-530
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ dist
128128
.yarn/build-state.yml
129129
.yarn/install-state.gz
130130
.pnp.*
131+
.DS_Store

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.18.0
4+
5+
### Updates
6+
7+
- Added support for node 22;
8+
- Upgraded `connectycube` >=4.2.2 to use import types and enums from "connectycube/types".
9+
310
## 0.17.0
411

512
### Updates

package-lock.json

Lines changed: 126 additions & 508 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,28 @@
3939
"react-usestateref": "^1.0.9"
4040
},
4141
"devDependencies": {
42-
"@rollup/plugin-commonjs": "^28.0.2",
43-
"@rollup/plugin-node-resolve": "^16.0.0",
42+
"@rollup/plugin-commonjs": "^28.0.3",
43+
"@rollup/plugin-node-resolve": "^16.0.1",
4444
"@rollup/plugin-terser": "^0.4.4",
4545
"@rollup/plugin-typescript": "^12.1.2",
4646
"@types/react": "^19.0.10",
47+
"@types/node": "^22.13.10",
4748
"prettier": "^3.5.3",
48-
"rollup": "^4.34.9",
49+
"rollup": "^4.36.0",
4950
"rollup-plugin-peer-deps-external": "^2.2.4",
5051
"tslib": "^2.8.1",
5152
"typescript": "^5.8.2"
5253
},
5354
"peerDependencies": {
54-
"connectycube": ">=4.1.3",
55+
"connectycube": ">=4.2.2",
5556
"react": ">=18.0.0",
5657
"react-dom": ">=18.0.0"
5758
},
5859
"optionalDependencies": {
59-
"@rollup/rollup-linux-x64-gnu": "^4.34.9"
60+
"@rollup/rollup-linux-x64-gnu": "^4.36.0"
61+
},
62+
"engines": {
63+
"node": ">=18.0.0",
64+
"npm": ">=8.0.0"
6065
}
6166
}

rollup.config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import commonjs from "@rollup/plugin-commonjs";
55
import typescript from "@rollup/plugin-typescript";
66
import terser from "@rollup/plugin-terser";
77
import peerDepsExternal from "rollup-plugin-peer-deps-external";
8-
import packageJson from './package.json' assert { type: 'json' };
8+
import { createRequire } from 'module';
9+
10+
const require = createRequire(import.meta.url);
11+
const packageJson = require('./package.json');
912

1013
const globals = {
1114
"connectycube": "ConnectyCube",

src/ChatContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createContext, useContext, useEffect, useRef, useState } from "react";
22
import { ChatContextType, ChatProviderType, GroupChatEventType, UnreadMessagesCount } from "./types";
3-
import { Chat, DateOrTimestamp, Dialogs, Messages, Users } from "connectycube/dist/types/types";
3+
import { Chat, DateOrTimestamp, Dialogs, Messages, Users } from "connectycube/types";
44
import ConnectyCube from "connectycube";
55
import useStateRef from "react-usestateref";
66
import { formatDistanceToNow } from "date-fns";
@@ -181,7 +181,7 @@ export const ChatProvider = ({ children }: ChatProviderType): React.ReactElement
181181
}
182182
};
183183

184-
const selectDialog = async (dialog: Dialogs.Dialog): Promise<void> => {
184+
const selectDialog = async (dialog?: Dialogs.Dialog): Promise<void> => {
185185
setSelectedDialog(dialog);
186186
if (!dialog) {
187187
return;
@@ -641,11 +641,11 @@ export const ChatProvider = ({ children }: ChatProviderType): React.ReactElement
641641
});
642642
};
643643

644-
const processOnMessage = (callbackFn: Chat.OnMessageListener) => {
644+
const processOnMessage = (callbackFn: Chat.OnMessageListener | null) => {
645645
onMessageRef.current = callbackFn;
646646
};
647647

648-
const processOnMessageError = (callbackFn: Chat.OnMessageErrorListener) => {
648+
const processOnMessageError = (callbackFn: Chat.OnMessageErrorListener | null) => {
649649
onMessageErrorRef.current = callbackFn;
650650
};
651651

src/hooks/useBlockList.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ConnectyCube from "connectycube";
2+
import { PrivacyListAction } from "connectycube/types";
23
import { useEffect, useState, useRef } from "react";
34

45
export const BLOCK_LIST_LOG_TAG = "[useChat][useBlockList]";
@@ -11,11 +12,6 @@ export type BlockListHook = {
1112
blockUser: (userId: number) => Promise<void>;
1213
};
1314

14-
enum PrivacyListAction {
15-
ALLOW = "allow",
16-
DENY = "deny",
17-
}
18-
1915
function useBlockList(isConnected: boolean): BlockListHook {
2016
const [state, setState] = useState<Set<number>>(new Set<number>());
2117
const isApplied = useRef<boolean>(false);

src/types/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Chat, Dialogs, Messages, Users } from "connectycube/dist/types/types";
1+
import { Chat, Dialogs, Messages, Users } from "connectycube/types";
22
import { ReactNode } from "react";
33
import { BlockListHook } from "../hooks/useBlockList";
44

@@ -22,7 +22,7 @@ export interface ChatContextType extends BlockListHook {
2222
getDialogs: (filters?: Dialogs.ListParams) => Promise<Dialogs.Dialog[]>;
2323
dialogs: Dialogs.Dialog[];
2424
selectedDialog?: Dialogs.Dialog;
25-
selectDialog: (dialog: Dialogs.Dialog) => Promise<void>;
25+
selectDialog: (dialog?: Dialogs.Dialog) => Promise<void>;
2626
getDialogOpponentId: (dialog?: Dialogs.Dialog) => number | undefined;
2727
unreadMessagesCount: UnreadMessagesCount;
2828
users: { [userId: number]: Users.User };
@@ -45,8 +45,8 @@ export interface ChatContextType extends BlockListHook {
4545
lastActivity: { [userId: number]: string };
4646
lastMessageSentTimeString: (dialog: Dialogs.Dialog) => string;
4747
messageSentTimeString: (message: Messages.Message) => string;
48-
processOnMessage: (fn: Chat.OnMessageListener) => void;
49-
processOnMessageError: (fn: Chat.OnMessageErrorListener) => void;
48+
processOnMessage: (fn: Chat.OnMessageListener | null) => void;
49+
processOnMessageError: (fn: Chat.OnMessageErrorListener | null) => void;
5050
}
5151

5252
export enum GroupChatEventType {

tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"forceConsistentCasingInFileNames": true,
1111
"noFallthroughCasesInSwitch": true,
1212
"module": "esnext",
13-
"moduleResolution": "node",
13+
"moduleResolution": "bundler",
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"noEmit": true,
1717
"jsx": "react-jsx",
1818
"declarationDir": "./dist/types",
1919
"declaration": true,
20-
"declarationMap": true,
20+
"declarationMap": true
2121
},
2222
"include": ["src"]
23-
}
23+
}

0 commit comments

Comments
 (0)