@maebgch/rcs-emulator 0.1.0 → 0.1.2
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 +56 -86
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,9 +10,7 @@ Reusable, production-ready emulator UI for RCS Business Messaging (RBM). Ships a
|
|
|
10
10
|
- Ships typed helpers and guards (`validateConversationFlow`, `useJsonFetch`, RBM schema types)
|
|
11
11
|
- Bundled CSS (`dist/style.css`) generated from Tailwind classes—no Tailwind setup required in consumer apps
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
### From npm (once published)
|
|
13
|
+
## Installation
|
|
16
14
|
|
|
17
15
|
```bash
|
|
18
16
|
npm install @maebgch/rcs-emulator
|
|
@@ -22,25 +20,7 @@ pnpm add @maebgch/rcs-emulator
|
|
|
22
20
|
yarn add @maebgch/rcs-emulator
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
1. Build and pack the library:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npm install
|
|
31
|
-
npm run build:lib
|
|
32
|
-
npm pack # produces maebgch-rcs-emulator-0.1.0.tgz
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
2. In your consuming project:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npm install ../path/to/maebgch-rcs-emulator-0.1.0.tgz
|
|
39
|
-
# or
|
|
40
|
-
pnpm add file:../path/to/maebgch-rcs-emulator-0.1.0.tgz
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Quick start
|
|
23
|
+
## Quick Start
|
|
44
24
|
|
|
45
25
|
```tsx
|
|
46
26
|
import {
|
|
@@ -106,7 +86,9 @@ export default function App() {
|
|
|
106
86
|
}
|
|
107
87
|
```
|
|
108
88
|
|
|
109
|
-
##
|
|
89
|
+
## API Reference
|
|
90
|
+
|
|
91
|
+
### Props
|
|
110
92
|
|
|
111
93
|
- `messages?: RbmConversationFlow` – Inline RBM JSON (provide this OR `jsonUrl`)
|
|
112
94
|
- `jsonUrl?: string` – Remote RBM JSON to fetch
|
|
@@ -119,84 +101,72 @@ export default function App() {
|
|
|
119
101
|
- `showSuggestions?: boolean` – Toggle suggestion chips
|
|
120
102
|
- `showLockScreen?: boolean` – Start on lock screen preview
|
|
121
103
|
|
|
122
|
-
### Callback
|
|
104
|
+
### Callback Payload
|
|
123
105
|
|
|
124
106
|
`UserReplyPayload` includes `{ type: "reply" | "action", postbackData, displayText, actionData?, timestamp }`. WebView actions surface `actionData: { type: "webview", url, viewMode, description? }`.
|
|
125
107
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- Helpers: `validateConversationFlow`, `getFirstMessagePreview`
|
|
129
|
-
- Hooks: `useJsonFetch`
|
|
130
|
-
- RBM types & guards: `RbmConversationFlow`, `RbmMessage`, `isSuggestedReply`, `isSuggestedAction`, `isWebViewAction`, `getWebViewConfig`
|
|
131
|
-
- Standalone component: `WebViewRenderer`
|
|
108
|
+
### Additional Exports
|
|
132
109
|
|
|
133
|
-
|
|
110
|
+
- **Helpers:** `validateConversationFlow`, `getFirstMessagePreview`
|
|
111
|
+
- **Hooks:** `useJsonFetch`
|
|
112
|
+
- **RBM types & guards:** `RbmConversationFlow`, `RbmMessage`, `isSuggestedReply`, `isSuggestedAction`, `isWebViewAction`, `getWebViewConfig`
|
|
113
|
+
- **Standalone component:** `WebViewRenderer`
|
|
134
114
|
|
|
135
|
-
|
|
136
|
-
- A ready-made sample lives at `public/test.json`.
|
|
137
|
-
- Each node supports text, rich cards, carousels, suggestions, and optional branching via `nextMessageIds`.
|
|
138
|
-
|
|
139
|
-
## Building the library (for publish/testing)
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npm install
|
|
143
|
-
npm run build:lib
|
|
144
|
-
```
|
|
115
|
+
## RBM JSON Schema
|
|
145
116
|
|
|
146
|
-
|
|
117
|
+
- Use `RbmConversationFlow` type as the schema reference
|
|
118
|
+
- Each node supports text, rich cards, carousels, suggestions, and optional branching via `nextMessageIds`
|
|
119
|
+
- See TypeScript types in `src/components/RcsEmulator/types/rbm.types.ts` for full schema
|
|
147
120
|
|
|
148
|
-
|
|
149
|
-
- `style.css` (bundled Tailwind output)
|
|
150
|
-
- `types/index.d.ts` (TypeScript declarations)
|
|
121
|
+
## Usage Examples
|
|
151
122
|
|
|
152
|
-
|
|
123
|
+
### Basic Usage
|
|
153
124
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
- `import { RcsEmulator } from "@maebgch/rcs-emulator";`
|
|
158
|
-
3. Pass an RBM JSON payload or `jsonUrl`, and handle `onUserReply`.
|
|
159
|
-
|
|
160
|
-
## Developing the demo app locally
|
|
161
|
-
|
|
162
|
-
- `npm run dev` – run the playground app
|
|
163
|
-
- `npm run build` – build the playground app
|
|
164
|
-
- `npm run lint` – lint the repo
|
|
165
|
-
|
|
166
|
-
## Publishing to npm
|
|
167
|
-
|
|
168
|
-
1. **Ensure you're logged in to npm:**
|
|
125
|
+
```tsx
|
|
126
|
+
import { RcsEmulator } from "@maebgch/rcs-emulator";
|
|
127
|
+
import "@maebgch/rcs-emulator/style.css";
|
|
169
128
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
129
|
+
function App() {
|
|
130
|
+
return (
|
|
131
|
+
<RcsEmulator
|
|
132
|
+
jsonUrl="https://example.com/conversation.json"
|
|
133
|
+
onUserReply={(payload) => console.log(payload)}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
174
138
|
|
|
175
|
-
|
|
139
|
+
### With Custom Theme and Device
|
|
176
140
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
141
|
+
```tsx
|
|
142
|
+
<RcsEmulator
|
|
143
|
+
messages={conversationFlow}
|
|
144
|
+
onUserReply={handleReply}
|
|
145
|
+
theme="dark"
|
|
146
|
+
device="ios"
|
|
147
|
+
width={414}
|
|
148
|
+
height={896}
|
|
149
|
+
/>
|
|
150
|
+
```
|
|
180
151
|
|
|
181
|
-
|
|
152
|
+
### With Business Branding
|
|
182
153
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
154
|
+
```tsx
|
|
155
|
+
<RcsEmulator
|
|
156
|
+
messages={conversationFlow}
|
|
157
|
+
onUserReply={handleReply}
|
|
158
|
+
businessInfo={{
|
|
159
|
+
name: "My Business",
|
|
160
|
+
logo: "https://example.com/logo.png",
|
|
161
|
+
brandColor: "#FF5733",
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
```
|
|
187
165
|
|
|
188
|
-
|
|
166
|
+
## License
|
|
189
167
|
|
|
190
|
-
|
|
191
|
-
npm publish --access public
|
|
192
|
-
```
|
|
168
|
+
MIT
|
|
193
169
|
|
|
194
|
-
|
|
170
|
+
## Contributing
|
|
195
171
|
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
npm version patch # for bug fixes (0.1.0 -> 0.1.1)
|
|
199
|
-
npm version minor # for new features (0.1.0 -> 0.2.0)
|
|
200
|
-
npm version major # for breaking changes (0.1.0 -> 1.0.0)
|
|
201
|
-
npm publish --access public
|
|
202
|
-
```
|
|
172
|
+
See [DEVELOPMENT.md](./DEVELOPMENT.md) for development setup and contribution guidelines.
|
package/package.json
CHANGED