pdf-master-landing 0.2.0 → 0.2.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.
Binary file
@@ -1 +1 @@
1
- {"app_name":"pdf_master","version":"0.2.0","build_number":"20","package_name":"pdf_master"}
1
+ {"app_name":"pdf_master","version":"0.2.3","build_number":"23","package_name":"pdf_master"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pdf-master-landing",
3
3
  "description": "PDF Master static landing site.",
4
- "version": "0.2.0",
4
+ "version": "0.2.3",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
7
7
  "files": [
package/dist/_diag.html DELETED
@@ -1,159 +0,0 @@
1
- <!doctype html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="utf-8" />
5
- <title>Flutter Web 加载路径检测</title>
6
- <style>
7
- body {
8
- font: 14px/1.6 -apple-system, system-ui, "PingFang SC", sans-serif;
9
- max-width: 760px;
10
- margin: 40px auto;
11
- padding: 0 20px;
12
- color: #15161a;
13
- }
14
- h1 { font-size: 22px; margin: 0 0 6px; }
15
- h2 { font-size: 16px; margin: 32px 0 10px; }
16
- p.lede { color: #5c6068; margin: 0 0 24px; }
17
- table { width: 100%; border-collapse: collapse; }
18
- td { padding: 10px 12px; border-bottom: 1px solid #eee; vertical-align: top; }
19
- td:first-child { width: 240px; color: #5c6068; }
20
- td b { color: #15161a; font-weight: 600; }
21
- .yes { color: #1a7f3c; font-weight: 600; }
22
- .no { color: #b3261e; font-weight: 600; }
23
- code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: #f4f4f4; padding: 1px 6px; border-radius: 4px; }
24
- .verdict { margin-top: 24px; padding: 16px 18px; border-radius: 10px; }
25
- .verdict.wasm { background: #e8f4ec; border: 1px solid #1a7f3c; }
26
- .verdict.js { background: #fdecea; border: 1px solid #b3261e; }
27
- .verdict h2 { margin: 0 0 6px; }
28
- .net { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; color: #5c6068; }
29
- </style>
30
- </head>
31
- <body>
32
- <h1>Flutter Web 加载路径检测</h1>
33
- <p class="lede">这一页直接读浏览器 capability + 本次实际加载的脚本,告诉你跑的是 wasm 还是 JS fallback。</p>
34
-
35
- <h2>浏览器能力</h2>
36
- <table id="caps"></table>
37
-
38
- <h2>本次实际加载</h2>
39
- <table id="loaded"></table>
40
-
41
- <div id="verdict" class="verdict"></div>
42
-
43
- <h2>原始抓取详情</h2>
44
- <pre class="net" id="raw"></pre>
45
-
46
- <script type="module">
47
- // —— 浏览器 capability ——
48
- const wasmGcBytes = [0,97,115,109,1,0,0,0,1,5,1,95,1,120,0];
49
- const supportsWasmGC = (() => {
50
- try { return WebAssembly.validate(new Uint8Array(wasmGcBytes)); } catch { return false; }
51
- })();
52
- const c = document.createElement('canvas');
53
- const webgl2 = c.getContext('webgl2') != null;
54
- const webgl1 = !webgl2 && c.getContext('webgl') != null;
55
- const webglVersion = webgl2 ? 2 : (webgl1 ? 1 : 0);
56
- const crossOriginIsolated = window.crossOriginIsolated;
57
- const isHttps = location.protocol === 'https:' || location.hostname === 'localhost' || location.hostname === '127.0.0.1';
58
-
59
- const caps = [
60
- ['supportsWasmGC', supportsWasmGC, 'dart2wasm 必需'],
61
- ['webGLVersion', webglVersion, 'skwasm renderer 要 WebGL2,否则降到 canvaskit'],
62
- ['crossOriginIsolated', crossOriginIsolated, 'COOP+COEP 头是否生效;skwasm 多线程必需'],
63
- ['secure context', isHttps, 'HTTPS 或 localhost'],
64
- ];
65
- const capsEl = document.getElementById('caps');
66
- caps.forEach(([k, v, hint]) => {
67
- const ok = !!v && v !== 0;
68
- const row = document.createElement('tr');
69
- row.innerHTML = `<td><b>${k}</b><div style="font-size:12px;color:#888">${hint}</div></td>` +
70
- `<td><span class="${ok ? 'yes' : 'no'}">${typeof v === 'boolean' ? (v ? 'true' : 'false') : v}</span></td>`;
71
- capsEl.appendChild(row);
72
- });
73
-
74
- // —— 抓 build config ——
75
- const cfgRes = await fetch('/app/flutter_bootstrap.js', { cache: 'no-cache' });
76
- const cfgText = await cfgRes.text();
77
- const cfgMatch = cfgText.match(/_flutter\.buildConfig\s*=\s*(\{[^;]+\})/);
78
- const buildConfig = cfgMatch ? JSON.parse(cfgMatch[1]) : null;
79
- const builds = buildConfig?.builds ?? [];
80
-
81
- // —— 模拟 flutter.js 选择逻辑 ——
82
- const browserEngine = (() => {
83
- if (navigator.vendor === 'Google Inc.' || navigator.userAgent.includes('Edg/')) return 'blink';
84
- if (navigator.vendor === 'Apple Computer, Inc.') return 'webkit';
85
- if (navigator.vendor === '' && navigator.userAgent.includes('Firefox')) return 'gecko';
86
- return 'unknown';
87
- })();
88
- // flutter.js 默认 wasmAllowList: blink=true, gecko=false, webkit=false
89
- const wasmAllowed = browserEngine === 'blink';
90
-
91
- const picked = builds.find(b => {
92
- if (b.compileTarget === 'dart2wasm' && !supportsWasmGC) return false;
93
- if (b.renderer === 'skwasm' && (webglVersion === 0 || !wasmAllowed)) return false;
94
- return true;
95
- });
96
-
97
- // —— 探测实际加载(runtime 监听) ——
98
- const seen = new Set();
99
- const obs = new PerformanceObserver((entries) => {
100
- for (const e of entries.getEntries()) {
101
- if (/main\.dart\.(wasm|mjs|js)|canvaskit\.|skwasm/.test(e.name)) {
102
- seen.add(e.name.split(/[?#]/)[0].split('/').slice(-2).join('/'));
103
- }
104
- }
105
- });
106
- obs.observe({ type: 'resource', buffered: true });
107
-
108
- // 把已有的 performance entries 也吃一遍(首次进页面之前已发生的)
109
- performance.getEntriesByType('resource').forEach(e => {
110
- if (/main\.dart\.(wasm|mjs|js)|canvaskit\.|skwasm/.test(e.name)) {
111
- seen.add(e.name.split(/[?#]/)[0].split('/').slice(-2).join('/'));
112
- }
113
- });
114
-
115
- // —— 渲染结论 ——
116
- const loadedEl = document.getElementById('loaded');
117
- [
118
- ['browserEngine', browserEngine],
119
- ['build config 优先项', picked ? `${picked.compileTarget} / ${picked.renderer}` : '<无匹配>'],
120
- ['理论选中入口', picked?.mainWasmPath ?? picked?.mainJsPath ?? '-'],
121
- ].forEach(([k, v]) => {
122
- const row = document.createElement('tr');
123
- row.innerHTML = `<td><b>${k}</b></td><td>${v}</td>`;
124
- loadedEl.appendChild(row);
125
- });
126
-
127
- const verdict = document.getElementById('verdict');
128
- if (picked?.compileTarget === 'dart2wasm') {
129
- verdict.classList.add('wasm');
130
- verdict.innerHTML = `<h2>✅ 走的是 WASM 路径</h2>` +
131
- `<p>本次会加载 <code>main.dart.wasm</code> + <code>main.dart.mjs</code>,渲染器 <code>${picked.renderer}</code>。如果体感仍然慢,更可能是 Flutter 应用自身的工作量(首屏 widget 树、字体、PDF 渲染),而不是 wasm 没启用。</p>`;
132
- } else if (picked) {
133
- verdict.classList.add('js');
134
- verdict.innerHTML = `<h2>⚠️ 走的是 JS fallback (dart2js)</h2>` +
135
- `<p>本次将加载 <code>main.dart.js</code> + 渲染器 <code>${picked.renderer}</code>。原因看上方"浏览器能力"——任何一项 false 都会让 wasm 路径被淘汰。</p>` +
136
- `<ul>` +
137
- `<li>如果 <code>supportsWasmGC</code> false:浏览器版本不够新(Chrome 119+/Safari 18.2+/FF 120+)。</li>` +
138
- `<li>如果 <code>webGLVersion</code> 是 0:硬件加速被关或者驱动有问题,skwasm 用不了 → 整套 wasm 路径被砍。</li>` +
139
- `<li>如果 <code>crossOriginIsolated</code> false:服务器没配 COOP/COEP 头,skwasm 多线程会被禁。</li>` +
140
- `<li>如果 <code>browserEngine</code> 是 webkit/gecko:flutter.js 默认 wasmAllowList 只允许 blink,要打开需要 <code>config.wasmAllowList</code>。</li>` +
141
- `</ul>`;
142
- } else {
143
- verdict.classList.add('js');
144
- verdict.innerHTML = `<h2>❌ build config 里没有匹配项</h2>`;
145
- }
146
-
147
- // 等几百毫秒让 flutter_bootstrap.js 真的开始加载
148
- setTimeout(() => {
149
- const raw = document.getElementById('raw');
150
- raw.textContent = '已观测到的网络请求(资源名):\n' +
151
- Array.from(seen).sort().map(s => ' • ' + s).join('\n') +
152
- '\n\nbuildConfig:\n' + JSON.stringify(buildConfig, null, 2);
153
- }, 1500);
154
- </script>
155
-
156
- <h2>下一步</h2>
157
- <p>访问 <code>http://localhost:5180/_diag.html</code> 即可看本机当前的判定。</p>
158
- </body>
159
- </html>