@polyvharmony/live-scenes-foundation 1.2.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.
- package/CHANGELOG.md +21 -0
- package/Index.d.ets +30 -0
- package/Index.js +28 -0
- package/LICENSE +8 -0
- package/README.md +21 -0
- package/ResourceTable.txt +16 -0
- package/libs/plvjsbridge.har +0 -0
- package/libs/plvsocket.har +0 -0
- package/obfuscation.txt +4 -0
- package/oh-package.json5 +1 -0
- package/package.json +1 -0
- package/src/main/ets/common/IPLVBackwardInterface.d.ets +5 -0
- package/src/main/ets/common/IPLVBackwardInterface.js +1 -0
- package/src/main/ets/common/PLVBasicDataSource.d.ets +30 -0
- package/src/main/ets/common/PLVBasicDataSource.js +172 -0
- package/src/main/ets/common/PLVCallback.d.ets +52 -0
- package/src/main/ets/common/PLVCallback.js +128 -0
- package/src/main/ets/common/PLVCommonConstants.d.ets +13 -0
- package/src/main/ets/common/PLVCommonConstants.js +10 -0
- package/src/main/ets/common/PLVCommonEnums.d.ets +19 -0
- package/src/main/ets/common/PLVCommonEnums.js +22 -0
- package/src/main/ets/common/PLVDeviceUtils.d.ets +4 -0
- package/src/main/ets/common/PLVDeviceUtils.js +9 -0
- package/src/main/ets/common/PLVHashMap.d.ets +4 -0
- package/src/main/ets/common/PLVHashMap.js +7 -0
- package/src/main/ets/common/PLVJSONUtils.d.ets +21 -0
- package/src/main/ets/common/PLVJSONUtils.js +103 -0
- package/src/main/ets/common/PLVNetUtils.d.ets +5 -0
- package/src/main/ets/common/PLVNetUtils.js +29 -0
- package/src/main/ets/common/PLVPreferencesUtils.d.ets +58 -0
- package/src/main/ets/common/PLVPreferencesUtils.js +30 -0
- package/src/main/ets/common/PLVScheduledTask.d.ets +12 -0
- package/src/main/ets/common/PLVScheduledTask.js +44 -0
- package/src/main/ets/common/PLVSimpleBuffer.d.ets +11 -0
- package/src/main/ets/common/PLVSimpleBuffer.js +30 -0
- package/src/main/ets/common/PLVTextUtils.d.ets +9 -0
- package/src/main/ets/common/PLVTextUtils.js +73 -0
- package/src/main/ets/common/PLVTimeUtils.d.ets +8 -0
- package/src/main/ets/common/PLVTimeUtils.js +14 -0
- package/src/main/ets/common/PLVToastUtils.d.ets +7 -0
- package/src/main/ets/common/PLVToastUtils.js +17 -0
- package/src/main/ets/common/PLVType.d.ets +8 -0
- package/src/main/ets/common/PLVType.js +1 -0
- package/src/main/ets/common/PLVUACreator.d.ets +3 -0
- package/src/main/ets/common/PLVUACreator.js +11 -0
- package/src/main/ets/common/PLVUtils.d.ets +25 -0
- package/src/main/ets/common/PLVUtils.js +197 -0
- package/src/main/ets/common/PLVWebUtils.d.ets +6 -0
- package/src/main/ets/common/PLVWebUtils.js +79 -0
- package/src/main/ets/modules/log/PLVLogger.d.ets +20 -0
- package/src/main/ets/modules/log/PLVLogger.js +67 -0
- package/src/main/ets/modules/log/PLVXLogFilePrinter.d.ets +12 -0
- package/src/main/ets/modules/log/PLVXLogFilePrinter.js +37 -0
- package/src/main/ets/modules/log/PLVXLogWorker.d.ets +1 -0
- package/src/main/ets/modules/log/PLVXLogWorker.js +4 -0
- package/src/main/ets/modules/net/PLVApiConstants.d.ets +7 -0
- package/src/main/ets/modules/net/PLVApiConstants.js +7 -0
- package/src/main/ets/modules/net/PLVHttpData.d.ets +8 -0
- package/src/main/ets/modules/net/PLVHttpData.js +8 -0
- package/src/main/ets/modules/net/PLVHttpError.d.ets +5 -0
- package/src/main/ets/modules/net/PLVHttpError.js +13 -0
- package/src/main/ets/modules/net/PLVHttpRequest.d.ets +25 -0
- package/src/main/ets/modules/net/PLVHttpRequest.js +147 -0
- package/src/main/ets/modules/net/PLVRequestSetting.d.ets +9 -0
- package/src/main/ets/modules/net/PLVRequestSetting.js +33 -0
- package/src/main/ets/modules/socket/PLVSocketIO.d.ets +50 -0
- package/src/main/ets/modules/socket/PLVSocketIO.js +164 -0
- package/src/main/ets/modules/web/PLVFailureLayout.d.ets +5 -0
- package/src/main/ets/modules/web/PLVFailureLayout.js +77 -0
- package/src/main/ets/modules/web/PLVLoadingLayout.d.ets +4 -0
- package/src/main/ets/modules/web/PLVLoadingLayout.js +46 -0
- package/src/main/ets/modules/web/PLVNewWindowLayout.d.ets +8 -0
- package/src/main/ets/modules/web/PLVNewWindowLayout.js +62 -0
- package/src/main/ets/modules/web/PLVSimpleWeb.d.ets +14 -0
- package/src/main/ets/modules/web/PLVSimpleWeb.js +260 -0
- package/src/main/ets/modules/web/PLVWebController.d.ets +86 -0
- package/src/main/ets/modules/web/PLVWebController.js +275 -0
- package/src/main/ets/modules/web/PLVWebModel.d.ets +30 -0
- package/src/main/ets/modules/web/PLVWebModel.js +1 -0
- package/src/main/module.json +28 -0
- package/src/main/resources/base/element/color.json +12 -0
- package/src/main/resources/base/element/float.json +40 -0
- package/src/main/resources/base/element/string.json +12 -0
- package/src/main/resources/base/media/plv_web_ic_failure.svg +30 -0
- package/src/main/resources/en_US/element/string.json +12 -0
- package/src/main/resources/zh_CN/element/string.json +12 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
if (!("finalizeConstruction" in ViewPU.prototype)) {
|
|
2
|
+
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => {
|
|
3
|
+
});
|
|
4
|
+
}
|
|
5
|
+
import PLVCommonConstants from '../../common/PLVCommonConstants';
|
|
6
|
+
import { PLVFullScreenStatus, PLVWebpageStatus } from '../../common/PLVCommonEnums';
|
|
7
|
+
import PLVLogger from '../log/PLVLogger';
|
|
8
|
+
import { PLVFailureLayout } from './PLVFailureLayout';
|
|
9
|
+
import { PLVLoadingLayout } from './PLVLoadingLayout';
|
|
10
|
+
import { PLVNewWindowLayout } from './PLVNewWindowLayout';
|
|
11
|
+
import { PLVWebController } from './PLVWebController';
|
|
12
|
+
export const TAG = "[PLVSimpleWeb]";
|
|
13
|
+
export class PLVSimpleWeb extends ViewPU {
|
|
14
|
+
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
|
|
15
|
+
super(parent, __localStorage, elmtId, extraInfo);
|
|
16
|
+
if (typeof paramsLambda === "function") {
|
|
17
|
+
this.paramsGenerator_ = paramsLambda;
|
|
18
|
+
}
|
|
19
|
+
this.a2 = new ObservedPropertySimplePU(PLVWebpageStatus.INIT, this, "webStatus");
|
|
20
|
+
this.controller = new PLVWebController();
|
|
21
|
+
this.src = undefined;
|
|
22
|
+
this.incognitoMode = undefined;
|
|
23
|
+
this.showLoading = undefined;
|
|
24
|
+
this.setInitiallyProvidedValue(params);
|
|
25
|
+
this.finalizeConstruction();
|
|
26
|
+
}
|
|
27
|
+
setInitiallyProvidedValue(params) {
|
|
28
|
+
if (params.webStatus !== undefined) {
|
|
29
|
+
this.webStatus = params.webStatus;
|
|
30
|
+
}
|
|
31
|
+
if (params.controller !== undefined) {
|
|
32
|
+
this.controller = params.controller;
|
|
33
|
+
}
|
|
34
|
+
if (params.src !== undefined) {
|
|
35
|
+
this.src = params.src;
|
|
36
|
+
}
|
|
37
|
+
if (params.incognitoMode !== undefined) {
|
|
38
|
+
this.incognitoMode = params.incognitoMode;
|
|
39
|
+
}
|
|
40
|
+
if (params.showLoading !== undefined) {
|
|
41
|
+
this.showLoading = params.showLoading;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
updateStateVars(params) {
|
|
45
|
+
}
|
|
46
|
+
purgeVariableDependenciesOnElmtId(rmElmtId) {
|
|
47
|
+
this.a2.purgeDependencyOnElmtId(rmElmtId);
|
|
48
|
+
}
|
|
49
|
+
aboutToBeDeleted() {
|
|
50
|
+
this.a2.aboutToBeDeleted();
|
|
51
|
+
SubscriberManager.Get().delete(this.id__());
|
|
52
|
+
this.aboutToBeDeletedInternal();
|
|
53
|
+
}
|
|
54
|
+
get webStatus() {
|
|
55
|
+
return this.a2.get();
|
|
56
|
+
}
|
|
57
|
+
set webStatus(newValue) {
|
|
58
|
+
this.a2.set(newValue);
|
|
59
|
+
}
|
|
60
|
+
aboutToAppear() {
|
|
61
|
+
PLVLogger.info(TAG, `load url: ${this.src}`);
|
|
62
|
+
}
|
|
63
|
+
initialRender() {
|
|
64
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
65
|
+
Stack.create();
|
|
66
|
+
Stack.width(PLVCommonConstants.FULL_PERCENT);
|
|
67
|
+
Stack.height(PLVCommonConstants.FULL_PERCENT);
|
|
68
|
+
}, Stack);
|
|
69
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
70
|
+
Web.create({
|
|
71
|
+
controller: this.controller,
|
|
72
|
+
src: this.src,
|
|
73
|
+
incognitoMode: this.incognitoMode
|
|
74
|
+
});
|
|
75
|
+
Web.darkMode(this.controller._darkMode);
|
|
76
|
+
Web.forceDarkAccess(this.controller._forceDarkAccess);
|
|
77
|
+
Web.domStorageAccess(this.controller._domStorageAccess);
|
|
78
|
+
Web.zoomAccess(this.controller._zoomAccess);
|
|
79
|
+
Web.fileAccess(this.controller._fileAccess);
|
|
80
|
+
Web.multiWindowAccess(this.controller._multiWindowAccess);
|
|
81
|
+
Web.allowWindowOpenMethod(this.controller._allowWindowOpenMethod);
|
|
82
|
+
Web.javaScriptAccess(this.controller._javaScriptAccess);
|
|
83
|
+
Web.mixedMode(this.controller._mixedMode);
|
|
84
|
+
Web.cacheMode(this.controller._cacheMode);
|
|
85
|
+
Web.backgroundColor(this.controller._backgroundColor);
|
|
86
|
+
Web.verticalScrollBarAccess(this.controller._verticalScrollBarAccess);
|
|
87
|
+
Web.nestedScroll(this.controller._nestedScrollOptions);
|
|
88
|
+
Web.overScrollMode(this.controller._overScrollMode);
|
|
89
|
+
Web.onControllerAttached(() => {
|
|
90
|
+
PLVLogger.info(TAG, "onControllerAttached: " + this.src);
|
|
91
|
+
this.controller.handleControllerAttached();
|
|
92
|
+
this.controller._onControllerAttached?.();
|
|
93
|
+
});
|
|
94
|
+
Web.onInterceptRequest((event) => {
|
|
95
|
+
if (this.controller._onInterceptRequest) {
|
|
96
|
+
return this.controller._onInterceptRequest?.(event.request);
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
});
|
|
100
|
+
Web.onLoadIntercept((event) => {
|
|
101
|
+
let result = false;
|
|
102
|
+
if (this.controller._onLoadIntercept) {
|
|
103
|
+
result = this.controller._onLoadIntercept?.(event.data);
|
|
104
|
+
}
|
|
105
|
+
result = result || this.controller.handleIsLoadIntercept(event.data);
|
|
106
|
+
return result;
|
|
107
|
+
});
|
|
108
|
+
Web.onWindowNew((event) => {
|
|
109
|
+
if (this.controller._onWindowNew?.(event)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.controller.handleWindowNew(event, (z10) => {
|
|
113
|
+
return new CustomDialogController({
|
|
114
|
+
builder: () => {
|
|
115
|
+
let jsDialog = new PLVNewWindowLayout(this, { webviewController: z10 }, undefined, -1, () => {
|
|
116
|
+
}, { page: "foundation/src/main/ets/modules/web/PLVSimpleWeb.ets", line: 72, b2: 24 });
|
|
117
|
+
jsDialog.setController();
|
|
118
|
+
ViewPU.create(jsDialog);
|
|
119
|
+
let paramsLambda = () => {
|
|
120
|
+
return {
|
|
121
|
+
webviewController: z10
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
jsDialog.paramsGenerator_ = paramsLambda;
|
|
125
|
+
},
|
|
126
|
+
cornerRadius: 0
|
|
127
|
+
}, this);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
Web.onShowFileSelector((event) => {
|
|
131
|
+
if (this.controller._onShowFileSelector) {
|
|
132
|
+
return this.controller._onShowFileSelector?.(event);
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
});
|
|
136
|
+
Web.onFullScreenExit(() => {
|
|
137
|
+
PLVLogger.info(TAG, 'onFullScreenExit');
|
|
138
|
+
this.controller._fullScreenStatus = PLVFullScreenStatus.EXIT;
|
|
139
|
+
if (this.controller._onFullScreenExit?.()) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.controller.handleFullScreenExit();
|
|
143
|
+
});
|
|
144
|
+
Web.onFullScreenEnter(() => {
|
|
145
|
+
PLVLogger.info(TAG, 'onFullScreenEnter');
|
|
146
|
+
this.controller._fullScreenStatus = PLVFullScreenStatus.ENTER;
|
|
147
|
+
if (this.controller._onFullScreenEnter?.()) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this.controller.handleFullScreenEnter();
|
|
151
|
+
});
|
|
152
|
+
Web.onProgressChange((event) => {
|
|
153
|
+
PLVLogger.info(TAG, 'onProgressChange:' + event?.newProgress);
|
|
154
|
+
this.controller._onProgressChange?.(event);
|
|
155
|
+
});
|
|
156
|
+
Web.onPageBegin((event) => {
|
|
157
|
+
PLVLogger.info(TAG, 'onPageBegin');
|
|
158
|
+
this.controller._onPageBegin?.(event);
|
|
159
|
+
});
|
|
160
|
+
Web.onErrorReceive((event) => {
|
|
161
|
+
PLVLogger.info(TAG, "onErrorReceive:" + `{info:${event?.error.getErrorInfo()},code:${event?.error.getErrorCode()}}`);
|
|
162
|
+
this.controller.handleErrorReceive();
|
|
163
|
+
this.webStatus = PLVWebpageStatus.FINISHED;
|
|
164
|
+
this.controller._onErrorReceive?.(event);
|
|
165
|
+
});
|
|
166
|
+
Web.onPageEnd((event) => {
|
|
167
|
+
PLVLogger.info(TAG, 'onPageEnd');
|
|
168
|
+
this.controller.handlePageEnd(event);
|
|
169
|
+
if (this.webStatus != PLVWebpageStatus.ERROR) {
|
|
170
|
+
this.webStatus = PLVWebpageStatus.FINISHED;
|
|
171
|
+
this.controller._onPageEnd?.(event);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}, Web);
|
|
175
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
176
|
+
If.create();
|
|
177
|
+
if (this.webStatus === PLVWebpageStatus.INIT && this.showLoading) {
|
|
178
|
+
this.ifElseBranchUpdateFunction(0, () => {
|
|
179
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
180
|
+
Column.create();
|
|
181
|
+
Column.backgroundColor(Color.White);
|
|
182
|
+
}, Column);
|
|
183
|
+
{
|
|
184
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
185
|
+
if (isInitialRender) {
|
|
186
|
+
let componentCall = new PLVLoadingLayout(this, {}, undefined, elmtId, () => {
|
|
187
|
+
}, { page: "foundation/src/main/ets/modules/web/PLVSimpleWeb.ets", line: 124, b2: 11 });
|
|
188
|
+
ViewPU.create(componentCall);
|
|
189
|
+
let paramsLambda = () => {
|
|
190
|
+
return {};
|
|
191
|
+
};
|
|
192
|
+
componentCall.paramsGenerator_ = paramsLambda;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
this.updateStateVarsOfChildByElmtId(elmtId, {});
|
|
196
|
+
}
|
|
197
|
+
}, { name: "PLVLoadingLayout" });
|
|
198
|
+
}
|
|
199
|
+
Column.pop();
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this.ifElseBranchUpdateFunction(1, () => {
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}, If);
|
|
207
|
+
If.pop();
|
|
208
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
209
|
+
If.create();
|
|
210
|
+
if (this.webStatus === PLVWebpageStatus.ERROR && this.showLoading) {
|
|
211
|
+
this.ifElseBranchUpdateFunction(0, () => {
|
|
212
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
213
|
+
Column.create();
|
|
214
|
+
Column.justifyContent(FlexAlign.Center);
|
|
215
|
+
Column.alignItems(HorizontalAlign.Center);
|
|
216
|
+
Column.backgroundColor(Color.White);
|
|
217
|
+
Column.width(PLVCommonConstants.FULL_PERCENT);
|
|
218
|
+
Column.height(PLVCommonConstants.FULL_PERCENT);
|
|
219
|
+
}, Column);
|
|
220
|
+
{
|
|
221
|
+
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
|
222
|
+
if (isInitialRender) {
|
|
223
|
+
let componentCall = new PLVFailureLayout(this, {
|
|
224
|
+
handleReload: () => {
|
|
225
|
+
this.webStatus = PLVWebpageStatus.INIT;
|
|
226
|
+
this.controller?.refresh();
|
|
227
|
+
}
|
|
228
|
+
}, undefined, elmtId, () => {
|
|
229
|
+
}, { page: "foundation/src/main/ets/modules/web/PLVSimpleWeb.ets", line: 131, b2: 11 });
|
|
230
|
+
ViewPU.create(componentCall);
|
|
231
|
+
let paramsLambda = () => {
|
|
232
|
+
return {
|
|
233
|
+
handleReload: () => {
|
|
234
|
+
this.webStatus = PLVWebpageStatus.INIT;
|
|
235
|
+
this.controller?.refresh();
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
componentCall.paramsGenerator_ = paramsLambda;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
this.updateStateVarsOfChildByElmtId(elmtId, {});
|
|
243
|
+
}
|
|
244
|
+
}, { name: "PLVFailureLayout" });
|
|
245
|
+
}
|
|
246
|
+
Column.pop();
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.ifElseBranchUpdateFunction(1, () => {
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}, If);
|
|
254
|
+
If.pop();
|
|
255
|
+
Stack.pop();
|
|
256
|
+
}
|
|
257
|
+
rerender() {
|
|
258
|
+
this.updateDirtyElements();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { webview } from '@kit.ArkWeb';
|
|
2
|
+
import { PLVCallback, PLVCallback2 } from '../../common/PLVCallback';
|
|
3
|
+
import { PLVFullScreenStatus, PLVWebpageStatus } from '../../common/PLVCommonEnums';
|
|
4
|
+
import { common } from '@kit.AbilityKit';
|
|
5
|
+
export declare class PLVWebController extends webview.WebviewController {
|
|
6
|
+
static importSDKModuleContext: common.UIAbilityContext;
|
|
7
|
+
_webStatus: PLVWebpageStatus;
|
|
8
|
+
_fullScreenStatus: PLVFullScreenStatus;
|
|
9
|
+
_originalIsLayoutFullScreen: boolean;
|
|
10
|
+
_originalIsFullScreen: boolean;
|
|
11
|
+
_accessBackward?: PLVCallback<void, boolean>;
|
|
12
|
+
_backward?: PLVCallback<void, boolean>;
|
|
13
|
+
_userAgent?: string;
|
|
14
|
+
_addOnReloaded: PLVCallback<void, void>[];
|
|
15
|
+
_darkMode: WebDarkMode;
|
|
16
|
+
_forceDarkAccess: boolean;
|
|
17
|
+
_domStorageAccess: boolean;
|
|
18
|
+
_zoomAccess: boolean;
|
|
19
|
+
_fileAccess: boolean;
|
|
20
|
+
_multiWindowAccess: boolean;
|
|
21
|
+
_allowWindowOpenMethod: boolean;
|
|
22
|
+
_javaScriptAccess: boolean;
|
|
23
|
+
_mixedMode: MixedMode;
|
|
24
|
+
_cacheMode: CacheMode;
|
|
25
|
+
_onControllerAttached?: PLVCallback<void, void>;
|
|
26
|
+
_addOnControllerAttached: PLVCallback<void, void>[];
|
|
27
|
+
_onInterceptRequest?: PLVCallback<WebResourceRequest, WebResourceResponse>;
|
|
28
|
+
_onLoadIntercept?: PLVCallback<WebResourceRequest, boolean>;
|
|
29
|
+
_onWindowNew?: PLVCallback<OnWindowNewEvent, boolean>;
|
|
30
|
+
_onShowFileSelector?: PLVCallback<OnShowFileSelectorEvent, boolean>;
|
|
31
|
+
_onFullScreenEnter?: PLVCallback<void, boolean>;
|
|
32
|
+
_onFullScreenExit?: PLVCallback<void, boolean>;
|
|
33
|
+
_onProgressChange?: PLVCallback<OnProgressChangeEvent, void>;
|
|
34
|
+
_onPageBegin?: PLVCallback<OnPageBeginEvent, void>;
|
|
35
|
+
_onPageEnd?: PLVCallback<OnPageEndEvent, void>;
|
|
36
|
+
_addOnPageEnd: PLVCallback<OnPageEndEvent, void>[];
|
|
37
|
+
_onErrorReceive?: PLVCallback<OnErrorReceiveEvent, void>;
|
|
38
|
+
_backgroundColor?: ResourceColor;
|
|
39
|
+
_verticalScrollBarAccess?: boolean;
|
|
40
|
+
_nestedScrollOptions: NestedScrollOptions;
|
|
41
|
+
_overScrollMode: OverScrollMode;
|
|
42
|
+
private dialogController;
|
|
43
|
+
private jsBridge;
|
|
44
|
+
constructor(webTag?: string);
|
|
45
|
+
accessBackward(): boolean;
|
|
46
|
+
backward(): void;
|
|
47
|
+
darkMode(darkMode: WebDarkMode): PLVWebController;
|
|
48
|
+
forceDarkAccess(forceDarkAccess: boolean): PLVWebController;
|
|
49
|
+
domStorageAccess(domStorageAccess: boolean): PLVWebController;
|
|
50
|
+
zoomAccess(zoomAccess: boolean): PLVWebController;
|
|
51
|
+
fileAccess(fileAccess: boolean): PLVWebController;
|
|
52
|
+
multiWindowAccess(multiWindowAccess: boolean): PLVWebController;
|
|
53
|
+
allowWindowOpenMethod(allowWindowOpenMethod: boolean): PLVWebController;
|
|
54
|
+
javaScriptAccess(javaScriptAccess: boolean): PLVWebController;
|
|
55
|
+
onControllerAttached(callback: PLVCallback<void, void>): PLVWebController;
|
|
56
|
+
addOnControllerAttached(callback: PLVCallback<void, void>): PLVWebController;
|
|
57
|
+
onInterceptRequest(callback: PLVCallback<WebResourceRequest, WebResourceResponse>): PLVWebController;
|
|
58
|
+
onLoadIntercept(callback: PLVCallback<WebResourceRequest, boolean>): PLVWebController;
|
|
59
|
+
onWindowNew(callback: PLVCallback<OnWindowNewEvent, boolean>): PLVWebController;
|
|
60
|
+
onShowFileSelector(callback: PLVCallback<OnShowFileSelectorEvent, boolean>): PLVWebController;
|
|
61
|
+
onFullScreenEnter(callback: PLVCallback<void, boolean>): PLVWebController;
|
|
62
|
+
onFullScreenExit(callback: PLVCallback<void, boolean>): PLVWebController;
|
|
63
|
+
onProgressChange(callback: PLVCallback<OnProgressChangeEvent, void>): PLVWebController;
|
|
64
|
+
onPageBegin(callback: PLVCallback<OnPageBeginEvent, void>): PLVWebController;
|
|
65
|
+
onPageEnd(callback: PLVCallback<OnPageEndEvent, void>): PLVWebController;
|
|
66
|
+
addOnPageEnd(callback: PLVCallback<OnPageEndEvent, void>): PLVWebController;
|
|
67
|
+
onErrorReceive(callback: PLVCallback<OnErrorReceiveEvent, void>): PLVWebController;
|
|
68
|
+
backgroundColor(backgroundColor: ResourceColor): this;
|
|
69
|
+
verticalScrollBarAccess(verticalScrollBarAccess: boolean): this;
|
|
70
|
+
nestedScrollOptions(w11: NestedScrollOptions): this;
|
|
71
|
+
overScrollMode(overScrollMode: OverScrollMode): void;
|
|
72
|
+
userAgent(userAgent?: string): this;
|
|
73
|
+
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
|
+
loadHtmlData(data?: string): this;
|
|
77
|
+
loadUrlCatch(url: string | Resource): void;
|
|
78
|
+
handleControllerAttached(): void;
|
|
79
|
+
handleFullScreenExit(): void;
|
|
80
|
+
handleFullScreenEnter(): void;
|
|
81
|
+
handleWindowNew(event: OnWindowNewEvent, builder: (webviewController: WebviewController) => CustomDialogController): void;
|
|
82
|
+
handleIsLoadIntercept(intercept: WebResourceRequest | undefined): boolean;
|
|
83
|
+
handlePageEnd(event: OnPageEndEvent): void;
|
|
84
|
+
handleErrorReceive(): void;
|
|
85
|
+
private getVideoWHEnterFullScreen;
|
|
86
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import webview from "@ohos.web.webview";
|
|
2
|
+
import { PLVJsBridge } from 'jsbridge';
|
|
3
|
+
import { PLVFullScreenStatus, PLVWebpageStatus } from '../../common/PLVCommonEnums';
|
|
4
|
+
import PLVUtils from '../../common/PLVUtils';
|
|
5
|
+
import PLVLogger from '../log/PLVLogger';
|
|
6
|
+
const d11 = 100;
|
|
7
|
+
const TAG = "[PLVWebController]";
|
|
8
|
+
export class PLVWebController extends webview.WebviewController {
|
|
9
|
+
constructor(webTag) {
|
|
10
|
+
super(webTag || 'PLVWeb');
|
|
11
|
+
this._webStatus = PLVWebpageStatus.INIT;
|
|
12
|
+
this._fullScreenStatus = PLVFullScreenStatus.IDLE;
|
|
13
|
+
this._originalIsLayoutFullScreen = false;
|
|
14
|
+
this._originalIsFullScreen = false;
|
|
15
|
+
this._addOnReloaded = [];
|
|
16
|
+
this._darkMode = WebDarkMode.Auto;
|
|
17
|
+
this._forceDarkAccess = false;
|
|
18
|
+
this._domStorageAccess = true;
|
|
19
|
+
this._zoomAccess = true;
|
|
20
|
+
this._fileAccess = true;
|
|
21
|
+
this._multiWindowAccess = true;
|
|
22
|
+
this._allowWindowOpenMethod = true;
|
|
23
|
+
this._javaScriptAccess = true;
|
|
24
|
+
this._mixedMode = MixedMode.All;
|
|
25
|
+
this._cacheMode = CacheMode.None;
|
|
26
|
+
this._addOnControllerAttached = [];
|
|
27
|
+
this._addOnPageEnd = [];
|
|
28
|
+
this._backgroundColor = Color.Transparent;
|
|
29
|
+
this._verticalScrollBarAccess = false;
|
|
30
|
+
this._nestedScrollOptions = { scrollForward: NestedScrollMode.SELF_FIRST, scrollBackward: NestedScrollMode.SELF_FIRST };
|
|
31
|
+
this._overScrollMode = OverScrollMode.NEVER;
|
|
32
|
+
this.dialogController = null;
|
|
33
|
+
this.jsBridge = new PLVJsBridge(this);
|
|
34
|
+
}
|
|
35
|
+
accessBackward() {
|
|
36
|
+
if (this._accessBackward?.()) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
else if (this._fullScreenStatus === PLVFullScreenStatus.ENTER) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
return super.accessBackward();
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
backward() {
|
|
50
|
+
if (this._backward?.()) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (this._fullScreenStatus === PLVFullScreenStatus.ENTER) {
|
|
54
|
+
this._fullScreenStatus = PLVFullScreenStatus.EXIT;
|
|
55
|
+
this.runJavaScript(PLVUtils.getExitFullScreenJS(true));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
super.backward();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
darkMode(darkMode) {
|
|
62
|
+
this._darkMode = darkMode;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
forceDarkAccess(forceDarkAccess) {
|
|
66
|
+
this._forceDarkAccess = forceDarkAccess;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
domStorageAccess(domStorageAccess) {
|
|
70
|
+
this._domStorageAccess = domStorageAccess;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
zoomAccess(zoomAccess) {
|
|
74
|
+
this._zoomAccess = zoomAccess;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
fileAccess(fileAccess) {
|
|
78
|
+
this._fileAccess = fileAccess;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
multiWindowAccess(multiWindowAccess) {
|
|
82
|
+
this._multiWindowAccess = multiWindowAccess;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
allowWindowOpenMethod(allowWindowOpenMethod) {
|
|
86
|
+
this._allowWindowOpenMethod = allowWindowOpenMethod;
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
javaScriptAccess(javaScriptAccess) {
|
|
90
|
+
this._javaScriptAccess = javaScriptAccess;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
onControllerAttached(callback) {
|
|
94
|
+
this._onControllerAttached = callback;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
addOnControllerAttached(callback) {
|
|
98
|
+
this._addOnControllerAttached.push(callback);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
onInterceptRequest(callback) {
|
|
102
|
+
this._onInterceptRequest = callback;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
onLoadIntercept(callback) {
|
|
106
|
+
this._onLoadIntercept = callback;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
onWindowNew(callback) {
|
|
110
|
+
this._onWindowNew = callback;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
onShowFileSelector(callback) {
|
|
114
|
+
this._onShowFileSelector = callback;
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
onFullScreenEnter(callback) {
|
|
118
|
+
this._onFullScreenEnter = callback;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
onFullScreenExit(callback) {
|
|
122
|
+
this._onFullScreenExit = callback;
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
onProgressChange(callback) {
|
|
126
|
+
this._onProgressChange = callback;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
onPageBegin(callback) {
|
|
130
|
+
this._onPageBegin = callback;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
onPageEnd(callback) {
|
|
134
|
+
this._onPageEnd = callback;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
addOnPageEnd(callback) {
|
|
138
|
+
this._addOnPageEnd.push(callback);
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
onErrorReceive(callback) {
|
|
142
|
+
this._onErrorReceive = callback;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
backgroundColor(backgroundColor) {
|
|
146
|
+
this._backgroundColor = backgroundColor;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
verticalScrollBarAccess(verticalScrollBarAccess) {
|
|
150
|
+
this._verticalScrollBarAccess = verticalScrollBarAccess;
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
nestedScrollOptions(w11) {
|
|
154
|
+
this._nestedScrollOptions = w11;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
overScrollMode(overScrollMode) {
|
|
158
|
+
this._overScrollMode = overScrollMode;
|
|
159
|
+
}
|
|
160
|
+
userAgent(userAgent) {
|
|
161
|
+
this._userAgent = userAgent;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
addOnReloaded(callback) {
|
|
165
|
+
this._addOnReloaded.push(callback);
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
registerHandler(v11, handle) {
|
|
169
|
+
this.jsBridge.registerHandler(v11, handle);
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
callHandle(t11, data, u11) {
|
|
173
|
+
this.jsBridge.callHandle(t11, data, u11);
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
loadHtmlData(data) {
|
|
177
|
+
PLVLogger.info(TAG, `loadHtmlData: ${data}`);
|
|
178
|
+
try {
|
|
179
|
+
super.loadData(data, "text/html", "UTF-8", ' ', ' ');
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
const e = err;
|
|
183
|
+
PLVLogger.printError(TAG, `webController loadHtmlData err ${e.code}`, e);
|
|
184
|
+
}
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
loadUrlCatch(url) {
|
|
188
|
+
PLVLogger.info(TAG, `loadUrlCatch: ${url}`);
|
|
189
|
+
try {
|
|
190
|
+
super.loadUrl(url);
|
|
191
|
+
this._addOnReloaded.forEach((value) => {
|
|
192
|
+
value();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
const e = err;
|
|
197
|
+
PLVLogger.printError(TAG, `webController loadUrlCatch err ${e.code}`, e);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
handleControllerAttached() {
|
|
201
|
+
this._addOnControllerAttached.forEach((value) => {
|
|
202
|
+
value();
|
|
203
|
+
});
|
|
204
|
+
if (this._userAgent) {
|
|
205
|
+
this.setCustomUserAgent(this._userAgent);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
handleFullScreenExit() {
|
|
209
|
+
if (PLVUtils.isLandscape()) {
|
|
210
|
+
PLVUtils.changeOrientation(false);
|
|
211
|
+
PLVUtils.setWindowFullScreen(this._originalIsLayoutFullScreen, this._originalIsFullScreen);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
handleFullScreenEnter() {
|
|
215
|
+
this.getVideoWHEnterFullScreen(d11, d11, d11 * 10);
|
|
216
|
+
}
|
|
217
|
+
handleWindowNew(event, builder) {
|
|
218
|
+
if (this.dialogController) {
|
|
219
|
+
this.dialogController.close();
|
|
220
|
+
}
|
|
221
|
+
let q11 = new webview.WebviewController();
|
|
222
|
+
this.dialogController = builder(q11);
|
|
223
|
+
this.dialogController.open();
|
|
224
|
+
event.handler.setWebController(q11);
|
|
225
|
+
}
|
|
226
|
+
handleIsLoadIntercept(intercept) {
|
|
227
|
+
try {
|
|
228
|
+
return this.jsBridge.isInterceptRequest(intercept);
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
PLVLogger.info(TAG, 'IsLoadIntercept catch');
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
handlePageEnd(event) {
|
|
236
|
+
this._addOnPageEnd.forEach((value) => {
|
|
237
|
+
value(event);
|
|
238
|
+
});
|
|
239
|
+
this._webStatus = PLVWebpageStatus.FINISHED;
|
|
240
|
+
PLVUtils.retryWhen(() => {
|
|
241
|
+
this.jsBridge.loadLocalJs(PLVWebController.importSDKModuleContext);
|
|
242
|
+
}, () => {
|
|
243
|
+
this.jsBridge.loadLocalJs(getContext(this));
|
|
244
|
+
})
|
|
245
|
+
.then(() => {
|
|
246
|
+
PLVLogger.info(TAG, 'LoadLocalJs success');
|
|
247
|
+
})
|
|
248
|
+
.catch((err) => {
|
|
249
|
+
PLVLogger.info(TAG, `LoadLocalJs catch\n${err.stack}`);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
handleErrorReceive() {
|
|
253
|
+
this._webStatus = PLVWebpageStatus.FINISHED;
|
|
254
|
+
}
|
|
255
|
+
getVideoWHEnterFullScreen(delayTime, e11, f11) {
|
|
256
|
+
if (delayTime > f11) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
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);
|
|
264
|
+
}
|
|
265
|
+
else if (i11.width > i11.height) {
|
|
266
|
+
PLVUtils.changeOrientation(true);
|
|
267
|
+
PLVUtils.setWindowFullScreen(true, true).then((k11) => {
|
|
268
|
+
this._originalIsLayoutFullScreen = k11[0];
|
|
269
|
+
this._originalIsFullScreen = k11[1];
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}, delayTime);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface PLVVideoWH {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export interface PLVProgressEvent {
|
|
6
|
+
newProgress: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PLVPageEvent {
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PLVErrorReceiveEvent {
|
|
12
|
+
request: WebResourceRequest;
|
|
13
|
+
error: WebResourceError;
|
|
14
|
+
}
|
|
15
|
+
export interface PLVInterceptRequestEvent {
|
|
16
|
+
request: WebResourceRequest;
|
|
17
|
+
}
|
|
18
|
+
export interface PLVLoadInterceptEvent {
|
|
19
|
+
data: WebResourceRequest;
|
|
20
|
+
}
|
|
21
|
+
export interface PLVWindowNewEvent {
|
|
22
|
+
isAlert: boolean;
|
|
23
|
+
isUserTrigger: boolean;
|
|
24
|
+
targetUrl: string;
|
|
25
|
+
handler: ControllerHandler;
|
|
26
|
+
}
|
|
27
|
+
export interface PLVShowFileSelectorEvent {
|
|
28
|
+
result: FileSelectorResult;
|
|
29
|
+
fileSelector: FileSelectorParam;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
}
|