@quantabit/push-sdk 1.0.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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/index.cjs +2142 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +2094 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/styles.css.map +1 -0
- package/package.json +89 -0
- package/types/index.d.ts +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QuantaBit Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @quantabit/push-sdk
|
|
2
|
+
|
|
3
|
+
> 通用推送通知适配层 — 一套 API 接入多种推送服务
|
|
4
|
+
|
|
5
|
+
## 支持的推送服务
|
|
6
|
+
|
|
7
|
+
| 适配器 | 类型 | 场景 |
|
|
8
|
+
|--------|------|------|
|
|
9
|
+
| WebPushAdapter | 浏览器原生 | 标准 Web Push |
|
|
10
|
+
| WebSocketAdapter | 自研 | IM / 实时推送 |
|
|
11
|
+
| SSEAdapter | 服务端推送 | 单向实时流 |
|
|
12
|
+
| FCMAdapter | 商业 | Firebase Cloud Messaging |
|
|
13
|
+
| OneSignalAdapter | 商业 | OneSignal 推送 |
|
|
14
|
+
| JPushAdapter | 商业 | 极光推送 |
|
|
15
|
+
| MockAdapter | 测试 | 开发/测试模拟 |
|
|
16
|
+
|
|
17
|
+
## 使用示例
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { PushManager, usePush } from '@quantabit/push-sdk';
|
|
21
|
+
|
|
22
|
+
// 方式1: 类实例
|
|
23
|
+
const push = new PushManager({ adapter: 'websocket', url: 'wss://your-server/ws' });
|
|
24
|
+
push.connect();
|
|
25
|
+
push.onMessage(msg => console.log(msg));
|
|
26
|
+
|
|
27
|
+
// 方式2: React Hook
|
|
28
|
+
const { connected, lastMessage, send } = usePush({ adapter: 'websocket', url: 'wss://...' });
|
|
29
|
+
|
|
30
|
+
// 方式3: 自定义适配器
|
|
31
|
+
const push = new PushManager({ adapter: myCustomAdapter });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 特性
|
|
35
|
+
- 🔌 适配器模式,一行切换推送服务
|
|
36
|
+
- 🔄 自动重连 + 指数退避
|
|
37
|
+
- 📦 离线消息队列
|
|
38
|
+
- 🔧 消息中间件管线
|
|
39
|
+
- ⚛️ React Hook + Provider
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
MIT
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🌐 Brand & Links
|
|
49
|
+
- Official Mainnet: [QuantaBit Chain](https://qbitchain.io/)
|
|
50
|
+
- Developer Platform: [Developer Platform](https://developer.quantabit.io/)
|
|
51
|
+
- Open Platform: [Open Platform](https://open.quantabit.io/)
|
|
52
|
+
- Payment Platform: [Pay Platform](https://pay.qbitwallet.io/)
|
|
53
|
+
- Feedback: [Feedback](https://xwin.live/qbit)
|