flet-web 0.29.0.dev5035__py3-none-any.whl → 0.70.0.dev5066__py3-none-any.whl
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_web/__init__.py +8 -1
- flet_web/fastapi/__init__.py +2 -0
- flet_web/fastapi/app.py +44 -17
- flet_web/fastapi/flet_app.py +195 -288
- flet_web/fastapi/flet_app_manager.py +41 -64
- flet_web/fastapi/flet_oauth.py +2 -1
- flet_web/fastapi/flet_static_files.py +54 -50
- flet_web/fastapi/serve_fastapi_web_app.py +30 -27
- flet_web/patch_index.py +35 -35
- flet_web/version.py +1 -1
- flet_web/web/assets/NOTICES +1815 -3803
- flet_web/web/assets/fonts/roboto.woff2 +0 -0
- flet_web/web/assets/packages/media_kit/assets/web/hls1.4.10.js +2 -2
- flet_web/web/canvaskit/canvaskit.js +192 -0
- flet_web/web/canvaskit/canvaskit.js.symbols +12098 -0
- flet_web/web/canvaskit/canvaskit.wasm +0 -0
- flet_web/web/canvaskit/chromium/canvaskit.js +192 -0
- flet_web/web/canvaskit/chromium/canvaskit.js.symbols +11050 -0
- flet_web/web/canvaskit/chromium/canvaskit.wasm +0 -0
- flet_web/web/canvaskit/skwasm.js +137 -0
- flet_web/web/canvaskit/skwasm.js.symbols +12073 -0
- flet_web/web/canvaskit/skwasm.wasm +0 -0
- flet_web/web/flutter.js +30 -2
- flet_web/web/flutter.js.map +3 -3
- flet_web/web/flutter_bootstrap.js +50 -10
- flet_web/web/flutter_service_worker.js +23 -21
- flet_web/web/index.html +56 -11
- flet_web/web/main.dart.js +170402 -167642
- flet_web/web/main.dart.mjs +44188 -0
- flet_web/web/main.dart.wasm +0 -0
- flet_web/web/pyodide/ffi.d.ts +10 -1
- flet_web/web/pyodide/micropip-0.8.0-py3-none-any.whl +14 -0
- flet_web/web/pyodide/package.json +2 -2
- flet_web/web/pyodide/packaging-24.2-py3-none-any.whl +0 -0
- flet_web/web/pyodide/pyodide-lock.json +1 -1
- flet_web/web/pyodide/pyodide.asm.js +1 -1
- flet_web/web/pyodide/pyodide.asm.wasm +0 -0
- flet_web/web/pyodide/pyodide.d.ts +15 -3
- flet_web/web/pyodide/pyodide.js +1 -1
- flet_web/web/pyodide/pyodide.mjs +2 -2
- flet_web/web/pyodide/python_stdlib.zip +0 -0
- flet_web/web/python-worker.js +75 -24
- flet_web/web/python.js +62 -20
- {flet_web-0.29.0.dev5035.dist-info → flet_web-0.70.0.dev5066.dist-info}/METADATA +3 -3
- flet_web-0.70.0.dev5066.dist-info/RECORD +71 -0
- flet_web-0.29.0.dev5035.dist-info/RECORD +0 -57
- {flet_web-0.29.0.dev5035.dist-info → flet_web-0.70.0.dev5066.dist-info}/WHEEL +0 -0
- {flet_web-0.29.0.dev5035.dist-info → flet_web-0.70.0.dev5066.dist-info}/top_level.txt +0 -0
flet_web/__init__.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
|
|
4
|
-
from flet_web.patch_index import
|
|
4
|
+
from flet_web.patch_index import (
|
|
5
|
+
patch_font_manifest_json,
|
|
6
|
+
patch_index_html,
|
|
7
|
+
patch_manifest_json,
|
|
8
|
+
)
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
def get_package_web_dir():
|
|
8
12
|
web_root_dir = os.environ.get("FLET_WEB_PATH")
|
|
9
13
|
return web_root_dir or str(Path(__file__).parent.joinpath("web"))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ["patch_font_manifest_json", "patch_index_html", "patch_manifest_json"]
|
flet_web/fastapi/__init__.py
CHANGED
|
@@ -4,3 +4,5 @@ from flet_web.fastapi.flet_app_manager import app_manager
|
|
|
4
4
|
from flet_web.fastapi.flet_fastapi import FastAPI
|
|
5
5
|
from flet_web.fastapi.flet_static_files import FletStaticFiles
|
|
6
6
|
from flet_web.fastapi.flet_upload import FletUpload
|
|
7
|
+
|
|
8
|
+
__all__ = ["app", "FletApp", "app_manager", "FastAPI", "FletStaticFiles", "FletUpload"]
|
flet_web/fastapi/app.py
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import os
|
|
3
|
-
from
|
|
3
|
+
from collections.abc import Awaitable
|
|
4
|
+
from typing import Callable, Optional, Union
|
|
4
5
|
|
|
5
6
|
from fastapi import Request, WebSocket
|
|
6
|
-
from flet.
|
|
7
|
-
from flet.
|
|
7
|
+
from flet.controls.page import Page
|
|
8
|
+
from flet.controls.types import RouteUrlStrategy, WebRenderer
|
|
9
|
+
from starlette.middleware.base import BaseHTTPMiddleware
|
|
8
10
|
|
|
9
11
|
from flet_web.fastapi.flet_app import (
|
|
10
12
|
DEFAULT_FLET_OAUTH_STATE_TIMEOUT,
|
|
11
13
|
DEFAULT_FLET_SESSION_TIMEOUT,
|
|
12
14
|
FletApp,
|
|
15
|
+
app_manager,
|
|
13
16
|
)
|
|
14
17
|
from flet_web.fastapi.flet_fastapi import FastAPI
|
|
15
18
|
from flet_web.fastapi.flet_oauth import FletOAuth
|
|
@@ -18,15 +21,16 @@ from flet_web.fastapi.flet_upload import FletUpload
|
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
def app(
|
|
21
|
-
|
|
24
|
+
main: Union[Callable[[Page], Awaitable], Callable[[Page], None]],
|
|
25
|
+
before_main: Union[Callable[[Page], Awaitable], Callable[[Page], None]],
|
|
22
26
|
proxy_path: Optional[str] = None,
|
|
23
27
|
assets_dir: Optional[str] = None,
|
|
24
28
|
app_name: Optional[str] = None,
|
|
25
29
|
app_short_name: Optional[str] = None,
|
|
26
30
|
app_description: Optional[str] = None,
|
|
27
|
-
web_renderer: WebRenderer = WebRenderer.
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
web_renderer: WebRenderer = WebRenderer.AUTO,
|
|
32
|
+
route_url_strategy: RouteUrlStrategy = RouteUrlStrategy.PATH,
|
|
33
|
+
no_cdn: bool = False,
|
|
30
34
|
upload_dir: Optional[str] = None,
|
|
31
35
|
upload_endpoint_path: Optional[str] = None,
|
|
32
36
|
max_upload_size: Optional[int] = None,
|
|
@@ -38,20 +42,29 @@ def app(
|
|
|
38
42
|
Mount all Flet FastAPI handlers in one call.
|
|
39
43
|
|
|
40
44
|
Parameters:
|
|
41
|
-
* `
|
|
45
|
+
* `main` (function or coroutine) - application entry point - a method
|
|
46
|
+
called for newly connected user. Handler must have 1 parameter: `page` - `Page`
|
|
47
|
+
instance.
|
|
48
|
+
* `before_main` - a function that is called after Page was created, but before
|
|
49
|
+
calling `main`.
|
|
42
50
|
* `assets_dir` (str, optional) - an absolute path to app's assets directory.
|
|
43
51
|
* `app_name` (str, optional) - PWA application name.
|
|
44
52
|
* `app_short_name` (str, optional) - PWA application short name.
|
|
45
53
|
* `app_description` (str, optional) - PWA application description.
|
|
46
|
-
* `web_renderer` (WebRenderer) - web renderer defaulting to `WebRenderer.
|
|
47
|
-
* `use_color_emoji` (bool) - whether to load a font with color emoji. Default is `False`.
|
|
54
|
+
* `web_renderer` (WebRenderer) - web renderer defaulting to `WebRenderer.AUTO`.
|
|
48
55
|
* `route_url_strategy` (str) - routing URL strategy: `path` (default) or `hash`.
|
|
56
|
+
* `no_cdn` (bool) - do not load resources from CDN.
|
|
49
57
|
* `upload_dir` (str) - an absolute path to a directory with uploaded files.
|
|
50
|
-
* `upload_endpoint_path` (str, optional) - absolute URL of upload endpoint,
|
|
51
|
-
|
|
58
|
+
* `upload_endpoint_path` (str, optional) - absolute URL of upload endpoint,
|
|
59
|
+
e.g. `/upload`.
|
|
60
|
+
* `max_upload_size` (str, int) - maximum size of a single upload, bytes.
|
|
61
|
+
Unlimited if `None`.
|
|
52
62
|
* `secret_key` (str, optional) - secret key to sign and verify upload requests.
|
|
53
|
-
* `session_timeout_seconds` (int, optional)- session lifetime, in seconds, after
|
|
54
|
-
|
|
63
|
+
* `session_timeout_seconds` (int, optional)- session lifetime, in seconds, after
|
|
64
|
+
user disconnected.
|
|
65
|
+
* `oauth_state_timeout_seconds` (int, optional) - OAuth state lifetime, in seconds,
|
|
66
|
+
which is a maximum allowed time between starting OAuth flow and redirecting
|
|
67
|
+
to OAuth callback URL.
|
|
55
68
|
"""
|
|
56
69
|
|
|
57
70
|
env_upload_dir = os.getenv("FLET_UPLOAD_DIR")
|
|
@@ -80,8 +93,10 @@ def app(
|
|
|
80
93
|
@fastapi_app.websocket(f"/{websocket_endpoint}")
|
|
81
94
|
async def app_handler(websocket: WebSocket):
|
|
82
95
|
await FletApp(
|
|
83
|
-
asyncio.get_running_loop(),
|
|
84
|
-
|
|
96
|
+
loop=asyncio.get_running_loop(),
|
|
97
|
+
executor=app_manager.executor,
|
|
98
|
+
main=main,
|
|
99
|
+
before_main=before_main,
|
|
85
100
|
session_timeout_seconds=session_timeout_seconds,
|
|
86
101
|
oauth_state_timeout_seconds=oauth_state_timeout_seconds,
|
|
87
102
|
upload_endpoint_path=upload_endpoint_path,
|
|
@@ -113,9 +128,21 @@ def app(
|
|
|
113
128
|
app_short_name=app_short_name,
|
|
114
129
|
app_description=app_description,
|
|
115
130
|
web_renderer=web_renderer,
|
|
116
|
-
use_color_emoji=use_color_emoji,
|
|
117
131
|
route_url_strategy=route_url_strategy,
|
|
132
|
+
websocket_endpoint_path=websocket_endpoint,
|
|
133
|
+
no_cdn=no_cdn,
|
|
118
134
|
),
|
|
119
135
|
)
|
|
120
136
|
|
|
137
|
+
# Add middleware for custom headers
|
|
138
|
+
class CustomHeadersMiddleware(BaseHTTPMiddleware):
|
|
139
|
+
async def dispatch(self, request: Request, call_next):
|
|
140
|
+
response = await call_next(request)
|
|
141
|
+
response.headers["Cross-Origin-Opener-Policy"] = "same-origin"
|
|
142
|
+
response.headers["Cross-Origin-Embedder-Policy"] = "require-corp"
|
|
143
|
+
response.headers["Access-Control-Allow-Origin"] = "*"
|
|
144
|
+
return response
|
|
145
|
+
|
|
146
|
+
fastapi_app.add_middleware(CustomHeadersMiddleware)
|
|
147
|
+
|
|
121
148
|
return fastapi_app
|