flet-webview 0.86.4__tar.gz → 1.0.0.dev0__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.
- {flet_webview-0.86.4/src/flet_webview.egg-info → flet_webview-1.0.0.dev0}/PKG-INFO +2 -2
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/pyproject.toml +2 -2
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview/webview.py +17 -3
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0/src/flet_webview.egg-info}/PKG-INFO +2 -2
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview.egg-info/SOURCES.txt +2 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview.egg-info/requires.txt +1 -1
- flet_webview-1.0.0.dev0/src/flutter/flet_webview/lib/src/utils/file_access.dart +15 -0
- flet_webview-1.0.0.dev0/src/flutter/flet_webview/lib/src/utils/file_access_vain.dart +7 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview_mobile_and_mac.dart +42 -10
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/pubspec.yaml +1 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/LICENSE +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/README.md +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/setup.cfg +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview/__init__.py +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview/types.py +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview.egg-info/dependency_links.txt +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview.egg-info/top_level.txt +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/flet_webview.dart +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/extension.dart +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/utils/webview.dart +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview.dart +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview_web.dart +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview_web_vain.dart +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview_windows_and_linux.dart +0 -0
- {flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview_windows_and_linux_vain.dart +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flet-webview
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0.dev0
|
|
4
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
|
|
@@ -11,7 +11,7 @@ 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==0.
|
|
14
|
+
Requires-Dist: flet==1.0.0.dev0
|
|
15
15
|
Requires-Dist: typing-extensions; python_version < "3.11"
|
|
16
16
|
Dynamic: license-file
|
|
17
17
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "flet-webview"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "1.0.0.dev0"
|
|
4
4
|
description = "Embed web content inside Flet apps via WebView."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Flet contributors", email = "hello@flet.dev" }]
|
|
7
7
|
license = "Apache-2.0"
|
|
8
8
|
requires-python = ">=3.10"
|
|
9
9
|
dependencies = [
|
|
10
|
-
"flet==0.
|
|
10
|
+
"flet==1.0.0.dev0",
|
|
11
11
|
"typing-extensions; python_version < '3.11'",
|
|
12
12
|
]
|
|
13
13
|
|
|
@@ -30,7 +30,16 @@ class WebView(ft.LayoutControl):
|
|
|
30
30
|
"""
|
|
31
31
|
|
|
32
32
|
url: Optional[str] = None
|
|
33
|
-
"""
|
|
33
|
+
"""
|
|
34
|
+
The URL of the web page to load.
|
|
35
|
+
|
|
36
|
+
Note:
|
|
37
|
+
A `file://` URL pointing to a local file is supported on the following
|
|
38
|
+
platforms only: iOS, Android, and macOS. It loads that file's sibling
|
|
39
|
+
assets (scripts, stylesheets, images) as well, and is equivalent to
|
|
40
|
+
calling :meth:`load_file` with the same file once this control is
|
|
41
|
+
mounted. On web, only URLs the browser can load in an iframe work.
|
|
42
|
+
"""
|
|
34
43
|
|
|
35
44
|
prevent_links: Optional[list[str]] = None
|
|
36
45
|
"""List of url-prefixes that should not be followed/loaded/downloaded."""
|
|
@@ -296,8 +305,9 @@ class WebView(ft.LayoutControl):
|
|
|
296
305
|
Makes an HTTP request and loads the response in the webview.
|
|
297
306
|
|
|
298
307
|
Args:
|
|
299
|
-
url: The URL to load.
|
|
300
|
-
|
|
308
|
+
url: The URL to load. A `file://` URL is loaded as a local file,
|
|
309
|
+
the same way :meth:`load_file` does.
|
|
310
|
+
method: The HTTP method to use. Ignored for `file://` URLs.
|
|
301
311
|
|
|
302
312
|
Note:
|
|
303
313
|
Works only on the following platforms: iOS, Android, and macOS.
|
|
@@ -333,6 +343,8 @@ class WebView(ft.LayoutControl):
|
|
|
333
343
|
Args:
|
|
334
344
|
value: The HTML string to load.
|
|
335
345
|
base_url: The base URL to use when resolving relative URLs within the value.
|
|
346
|
+
May be a `file://` URL, in which case the referenced local files are
|
|
347
|
+
made readable to the webview.
|
|
336
348
|
"""
|
|
337
349
|
self._check_mobile_or_mac_platform()
|
|
338
350
|
await self._invoke_method(
|
|
@@ -383,6 +395,8 @@ class WebView(ft.LayoutControl):
|
|
|
383
395
|
- Works only on the following platforms: iOS, Android, and macOS.
|
|
384
396
|
- Disabling the JavaScript execution on the page may result to
|
|
385
397
|
unexpected web page behaviour.
|
|
398
|
+
- Defaults to :attr:`flet_webview.JavaScriptMode.UNRESTRICTED`,
|
|
399
|
+
which is applied before the first page load.
|
|
386
400
|
|
|
387
401
|
Args:
|
|
388
402
|
mode: The JavaScript mode to set.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flet-webview
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0.dev0
|
|
4
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
|
|
@@ -11,7 +11,7 @@ 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==0.
|
|
14
|
+
Requires-Dist: flet==1.0.0.dev0
|
|
15
15
|
Requires-Dist: typing-extensions; python_version < "3.11"
|
|
16
16
|
Dynamic: license-file
|
|
17
17
|
|
|
@@ -18,4 +18,6 @@ src/flutter/flet_webview/lib/src/webview_web.dart
|
|
|
18
18
|
src/flutter/flet_webview/lib/src/webview_web_vain.dart
|
|
19
19
|
src/flutter/flet_webview/lib/src/webview_windows_and_linux.dart
|
|
20
20
|
src/flutter/flet_webview/lib/src/webview_windows_and_linux_vain.dart
|
|
21
|
+
src/flutter/flet_webview/lib/src/utils/file_access.dart
|
|
22
|
+
src/flutter/flet_webview/lib/src/utils/file_access_vain.dart
|
|
21
23
|
src/flutter/flet_webview/lib/src/utils/webview.dart
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import 'package:webview_flutter/webview_flutter.dart';
|
|
2
|
+
import 'package:webview_flutter_android/webview_flutter_android.dart';
|
|
3
|
+
|
|
4
|
+
/// Grants the underlying webview permission to read `file://` URLs.
|
|
5
|
+
///
|
|
6
|
+
/// Only Android needs this: `WebSettings.allowFileAccess` defaults to `false`
|
|
7
|
+
/// when the app targets API 30 or above, so local pages fail to load with
|
|
8
|
+
/// `net::ERR_ACCESS_DENIED`. A no-op on every other platform, where the
|
|
9
|
+
/// webview already has access to the app's own container.
|
|
10
|
+
Future<void> allowFileAccess(WebViewController controller) async {
|
|
11
|
+
final platformController = controller.platform;
|
|
12
|
+
if (platformController is AndroidWebViewController) {
|
|
13
|
+
await platformController.setAllowFileAccess(true);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'package:webview_flutter/webview_flutter.dart';
|
|
2
|
+
|
|
3
|
+
/// Web stub for [allowFileAccess].
|
|
4
|
+
///
|
|
5
|
+
/// `webview_flutter_android` imports `dart:io` and therefore cannot be
|
|
6
|
+
/// compiled for the web, so it is conditionally swapped out for this no-op.
|
|
7
|
+
Future<void> allowFileAccess(WebViewController controller) async {}
|
|
@@ -3,6 +3,9 @@ import 'package:flet_webview/src/utils/webview.dart';
|
|
|
3
3
|
import 'package:flutter/material.dart';
|
|
4
4
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
5
5
|
|
|
6
|
+
import 'utils/file_access_vain.dart'
|
|
7
|
+
if (dart.library.io) 'utils/file_access.dart';
|
|
8
|
+
|
|
6
9
|
class WebviewMobileAndMac extends StatefulWidget {
|
|
7
10
|
final Control control;
|
|
8
11
|
|
|
@@ -24,6 +27,28 @@ class _WebviewMobileAndMacState extends State<WebviewMobileAndMac> {
|
|
|
24
27
|
return links.any((link) => link is String && url.startsWith(link));
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
/// Loads [url], routing `file:` URLs through [WebViewController.loadFile].
|
|
31
|
+
///
|
|
32
|
+
/// `loadFile` is the only entry point that grants the platform webview
|
|
33
|
+
/// access to the local filesystem: on Android it flips
|
|
34
|
+
/// `WebSettings.allowFileAccess`, which defaults to `false` when targeting
|
|
35
|
+
/// API 30+, and on iOS/macOS it uses `loadFileURL:allowingReadAccessToURL:`
|
|
36
|
+
/// so that sibling assets (scripts, stylesheets, images) resolve too.
|
|
37
|
+
/// A plain `loadRequest` of a `file:` URL fails with
|
|
38
|
+
/// `net::ERR_ACCESS_DENIED` on Android.
|
|
39
|
+
Future<void> _load(String url, LoadRequestMethod method) async {
|
|
40
|
+
var uri = Uri.parse(url);
|
|
41
|
+
if (uri.scheme == "file") {
|
|
42
|
+
try {
|
|
43
|
+
await controller.loadFile(uri.toFilePath());
|
|
44
|
+
return;
|
|
45
|
+
} on UnsupportedError catch (e) {
|
|
46
|
+
debugPrint("WebView: $url is not a valid local file path: $e");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await controller.loadRequest(uri, method: method);
|
|
50
|
+
}
|
|
51
|
+
|
|
27
52
|
void _setOptionalEventHandlers() {
|
|
28
53
|
// macOS currently does not surface scroll callbacks via webview_flutter.
|
|
29
54
|
if (!isMacOSDesktop() &&
|
|
@@ -107,11 +132,14 @@ class _WebviewMobileAndMacState extends State<WebviewMobileAndMac> {
|
|
|
107
132
|
),
|
|
108
133
|
);
|
|
109
134
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
135
|
+
// Android's WebSettings.javaScriptEnabled defaults to false, unlike
|
|
136
|
+
// WKWebView and the web platform, so a page would silently run no script
|
|
137
|
+
// there. Enable it before the first load; `set_javascript_mode` can turn
|
|
138
|
+
// it back off afterwards.
|
|
139
|
+
controller.setJavaScriptMode(JavaScriptMode.unrestricted).then((_) => _load(
|
|
140
|
+
widget.control.getString("url", "https://flet.dev")!,
|
|
141
|
+
parseLoadRequestMethod(
|
|
142
|
+
widget.control.getString("method"), LoadRequestMethod.get)!));
|
|
115
143
|
|
|
116
144
|
_setOptionalEventHandlers();
|
|
117
145
|
}
|
|
@@ -158,15 +186,19 @@ class _WebviewMobileAndMacState extends State<WebviewMobileAndMac> {
|
|
|
158
186
|
await controller.loadFile(args["path"]);
|
|
159
187
|
break;
|
|
160
188
|
case "load_html":
|
|
161
|
-
|
|
162
|
-
|
|
189
|
+
var baseUrl = args["base_url"];
|
|
190
|
+
if (baseUrl != null && Uri.tryParse(baseUrl)?.scheme == "file") {
|
|
191
|
+
// Android's loadDataWithBaseURL does not grant file access on its
|
|
192
|
+
// own, so local sub-resources would be denied.
|
|
193
|
+
await allowFileAccess(controller);
|
|
194
|
+
}
|
|
195
|
+
await controller.loadHtmlString(args["value"], baseUrl: baseUrl);
|
|
163
196
|
break;
|
|
164
197
|
case "load_request":
|
|
165
198
|
var url = args["url"];
|
|
166
199
|
if (url != null) {
|
|
167
|
-
await
|
|
168
|
-
method
|
|
169
|
-
args["method"], LoadRequestMethod.get)!);
|
|
200
|
+
await _load(url,
|
|
201
|
+
parseLoadRequestMethod(args["method"], LoadRequestMethod.get)!);
|
|
170
202
|
}
|
|
171
203
|
break;
|
|
172
204
|
case "run_javascript":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flet_webview.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/flet_webview.dart
RENAMED
|
File without changes
|
{flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/extension.dart
RENAMED
|
File without changes
|
{flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/utils/webview.dart
RENAMED
|
File without changes
|
{flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview.dart
RENAMED
|
File without changes
|
{flet_webview-0.86.4 → flet_webview-1.0.0.dev0}/src/flutter/flet_webview/lib/src/webview_web.dart
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|