@cloudbase/js-sdk 3.9.4 → 3.9.5-alpha.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/core.d.ts CHANGED
@@ -38,6 +38,7 @@ declare namespace cloudbase {
38
38
  type OrmClient = import('@cloudbase/js-sdk/model').OrmClient
39
39
  type OrmRawQueryClient = import('@cloudbase/js-sdk/model').OrmRawQueryClient
40
40
  type IMySqlClient = import('@cloudbase/js-sdk/mysql').IMySqlClient
41
+ type RealtimeClient = import('@cloudbase/realtime-js').RealtimeClient
41
42
  type AI = import('@cloudbase/js-sdk/ai').AI
42
43
  type CloudbaseAdapter = import('@cloudbase/adapter-interface').CloudbaseAdapter
43
44
  type ResponseObject = import('@cloudbase/adapter-interface').ResponseObject
@@ -751,6 +752,26 @@ declare namespace cloudbase.app {
751
752
  mysql: IMySqlClient
752
753
  rdb: IMySqlClient
753
754
 
755
+ /**
756
+ * Realtime 客户端(Broadcast / Presence / Postgres CDC)
757
+ *
758
+ * WebSocket 地址为 `wss://{GW}/v1/realtime/websocket?apikey={accessToken}&vsn=1.0.0`。
759
+ *
760
+ * 浏览器 / Node / 微信小程序均通过 `app.realtime()` 获取客户端。
761
+ * 小程序不要单独 `new RealtimeClient()`,需使用已注册 adapter 的 `wsClass`。
762
+ * 使用前需先登录(如 `auth.signInAnonymously()`);没有登录态时会在控制台提示。
763
+ *
764
+ * @example
765
+ * ```javascript
766
+ * const app = cloudbase.init({ env: 'xxxx-yyy' })
767
+ * const realtime = app.realtime()
768
+ * const channel = realtime.channel('room')
769
+ * channel.on('broadcast', { event: 'cursor-pos' }, (payload) => console.log(payload))
770
+ * channel.subscribe()
771
+ * ```
772
+ */
773
+ realtime(): RealtimeClient
774
+
754
775
  ai(options?: { baseUrl?: string }): AI
755
776
 
756
777
  apis: ICloudbaseApis