ws-process 0.3.41 → 0.3.43

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/actions.js CHANGED
@@ -4,9 +4,10 @@ export const newWSInstance = (wSocket) => ({
4
4
  wSocket,
5
5
  });
6
6
  export const REMOVE_WS_INSTANCE = 'REMOVE_WS_INSTANCE';
7
- export const removeWSInstance = (wSocket) => ({
7
+ export const removeWSInstance = (wSocket, doNotClose) => ({
8
8
  type: REMOVE_WS_INSTANCE,
9
9
  wSocket,
10
+ doNotClose,
10
11
  });
11
12
 
12
13
  export const STORE_SPLITTED_DATA = 'STORE_SPLITTED_DATA';
package/index.js CHANGED
@@ -65,6 +65,10 @@ function getUSP(url) {
65
65
  return [usp, urlPath];
66
66
  }
67
67
 
68
+ function isPreviewMode() {
69
+ return window.location.pathname.startsWith('/lc-ui5/preview/');
70
+ }
71
+
68
72
  function getWebSocket() {
69
73
  return (dispatch) => new Promise((resolve, reject) => {
70
74
  const existWS = local.wsProcess.wSocket;
@@ -78,13 +82,35 @@ function getWebSocket() {
78
82
  }),
79
83
  );
80
84
  }
85
+ /*
86
+ 현재 프리뷰 모드인데
87
+ 이미 생성한 웹소켓이 프리뷰 모드가 아닐때 만들어진것일 경우에는
88
+ 제거하고 다시 만들어준다. 단 close()는 하지 않는다.
89
+ close()하면 onmessage 이벤트핸들러가 실행중에 중단되어
90
+ 프로그램이 정상적으로 동작하지 않는다.
91
+ */
92
+ if (isPreviewMode() && !existWS.url.endsWith('/dev')) {
93
+ //
94
+ if (existWS.readyState === existWS.OPEN) {
95
+ // existWS.close();
96
+ local.dispatch(removeWSInstance(existWS, true));
97
+ }
98
+ return resolve(
99
+ new Promise((resolveInner) => {
100
+ setTimeout(() => {
101
+ resolveInner(dispatch(getWebSocket()));
102
+ }, 500);
103
+ }),
104
+ );
105
+ }
81
106
  return resolve(existWS);
82
107
  }
83
108
  if (!local.wsURL) {
84
109
  console.error('URL of WebSocket is undefined');
85
110
  return reject(new Error('URL of WebSocket is undefined'));
86
111
  }
87
- const wSocket = new WebSocket(local.wsURL);
112
+ const newWsUrl = isPreviewMode() ? local.wsURL.replace(/\/(prod){1}$/, '/dev') : local.wsURL;
113
+ const wSocket = new WebSocket(newWsUrl);
88
114
 
89
115
  wSocket.onopen = (event) => {
90
116
  console.debug('web socket event onopen: ', event);
@@ -599,7 +625,7 @@ function asyncSend(msg) {
599
625
  const headers = {};
600
626
  headers['bsg-support-process-id'] = msg.processID;
601
627
  headers['bsg-support-api-key'] = user.apiKey || undefined;
602
- headers['bsg-support-stage'] = local.stage;
628
+ headers['bsg-support-stage'] = isPreviewMode() ? 'dev' : local.stage;
603
629
  headers['bsg-support-token'] = user.token;
604
630
  headers['bsg-support-session'] = user.session;
605
631
  headers['bsg-support-user-id'] = user.id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ws-process",
3
- "version": "0.3.41",
3
+ "version": "0.3.43",
4
4
  "description": "Process Management for Web Socket Client",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/reducer.js CHANGED
@@ -36,7 +36,11 @@ export default function (state = initialState, action) {
36
36
  (stt) => stt === action.wSocket.readyState,
37
37
  ).length === 0
38
38
  ) {
39
- action.wSocket.close();
39
+ if (action.doNotClose === true) {
40
+ // pass
41
+ } else {
42
+ action.wSocket.close();
43
+ }
40
44
  }
41
45
  }
42
46
  draft.wSocket = null;