diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8e0e497 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +jobs: + release: + name: Release + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Authenticate with npm registry + run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + + - name: Config npm + run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish -r --access public --no-git-checks diff --git a/README.md b/README.md index a8a593a..83647e0 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ For the SDK reference, see [https://docs.openim.io/sdks/quickstart/electron](htt ### Adding Dependencies ```shell -npm install open-im-sdk-wasm @openim/electron-client-sdk --save +npm install @openim/wasm-client-sdk @openim/electron-client-sdk --save ``` ### Obtaining Required Static Resources for WASM Follow these steps to obtain the static resources required for WebAssembly (WASM): -1. Locate the `open-im-sdk-wasm` subdirectory in the `node_modules` directory of your project. Copy all the files in the `assets` folder to your project's public resource directory. +1. Locate the `@openim/wasm-client-sdk` subdirectory in the `node_modules` directory of your project. Copy all the files in the `assets` folder to your project's public resource directory. The files to be copied are: @@ -34,7 +34,7 @@ Follow these steps to obtain the static resources required for WebAssembly (WASM ### Possible Issues ❗ -> if you are using webpack4, you may flow this issue [How to import open-im-sdk-wasm in webpack4.x](https://github.com/openimsdk/open-im-sdk-web-wasm/issues/73). +> if you are using webpack4, you may flow this issue [How to import @openim/wasm-client-sdk in webpack4.x](https://github.com/openimsdk/open-im-sdk-web-wasm/issues/73). ## Usage 🚀 @@ -73,8 +73,8 @@ export const IMSDK = instance; > Note: You need to [deploy](https://github.com/openimsdk/open-im-server#rocket-quick-start) OpenIM Server first, the default port of OpenIM Server is 10001, 10002. ```typescript -import { CbEvents, LogLevel } from 'open-im-sdk-wasm'; -import type { WSEvent } from 'open-im-sdk-wasm/lib/types/entity'; +import { CbEvents, LogLevel } from '@openim/wasm-client-sdk'; +import type { WSEvent } from '@openim/wasm-client-sdk/lib/types/entity'; IMSDK.on(CbEvents.OnConnecting, handleConnecting); IMSDK.on(CbEvents.OnConnectFailed, handleConnectFailed); @@ -127,8 +127,11 @@ To log into the IM server, you need to create an account and obtain a user ID an OpenIM makes it easy to send and receive messages. By default, there is no restriction on having a friend relationship to send messages (although you can configure other policies on the server). If you know the user ID of the recipient, you can conveniently send a message to them. ```typescript -import { CbEvents } from 'open-im-sdk-wasm'; -import type { WSEvent, MessageItem } from 'open-im-sdk-wasm/lib/types/entity'; +import { CbEvents } from '@openim/wasm-client-sdk'; +import type { + WSEvent, + MessageItem, +} from '@openim/wasm-client-sdk/lib/types/entity'; // Listenfor new messages 📩 IMSDK.on(CbEvents.OnRecvNewMessages, handleNewMessages); diff --git a/assets/linux_arm64/libopenimsdk.so b/assets/linux_arm64/libopenimsdk.so index a2e9e9f..ff59ed5 100644 Binary files a/assets/linux_arm64/libopenimsdk.so and b/assets/linux_arm64/libopenimsdk.so differ diff --git a/assets/linux_x64/libopenimsdk.so b/assets/linux_x64/libopenimsdk.so index a2e9e9f..ff59ed5 100644 Binary files a/assets/linux_x64/libopenimsdk.so and b/assets/linux_x64/libopenimsdk.so differ diff --git a/assets/mac_arm64/libopenimsdk.dylib b/assets/mac_arm64/libopenimsdk.dylib index e3e117b..c224617 100644 Binary files a/assets/mac_arm64/libopenimsdk.dylib and b/assets/mac_arm64/libopenimsdk.dylib differ diff --git a/assets/mac_x64/libopenimsdk.dylib b/assets/mac_x64/libopenimsdk.dylib index e3e117b..c224617 100644 Binary files a/assets/mac_x64/libopenimsdk.dylib and b/assets/mac_x64/libopenimsdk.dylib differ diff --git a/assets/win_ia32/libopenimsdk.dll b/assets/win_ia32/libopenimsdk.dll index 5a836f4..1931511 100644 Binary files a/assets/win_ia32/libopenimsdk.dll and b/assets/win_ia32/libopenimsdk.dll differ diff --git a/assets/win_x64/libopenimsdk.dll b/assets/win_x64/libopenimsdk.dll index 5a836f4..1931511 100644 Binary files a/assets/win_x64/libopenimsdk.dll and b/assets/win_x64/libopenimsdk.dll differ diff --git a/package-lock.json b/package-lock.json index 2ed6c82..2519328 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@openim/electron-client-sdk", - "version": "1.0.2", + "version": "1.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@openim/electron-client-sdk", - "version": "1.0.2", + "version": "1.0.6", "license": "MIT", "dependencies": { "koffi": "^2.8.0", @@ -31,7 +31,6 @@ "husky": "^6.0.0", "jest": "^27.2.0", "lint-staged": "^10.5.4", - "open-im-sdk-wasm": "^3.5.3-alpha.3", "prettier": "^2.2.1", "rollup": "^2.79.1", "rollup-plugin-typescript2": "^0.36.0", @@ -43,8 +42,8 @@ "node": ">=12.0" }, "peerDependencies": { - "electron": ">=12.0.0", - "open-im-sdk-wasm": "^3.5.3-alpha.5" + "@openim/wasm-client-sdk": "^3.8.0-rc.0", + "electron": ">=12.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1881,6 +1880,15 @@ "@octokit/openapi-types": "^18.0.0" } }, + "node_modules/@openim/wasm-client-sdk": { + "version": "3.8.0-rc.0", + "resolved": "https://registry.npmjs.org/@openim/wasm-client-sdk/-/wasm-client-sdk-3.8.0-rc.0.tgz", + "integrity": "sha512-SGd0Yu4tUQfs9FDkR3x49NjX0jPO1W0ETxGYqKO1BMmIyhwVGeKQMpfHD2QXPh2yefhT4OLoNBffHihopUrK6Q==", + "peer": true, + "engines": { + "node": ">=12.0" + } + }, "node_modules/@pnpm/config.env-replace": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@pnpm/config.env-replace/-/config.env-replace-1.1.0.tgz", @@ -10172,15 +10180,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/open-im-sdk-wasm": { - "version": "3.5.3-alpha.3", - "resolved": "https://registry.npmjs.org/open-im-sdk-wasm/-/open-im-sdk-wasm-3.5.3-alpha.3.tgz", - "integrity": "sha512-J3NMi+G3LM1yjogl47dOR3LS4RD2fyTzn6NzVg9uKcgik2GD5zlopbX9IxH9AMBWEint/f9TpMe3qSF9+9NBBQ==", - "dev": true, - "engines": { - "node": ">=12.0" - } - }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", diff --git a/package.json b/package.json index ceb1d5e..26642ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openim/electron-client-sdk", - "version": "1.0.6", + "version": "1.0.7", "description": "open im sdk for node", "source": "src/index.ts", "main": "lib/index.js", @@ -45,6 +45,7 @@ "@commitlint/config-conventional": "^16.2.4", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-terser": "^0.4.4", + "@openim/wasm-client-sdk": "^3.8.0", "@types/ffi-napi": "^4.0.10", "@types/node": "^12.20.55", "@types/uuid": "^8.3.4", @@ -59,7 +60,6 @@ "husky": "^6.0.0", "jest": "^27.2.0", "lint-staged": "^10.5.4", - "open-im-sdk-wasm": "^3.5.3-alpha.6", "prettier": "^2.2.1", "rollup": "^2.79.1", "rollup-plugin-typescript2": "^0.36.0", @@ -80,7 +80,7 @@ "uuid": "^9.0.0" }, "peerDependencies": { - "electron": ">=12.0.0", - "open-im-sdk-wasm": "^3.8.0-rc.8" + "@openim/wasm-client-sdk": "^3.8.0", + "electron": ">=12.0.0" } } diff --git a/src/constant/callback.ts b/src/constant/callback.ts index a4cddbe..9f44ad9 100644 --- a/src/constant/callback.ts +++ b/src/constant/callback.ts @@ -1,4 +1,4 @@ -import { CbEvents } from 'open-im-sdk-wasm'; +import { CbEvents } from '@openim/wasm-client-sdk'; export enum NativeEvent { CONNECTING, CONNECT_SUCCESS, diff --git a/src/core/index.ts b/src/core/index.ts index d7896d3..4e2c676 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -14,13 +14,13 @@ import { setupConversationModule, } from './modules/conversation'; import { type MessageModuleApi, setupMessageModule } from './modules/message'; -import { CbEvents, LoginStatus } from 'open-im-sdk-wasm'; -import { SelfUserInfo } from 'open-im-sdk-wasm/lib/types/entity'; +import { CbEvents, LoginStatus } from '@openim/wasm-client-sdk'; +import { SelfUserInfo } from '@openim/wasm-client-sdk/lib/types/entity'; import { SetConversationExParams, SetFriendExParams, UploadFileParams, -} from 'open-im-sdk-wasm/lib/types/params'; +} from '@openim/wasm-client-sdk/lib/types/params'; import { type SignalingModuleApi, setupSignalingModule, diff --git a/src/core/modules/conversation.ts b/src/core/modules/conversation.ts index 8cbb698..9581f27 100644 --- a/src/core/modules/conversation.ts +++ b/src/core/modules/conversation.ts @@ -12,8 +12,8 @@ import { SetConversationExParams, SetConversationMsgDestructTimeParams, SetConversationMsgDestructParams, -} from 'open-im-sdk-wasm/lib/types/params'; -import { ConversationItem } from 'open-im-sdk-wasm/lib/types/entity'; +} from '@openim/wasm-client-sdk/lib/types/params'; +import { ConversationItem } from '@openim/wasm-client-sdk/lib/types/entity'; export function setupConversationModule(openIMSDK: OpenIMSDK) { return { diff --git a/src/core/modules/friend.ts b/src/core/modules/friend.ts index 9674cc8..5189422 100644 --- a/src/core/modules/friend.ts +++ b/src/core/modules/friend.ts @@ -10,14 +10,14 @@ import { RemarkFriendParams, SearchFriendParams, SetFriendExParams, -} from 'open-im-sdk-wasm/lib/types/params'; +} from '@openim/wasm-client-sdk/lib/types/params'; import { FriendshipInfo, BlackUserItem, FriendApplicationItem, FullUserItem, SearchedFriendsInfo, -} from 'open-im-sdk-wasm/lib/types/entity'; +} from '@openim/wasm-client-sdk/lib/types/entity'; export function setupFriendModule(openIMSDK: OpenIMSDK) { return { diff --git a/src/core/modules/group.ts b/src/core/modules/group.ts index d869c24..18f2ed8 100644 --- a/src/core/modules/group.ts +++ b/src/core/modules/group.ts @@ -5,7 +5,7 @@ import { GroupItem, GroupApplicationItem, GroupMemberItem, -} from 'open-im-sdk-wasm/lib/types/entity'; +} from '@openim/wasm-client-sdk/lib/types/entity'; import { CreateGroupParams, JoinGroupParams, @@ -20,7 +20,7 @@ import { TransferGroupParams, AccessToGroupParams, OffsetParams, -} from 'open-im-sdk-wasm/lib/types/params'; +} from '@openim/wasm-client-sdk/lib/types/params'; export function setupGroupModule(openIMSDK: OpenIMSDK) { return { diff --git a/src/core/modules/message.ts b/src/core/modules/message.ts index 15ceb1b..4033c6a 100644 --- a/src/core/modules/message.ts +++ b/src/core/modules/message.ts @@ -5,7 +5,7 @@ import { MessageItem, CardElem, AdvancedGetMessageResult, -} from 'open-im-sdk-wasm/lib/types/entity'; +} from '@openim/wasm-client-sdk/lib/types/entity'; import { AtMsgParams, LocationMsgParams, @@ -28,7 +28,7 @@ import { SoundMsgParamsByURL, SendGroupReadReceiptParams, GetGroupMessageReaderParams, -} from 'open-im-sdk-wasm/lib/types/params'; +} from '@openim/wasm-client-sdk/lib/types/params'; import { VideoMsgByPathParams, SoundMsgByPathParams, diff --git a/src/core/modules/signaling.ts b/src/core/modules/signaling.ts index 3a52023..18ba6fd 100644 --- a/src/core/modules/signaling.ts +++ b/src/core/modules/signaling.ts @@ -8,12 +8,12 @@ import { RtcActionParams, SignalingInviteParams, UpdateMeetingParams, -} from 'open-im-sdk-wasm/lib/types/params'; +} from '@openim/wasm-client-sdk/lib/types/params'; import { RtcInviteResults, CallingRoomData, MeetingRecord, -} from 'open-im-sdk-wasm/lib/types/entity'; +} from '@openim/wasm-client-sdk/lib/types/entity'; export function setupSignalingModule(openIMSDK: OpenIMSDK) { return { diff --git a/src/core/modules/user.ts b/src/core/modules/user.ts index 7ede519..e9bbbc7 100644 --- a/src/core/modules/user.ts +++ b/src/core/modules/user.ts @@ -1,16 +1,16 @@ import { v4 as uuidV4 } from 'uuid'; import { BaseResponse } from '@/types/entity'; import OpenIMSDK from '..'; -import { MessageReceiveOptType } from 'open-im-sdk-wasm'; +import { MessageReceiveOptType } from '@openim/wasm-client-sdk'; import { SelfUserInfo, FullUserItemWithCache, UserOnlineState, -} from 'open-im-sdk-wasm/lib/types/entity'; +} from '@openim/wasm-client-sdk/lib/types/entity'; import { GetUserInfoWithCacheParams, PartialUserItem, -} from 'open-im-sdk-wasm/lib/types/params'; +} from '@openim/wasm-client-sdk/lib/types/params'; export function setupUserModule(openIMSDK: OpenIMSDK) { return { diff --git a/src/main.ts b/src/main.ts index 8adae0d..16ae098 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import { ipcMain, WebContents } from 'electron'; -import { CbEvents } from 'open-im-sdk-wasm'; +import { CbEvents } from '@openim/wasm-client-sdk'; import OpenIMSDK from './core'; class OpenIMSDKMain { diff --git a/src/render.ts b/src/render.ts index 7cdee05..2b769a7 100644 --- a/src/render.ts +++ b/src/render.ts @@ -1,9 +1,12 @@ -import { CbEvents, getSDK as WasmGetSDK } from 'open-im-sdk-wasm'; -import { MessageItem, WsResponse } from 'open-im-sdk-wasm/lib/types/entity'; +import { CbEvents, getSDK as WasmGetSDK } from '@openim/wasm-client-sdk'; +import { + MessageItem, + WsResponse, +} from '@openim/wasm-client-sdk/lib/types/entity'; import { WasmPathConfig, InitAndLoginConfig, -} from 'open-im-sdk-wasm/lib/types/params'; +} from '@openim/wasm-client-sdk/lib/types/params'; import Emitter from './utils/emitter'; import { InitConfig, @@ -109,7 +112,7 @@ const methodCache = new WeakMap(); async function createWasmSDK(wasmConfig?: WasmPathConfig): Promise { if (!wasmSDK) { - const { getSDK } = await import('open-im-sdk-wasm'); + const { getSDK } = await import('@openim/wasm-client-sdk'); wasmSDK = getSDK(wasmConfig) as unknown as IMSDKInterface; } } @@ -148,6 +151,7 @@ export function getWithRenderProcess( return cachedMethod(...args); } // @ts-ignore + // eslint-disable-next-line const method = async (...args: any[]) => wasmSDK![prop](...args); methodCache.set(wasmSDK![prop], method); return method(...args); diff --git a/src/types/entity.ts b/src/types/entity.ts index 201be26..0e26752 100644 --- a/src/types/entity.ts +++ b/src/types/entity.ts @@ -1,4 +1,4 @@ -import { CbEvents } from 'open-im-sdk-wasm'; +import { CbEvents } from '@openim/wasm-client-sdk'; export type EmitProxy = (event: CbEvents, ...args: any[]) => void; diff --git a/src/types/global.d.ts b/src/types/global.d.ts index e635b4f..1aef63f 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -1,4 +1,4 @@ -import { WsResponse } from 'open-im-sdk-wasm/lib/types/entity'; +import { WsResponse } from '@openim/wasm-client-sdk/lib/types/entity'; export interface IOpenIMRenderAPI { subscribe: ( diff --git a/src/types/params.ts b/src/types/params.ts index a3d8efd..36edb2f 100644 --- a/src/types/params.ts +++ b/src/types/params.ts @@ -1,4 +1,4 @@ -import { LogLevel } from 'open-im-sdk-wasm'; +import { LogLevel } from '@openim/wasm-client-sdk'; export interface InitConfig { apiAddr: string; wsAddr: string; diff --git a/src/utils/emitter.ts b/src/utils/emitter.ts index 08bea04..db45284 100644 --- a/src/utils/emitter.ts +++ b/src/utils/emitter.ts @@ -1,4 +1,4 @@ -import { CbEvents } from 'open-im-sdk-wasm'; +import { CbEvents } from '@openim/wasm-client-sdk'; interface Events { [key: string]: Cbfn[];