Skip to content

Commit 8eac472

Browse files
authored
sync features and bugfixs from b33ddb14 (#1660)
1 parent 504e0c9 commit 8eac472

File tree

418 files changed

+9442
-2242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

418 files changed

+9442
-2242
lines changed

.sync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
94b20ac373f4b4b2b76a4023a3f2e369eb193d91
1+
b33ddb1410019452acbe86c80a5efa52d1331701

packages/babel-settings/babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const plugins = [
1616
'@babel/plugin-proposal-object-rest-spread',
1717
'@babel/plugin-proposal-optional-chaining',
1818
'@babel/plugin-proposal-nullish-coalescing-operator',
19+
'const-enum',
1920
];
2021

2122
module.exports = function baseBabelConfig(api) {

packages/babel-settings/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@babel/preset-react": "^7.10.4",
2626
"@babel/preset-typescript": "^7.10.4",
2727
"@babel/register": "^7.10.5",
28+
"babel-plugin-const-enum": "^1.0.1",
2829
"core-js": "^2.6.11",
2930
"typescript": "^4.0.2"
3031
},

packages/core/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ yarn add @ringcentral-integration/core
1717
- [state API](#state-api)
1818
- [action API](#action-api)
1919
- [computed API](#computed-api)
20-
- [proxyState API](#proxystate-api)
2120
- [RcUIModule APIs](#rcuimodule-apis)
2221
- [Dependency Injection](#dependency-injection)
2322
- [Storage and GlobalStorage APIs](#storage-and-globalstorage-apis)
@@ -26,7 +25,7 @@ yarn add @ringcentral-integration/core
2625

2726
### RcModule APIs
2827

29-
`@ringcentral-integration/core` provides `RcModuleV2` base module, decorators `state`, `action`, `computed`, `storage` and `globalStorage`, `proxyState`.
28+
`@ringcentral-integration/core` provides `RcModuleV2` base module, decorators `state`, `action`, `computed`, `storage` and `globalStorage`.
3029

3130
The decorator `storage` depends on `Storage` Module, And The decorator `globalStorage` depends on `GlobalStorage` Module.
3231

@@ -122,10 +121,6 @@ class Auth extends RcModuleV2<Deps> {
122121
}
123122
```
124123

125-
#### proxyState API
126-
127-
`@proxyState` is used for asynchronous state changes of the browser client, and its parameter must be an asynchronous function and cannot be used with `@storage`/`@globalStorage`.
128-
129124
### RcUIModule APIs
130125

131126
`@ringcentral-integration/core` provides `RcUIModuleV2` base module and all decorators in `RcModuleV2`.
@@ -253,18 +248,30 @@ class Call extends RcModuleV2<Deps> {
253248
});
254249
}
255250

251+
// Pass a tracking event type
256252
@track(trackEvents.inbound)
257253
inboundCall() {
258254
//
259255
}
260256

257+
// Pass a function that returns an array `[customTrackEvent, trackProps]`
261258
@track((that: Call, phoneNumber: string) => [
262259
trackEvents.outbound,
263260
{ loginType: that.callType, phoneNumber },
264261
])
265262
async dialout(phoneNumber: string) {
266263
//
267264
}
265+
266+
// Pass a higher-order function and the sub-function has access to the `analytics` module
267+
@track(() => (analytics) => {
268+
analytics.setUserId();
269+
return [trackEvents.authentication];
270+
})
271+
@action
272+
setLoginSuccess(token: TokenInfo) {
273+
//
274+
}
268275
}
269276
```
270277

packages/core/lib/RcModule/RcModule.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Storage as StorageV2 } from 'ringcentral-integration/modules/StorageV2'
55
import { GlobalStorage as GlobalStorageV2 } from 'ringcentral-integration/modules/GlobalStorageV2';
66
import Storage from 'ringcentral-integration/modules/Storage';
77
import GlobalStorage from 'ringcentral-integration/modules/GlobalStorage';
8-
import { Analytics } from 'ringcentral-integration/modules/Analytics';
8+
import { Analytics } from 'ringcentral-integration/modules/AnalyticsV2';
99
import BaseModule, { state, action } from '../usm-redux';
1010
import { moduleStatuses } from '../../enums/moduleStatuses';
1111
import { Params } from '../usm/core/module';
@@ -42,7 +42,11 @@ function storage(
4242
return descriptor;
4343
}
4444

45-
type TrackEvent = string | ((...args: any) => [string, object?]);
45+
type TrackEvent =
46+
| string
47+
| ((
48+
...args: any
49+
) => [string, object?] | ((analytics: Analytics) => [string, object?]));
4650

4751
/**
4852
* decorate a method with `Analytics` Module
@@ -75,7 +79,11 @@ function track(trackEvent: TrackEvent) {
7579
if (typeof trackEvent === 'string') {
7680
analytics.track(trackEvent);
7781
} else {
78-
const [event, trackProps] = trackEvent(this, ...args) ?? [];
82+
let trackReturn = trackEvent(this, ...args);
83+
if (typeof trackReturn === 'function') {
84+
trackReturn = trackReturn(analytics);
85+
}
86+
const [event, trackProps] = trackReturn ?? [];
7987
if (event) {
8088
analytics.track(event, trackProps);
8189
}
@@ -123,6 +131,7 @@ class RcModuleV2<
123131
S extends Record<string, any> = {}
124132
> extends BaseModule<T> {
125133
__$$state$$__: any;
134+
protected initializeProxy?(): Promise<void> | void;
126135
/**
127136
* `onInit` life cycle for current initialization before all deps modules are all ready.
128137
*/

packages/core/lib/usm-redux/core/module.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,8 @@ class Module<T extends Record<string, any> = {}> extends BaseModule<T> {
3030
this._actionTypes.forEach((name) => {
3131
this._reducersMaps[name] = (types) => (
3232
_state = this._initialValue[name],
33-
{ type, states, __proxyState__ },
34-
) => {
35-
if (type.indexOf(types[name]) > -1 && __proxyState__) {
36-
return __proxyState__[name];
37-
} else if (type.indexOf(types[name]) > -1 && states) {
38-
if (this._transport && this.__proxyState__?.[name]) {
39-
// sync up state with async proxy callback
40-
(async () => {
41-
await this.__proxyState__[name](this, states[name]);
42-
this._dispatch({
43-
type: this.parentModule.__proxyAction__,
44-
action: {
45-
type: [types[name]],
46-
__proxyState__: { [name]: states[name] },
47-
},
48-
});
49-
})();
50-
return _state;
51-
}
52-
return states[name];
53-
}
54-
return _state;
55-
};
33+
{ type, states },
34+
) => (type.indexOf(types[name]) > -1 && states ? states[name] : _state);
5635
});
5736
}
5837
super._makeInstance(params);

packages/core/lib/usm/core/module.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export interface Params<T = {}> {
1818
export interface Action {
1919
type: string[] | string;
2020
states?: Properties;
21-
__proxyState__?: Record<string, any>;
2221
[K: string]: any;
2322
}
2423

@@ -39,10 +38,6 @@ interface Module {
3938
* Used by browser client to transport data.
4039
*/
4140
_transport?: any;
42-
/**
43-
* browser client's proxy state.
44-
*/
45-
__proxyState__: Record<string, (...args: any) => any>;
4641
/**
4742
* Used by browser client to dispatch.
4843
*/

packages/engage-voice-widget/assets/icons/icon-pvc-connecting.svg

Lines changed: 1 addition & 1 deletion
Loading

packages/engage-voice-widget/assets/icons/icon-pvc-disabled.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)