Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
199 lines (190 loc) · 9.09 KB
/
Copy pathindex.html
File metadata and controls
199 lines (190 loc) · 9.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!doctype html>
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8" />
<!-- maximum-scale=1 / user-scalable=no: this is an app shell, not a
document - without them iOS zooms the whole page whenever a focused
input's font is under 16px, and leaves it zoomed. viewport-fit=cover
is what makes env(safe-area-inset-*) report real values, so the
notch/home-indicator padding in app.css actually engages. -->
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
/>
<title>AttackFM</title>
<style>
/* Pre-tokens paint so the first frame is never a white flash. */
html { background: #0f0f10; }
html[data-theme='light'] { background: #ffffff; }
</style>
<!--
Which way the page runs, before anything is drawn.
LocaleShell stamps `dir` and `lang` too, and does it during its first
render - which is early, but it is still after this document has been
parsed and after several hundred KB of app.js has been evaluated. On a
phone that is long enough to see: the entire app laid out left-to-right,
then flipping. So the stored choice is read HERE, in the same breath as
the background colour above and for the same reason.
This duplicates two things from src/app/i18n/index.ts - the storage key
and the fact that Arabic is the only RTL language in `locales`. It has to:
nothing has loaded yet. Keep them in step; if a second RTL language is
ever added to the kit's list, this line is the other place it goes.
-->
<script>
try {
var afmLocale = localStorage.getItem('attackfm-locale');
if (afmLocale) {
document.documentElement.lang = afmLocale;
document.documentElement.dir = afmLocale === 'ar' ? 'rtl' : 'ltr';
}
} catch (e) {
/* Private mode, or storage off. The shell settles it a moment later. */
}
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<!--
The boot loader: which frontend actually runs.
It sits at the END of <body> on purpose. Vite's built entry is a module
script, and module scripts are DEFERRED - they execute only once the
document is parsed - so a classic inline script here still runs first and
can take the tag out before it ever executes. That is the only window in
which the choice can be made.
The embedded bundle is the floor. Without Tauri (a browser, the dev
server), or with no downloaded bundle, or if anything at all goes wrong
asking, this puts the embedded tag back exactly as Vite wrote it. The
swap happens only on the narrow happy path, and every launch that takes
it is recorded as a wager settled by bundle_boot_ok - see bundle.rs.
-->
<script>
(function () {
// The app's own entry, which is NOT simply the first module script.
// Vite injects its client (`/@vite/client`) ahead of /src/main.tsx, so
// taking the first one made the dev server look like a built bundle:
// the loader published `/@vite/client` as the chosen frontend, and
// main.tsx - seeing a name that was not its own - correctly concluded
// it was the losing half of a double boot and stood down. A black page
// on every dev launch, from a guard that is right in production.
var tags = document.querySelectorAll('script[type="module"][src]');
var moduleTag = null;
for (var i = 0; i < tags.length; i++) {
var src = tags[i].getAttribute('src') || '';
// Served from source: this is the dev server and there is no bundle
// to swap, whichever order the tags happen to be in.
if (src.indexOf('/src/') === 0) return;
// Vite's own machinery, never the app.
if (src.indexOf('/@') === 0) continue;
moduleTag = tags[i];
break;
}
if (!moduleTag) return;
var embeddedJs = moduleTag.getAttribute('src');
var cssTag = document.querySelector('link[rel="stylesheet"][href*="app.css"]');
// Removed before it runs; re-added below on whichever path we take.
moduleTag.remove();
// What the binary underneath can do. The launch-time update check is
// only safe from generation 2, where `bundle_state` stopped being able
// to quarantine the bundle asking it - so the frontend has to be able
// to tell, and an older binary ships an older copy of this file that
// never sets it. Absent therefore means "assume the worst", which is
// exactly right.
function run(js, css, version, generation) {
window.__afmNativeGeneration = generation || 0;
// Which frontend is the real one. Removing the loser's tag below does
// NOT stop it running - a prepared module script evaluates even after
// its element is gone - so the loser has to be told to stand down;
// see the guard at the top of main.tsx.
window.__afmFrontend = js;
if (css) {
var link = document.createElement('link');
link.rel = 'stylesheet';
// Same crossorigin the module tag below takes, and the same the
// embedded <link> is written with. Without it the stylesheet is
// the one request in this file fetched under different rules than
// everything around it.
link.crossOrigin = 'anonymous';
// The embedded sheet stays until the bundle's has actually landed.
// Dropping it first is what turns a failed stylesheet into a
// BRICK rather than a blemish: the module still boots, so
// bundle_boot_ok records the wager as won and the bundle is never
// quarantined - leaving a working app with no styles at all, every
// image at its natural size, and no way out but a reinstall.
link.onload = function () {
if (cssTag) cssTag.remove();
};
link.onerror = function () {
// Keep the embedded sheet and drop the one that failed, so the
// app is merely a version behind on looks instead of unusable.
link.remove();
};
document.head.appendChild(link);
link.href = css;
}
var tag = document.createElement('script');
tag.type = 'module';
tag.crossOrigin = 'anonymous';
tag.src = js;
window.__afmBundleVersion = version || null;
document.head.appendChild(tag);
}
var core = window.__TAURI__ && window.__TAURI__.core;
if (!core || !core.invoke) {
run(embeddedJs, null, null, 0);
return;
}
var settled = false;
// A hung IPC must not mean a blank app: if the answer has not arrived
// in a second, boot embedded and carry on.
var guard = setTimeout(function () {
if (settled) return;
settled = true;
run(embeddedJs, null, null, 0);
}, 1000);
// ONE call, not two. This used to ask `bundle_state` and then
// `bundle_begin_boot`, which meant a window between "the last wager was
// judged" and "this one is placed" that any other caller could land in
// - and `bundle_state` was itself destructive, so any of them could
// quarantine the bundle about to run. `bundle_claim_boot` does both
// halves under one lock and is the only thing that can quarantine
// anything. Five over-the-air versions were spent trying to sequence
// around the old shape from up here; it could not be done.
//
// Older binaries have no such command and answer with an error, which
// lands in the catch below and boots embedded - correct, and no worse
// than they already were.
core
.invoke('bundle_claim_boot')
.then(function (state) {
if (settled) return;
settled = true;
clearTimeout(guard);
// The generation belongs to the BINARY, not to whichever frontend
// ends up running - so it is reported even when falling back to
// embedded. Passing 0 here would tell a perfectly capable build
// that it was an old one, and switch off the launch check on every
// device that happens to be running its embedded bundle.
var gen = state && state.nativeGeneration;
if (!state || !state.dir || !state.active) {
run(embeddedJs, null, null, gen);
return;
}
var dir = state.dir;
run(
core.convertFileSrc(dir + '/app.js'),
core.convertFileSrc(dir + '/app.css'),
state.active,
gen
);
})
.catch(function () {
if (settled) return;
settled = true;
clearTimeout(guard);
run(embeddedJs, null, null, 0);
});
})();
</script>
</body>
</html>