@maebgch/rcs-emulator 0.1.0 → 0.1.1
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 +70 -78
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +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
|
-
##
|
|
13
|
+
## Installation
|
|
14
14
|
|
|
15
15
|
### From npm (once published)
|
|
16
16
|
|
|
@@ -24,23 +24,25 @@ yarn add @maebgch/rcs-emulator
|
|
|
24
24
|
|
|
25
25
|
### Local install (for development/testing)
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
If you want to test the package locally before it's published or use a local development version:
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
npm install
|
|
31
|
-
npm run build:lib
|
|
32
|
-
npm pack # produces maebgch-rcs-emulator-0.1.0.tgz
|
|
33
|
-
```
|
|
29
|
+
1. **Build and pack the library:**
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
```bash
|
|
32
|
+
npm install
|
|
33
|
+
npm run build:lib
|
|
34
|
+
npm pack # produces maebgch-rcs-emulator-0.1.0.tgz
|
|
35
|
+
```
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
2. **In your consuming project:**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install ../path/to/maebgch-rcs-emulator-0.1.0.tgz
|
|
41
|
+
# or
|
|
42
|
+
pnpm add file:../path/to/maebgch-rcs-emulator-0.1.0.tgz
|
|
43
|
+
```
|
|
42
44
|
|
|
43
|
-
## Quick
|
|
45
|
+
## Quick Start
|
|
44
46
|
|
|
45
47
|
```tsx
|
|
46
48
|
import {
|
|
@@ -106,7 +108,9 @@ export default function App() {
|
|
|
106
108
|
}
|
|
107
109
|
```
|
|
108
110
|
|
|
109
|
-
##
|
|
111
|
+
## API Reference
|
|
112
|
+
|
|
113
|
+
### Props
|
|
110
114
|
|
|
111
115
|
- `messages?: RbmConversationFlow` – Inline RBM JSON (provide this OR `jsonUrl`)
|
|
112
116
|
- `jsonUrl?: string` – Remote RBM JSON to fetch
|
|
@@ -119,84 +123,72 @@ export default function App() {
|
|
|
119
123
|
- `showSuggestions?: boolean` – Toggle suggestion chips
|
|
120
124
|
- `showLockScreen?: boolean` – Start on lock screen preview
|
|
121
125
|
|
|
122
|
-
### Callback
|
|
126
|
+
### Callback Payload
|
|
123
127
|
|
|
124
128
|
`UserReplyPayload` includes `{ type: "reply" | "action", postbackData, displayText, actionData?, timestamp }`. WebView actions surface `actionData: { type: "webview", url, viewMode, description? }`.
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- Helpers: `validateConversationFlow`, `getFirstMessagePreview`
|
|
129
|
-
- Hooks: `useJsonFetch`
|
|
130
|
-
- RBM types & guards: `RbmConversationFlow`, `RbmMessage`, `isSuggestedReply`, `isSuggestedAction`, `isWebViewAction`, `getWebViewConfig`
|
|
131
|
-
- Standalone component: `WebViewRenderer`
|
|
132
|
-
|
|
133
|
-
## RBM JSON shape
|
|
130
|
+
### Additional Exports
|
|
134
131
|
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
132
|
+
- **Helpers:** `validateConversationFlow`, `getFirstMessagePreview`
|
|
133
|
+
- **Hooks:** `useJsonFetch`
|
|
134
|
+
- **RBM types & guards:** `RbmConversationFlow`, `RbmMessage`, `isSuggestedReply`, `isSuggestedAction`, `isWebViewAction`, `getWebViewConfig`
|
|
135
|
+
- **Standalone component:** `WebViewRenderer`
|
|
138
136
|
|
|
139
|
-
##
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npm install
|
|
143
|
-
npm run build:lib
|
|
144
|
-
```
|
|
137
|
+
## RBM JSON Schema
|
|
145
138
|
|
|
146
|
-
|
|
139
|
+
- Use `RbmConversationFlow` type as the schema reference
|
|
140
|
+
- Each node supports text, rich cards, carousels, suggestions, and optional branching via `nextMessageIds`
|
|
141
|
+
- See TypeScript types in `src/components/RcsEmulator/types/rbm.types.ts` for full schema
|
|
147
142
|
|
|
148
|
-
|
|
149
|
-
- `style.css` (bundled Tailwind output)
|
|
150
|
-
- `types/index.d.ts` (TypeScript declarations)
|
|
143
|
+
## Usage Examples
|
|
151
144
|
|
|
152
|
-
|
|
145
|
+
### Basic Usage
|
|
153
146
|
|
|
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:**
|
|
147
|
+
```tsx
|
|
148
|
+
import { RcsEmulator } from "@maebgch/rcs-emulator";
|
|
149
|
+
import "@maebgch/rcs-emulator/style.css";
|
|
169
150
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
151
|
+
function App() {
|
|
152
|
+
return (
|
|
153
|
+
<RcsEmulator
|
|
154
|
+
jsonUrl="https://example.com/conversation.json"
|
|
155
|
+
onUserReply={(payload) => console.log(payload)}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
174
160
|
|
|
175
|
-
|
|
161
|
+
### With Custom Theme and Device
|
|
176
162
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
163
|
+
```tsx
|
|
164
|
+
<RcsEmulator
|
|
165
|
+
messages={conversationFlow}
|
|
166
|
+
onUserReply={handleReply}
|
|
167
|
+
theme="dark"
|
|
168
|
+
device="ios"
|
|
169
|
+
width={414}
|
|
170
|
+
height={896}
|
|
171
|
+
/>
|
|
172
|
+
```
|
|
180
173
|
|
|
181
|
-
|
|
174
|
+
### With Business Branding
|
|
182
175
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
```tsx
|
|
177
|
+
<RcsEmulator
|
|
178
|
+
messages={conversationFlow}
|
|
179
|
+
onUserReply={handleReply}
|
|
180
|
+
businessInfo={{
|
|
181
|
+
name: "My Business",
|
|
182
|
+
logo: "https://example.com/logo.png",
|
|
183
|
+
brandColor: "#FF5733",
|
|
184
|
+
}}
|
|
185
|
+
/>
|
|
186
|
+
```
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
## License
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
npm publish --access public
|
|
192
|
-
```
|
|
190
|
+
MIT
|
|
193
191
|
|
|
194
|
-
|
|
192
|
+
## Contributing
|
|
195
193
|
|
|
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
|
-
```
|
|
194
|
+
See [DEVELOPMENT.md](./DEVELOPMENT.md) for development setup and contribution guidelines.
|
package/package.json
CHANGED