@polyvharmony/live-scenes-foundation 1.2.0-rc.1 → 1.3.0-rc.1

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/Index.d.ets +4 -2
  3. package/Index.js +3 -1
  4. package/ResourceTable.txt +2 -1
  5. package/libs/plvclasstransformer.har +0 -0
  6. package/oh-package.json5 +1 -1
  7. package/package.json +1 -1
  8. package/src/main/ets/common/PLVCallback.d.ets +31 -6
  9. package/src/main/ets/common/PLVCallback.js +85 -27
  10. package/src/main/ets/common/PLVCommonConstants.d.ets +1 -0
  11. package/src/main/ets/common/PLVCommonConstants.js +1 -0
  12. package/src/main/ets/common/PLVCommonEnums.js +16 -16
  13. package/src/main/ets/common/PLVDeviceUtils.d.ets +7 -0
  14. package/src/main/ets/common/PLVDeviceUtils.js +28 -1
  15. package/src/main/ets/common/PLVJSONUtils.d.ets +7 -7
  16. package/src/main/ets/common/PLVJSONUtils.js +20 -20
  17. package/src/main/ets/common/PLVNetUtils.d.ets +4 -3
  18. package/src/main/ets/common/PLVNetUtils.js +20 -14
  19. package/src/main/ets/common/PLVPreferencesUtils.d.ets +8 -8
  20. package/src/main/ets/common/PLVPreferencesUtils.js +16 -16
  21. package/src/main/ets/common/PLVScheduledTask.js +2 -2
  22. package/src/main/ets/common/PLVSimpleBuffer.d.ets +2 -2
  23. package/src/main/ets/common/PLVSimpleBuffer.js +6 -6
  24. package/src/main/ets/common/PLVSparseArray.d.ets +10 -0
  25. package/src/main/ets/common/PLVSparseArray.js +44 -0
  26. package/src/main/ets/common/PLVTextUtils.d.ets +2 -1
  27. package/src/main/ets/common/PLVTextUtils.js +28 -22
  28. package/src/main/ets/common/PLVTimeUtils.d.ets +1 -1
  29. package/src/main/ets/common/PLVTimeUtils.js +8 -8
  30. package/src/main/ets/common/PLVToastUtils.d.ets +2 -2
  31. package/src/main/ets/common/PLVType.d.ets +1 -0
  32. package/src/main/ets/common/PLVUACreator.d.ets +1 -1
  33. package/src/main/ets/common/PLVUACreator.js +6 -6
  34. package/src/main/ets/common/PLVUtils.d.ets +15 -8
  35. package/src/main/ets/common/PLVUtils.js +89 -45
  36. package/src/main/ets/common/PLVWebUtils.d.ets +1 -1
  37. package/src/main/ets/common/PLVWebUtils.js +22 -22
  38. package/src/main/ets/common/ui/PLVNodeController.d.ets +41 -0
  39. package/src/main/ets/common/ui/PLVNodeController.js +103 -0
  40. package/src/main/ets/modules/log/PLVLogger.d.ets +9 -9
  41. package/src/main/ets/modules/log/PLVLogger.js +20 -20
  42. package/src/main/ets/modules/log/PLVXLogFilePrinter.d.ets +1 -1
  43. package/src/main/ets/modules/log/PLVXLogFilePrinter.js +2 -2
  44. package/src/main/ets/modules/net/PLVHttpData.d.ets +1 -1
  45. package/src/main/ets/modules/net/PLVHttpData.js +2 -2
  46. package/src/main/ets/modules/net/PLVHttpError.d.ets +2 -2
  47. package/src/main/ets/modules/net/PLVHttpError.js +5 -5
  48. package/src/main/ets/modules/net/PLVHttpRequest.d.ets +7 -7
  49. package/src/main/ets/modules/net/PLVHttpRequest.js +31 -31
  50. package/src/main/ets/modules/net/PLVRequestSetting.js +7 -7
  51. package/src/main/ets/modules/socket/PLVSocketIO.d.ets +19 -18
  52. package/src/main/ets/modules/socket/PLVSocketIO.js +70 -53
  53. package/src/main/ets/modules/web/PLVSimpleWeb.js +3 -3
  54. package/src/main/ets/modules/web/PLVWebController.d.ets +5 -3
  55. package/src/main/ets/modules/web/PLVWebController.js +29 -21
  56. package/src/main/module.json +1 -28
@@ -1,44 +1,51 @@
1
1
  import { client_socket } from 'socket';
2
+ import PLVCommonConstants from '../../common/PLVCommonConstants';
2
3
  import PLVLogger from '../log/PLVLogger';
3
4
  const TAG = '[PLVSocketIO]';
4
5
  export class PLVSocketIO {
5
6
  constructor() {
6
7
  this.client = new client_socket();
7
8
  this.socketIOStatus = PLVSocketIOStatus.IDLE;
9
+ this.isTokenExpired = false;
8
10
  }
9
- set_open_listener(g9) {
10
- this.client.set_open_listener(g9);
11
+ set_open_listener(i8) {
12
+ this.client.set_open_listener(i8);
11
13
  }
12
- set_fail_listener(f9) {
13
- this.client.set_fail_listener(f9);
14
+ set_fail_listener(h8) {
15
+ this.client.set_fail_listener(h8);
14
16
  }
15
- set_reconnecting_listener(e9) {
16
- this.client.set_reconnecting_listener(e9);
17
+ set_reconnecting_listener(g8) {
18
+ this.client.set_reconnecting_listener(g8);
17
19
  }
18
- set_reconnect_listener(d9) {
19
- this.client.set_reconnect_listener(d9);
20
+ set_reconnect_listener(f8) {
21
+ this.client.set_reconnect_listener(f8);
20
22
  }
21
- set_close_listener(c9) {
22
- this.client.set_close_listener(c9);
23
+ set_close_listener(e8) {
24
+ this.client.set_close_listener(e8);
23
25
  }
24
- set_socket_open_listener(b9) {
25
- this.client.set_socket_open_listener(b9);
26
+ set_socket_open_listener(d8) {
27
+ this.client.set_socket_open_listener(d8);
26
28
  }
27
- set_socket_close_listener(a9) {
28
- this.client.set_socket_close_listener(a9);
29
+ set_socket_close_listener(c8) {
30
+ this.client.set_socket_close_listener(c8);
29
31
  }
30
32
  connect(uri) {
31
33
  this.connectWithQuery(uri, '', '');
32
34
  }
33
- connectWithQuery(uri, query, v8) {
35
+ connectWithQuery(uri, query, b8) {
36
+ this.isTokenExpired = false;
34
37
  if (this.socketIOStatus == PLVSocketIOStatus.IDLE || this.socketIOStatus == PLVSocketIOStatus.SOCKET_CLOSE) {
35
38
  this.socketIOStatus = PLVSocketIOStatus.CONNECT;
36
39
  this.onSocketIOStatusListener?.(this.socketIOStatus);
37
40
  }
38
41
  this.set_open_listener(() => {
39
- PLVLogger.info(TAG, 'call socket open');
40
- this.socketIOStatus = this.socketIOStatus == PLVSocketIOStatus.RECONNECT ? PLVSocketIOStatus.RECONNECT_SUCCESS : PLVSocketIOStatus.OPEN;
41
- this.onSocketIOStatusListener?.(this.socketIOStatus);
42
+ PLVLogger.info(TAG, `call socket open, isTokenExpired=${this.isTokenExpired}`);
43
+ setTimeout(() => {
44
+ if (!this.isTokenExpired) {
45
+ this.socketIOStatus = this.socketIOStatus == PLVSocketIOStatus.RECONNECT ? PLVSocketIOStatus.RECONNECT_SUCCESS : PLVSocketIOStatus.OPEN;
46
+ this.onSocketIOStatusListener?.(this.socketIOStatus);
47
+ }
48
+ }, this.isTokenExpired ? 0 : PLVCommonConstants.DELAY_TIME_S);
42
49
  });
43
50
  this.set_reconnect_listener(() => {
44
51
  PLVLogger.info(TAG, 'call socket reconnect');
@@ -46,26 +53,31 @@ export class PLVSocketIO {
46
53
  this.onSocketIOStatusListener?.(this.socketIOStatus);
47
54
  });
48
55
  this.set_socket_close_listener(() => {
49
- PLVLogger.info(TAG, 'call socket close');
56
+ PLVLogger.info(TAG, `call socket close, isTokenExpired=${this.isTokenExpired}`);
50
57
  this.socketIOStatus = PLVSocketIOStatus.SOCKET_CLOSE;
51
58
  this.onSocketIOStatusListener?.(this.socketIOStatus);
59
+ setTimeout(() => {
60
+ if (!this.isTokenExpired) {
61
+ this.close();
62
+ }
63
+ }, this.isTokenExpired ? 0 : PLVCommonConstants.DELAY_TIME_S);
52
64
  });
53
65
  this.set_close_listener(() => {
54
66
  PLVLogger.info(TAG, 'call close');
55
67
  });
56
- this.client.connectWithQuery(uri, query, v8);
68
+ this.client.connectWithQuery(uri, query, b8);
57
69
  }
58
70
  connected() {
59
71
  return this.opened() && this.socketIOStatus != PLVSocketIOStatus.SOCKET_CLOSE;
60
72
  }
61
- disconnect(u8) {
62
- if (this.socketIOStatus != PLVSocketIOStatus.SOCKET_CLOSE && !u8) {
73
+ disconnect(a8) {
74
+ if (this.socketIOStatus != PLVSocketIOStatus.SOCKET_CLOSE && !a8) {
63
75
  this.socket_close();
64
76
  }
65
77
  this.close();
66
78
  }
67
- destroy(t8) {
68
- this.disconnect(t8);
79
+ destroy(z7) {
80
+ this.disconnect(z7);
69
81
  this.clear_con_listeners();
70
82
  this.clear_socket_listeners();
71
83
  }
@@ -75,14 +87,14 @@ export class PLVSocketIO {
75
87
  clear_socket_listeners() {
76
88
  this.client.clear_socket_listeners();
77
89
  }
78
- set_reconnect_attempts(s8) {
79
- this.client.set_reconnect_attempts(s8);
90
+ set_reconnect_attempts(y7) {
91
+ this.client.set_reconnect_attempts(y7);
80
92
  }
81
- set_reconnect_delay(r8) {
82
- this.client.set_reconnect_delay(r8);
93
+ set_reconnect_delay(x7) {
94
+ this.client.set_reconnect_delay(x7);
83
95
  }
84
- set_reconnect_delay_max(q8) {
85
- this.client.set_reconnect_delay_max(q8);
96
+ set_reconnect_delay_max(w7) {
97
+ this.client.set_reconnect_delay_max(w7);
86
98
  }
87
99
  set_logs_default() {
88
100
  this.client.set_logs_default();
@@ -108,19 +120,19 @@ export class PLVSocketIO {
108
120
  get_sessionid() {
109
121
  return this.client.get_sessionid();
110
122
  }
111
- set_nsp(p8) {
112
- this.client.set_nsp(p8);
123
+ set_nsp(v7) {
124
+ this.client.set_nsp(v7);
113
125
  }
114
- on(m8, n8) {
115
- this.client.on(m8, (json) => {
116
- n8(this.replaceJson(json));
126
+ on(t7, u7) {
127
+ this.client.on(t7, (json) => {
128
+ u7(this.replaceJson(json));
117
129
  });
118
130
  }
119
- once(k8, l8) {
120
- this.client.once(k8, l8);
131
+ once(r7, s7) {
132
+ this.client.once(r7, s7);
121
133
  }
122
- off(j8) {
123
- this.client.off(j8);
134
+ off(q7) {
135
+ this.client.off(q7);
124
136
  }
125
137
  off_all() {
126
138
  this.client.off_all();
@@ -128,37 +140,42 @@ export class PLVSocketIO {
128
140
  socket_close() {
129
141
  this.client.socket_close();
130
142
  }
131
- on_error(i8) {
132
- this.client.on_error(i8);
143
+ on_error(p7) {
144
+ this.client.on_error(p7);
133
145
  }
134
146
  off_error() {
135
147
  this.client.off_error();
136
148
  }
137
- emitSkipCheck(name, message, g8) {
149
+ emitSkipCheck(name, message, o7) {
138
150
  this.client.emit(name, message, (json) => {
139
- g8?.(this.replaceJson(json));
151
+ o7?.(this.replaceJson(json));
140
152
  });
141
153
  }
142
- emit(name, message, e8) {
154
+ emit(name, message, n7) {
143
155
  PLVLogger.info(TAG, `emit: ${message}, name: ${name}, connected: ${this.connected()}`);
144
156
  if (this.connected()) {
145
157
  this.client.emit(name, message, (json) => {
146
- e8?.(this.replaceJson(json));
158
+ n7?.(this.replaceJson(json));
147
159
  });
148
160
  return true;
149
161
  }
150
162
  return false;
151
163
  }
152
164
  replaceJson(json) {
153
- return json.replace(/"{/g, '{').replace(/}"/g, '}');
165
+ json = json.replace(/^"{/, '{').replace(/}"$/, '}').replace(/"{/, '{');
166
+ const m7 = json.lastIndexOf('}"');
167
+ if (m7 !== -1) {
168
+ json = json.substring(0, m7) + '}' + json.substring(m7 + 2);
169
+ }
170
+ return json;
154
171
  }
155
172
  }
156
173
  export var PLVSocketIOStatus;
157
- (function (d8) {
158
- d8[d8["IDLE"] = 0] = "IDLE";
159
- d8[d8["CONNECT"] = 1] = "CONNECT";
160
- d8[d8["OPEN"] = 2] = "OPEN";
161
- d8[d8["RECONNECT"] = 3] = "RECONNECT";
162
- d8[d8["RECONNECT_SUCCESS"] = 4] = "RECONNECT_SUCCESS";
163
- d8[d8["SOCKET_CLOSE"] = 5] = "SOCKET_CLOSE";
174
+ (function (l7) {
175
+ l7[l7["IDLE"] = 0] = "IDLE";
176
+ l7[l7["CONNECT"] = 1] = "CONNECT";
177
+ l7[l7["OPEN"] = 2] = "OPEN";
178
+ l7[l7["RECONNECT"] = 3] = "RECONNECT";
179
+ l7[l7["RECONNECT_SUCCESS"] = 4] = "RECONNECT_SUCCESS";
180
+ l7[l7["SOCKET_CLOSE"] = 5] = "SOCKET_CLOSE";
164
181
  })(PLVSocketIOStatus || (PLVSocketIOStatus = {}));
@@ -109,16 +109,16 @@ export class PLVSimpleWeb extends ViewPU {
109
109
  if (this.controller._onWindowNew?.(event)) {
110
110
  return;
111
111
  }
112
- this.controller.handleWindowNew(event, (z10) => {
112
+ this.controller.handleWindowNew(event, (j8) => {
113
113
  return new CustomDialogController({
114
114
  builder: () => {
115
- let jsDialog = new PLVNewWindowLayout(this, { webviewController: z10 }, undefined, -1, () => {
115
+ let jsDialog = new PLVNewWindowLayout(this, { webviewController: j8 }, undefined, -1, () => {
116
116
  }, { page: "foundation/src/main/ets/modules/web/PLVSimpleWeb.ets", line: 72, b2: 24 });
117
117
  jsDialog.setController();
118
118
  ViewPU.create(jsDialog);
119
119
  let paramsLambda = () => {
120
120
  return {
121
- webviewController: z10
121
+ webviewController: j8
122
122
  };
123
123
  };
124
124
  jsDialog.paramsGenerator_ = paramsLambda;
@@ -52,6 +52,8 @@ export declare class PLVWebController extends webview.WebviewController {
52
52
  multiWindowAccess(multiWindowAccess: boolean): PLVWebController;
53
53
  allowWindowOpenMethod(allowWindowOpenMethod: boolean): PLVWebController;
54
54
  javaScriptAccess(javaScriptAccess: boolean): PLVWebController;
55
+ mixMode(mixedMode: MixedMode): PLVWebController;
56
+ cacheMode(cacheMode: CacheMode): PLVWebController;
55
57
  onControllerAttached(callback: PLVCallback<void, void>): PLVWebController;
56
58
  addOnControllerAttached(callback: PLVCallback<void, void>): PLVWebController;
57
59
  onInterceptRequest(callback: PLVCallback<WebResourceRequest, WebResourceResponse>): PLVWebController;
@@ -67,12 +69,12 @@ export declare class PLVWebController extends webview.WebviewController {
67
69
  onErrorReceive(callback: PLVCallback<OnErrorReceiveEvent, void>): PLVWebController;
68
70
  backgroundColor(backgroundColor: ResourceColor): this;
69
71
  verticalScrollBarAccess(verticalScrollBarAccess: boolean): this;
70
- nestedScrollOptions(w11: NestedScrollOptions): this;
72
+ nestedScrollOptions(t8: NestedScrollOptions): this;
71
73
  overScrollMode(overScrollMode: OverScrollMode): void;
72
74
  userAgent(userAgent?: string): this;
73
75
  addOnReloaded(callback: PLVCallback): this;
74
- registerHandler(v11: string, handle: PLVCallback2<string, PLVCallback<string>>): this;
75
- callHandle(t11: string, data: string, u11: PLVCallback<string>): this;
76
+ registerHandler(s8: string, handle: PLVCallback2<string, PLVCallback<string>>): this;
77
+ callHandle(q8: string, data: string, r8: PLVCallback<string>): this;
76
78
  loadHtmlData(data?: string): this;
77
79
  loadUrlCatch(url: string | Resource): void;
78
80
  handleControllerAttached(): void;
@@ -3,7 +3,7 @@ import { PLVJsBridge } from 'jsbridge';
3
3
  import { PLVFullScreenStatus, PLVWebpageStatus } from '../../common/PLVCommonEnums';
4
4
  import PLVUtils from '../../common/PLVUtils';
5
5
  import PLVLogger from '../log/PLVLogger';
6
- const d11 = 100;
6
+ const k8 = 100;
7
7
  const TAG = "[PLVWebController]";
8
8
  export class PLVWebController extends webview.WebviewController {
9
9
  constructor(webTag) {
@@ -22,7 +22,7 @@ export class PLVWebController extends webview.WebviewController {
22
22
  this._allowWindowOpenMethod = true;
23
23
  this._javaScriptAccess = true;
24
24
  this._mixedMode = MixedMode.All;
25
- this._cacheMode = CacheMode.None;
25
+ this._cacheMode = CacheMode.Online;
26
26
  this._addOnControllerAttached = [];
27
27
  this._addOnPageEnd = [];
28
28
  this._backgroundColor = Color.Transparent;
@@ -90,6 +90,14 @@ export class PLVWebController extends webview.WebviewController {
90
90
  this._javaScriptAccess = javaScriptAccess;
91
91
  return this;
92
92
  }
93
+ mixMode(mixedMode) {
94
+ this._mixedMode = mixedMode;
95
+ return this;
96
+ }
97
+ cacheMode(cacheMode) {
98
+ this._cacheMode = cacheMode;
99
+ return this;
100
+ }
93
101
  onControllerAttached(callback) {
94
102
  this._onControllerAttached = callback;
95
103
  return this;
@@ -150,8 +158,8 @@ export class PLVWebController extends webview.WebviewController {
150
158
  this._verticalScrollBarAccess = verticalScrollBarAccess;
151
159
  return this;
152
160
  }
153
- nestedScrollOptions(w11) {
154
- this._nestedScrollOptions = w11;
161
+ nestedScrollOptions(t8) {
162
+ this._nestedScrollOptions = t8;
155
163
  return this;
156
164
  }
157
165
  overScrollMode(overScrollMode) {
@@ -165,12 +173,12 @@ export class PLVWebController extends webview.WebviewController {
165
173
  this._addOnReloaded.push(callback);
166
174
  return this;
167
175
  }
168
- registerHandler(v11, handle) {
169
- this.jsBridge.registerHandler(v11, handle);
176
+ registerHandler(s8, handle) {
177
+ this.jsBridge.registerHandler(s8, handle);
170
178
  return this;
171
179
  }
172
- callHandle(t11, data, u11) {
173
- this.jsBridge.callHandle(t11, data, u11);
180
+ callHandle(q8, data, r8) {
181
+ this.jsBridge.callHandle(q8, data, r8);
174
182
  return this;
175
183
  }
176
184
  loadHtmlData(data) {
@@ -212,16 +220,16 @@ export class PLVWebController extends webview.WebviewController {
212
220
  }
213
221
  }
214
222
  handleFullScreenEnter() {
215
- this.getVideoWHEnterFullScreen(d11, d11, d11 * 10);
223
+ this.getVideoWHEnterFullScreen(k8, k8, k8 * 10);
216
224
  }
217
225
  handleWindowNew(event, builder) {
218
226
  if (this.dialogController) {
219
227
  this.dialogController.close();
220
228
  }
221
- let q11 = new webview.WebviewController();
222
- this.dialogController = builder(q11);
229
+ let p8 = new webview.WebviewController();
230
+ this.dialogController = builder(p8);
223
231
  this.dialogController.open();
224
- event.handler.setWebController(q11);
232
+ event.handler.setWebController(p8);
225
233
  }
226
234
  handleIsLoadIntercept(intercept) {
227
235
  try {
@@ -252,21 +260,21 @@ export class PLVWebController extends webview.WebviewController {
252
260
  handleErrorReceive() {
253
261
  this._webStatus = PLVWebpageStatus.FINISHED;
254
262
  }
255
- getVideoWHEnterFullScreen(delayTime, e11, f11) {
256
- if (delayTime > f11) {
263
+ getVideoWHEnterFullScreen(delayTime, l8, m8) {
264
+ if (delayTime > m8) {
257
265
  return;
258
266
  }
259
267
  setTimeout(() => {
260
268
  this.runJavaScript(PLVUtils.getVideoRectJS(true)).then((value) => {
261
- let i11 = JSON.parse(value);
262
- if (i11.width === 0 && i11.height === 0) {
263
- this.getVideoWHEnterFullScreen(delayTime + e11, e11, f11);
269
+ let n8 = JSON.parse(value);
270
+ if (n8.width === 0 && n8.height === 0) {
271
+ this.getVideoWHEnterFullScreen(delayTime + l8, l8, m8);
264
272
  }
265
- else if (i11.width > i11.height) {
273
+ else if (n8.width > n8.height) {
266
274
  PLVUtils.changeOrientation(true);
267
- PLVUtils.setWindowFullScreen(true, true).then((k11) => {
268
- this._originalIsLayoutFullScreen = k11[0];
269
- this._originalIsFullScreen = k11[1];
275
+ PLVUtils.setWindowFullScreen(true, true).then((o8) => {
276
+ this._originalIsLayoutFullScreen = o8[0];
277
+ this._originalIsFullScreen = o8[1];
270
278
  });
271
279
  }
272
280
  });
@@ -1,28 +1 @@
1
- {
2
- "app": {
3
- "bundleName": "net.plv.livescenes.demo",
4
- "versionCode": 1020000,
5
- "versionName": "1.2.0",
6
- "minAPIVersion": 50000012,
7
- "targetAPIVersion": 50000012,
8
- "apiReleaseType": "Release",
9
- "compileSdkVersion": "5.0.0.71",
10
- "compileSdkType": "HarmonyOS",
11
- "appEnvironments": [],
12
- "bundleType": "app"
13
- },
14
- "module": {
15
- "name": "foundation",
16
- "type": "har",
17
- "deviceTypes": [
18
- "default",
19
- "tablet",
20
- "2in1"
21
- ],
22
- "packageName": "@polyvharmony/live-scenes-foundation",
23
- "installationFree": false,
24
- "virtualMachine": "ark12.0.2.0",
25
- "compileMode": "esmodule",
26
- "dependencies": []
27
- }
28
- }
1
+ {"app":{"bundleName":"net.plv.livescenes.demo","debug":false,"versionCode":1030000,"versionName":"1.3.0","minAPIVersion":50000012,"targetAPIVersion":50004016,"apiReleaseType":"Release","compileSdkVersion":"5.0.4.150","compileSdkType":"HarmonyOS","appEnvironments":[],"bundleType":"app","buildMode":"release"},"module":{"name":"foundation","type":"har","deviceTypes":["default","tablet","2in1"],"packageName":"@polyvharmony/live-scenes-foundation","installationFree":false,"virtualMachine":"ark12.0.2.0","compileMode":"esmodule","dependencies":[]}}