@volorio/react-native-rtm 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +28 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @volorio/react-native-rtm
|
|
2
|
+
|
|
3
|
+
React Native RTM helpers for Volorio channel messages and presence.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @volorio/react-native-rtm
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { VolorioReactNativeRtmClient } from "@volorio/react-native-rtm";
|
|
11
|
+
|
|
12
|
+
const rtm = new VolorioReactNativeRtmClient(room);
|
|
13
|
+
await rtm.publishMessage("lobby", { text: "hello" });
|
|
14
|
+
await rtm.setPresence("lobby", { status: "online" });
|
|
15
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VolorioReactNativeRoomClient } from "@volorio/react-native";
|
|
2
|
+
export interface VolorioReactNativeRtmPresence {
|
|
3
|
+
identity?: string;
|
|
4
|
+
status: "online" | "away" | "busy" | "offline" | string;
|
|
5
|
+
metadata?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare class VolorioReactNativeRtmClient {
|
|
8
|
+
private readonly room;
|
|
9
|
+
constructor(room: Pick<VolorioReactNativeRoomClient, "sendMessage">);
|
|
10
|
+
publishMessage<TPayload>(channel: string, payload: TPayload, clientMessageId?: string): Promise<void>;
|
|
11
|
+
setPresence(channel: string, presence: VolorioReactNativeRtmPresence): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolorioReactNativeRtmClient = void 0;
|
|
4
|
+
class VolorioReactNativeRtmClient {
|
|
5
|
+
room;
|
|
6
|
+
constructor(room) {
|
|
7
|
+
this.room = room;
|
|
8
|
+
}
|
|
9
|
+
async publishMessage(channel, payload, clientMessageId) {
|
|
10
|
+
await this.room.sendMessage(JSON.stringify({
|
|
11
|
+
type: "volorio.rn.rtm.message",
|
|
12
|
+
channel,
|
|
13
|
+
payload,
|
|
14
|
+
clientMessageId,
|
|
15
|
+
sentAt: new Date().toISOString(),
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
async setPresence(channel, presence) {
|
|
19
|
+
await this.room.sendMessage(JSON.stringify({
|
|
20
|
+
type: "volorio.rn.rtm.presence",
|
|
21
|
+
channel,
|
|
22
|
+
payload: presence,
|
|
23
|
+
sentAt: new Date().toISOString(),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.VolorioReactNativeRtmClient = VolorioReactNativeRtmClient;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAQA,MAAa,2BAA2B;IACT;IAA7B,YAA6B,IAAuD;QAAvD,SAAI,GAAJ,IAAI,CAAmD;IAAG,CAAC;IAExF,KAAK,CAAC,cAAc,CAAW,OAAe,EAAE,OAAiB,EAAE,eAAwB;QACzF,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;YACzC,IAAI,EAAE,wBAAwB;YAC9B,OAAO;YACP,OAAO;YACP,eAAe;YACf,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACjC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,QAAuC;QACxE,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;YACzC,IAAI,EAAE,yBAAyB;YAC/B,OAAO;YACP,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACjC,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AArBD,kEAqBC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volorio/react-native-rtm",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Volorio React Native RTM helpers for channel messages and presence.",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"types": "dist/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
|
+
"default": "./dist/src/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/src",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org/"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.build.json",
|
|
24
|
+
"test": "pnpm build",
|
|
25
|
+
"pack:local": "pnpm build && npm pack --pack-destination dist"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@volorio/react-native": "^0.2.0"
|
|
29
|
+
}
|
|
30
|
+
}
|