flet-webview 0.2.0.dev49__tar.gz → 0.70.0.dev6555__tar.gz
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.
Potentially problematic release.
This version of flet-webview might be problematic. Click here for more details.
- {flet_webview-0.2.0.dev49/src/flet_webview.egg-info → flet_webview-0.70.0.dev6555}/PKG-INFO +17 -25
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/README.md +11 -19
- flet_webview-0.70.0.dev6555/pyproject.toml +24 -0
- flet_webview-0.70.0.dev6555/src/flet_webview/__init__.py +19 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flet_webview/types.py +28 -7
- flet_webview-0.70.0.dev6555/src/flet_webview/webview.py +384 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555/src/flet_webview.egg-info}/PKG-INFO +17 -25
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flet_webview.egg-info/SOURCES.txt +0 -3
- flet_webview-0.70.0.dev6555/src/flet_webview.egg-info/requires.txt +1 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/utils/webview.dart +8 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/webview_mobile_and_mac.dart +3 -4
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/pubspec.lock +95 -81
- flet_webview-0.70.0.dev6555/src/flutter/flet_webview/pubspec.yaml +27 -0
- flet_webview-0.2.0.dev49/pyproject.toml +0 -71
- flet_webview-0.2.0.dev49/src/flet_webview/__init__.py +0 -8
- flet_webview-0.2.0.dev49/src/flet_webview/webview.py +0 -517
- flet_webview-0.2.0.dev49/src/flet_webview.egg-info/requires.txt +0 -1
- flet_webview-0.2.0.dev49/src/flutter/flet_webview/CHANGELOG.md +0 -3
- flet_webview-0.2.0.dev49/src/flutter/flet_webview/LICENSE +0 -201
- flet_webview-0.2.0.dev49/src/flutter/flet_webview/README.md +0 -3
- flet_webview-0.2.0.dev49/src/flutter/flet_webview/pubspec.yaml +0 -27
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/LICENSE +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/setup.cfg +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flet_webview.egg-info/dependency_links.txt +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flet_webview.egg-info/top_level.txt +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/analysis_options.yaml +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/flet_webview.dart +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/extension.dart +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/webview.dart +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/webview_web.dart +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/webview_web_vain.dart +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/webview_windows_and_linux.dart +0 -0
- {flet_webview-0.2.0.dev49 → flet_webview-0.70.0.dev6555}/src/flutter/flet_webview/lib/src/webview_windows_and_linux_vain.dart +0 -0
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flet-webview
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.70.0.dev6555
|
|
4
|
+
Summary: Embed web content inside Flet apps via WebView.
|
|
5
5
|
Author-email: Flet contributors <hello@flet.dev>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
7
|
Project-URL: Homepage, https://flet.dev
|
|
8
|
-
Project-URL: Documentation, https://flet
|
|
9
|
-
Project-URL: Repository, https://github.com/flet-dev/flet-webview
|
|
10
|
-
Project-URL: Issues, https://github.com/flet-dev/flet
|
|
8
|
+
Project-URL: Documentation, https://docs.flet.dev/webview
|
|
9
|
+
Project-URL: Repository, https://github.com/flet-dev/flet/tree/main/sdk/python/packages/flet-webview
|
|
10
|
+
Project-URL: Issues, https://github.com/flet-dev/flet/issues
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: flet
|
|
14
|
+
Requires-Dist: flet==0.70.0.dev6555
|
|
15
15
|
Dynamic: license-file
|
|
16
16
|
|
|
17
17
|
# flet-webview
|
|
18
18
|
|
|
19
19
|
[](https://pypi.python.org/pypi/flet-webview)
|
|
20
20
|
[](https://pepy.tech/project/flet-webview)
|
|
21
|
-
[](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet-webview/LICENSE)
|
|
22
22
|
|
|
23
23
|
A [Flet](https://flet.dev) extension for displaying web content in a WebView.
|
|
24
24
|
|
|
25
25
|
It is based on the [webview_flutter](https://pub.dev/packages/webview_flutter)
|
|
26
26
|
and [webview_flutter_web](https://pub.dev/packages/webview_flutter_web) Flutter packages.
|
|
27
27
|
|
|
28
|
+
> **Important:** WebView requires platform-specific configuration (e.g., enabling webview on iOS). Consult Flutter's platform setup guides.
|
|
29
|
+
|
|
28
30
|
## Documentation
|
|
29
31
|
|
|
30
|
-
Detailed documentation to this package can be found [here](https://flet
|
|
32
|
+
Detailed documentation to this package can be found [here](https://docs.flet.dev/webview/).
|
|
31
33
|
|
|
32
34
|
## Platform Support
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
| Platform | Windows | macOS | Linux | iOS | Android | Web |
|
|
37
|
+
|----------|---------|-------|-------|-----|---------|-----|
|
|
38
|
+
| Supported| ❌ | ✅ | ❌ | ✅ | ✅ | ✅ |
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|----------|:---------:|
|
|
38
|
-
| Windows | ❌ |
|
|
39
|
-
| macOS | ✅ |
|
|
40
|
-
| Linux | ❌ |
|
|
41
|
-
| iOS | ✅ |
|
|
42
|
-
| Android | ✅ |
|
|
43
|
-
| Web | ✅ |
|
|
40
|
+
## Usage
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
### Installation
|
|
46
43
|
|
|
47
44
|
To install the `flet-webview` package and add it to your project dependencies:
|
|
48
45
|
|
|
@@ -57,11 +54,6 @@ To install the `flet-webview` package and add it to your project dependencies:
|
|
|
57
54
|
```
|
|
58
55
|
After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
poetry add flet-webview
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Examples
|
|
57
|
+
### Examples
|
|
66
58
|
|
|
67
|
-
For examples, see [
|
|
59
|
+
For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/controls/webview).
|
|
@@ -2,31 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://pypi.python.org/pypi/flet-webview)
|
|
4
4
|
[](https://pepy.tech/project/flet-webview)
|
|
5
|
-
[](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet-webview/LICENSE)
|
|
6
6
|
|
|
7
7
|
A [Flet](https://flet.dev) extension for displaying web content in a WebView.
|
|
8
8
|
|
|
9
9
|
It is based on the [webview_flutter](https://pub.dev/packages/webview_flutter)
|
|
10
10
|
and [webview_flutter_web](https://pub.dev/packages/webview_flutter_web) Flutter packages.
|
|
11
11
|
|
|
12
|
+
> **Important:** WebView requires platform-specific configuration (e.g., enabling webview on iOS). Consult Flutter's platform setup guides.
|
|
13
|
+
|
|
12
14
|
## Documentation
|
|
13
15
|
|
|
14
|
-
Detailed documentation to this package can be found [here](https://flet
|
|
16
|
+
Detailed documentation to this package can be found [here](https://docs.flet.dev/webview/).
|
|
15
17
|
|
|
16
18
|
## Platform Support
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
| Platform | Windows | macOS | Linux | iOS | Android | Web |
|
|
21
|
+
|----------|---------|-------|-------|-----|---------|-----|
|
|
22
|
+
| Supported| ❌ | ✅ | ❌ | ✅ | ✅ | ✅ |
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|----------|:---------:|
|
|
22
|
-
| Windows | ❌ |
|
|
23
|
-
| macOS | ✅ |
|
|
24
|
-
| Linux | ❌ |
|
|
25
|
-
| iOS | ✅ |
|
|
26
|
-
| Android | ✅ |
|
|
27
|
-
| Web | ✅ |
|
|
24
|
+
## Usage
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
### Installation
|
|
30
27
|
|
|
31
28
|
To install the `flet-webview` package and add it to your project dependencies:
|
|
32
29
|
|
|
@@ -41,11 +38,6 @@ To install the `flet-webview` package and add it to your project dependencies:
|
|
|
41
38
|
```
|
|
42
39
|
After this, you will have to manually add this package to your `requirements.txt` or `pyproject.toml`.
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
poetry add flet-webview
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Examples
|
|
41
|
+
### Examples
|
|
50
42
|
|
|
51
|
-
For examples, see [
|
|
43
|
+
For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/controls/webview).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "flet-webview"
|
|
3
|
+
version = "0.70.0.dev6555"
|
|
4
|
+
description = "Embed web content inside Flet apps via WebView."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [{ name = "Flet contributors", email = "hello@flet.dev" }]
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"flet==0.70.0.dev6555",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[project.urls]
|
|
14
|
+
Homepage = "https://flet.dev"
|
|
15
|
+
Documentation = "https://docs.flet.dev/webview"
|
|
16
|
+
Repository = "https://github.com/flet-dev/flet/tree/main/sdk/python/packages/flet-webview"
|
|
17
|
+
Issues = "https://github.com/flet-dev/flet/issues"
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.package-data]
|
|
20
|
+
"flutter.flet_webview" = ["**/*"]
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["setuptools"]
|
|
24
|
+
build-backend = "setuptools.build_meta"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from flet_webview.types import (
|
|
2
|
+
JavaScriptMode,
|
|
3
|
+
LogLevelSeverity,
|
|
4
|
+
RequestMethod,
|
|
5
|
+
WebViewConsoleMessageEvent,
|
|
6
|
+
WebViewJavaScriptEvent,
|
|
7
|
+
WebViewScrollEvent,
|
|
8
|
+
)
|
|
9
|
+
from flet_webview.webview import WebView
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"JavaScriptMode",
|
|
13
|
+
"LogLevelSeverity",
|
|
14
|
+
"RequestMethod",
|
|
15
|
+
"WebView",
|
|
16
|
+
"WebViewConsoleMessageEvent",
|
|
17
|
+
"WebViewJavaScriptEvent",
|
|
18
|
+
"WebViewScrollEvent",
|
|
19
|
+
]
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from enum import Enum
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
3
4
|
|
|
4
5
|
import flet as ft
|
|
5
6
|
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from flet_webview.webview import WebView # noqa
|
|
9
|
+
|
|
6
10
|
__all__ = [
|
|
7
|
-
"
|
|
11
|
+
"JavaScriptMode",
|
|
8
12
|
"LogLevelSeverity",
|
|
9
|
-
"
|
|
13
|
+
"RequestMethod",
|
|
10
14
|
"WebViewConsoleMessageEvent",
|
|
11
15
|
"WebViewJavaScriptEvent",
|
|
16
|
+
"WebViewScrollEvent",
|
|
12
17
|
]
|
|
13
18
|
|
|
14
19
|
|
|
@@ -44,17 +49,33 @@ class LogLevelSeverity(Enum):
|
|
|
44
49
|
"""Indicates a log message was logged using the `console.log` method."""
|
|
45
50
|
|
|
46
51
|
|
|
52
|
+
class JavaScriptMode(Enum):
|
|
53
|
+
"""Defines the state of JavaScript support in the `WebView`."""
|
|
54
|
+
|
|
55
|
+
UNRESTRICTED = "unrestricted"
|
|
56
|
+
"""JavaScript execution is unrestricted."""
|
|
57
|
+
|
|
58
|
+
DISABLED = "disabled"
|
|
59
|
+
"""JavaScript execution is disabled."""
|
|
60
|
+
|
|
61
|
+
|
|
47
62
|
@dataclass
|
|
48
|
-
class WebViewScrollEvent(ft.Event[
|
|
63
|
+
class WebViewScrollEvent(ft.Event["WebView"]):
|
|
49
64
|
x: float
|
|
50
|
-
"""
|
|
65
|
+
"""
|
|
66
|
+
The value of the horizontal offset with the origin being at the
|
|
67
|
+
leftmost of the `WebView`.
|
|
68
|
+
"""
|
|
51
69
|
|
|
52
70
|
y: float
|
|
53
|
-
"""
|
|
71
|
+
"""
|
|
72
|
+
The value of the vertical offset with the origin being at the
|
|
73
|
+
topmost of the `WebView`.
|
|
74
|
+
"""
|
|
54
75
|
|
|
55
76
|
|
|
56
77
|
@dataclass
|
|
57
|
-
class WebViewConsoleMessageEvent(ft.Event[
|
|
78
|
+
class WebViewConsoleMessageEvent(ft.Event["WebView"]):
|
|
58
79
|
message: str
|
|
59
80
|
"""The message written to the console."""
|
|
60
81
|
|
|
@@ -63,7 +84,7 @@ class WebViewConsoleMessageEvent(ft.Event[ft.EventControlType]):
|
|
|
63
84
|
|
|
64
85
|
|
|
65
86
|
@dataclass
|
|
66
|
-
class WebViewJavaScriptEvent(ft.Event[
|
|
87
|
+
class WebViewJavaScriptEvent(ft.Event["WebView"]):
|
|
67
88
|
message: str
|
|
68
89
|
"""The message to be displayed in the window."""
|
|
69
90
|
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import flet as ft
|
|
4
|
+
from flet_webview.types import (
|
|
5
|
+
JavaScriptMode,
|
|
6
|
+
RequestMethod,
|
|
7
|
+
WebViewConsoleMessageEvent,
|
|
8
|
+
WebViewJavaScriptEvent,
|
|
9
|
+
WebViewScrollEvent,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = ["WebView"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@ft.control("WebView")
|
|
16
|
+
class WebView(ft.LayoutControl):
|
|
17
|
+
"""
|
|
18
|
+
Easily load webpages while allowing user interaction.
|
|
19
|
+
|
|
20
|
+
Note:
|
|
21
|
+
Works only on the following platforms: iOS, Android, macOS and Web.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
url: str
|
|
25
|
+
"""The URL of the web page to load."""
|
|
26
|
+
|
|
27
|
+
prevent_links: Optional[list[str]] = None
|
|
28
|
+
"""List of url-prefixes that should not be followed/loaded/downloaded."""
|
|
29
|
+
|
|
30
|
+
bgcolor: Optional[ft.ColorValue] = None
|
|
31
|
+
"""Defines the background color of the WebView."""
|
|
32
|
+
|
|
33
|
+
on_page_started: Optional[ft.ControlEventHandler["WebView"]] = None
|
|
34
|
+
"""
|
|
35
|
+
Fires soon as the first loading process of the webview page is started.
|
|
36
|
+
|
|
37
|
+
Event handler argument's [`data`][flet.Event.data] property is of type
|
|
38
|
+
`str` and contains the URL.
|
|
39
|
+
|
|
40
|
+
Note:
|
|
41
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
on_page_ended: Optional[ft.ControlEventHandler["WebView"]] = None
|
|
45
|
+
"""
|
|
46
|
+
Fires when all the webview page loading processes are ended.
|
|
47
|
+
|
|
48
|
+
Event handler argument's [`data`][flet.Event.data] property is of type `str`
|
|
49
|
+
and contains the URL.
|
|
50
|
+
|
|
51
|
+
Note:
|
|
52
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
on_web_resource_error: Optional[ft.ControlEventHandler["WebView"]] = None
|
|
56
|
+
"""
|
|
57
|
+
Fires when there is error with loading a webview page resource.
|
|
58
|
+
|
|
59
|
+
Event handler argument's [`data`][flet.Event.data] property is of type
|
|
60
|
+
`str` and contains the error message.
|
|
61
|
+
|
|
62
|
+
Note:
|
|
63
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
on_progress: Optional[ft.ControlEventHandler["WebView"]] = None
|
|
67
|
+
"""
|
|
68
|
+
Fires when the progress of the webview page loading is changed.
|
|
69
|
+
|
|
70
|
+
Event handler argument's [`data`][flet.Event.data] property is of type
|
|
71
|
+
`int` and contains the progress value.
|
|
72
|
+
|
|
73
|
+
Note:
|
|
74
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
on_url_change: Optional[ft.ControlEventHandler["WebView"]] = None
|
|
78
|
+
"""
|
|
79
|
+
Fires when the URL of the webview page is changed.
|
|
80
|
+
|
|
81
|
+
Event handler argument's [`data`][flet.Event.data] property is of type
|
|
82
|
+
`str` and contains the new URL.
|
|
83
|
+
|
|
84
|
+
Note:
|
|
85
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
on_scroll: Optional[ft.EventHandler[WebViewScrollEvent]] = None
|
|
89
|
+
"""
|
|
90
|
+
Fires when the web page's scroll position changes.
|
|
91
|
+
|
|
92
|
+
Note:
|
|
93
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
on_console_message: Optional[ft.EventHandler[WebViewConsoleMessageEvent]] = None
|
|
97
|
+
"""
|
|
98
|
+
Fires when a log message is written to the JavaScript console.
|
|
99
|
+
|
|
100
|
+
Note:
|
|
101
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
on_javascript_alert_dialog: Optional[ft.EventHandler[WebViewJavaScriptEvent]] = None
|
|
105
|
+
"""
|
|
106
|
+
Fires when the web page attempts to display a JavaScript alert() dialog.
|
|
107
|
+
|
|
108
|
+
Note:
|
|
109
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
def _check_mobile_or_mac_platform(self):
|
|
113
|
+
"""
|
|
114
|
+
Checks/Validates support for the current platform (iOS, Android, or macOS).
|
|
115
|
+
"""
|
|
116
|
+
if self.page is None:
|
|
117
|
+
raise RuntimeError("WebView must be added to page first.")
|
|
118
|
+
if self.page.web or self.page.platform not in [
|
|
119
|
+
ft.PagePlatform.ANDROID,
|
|
120
|
+
ft.PagePlatform.IOS,
|
|
121
|
+
ft.PagePlatform.MACOS,
|
|
122
|
+
]:
|
|
123
|
+
raise ft.FletUnsupportedPlatformException(
|
|
124
|
+
"This method is supported on Android, iOS and macOS platforms only."
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
async def reload(self):
|
|
128
|
+
"""
|
|
129
|
+
Reloads the current URL.
|
|
130
|
+
|
|
131
|
+
Note:
|
|
132
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
133
|
+
"""
|
|
134
|
+
self._check_mobile_or_mac_platform()
|
|
135
|
+
await self._invoke_method("reload")
|
|
136
|
+
|
|
137
|
+
async def can_go_back(self) -> bool:
|
|
138
|
+
"""
|
|
139
|
+
Whether there's a back history item.
|
|
140
|
+
|
|
141
|
+
Note:
|
|
142
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
`True` if there is a back history item, `False` otherwise.
|
|
146
|
+
"""
|
|
147
|
+
self._check_mobile_or_mac_platform()
|
|
148
|
+
return await self._invoke_method("can_go_back")
|
|
149
|
+
|
|
150
|
+
async def can_go_forward(self) -> bool:
|
|
151
|
+
"""
|
|
152
|
+
Whether there's a forward history item.
|
|
153
|
+
|
|
154
|
+
Note:
|
|
155
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
`True` if there is a forward history item, `False` otherwise.
|
|
159
|
+
"""
|
|
160
|
+
self._check_mobile_or_mac_platform()
|
|
161
|
+
return await self._invoke_method("can_go_forward")
|
|
162
|
+
|
|
163
|
+
async def go_back(self):
|
|
164
|
+
"""
|
|
165
|
+
Goes back in the history of the webview, if `can_go_back()` is `True`.
|
|
166
|
+
|
|
167
|
+
Note:
|
|
168
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
169
|
+
"""
|
|
170
|
+
self._check_mobile_or_mac_platform()
|
|
171
|
+
await self._invoke_method("go_back")
|
|
172
|
+
|
|
173
|
+
async def go_forward(self):
|
|
174
|
+
"""
|
|
175
|
+
Goes forward in the history of the webview,
|
|
176
|
+
if [`can_go_forward()`][(c).can_go_forward] is `True`.
|
|
177
|
+
|
|
178
|
+
Note:
|
|
179
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
180
|
+
"""
|
|
181
|
+
self._check_mobile_or_mac_platform()
|
|
182
|
+
await self._invoke_method("go_forward")
|
|
183
|
+
|
|
184
|
+
async def enable_zoom(self):
|
|
185
|
+
"""
|
|
186
|
+
Enables zooming using the on-screen zoom controls and gestures.
|
|
187
|
+
|
|
188
|
+
Note:
|
|
189
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
190
|
+
"""
|
|
191
|
+
self._check_mobile_or_mac_platform()
|
|
192
|
+
await self._invoke_method("enable_zoom")
|
|
193
|
+
|
|
194
|
+
async def disable_zoom(self):
|
|
195
|
+
"""
|
|
196
|
+
Disables zooming using the on-screen zoom controls and gestures.
|
|
197
|
+
|
|
198
|
+
Note:
|
|
199
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
200
|
+
"""
|
|
201
|
+
self._check_mobile_or_mac_platform()
|
|
202
|
+
await self._invoke_method("disable_zoom")
|
|
203
|
+
|
|
204
|
+
async def clear_cache(self):
|
|
205
|
+
"""
|
|
206
|
+
Clears all caches used by the WebView.
|
|
207
|
+
|
|
208
|
+
The following caches are cleared:
|
|
209
|
+
- Browser HTTP Cache
|
|
210
|
+
- Cache API caches. Service workers tend to use this cache.
|
|
211
|
+
- Application cache
|
|
212
|
+
|
|
213
|
+
Note:
|
|
214
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
215
|
+
"""
|
|
216
|
+
self._check_mobile_or_mac_platform()
|
|
217
|
+
await self._invoke_method("clear_cache")
|
|
218
|
+
|
|
219
|
+
async def clear_local_storage(self):
|
|
220
|
+
"""
|
|
221
|
+
Clears the local storage used by the WebView.
|
|
222
|
+
|
|
223
|
+
Note:
|
|
224
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
225
|
+
"""
|
|
226
|
+
self._check_mobile_or_mac_platform()
|
|
227
|
+
await self._invoke_method("clear_local_storage")
|
|
228
|
+
|
|
229
|
+
async def get_current_url(self) -> Optional[str]:
|
|
230
|
+
"""
|
|
231
|
+
Gets the current URL that the WebView is displaying or `None`
|
|
232
|
+
if no URL was ever loaded.
|
|
233
|
+
|
|
234
|
+
Note:
|
|
235
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
The current URL that the WebView is displaying or `None`
|
|
239
|
+
if no URL was ever loaded.
|
|
240
|
+
"""
|
|
241
|
+
self._check_mobile_or_mac_platform()
|
|
242
|
+
return await self._invoke_method("get_current_url")
|
|
243
|
+
|
|
244
|
+
async def get_title(self) -> Optional[str]:
|
|
245
|
+
"""
|
|
246
|
+
Get the title of the currently loaded page.
|
|
247
|
+
|
|
248
|
+
Note:
|
|
249
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
250
|
+
|
|
251
|
+
Returns:
|
|
252
|
+
The title of the currently loaded page.
|
|
253
|
+
"""
|
|
254
|
+
self._check_mobile_or_mac_platform()
|
|
255
|
+
return await self._invoke_method("get_title")
|
|
256
|
+
|
|
257
|
+
async def get_user_agent(self) -> Optional[str]:
|
|
258
|
+
"""
|
|
259
|
+
Get the value used for the HTTP `User-Agent:` request header.
|
|
260
|
+
|
|
261
|
+
Note:
|
|
262
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
The value used for the HTTP `User-Agent:` request header.
|
|
266
|
+
"""
|
|
267
|
+
self._check_mobile_or_mac_platform()
|
|
268
|
+
return await self._invoke_method("get_user_agent")
|
|
269
|
+
|
|
270
|
+
async def load_file(self, path: str):
|
|
271
|
+
"""
|
|
272
|
+
Loads the provided local file.
|
|
273
|
+
|
|
274
|
+
Note:
|
|
275
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
path: The absolute path to the file.
|
|
279
|
+
"""
|
|
280
|
+
self._check_mobile_or_mac_platform()
|
|
281
|
+
await self._invoke_method(
|
|
282
|
+
method_name="load_file",
|
|
283
|
+
arguments={"path": path},
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
async def load_request(self, url: str, method: RequestMethod = RequestMethod.GET):
|
|
287
|
+
"""
|
|
288
|
+
Makes an HTTP request and loads the response in the webview.
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
url: The URL to load.
|
|
292
|
+
method: The HTTP method to use.
|
|
293
|
+
|
|
294
|
+
Note:
|
|
295
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
296
|
+
"""
|
|
297
|
+
self._check_mobile_or_mac_platform()
|
|
298
|
+
await self._invoke_method(
|
|
299
|
+
"load_request", arguments={"url": url, "method": method}
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
async def run_javascript(self, value: str):
|
|
303
|
+
"""
|
|
304
|
+
Runs the given JavaScript in the context of the current page.
|
|
305
|
+
|
|
306
|
+
Args:
|
|
307
|
+
value: The JavaScript code to run.
|
|
308
|
+
|
|
309
|
+
Note:
|
|
310
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
311
|
+
"""
|
|
312
|
+
self._check_mobile_or_mac_platform()
|
|
313
|
+
await self._invoke_method(
|
|
314
|
+
method_name="run_javascript",
|
|
315
|
+
arguments={"value": value},
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
async def load_html(self, value: str, base_url: Optional[str] = None):
|
|
319
|
+
"""
|
|
320
|
+
Loads the provided HTML string.
|
|
321
|
+
|
|
322
|
+
Note:
|
|
323
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
value: The HTML string to load.
|
|
327
|
+
base_url: The base URL to use when resolving relative URLs within the value.
|
|
328
|
+
"""
|
|
329
|
+
self._check_mobile_or_mac_platform()
|
|
330
|
+
await self._invoke_method(
|
|
331
|
+
"load_html", arguments={"value": value, "base_url": base_url}
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
async def scroll_to(self, x: int, y: int):
|
|
335
|
+
"""
|
|
336
|
+
Scrolls to the provided position of webview pixels.
|
|
337
|
+
|
|
338
|
+
Note:
|
|
339
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
340
|
+
|
|
341
|
+
Args:
|
|
342
|
+
x: The x-coordinate of the scroll position.
|
|
343
|
+
y: The y-coordinate of the scroll position.
|
|
344
|
+
"""
|
|
345
|
+
self._check_mobile_or_mac_platform()
|
|
346
|
+
await self._invoke_method(
|
|
347
|
+
method_name="scroll_to",
|
|
348
|
+
arguments={"x": x, "y": y},
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
async def scroll_by(self, x: int, y: int):
|
|
352
|
+
"""
|
|
353
|
+
Scrolls by the provided number of webview pixels.
|
|
354
|
+
|
|
355
|
+
Note:
|
|
356
|
+
Works only on the following platforms: iOS, Android and macOS.
|
|
357
|
+
|
|
358
|
+
Args:
|
|
359
|
+
x: The number of pixels to scroll by on the x-axis.
|
|
360
|
+
y: The number of pixels to scroll by on the y-axis.
|
|
361
|
+
"""
|
|
362
|
+
self._check_mobile_or_mac_platform()
|
|
363
|
+
await self._invoke_method(
|
|
364
|
+
method_name="scroll_by",
|
|
365
|
+
arguments={"x": x, "y": y},
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
async def set_javascript_mode(self, mode: JavaScriptMode):
|
|
369
|
+
"""
|
|
370
|
+
Sets the JavaScript mode of the WebView.
|
|
371
|
+
|
|
372
|
+
Note:
|
|
373
|
+
- Works only on the following platforms: iOS, Android and macOS.
|
|
374
|
+
- Disabling the JavaScript execution on the page may result to
|
|
375
|
+
unexpected web page behaviour.
|
|
376
|
+
|
|
377
|
+
Args:
|
|
378
|
+
mode: The JavaScript mode to set.
|
|
379
|
+
"""
|
|
380
|
+
self._check_mobile_or_mac_platform()
|
|
381
|
+
await self._invoke_method(
|
|
382
|
+
method_name="set_javascript_mode",
|
|
383
|
+
arguments={"mode": mode},
|
|
384
|
+
)
|