@ufjs/webview 0.1.3
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 +25 -0
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/components/WebViewWeb.vue +134 -0
- package/flutter/.dart_tool/flutter_build/dart_plugin_registrant.dart +132 -0
- package/flutter/.dart_tool/package_config.json +371 -0
- package/flutter/.dart_tool/package_config_subset +241 -0
- package/flutter/.dart_tool/version +1 -0
- package/flutter/.flutter-plugins +13 -0
- package/flutter/.flutter-plugins-dependencies +1 -0
- package/flutter/build/native_assets/macos/native_assets.yaml +5 -0
- package/flutter/build/test_cache/build/cache.dill.track.dill +4 -0
- package/flutter/build/unit_test_assets/AssetManifest.bin +0 -0
- package/flutter/build/unit_test_assets/AssetManifest.json +1 -0
- package/flutter/build/unit_test_assets/FontManifest.json +1 -0
- package/flutter/build/unit_test_assets/NOTICES.Z +0 -0
- package/flutter/build/unit_test_assets/shaders/ink_sparkle.frag +0 -0
- package/flutter/lib/fjs_webview.dart +472 -0
- package/flutter/pubspec.lock +468 -0
- package/flutter/pubspec.yaml +30 -0
- package/flutter/test/web_view_test.dart +369 -0
- package/index.ts +210 -0
- package/package.json +69 -0
- package/prepare.mjs +40 -0
- package/public/demo.html +79 -0
package/public/demo.html
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>web-view demo</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 16px;
|
|
11
|
+
/* NOT -apple-system / system-ui first. On the iOS Simulator the
|
|
12
|
+
web-content process resolves those to a face with no CJK
|
|
13
|
+
fallback, and WebKit then renders every Chinese character as a
|
|
14
|
+
tofu box — with `sans-serif` still at the end of the stack, and
|
|
15
|
+
with "PingFang SC" named explicitly. Verified three ways: the
|
|
16
|
+
bytes are valid UTF-8 with charset=utf-8 on the response, the
|
|
17
|
+
same file served by vite tofus identically, and m.baidu.com in
|
|
18
|
+
the same WebView renders Chinese fine. Swapping this one line to
|
|
19
|
+
a stack that does not start with -apple-system fixes it. */
|
|
20
|
+
font: 14px/1.5 "PingFang SC", "Helvetica Neue", sans-serif;
|
|
21
|
+
color: #333;
|
|
22
|
+
background: #fff;
|
|
23
|
+
}
|
|
24
|
+
h1 { font-size: 16px; margin: 0 0 8px; }
|
|
25
|
+
p { margin: 0 0 12px; color: #666; }
|
|
26
|
+
code { background: #f4f5f7; padding: 1px 4px; border-radius: 4px; }
|
|
27
|
+
button {
|
|
28
|
+
font: inherit;
|
|
29
|
+
padding: 8px 16px;
|
|
30
|
+
border: 0;
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
background: #007aff;
|
|
33
|
+
color: #fff;
|
|
34
|
+
}
|
|
35
|
+
.env { margin-top: 12px; font-size: 12px; color: #999; }
|
|
36
|
+
</style>
|
|
37
|
+
</head>
|
|
38
|
+
<body>
|
|
39
|
+
<h1>模块自带的页面</h1>
|
|
40
|
+
<p>
|
|
41
|
+
页面写的是 <code>asset://demo.html</code>;这一份文件在 dev 由 fjs dev server
|
|
42
|
+
提供,release 打进 Flutter assets,web 由应用的静态目录提供。
|
|
43
|
+
</p>
|
|
44
|
+
<p>URL 参数:<b id="q">(无)</b></p>
|
|
45
|
+
<p>URL 片段:<b id="hash">(无)</b></p>
|
|
46
|
+
<button id="send">给宿主发一条消息</button>
|
|
47
|
+
<p class="env" id="env"></p>
|
|
48
|
+
|
|
49
|
+
<script>
|
|
50
|
+
// The shim the docs ask a page to carry. On the app fjs.postMessage is
|
|
51
|
+
// already there (a JavaScriptChannel); in a browser a cross-origin
|
|
52
|
+
// iframe cannot be injected, so the page provides the same function
|
|
53
|
+
// over window.postMessage and fjs filters by source + shape.
|
|
54
|
+
var hadNative = !!window.fjs;
|
|
55
|
+
window.fjs = window.fjs || {
|
|
56
|
+
postMessage: (data) => parent.postMessage({ __fjs: String(data) }, '*'),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var injected = hadNative;
|
|
60
|
+
document.getElementById('env').textContent = injected
|
|
61
|
+
? '宿主注入了 fjs.postMessage(App)'
|
|
62
|
+
: '用的是页面自带的 shim(浏览器)';
|
|
63
|
+
|
|
64
|
+
var query = new URLSearchParams(location.search).get('q');
|
|
65
|
+
if (query) document.getElementById('q').textContent = query;
|
|
66
|
+
if (location.hash) document.getElementById('hash').textContent = location.hash;
|
|
67
|
+
|
|
68
|
+
var n = 0;
|
|
69
|
+
document.getElementById('send').addEventListener('click', function () {
|
|
70
|
+
n += 1;
|
|
71
|
+
window.fjs.postMessage('hello #' + n + (query ? ' (' + query + ')' : ''));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Reliable "it loaded", for the browser, where an iframe's error event
|
|
75
|
+
// almost never fires and its load event fires for error pages too.
|
|
76
|
+
window.fjs.postMessage('ready');
|
|
77
|
+
</script>
|
|
78
|
+
</body>
|
|
79
|
+
</html>
|