• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/// <reference path='./import.ts' />
17class WebJavaScriptAccessModifier extends ModifierWithKey<boolean> {
18  constructor(value: boolean) {
19    super(value);
20  }
21  static identity: Symbol = Symbol('webJavascriptAccess');
22  applyPeer(node: KNode, reset: boolean): void {
23    if (reset) {
24      getUINativeModule().web.resetJavaScriptAccess(node);
25    } else {
26      getUINativeModule().web.setJavaScriptAccess(node, this.value);
27    }
28  }
29}
30
31class WebFileAccessModifier extends ModifierWithKey<boolean> {
32  constructor(value: boolean) {
33    super(value);
34  }
35  static identity: Symbol = Symbol('webFileAccessModifier');
36  applyPeer(node: KNode, reset: boolean): void {
37    if (reset) {
38      getUINativeModule().web.resetFileAccess(node);
39    } else {
40      getUINativeModule().web.setFileAccess(node, this.value);
41    }
42  }
43}
44
45class WebDomStorageAccessModifier extends ModifierWithKey<boolean> {
46  constructor(value: boolean) {
47    super(value);
48  }
49  static identity: Symbol = Symbol('webDomStorageAccessModifier');
50  applyPeer(node: KNode, reset: boolean): void {
51    if (reset) {
52      getUINativeModule().web.resetDomStorageAccess(node);
53    } else {
54      getUINativeModule().web.setDomStorageAccess(node, this.value);
55    }
56  }
57}
58
59class WebMixedModeModifier extends ModifierWithKey<number> {
60  constructor(value: number) {
61    super(value);
62  }
63  static identity: Symbol = Symbol('webMixedMode');
64  applyPeer(node: KNode, reset: boolean): void {
65    if (reset) {
66      getUINativeModule().web.resetMixedMode(node);
67    } else {
68      getUINativeModule().web.setMixedMode(node, this.value);
69    }
70  }
71}
72
73class WebZoomAccessModifier extends ModifierWithKey<boolean> {
74  constructor(value: boolean) {
75    super(value);
76  }
77  static identity: Symbol = Symbol('webZoomAccessModifier');
78  applyPeer(node: KNode, reset: boolean): void {
79    if (reset) {
80      getUINativeModule().web.resetZoomAccess(node);
81    } else {
82      getUINativeModule().web.setZoomAccess(node, this.value);
83    }
84  }
85}
86
87class WebCacheModeModifier extends ModifierWithKey<number> {
88  constructor(value: number) {
89    super(value);
90  }
91  static identity: Symbol = Symbol('webCacheModeModifier');
92  applyPeer(node: KNode, reset: boolean): void {
93    if (reset) {
94      getUINativeModule().web.resetCacheMode(node);
95    } else {
96      getUINativeModule().web.setCacheMode(node, this.value);
97    }
98  }
99}
100
101class WebDarkModeModifier extends ModifierWithKey<number> {
102  constructor(value: number) {
103    super(value);
104  }
105  static identity: Symbol = Symbol('webDarkModeModifier');
106  applyPeer(node: KNode, reset: boolean): void {
107    if (reset) {
108      getUINativeModule().web.resetDarkMode(node);
109    } else {
110      getUINativeModule().web.setDarkMode(node, this.value);
111    }
112  }
113}
114
115class WebMultiWindowAccessModifier extends ModifierWithKey<boolean> {
116  constructor(value: boolean) {
117    super(value);
118  }
119  static identity: Symbol = Symbol('webMultiWindowAccessModifier');
120  applyPeer(node: KNode, reset: boolean): void {
121    if (reset) {
122      getUINativeModule().web.resetMultiWindowAccess(node);
123    } else {
124      getUINativeModule().web.setMultiWindowAccess(node, this.value);
125    }
126  }
127}
128class WebAllowWindowOpenMethodModifier extends ModifierWithKey<boolean> {
129  constructor(value: boolean) {
130    super(value);
131  }
132  static identity: Symbol = Symbol('webAllowWindowOpenMethodModifier');
133  applyPeer(node: KNode, reset: boolean): void {
134    if (reset) {
135      getUINativeModule().web.resetAllowWindowOpenMethod(node);
136    } else {
137      getUINativeModule().web.setAllowWindowOpenMethod(node, this.value);
138    }
139  }
140}
141
142class ArkWebComponent extends ArkComponent implements WebAttribute {
143  constructor(nativePtr: KNode, classType?: ModifierType) {
144    super(nativePtr, classType);
145  }
146  javaScriptAccess(javaScriptAccess: boolean): this {
147    modifierWithKey(this._modifiersWithKeys, WebJavaScriptAccessModifier.identity, WebJavaScriptAccessModifier, javaScriptAccess);
148    return this;
149  }
150  fileAccess(fileAccess: boolean): this {
151    modifierWithKey(this._modifiersWithKeys, WebFileAccessModifier.identity, WebFileAccessModifier, fileAccess);
152    return this;
153  }
154  onlineImageAccess(onlineImageAccess: boolean): this {
155    throw new Error('Method not implemented.');
156  }
157  domStorageAccess(domStorageAccess: boolean): this {
158    modifierWithKey(this._modifiersWithKeys, WebDomStorageAccessModifier.identity, WebDomStorageAccessModifier, domStorageAccess);
159    return this;
160  }
161  imageAccess(imageAccess: boolean): this {
162    throw new Error('Method not implemented.');
163  }
164  mixedMode(mixedMode: MixedMode): this {
165    modifierWithKey(this._modifiersWithKeys, WebMixedModeModifier.identity, WebDarkModeModifier, mixedMode);
166    return this;
167  }
168  zoomAccess(zoomAccess: boolean): this {
169    modifierWithKey(this._modifiersWithKeys, WebZoomAccessModifier.identity, WebZoomAccessModifier, zoomAccess);
170    return this;
171  }
172  geolocationAccess(geolocationAccess: boolean): this {
173    throw new Error('Method not implemented.');
174  }
175  javaScriptProxy(javaScriptProxy: { object: object; name: string; methodList: string[]; controller: any; }): this {
176    throw new Error('Method not implemented.');
177  }
178  password(password: boolean): this {
179    throw new Error('Method not implemented.');
180  }
181  cacheMode(cacheMode: CacheMode): this {
182    modifierWithKey(this._modifiersWithKeys, WebCacheModeModifier.identity, WebCacheModeModifier, cacheMode);
183    return this;
184  }
185  darkMode(mode: WebDarkMode): this {
186    modifierWithKey(this._modifiersWithKeys, WebDarkModeModifier.identity, WebDarkModeModifier, mode);
187    return this;
188  }
189  forceDarkAccess(access: boolean): this {
190    throw new Error('Method not implemented.');
191  }
192  mediaOptions(options: WebMediaOptions): this {
193    throw new Error('Method not implemented.');
194  }
195  tableData(tableData: boolean): this {
196    throw new Error('Method not implemented.');
197  }
198  wideViewModeAccess(wideViewModeAccess: boolean): this {
199    throw new Error('Method not implemented.');
200  }
201  overviewModeAccess(overviewModeAccess: boolean): this {
202    throw new Error('Method not implemented.');
203  }
204  overScrollMode(mode: OverScrollMode): this {
205    throw new Error('Method not implemented.');
206  }
207  textZoomAtio(textZoomAtio: number): this {
208    throw new Error('Method not implemented.');
209  }
210  textZoomRatio(textZoomRatio: number): this {
211    throw new Error('Method not implemented.');
212  }
213  databaseAccess(databaseAccess: boolean): this {
214    throw new Error('Method not implemented.');
215  }
216  initialScale(percent: number): this {
217    throw new Error('Method not implemented.');
218  }
219  userAgent(userAgent: string): this {
220    throw new Error('Method not implemented.');
221  }
222  onPageEnd(callback: (event?: { url: string; } | undefined) => void): this {
223    throw new Error('Method not implemented.');
224  }
225  onPageBegin(callback: (event?: { url: string; } | undefined) => void): this {
226    throw new Error('Method not implemented.');
227  }
228  onProgressChange(callback: (event?: { newProgress: number; } | undefined) => void): this {
229    throw new Error('Method not implemented.');
230  }
231  onTitleReceive(callback: (event?: { title: string; } | undefined) => void): this {
232    throw new Error('Method not implemented.');
233  }
234  onGeolocationHide(callback: () => void): this {
235    throw new Error('Method not implemented.');
236  }
237  onGeolocationShow(callback: (event?: { origin: string; geolocation: JsGeolocation; } | undefined) => void): this {
238    throw new Error('Method not implemented.');
239  }
240  onRequestSelected(callback: () => void): this {
241    throw new Error('Method not implemented.');
242  }
243  onAlert(callback: (event?: { url: string; message: string; result: JsResult; } | undefined) => boolean): this {
244    throw new Error('Method not implemented.');
245  }
246  onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResult; } | undefined) => boolean): this {
247    throw new Error('Method not implemented.');
248  }
249  onConfirm(callback: (event?: { url: string; message: string; result: JsResult; } | undefined) => boolean): this {
250    throw new Error('Method not implemented.');
251  }
252  onPrompt(callback: (event?: { url: string; message: string; value: string; result: JsResult; } | undefined) => boolean): this {
253    throw new Error('Method not implemented.');
254  }
255  onConsole(callback: (event?: { message: ConsoleMessage; } | undefined) => boolean): this {
256    throw new Error('Method not implemented.');
257  }
258  onErrorReceive(callback: (event?: { request: WebResourceRequest; error: WebResourceError; } | undefined) => void): this {
259    throw new Error('Method not implemented.');
260  }
261  onHttpErrorReceive(callback: (event?: { request: WebResourceRequest; response: WebResourceResponse; } | undefined) => void): this {
262    throw new Error('Method not implemented.');
263  }
264  onDownloadStart(callback: (event?: {
265    url: string;
266    userAgent: string; contentDisposition: string;
267    mimetype: string; contentLength: number;
268  } | undefined) => void): this {
269    throw new Error('Method not implemented.');
270  }
271  onRefreshAccessedHistory(callback: (event?: { url: string; isRefreshed: boolean; } | undefined) => void): this {
272    throw new Error('Method not implemented.');
273  }
274  onUrlLoadIntercept(callback: (event?: { data: string | WebResourceRequest; } | undefined) => boolean): this {
275    throw new Error('Method not implemented.');
276  }
277  onSslErrorReceive(callback: (event?: { handler: Function; error: object; } | undefined) => void): this {
278    throw new Error('Method not implemented.');
279  }
280  onRenderExited(callback: (event?: { renderExitReason: RenderExitReason; } | undefined) => void): this;
281  onRenderExited(callback: (event?: { detail: object; } | undefined) => boolean): this;
282  onRenderExited(callback: unknown): this {
283    throw new Error('Method not implemented.');
284  }
285  onShowFileSelector(callback: (event?: { result: FileSelectorResult; fileSelector: FileSelectorParam; } | undefined) => boolean): this {
286    throw new Error('Method not implemented.');
287  }
288  onFileSelectorShow(callback: (event?: { callback: Function; fileSelector: object; } | undefined) => void): this {
289    throw new Error('Method not implemented.');
290  }
291  onResourceLoad(callback: (event: { url: string; }) => void): this {
292    throw new Error('Method not implemented.');
293  }
294  onFullScreenExit(callback: () => void): this {
295    throw new Error('Method not implemented.');
296  }
297  onFullScreenEnter(callback: (event: { handler: FullScreenExitHandler; }) => void): this {
298    throw new Error('Method not implemented.');
299  }
300  onScaleChange(callback: (event: { oldScale: number; newScale: number; }) => void): this {
301    throw new Error('Method not implemented.');
302  }
303  onHttpAuthRequest(callback: (event?: { handler: HttpAuthHandler; host: string; realm: string; } | undefined) => boolean): this {
304    throw new Error('Method not implemented.');
305  }
306  onInterceptRequest(callback: (event?: { request: WebResourceRequest; } | undefined) => WebResourceResponse): this {
307    throw new Error('Method not implemented.');
308  }
309  onPermissionRequest(callback: (event?: { request: PermissionRequest; } | undefined) => void): this {
310    throw new Error('Method not implemented.');
311  }
312  onScreenCaptureRequest(callback: (event?: { handler: ScreenCaptureHandler; } | undefined) => void): this {
313    throw new Error('Method not implemented.');
314  }
315  onContextMenuShow(callback: (event?: { param: WebContextMenuParam; result: WebContextMenuResult; } | undefined) => boolean): this {
316    throw new Error('Method not implemented.');
317  }
318  mediaPlayGestureAccess(access: boolean): this {
319    throw new Error('Method not implemented.');
320  }
321  onSearchResultReceive(callback: (event?: { activeMatchOrdinal: number; numberOfMatches: number; isDoneCounting: boolean; } | undefined) => void): this {
322    throw new Error('Method not implemented.');
323  }
324  onScroll(callback: (event: { xOffset: number; yOffset: number; }) => void): this {
325    throw new Error('Method not implemented.');
326  }
327  onSslErrorEventReceive(callback: (event: { handler: SslErrorHandler; error: SslError; }) => void): this {
328    throw new Error('Method not implemented.');
329  }
330  onSslErrorEvent(callback: (event: { handler: SslErrorHandler; error: SslError; url: string;
331    originalUrl: string; referrer: string; isFatalError: boolean; isMainFrame: boolean; }) => void): this {
332    throw new Error('Method not implemented.');
333  }
334  onClientAuthenticationRequest(callback: (event: {
335    handler: ClientAuthenticationHandler;
336    host: string; port: number; keyTypes: string[]; issuers: string[];
337  }) => void): this {
338    throw new Error('Method not implemented.');
339  }
340  onWindowNew(callback: (event: { isAlert: boolean; isUserTrigger: boolean; targetUrl: string; handler: ControllerHandler; }) => void): this {
341    throw new Error('Method not implemented.');
342  }
343  onWindowExit(callback: () => void): this {
344    throw new Error('Method not implemented.');
345  }
346  multiWindowAccess(multiWindow: boolean): this {
347    modifierWithKey(this._modifiersWithKeys, WebMultiWindowAccessModifier.identity, WebMultiWindowAccessModifier, multiWindow);
348    return this;
349  }
350  onInterceptKeyEvent(callback: (event: KeyEvent) => boolean): this {
351    throw new Error('Method not implemented.');
352  }
353  webStandardFont(family: string): this {
354    throw new Error('Method not implemented.');
355  }
356  webSerifFont(family: string): this {
357    throw new Error('Method not implemented.');
358  }
359  webSansSerifFont(family: string): this {
360    throw new Error('Method not implemented.');
361  }
362  webFixedFont(family: string): this {
363    throw new Error('Method not implemented.');
364  }
365  webFantasyFont(family: string): this {
366    throw new Error('Method not implemented.');
367  }
368  webCursiveFont(family: string): this {
369    throw new Error('Method not implemented.');
370  }
371  defaultFixedFontSize(size: number): this {
372    throw new Error('Method not implemented.');
373  }
374  defaultFontSize(size: number): this {
375    throw new Error('Method not implemented.');
376  }
377  minFontSize(size: number): this {
378    throw new Error('Method not implemented.');
379  }
380  minLogicalFontSize(size: number): this {
381    throw new Error('Method not implemented.');
382  }
383  blockNetwork(block: boolean): this {
384    throw new Error('Method not implemented.');
385  }
386  horizontalScrollBarAccess(horizontalScrollBar: boolean): this {
387    throw new Error('Method not implemented.');
388  }
389  verticalScrollBarAccess(verticalScrollBar: boolean): this {
390    throw new Error('Method not implemented.');
391  }
392  onTouchIconUrlReceived(callback: (event: { url: string; precomposed: boolean; }) => void): this {
393    throw new Error('Method not implemented.');
394  }
395  onFaviconReceived(callback: (event: { favicon: any; }) => void): this {
396    throw new Error('Method not implemented.');
397  }
398  onPageVisible(callback: (event: { url: string; }) => void): this {
399    throw new Error('Method not implemented.');
400  }
401  onDataResubmitted(callback: (event: { handler: DataResubmissionHandler; }) => void): this {
402    throw new Error('Method not implemented.');
403  }
404  pinchSmooth(isEnabled: boolean): this {
405    throw new Error('Method not implemented.');
406  }
407  allowWindowOpenMethod(flag: boolean): this {
408    modifierWithKey(this._modifiersWithKeys, WebAllowWindowOpenMethodModifier.identity, WebAllowWindowOpenMethodModifier, flag);
409    return this;
410  }
411  onAudioStateChanged(callback: (event: { playing: boolean; }) => void): this {
412    throw new Error('Method not implemented.');
413  }
414  onFirstContentfulPaint(callback: (event?: { navigationStartTick: number; firstContentfulPaintMs: number; } | undefined) => void): this {
415    throw new Error('Method not implemented.');
416  }
417  onLoadIntercept(callback: (event: { data: WebResourceRequest; }) => boolean): this {
418    throw new Error('Method not implemented.');
419  }
420  onControllerAttached(callback: () => void): this {
421    throw new Error('Method not implemented.');
422  }
423  onOverScroll(callback: (event: { xOffset: number; yOffset: number; }) => void): this {
424    throw new Error('Method not implemented.');
425  }
426  javaScriptOnDocumentStart(scripts: ScriptItem[]): this {
427    throw new Error('Method not implemented.');
428  }
429  layoutMode(mode: WebLayoutMode): this {
430    throw new Error('Method not implemented.');
431  }
432  nestedScroll(value: NestedScrollOptions): this {
433    throw new Error('Method not implemented.');
434  }
435  onOverrideUrlLoading(callback: OnOverrideUrlLoadingCallback): this {
436    throw new Error('Method not implemented.');
437  }
438  enableNativeMediaPlayer(config: NativeMediaPlayerConfig): this {
439    throw new Error('Method not implemented.');
440  }
441  onRenderProcessNotResponding(callback: OnRenderProcessNotRespondingCallback): this {
442    throw new Error('Method not implemented.');
443  }
444  onRenderProcessResponding(callback: OnRenderProcessRespondingCallback): this {
445    throw new Error('Method not implemented.');
446  }
447  onViewportFitChanged(callback: OnViewportFitChangedCallback): this {
448    throw new Error('Method not implemented.');
449  }
450  onAdsBlockedBlock(callback: (details: { url: string; adsBlocked: string[]; } | undefined) => void): this {
451    throw new Error('Method not implemented.');
452  }
453}
454
455// @ts-ignore
456globalThis.Web.attributeModifier = function (modifier: ArkComponent): void {
457  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
458    return new ArkWebComponent(nativePtr);
459  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
460    return new modifierJS.CommonModifier(nativePtr, classType);
461  });
462};
463