@@ -16,6 +16,7 @@ import Connection, {
16
16
import { ErrorCode , createError } from './error' ;
17
17
import { tap , Cache , trim , internal , ensureArray , isWeapp } from './utils' ;
18
18
import { applyDecorators , applyDispatcher } from './plugin' ;
19
+ import { version as VERSION } from '../package.json' ;
19
20
20
21
const debug = d ( 'LC:Realtime' ) ;
21
22
const debugRequest = d ( 'LC:request' ) ;
@@ -37,8 +38,8 @@ export default class Realtime extends EventEmitter {
37
38
* @param {String|String[] } [options.RTMServers] 指定私有部署的 RTM 服务器地址(since 4.0.0)
38
39
* @param {Plugin[] } [options.plugins] 加载插件(since 3.1.0)
39
40
*/
40
- constructor ( options ) {
41
- debug ( 'initializing Realtime' ) ;
41
+ constructor ( { plugins , ... options } ) {
42
+ debug ( 'initializing Realtime %s %O' , VERSION , options ) ;
42
43
super ( ) ;
43
44
if ( typeof options . appId !== 'string' ) {
44
45
throw new TypeError ( `appId [${ options . appId } ] is not a string` ) ;
@@ -60,10 +61,12 @@ export default class Realtime extends EventEmitter {
60
61
) ;
61
62
this . _cache = new Cache ( 'endpoints' ) ;
62
63
internal ( this ) . clients = new Set ( ) ;
63
- this . _plugins = [
64
+ const mergedPlugins = [
64
65
...ensureArray ( Realtime . __preRegisteredPlugins ) ,
65
- ...ensureArray ( options . plugins ) ,
66
- ] . reduce ( ( result , plugin ) => {
66
+ ...ensureArray ( plugins ) ,
67
+ ] ;
68
+ debug ( 'Using plugins %o' , mergedPlugins . map ( plugin => plugin . name ) ) ;
69
+ this . _plugins = mergedPlugins . reduce ( ( result , plugin ) => {
67
70
// eslint-disable-next-line no-restricted-syntax
68
71
for ( const hook in plugin ) {
69
72
if ( { } . hasOwnProperty . call ( plugin , hook ) && hook !== 'name' ) {
0 commit comments