You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively you can add the library to your page using the file [`segmentsCalculator.js`](https://github.com/TwilioDevEd/message-segment-calculator/blob/main/docs/scripts/segmentsCalculator.js) provided in `docs/scripts/` and adding it to your page:
39
+
Alternatively you can add the library to your page using the file [`segmentsCalculator.js`](https://github.com/TwilioDevEd/message-segment-calculator/blob/main/docs/scripts/segmentsCalculator.js) provided in `docs/scripts/` and adding it to your page:
And example of usage can be find in [`docs/index.html`](https://github.com/TwilioDevEd/message-segment-calculator/blob/main/docs/index.html)
45
+
Once loaded, the browser bundle exposes `SegmentedMessage` and `RcsSegmentedMessage` as globals.
46
+
47
+
An example of usage can be find in [`docs/index.html`](https://github.com/TwilioDevEd/message-segment-calculator/blob/main/docs/index.html)
42
48
43
49
## Documentation
44
50
### `SegmentedMessage` class
@@ -70,12 +76,49 @@ Number of segment(s)
70
76
71
77
Return an array with the non GSM-7 characters in the body. It can be used to replace character and reduce the number of segments
72
78
79
+
### `RcsSegmentedMessage` class
80
+
81
+
RCS always uses UTF-8. For US destinations, messages are billed per 160 UTF-8 byte “Rich” segment. For international destinations, there is no segmentation: `<=160` bytes is billed as `Basic`, and `>160` bytes is billed as `Single`.
82
+
83
+
#### `constructor(message, region)`
84
+
Arguments:
85
+
*`message`: Body of the RCS message
86
+
*`region`: `us` or `international` (default: `us`)
87
+
88
+
##### `encodingName`
89
+
90
+
Always returns `"UTF-8"`.
91
+
92
+
##### `numberOfBytes`
93
+
94
+
Number of UTF-8 bytes in the message body.
95
+
96
+
##### `messageSize`
97
+
98
+
Total size of the message body in bits.
99
+
100
+
##### `segmentsCount`
101
+
102
+
Number of RCS segment(s) the message is split into for billing.
103
+
104
+
##### `segments`
105
+
106
+
An array with one entry per segment. Each entry contains `index`, `capacity`, and `used` (bytes).
107
+
108
+
##### `messageType`
109
+
110
+
Returns `Rich`, `Basic`, or `Single` based on the region and UTF-8 length.
111
+
112
+
##### `region`
113
+
114
+
The region used for calculation: `"us"` or `"international"`.
115
+
73
116
## Try the library
74
117
75
118
If you want to test the library you can use the script provided in `playground/index.js`. Install the dependencies (`npm install`) and then run:
76
119
77
120
```shell
78
-
$ node playground/index.js "👋 Hello World 🌍"
121
+
node playground/index.js "👋 Hello World 🌍"
79
122
```
80
123
81
124
## Contributing
@@ -89,6 +132,18 @@ The source code for the library is all contained in the `src` folder. Before sub
89
132
* Execute the test using `npm test` and make sure all tests pass
90
133
* Transpile the code using `npm run webpack` and test the web page in `docs/index.html`
91
134
135
+
## Accessibility
136
+
137
+
The docs UI follows Paste-aligned accessibility guidelines:
138
+
* All color meaning includes a text label (encoding, fill state)
139
+
* Stats updates use `aria-live="polite"` for screen reader announcements
140
+
* Inputs include visible focus styles and associated labels
141
+
* Segment bars use `role=\"meter\"` with value attributes
142
+
143
+
## Design Inspiration
144
+
145
+
We used the Kimoby SMS Segment Counter as visual inspiration: https://www.kimoby.com/calculators/sms-segment-counter
0 commit comments