-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
339 lines (263 loc) · 8.23 KB
/
index.html
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<head>
<link rel="stylesheet" href="main.css" />
<link rel="icon" type="image/png" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Windows">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="apple-touch-icon" href="fs/c/windows/branding/icon.png">
<title>Booting...</title>
<script src="fs/c/windows/lib64/console.dll/main.js"></script>
<script src="fs/c/windows/lib64/console.dll/console.js"></script>
<script src="fs/c/windows/lib64/console.dll/color-console.js"></script>
<script src="fs/c/windows/lib64/console.dll/unit.js"></script>
<script src="fs/c/windows/ime/root.js"></script>
<script src="fs/c/windows/ime/gen/beta.js"></script>
<script src="fs/c/windows/ime/gen/buildTime.js"></script>
<script src="fs/c/windows/ime/gen/iquery.js"></script>
<script src="fs/c/windows/ime/gen/productName.js"></script>
<script src="fs/c/windows/ime/gen/rc.js"></script>
<script src="fs/c/windows/ime/gen/rrsp.js"></script>
<script src="fs/c/windows/ime/gen/version.js"></script>
</head>
<body>
<screen>
<workspace>
<p>
Your browser does not support W2000.
Use this page with a new version of Google Chrome, Safari or Chromium.
</p>
</workspace>
<task-bar></task-bar>
<full-overlay></full-overlay>
</screen>
</body>
<script>
// global this
const global = window;
global.config = config;
// get elements
const workspace = document.querySelector("workspace");
// create console
const globalConsole = new Console(document.querySelector("full-overlay"));
// page icon
const pageIcon = document.querySelector("link[rel=icon]");
// page icon
const errorMessage = workspace.querySelector("p");
</script>
<script src="fs/c/windows/lib64/mscorlib.dll/main.js"></script>
<script>
onload = async () => {
errorMessage.remove();
// load dlls
globalConsole.writeln("Starting Windows v" + config.version + (config.beta ? "b" : "r") + "...\n");
if (!config.beta) {
globalConsole.lock();
globalConsole.hideCursor();
}
config.bootStartTime = new Date();
config.touch = "ontouchstart" in window;
config.cacheArgs = ""
const steps = JSON.parse(localStorage[config.version + "_bootsteps"] || "[{}]");
const bootSteps = [];
document.title = config.productName;
const bootLog = globalConsole.createUnit("boot");
// set beta attribute
if (config.beta) {
document.body.setAttribute("beta", "");
}
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 64;
const ctx = canvas.getContext("2d");
ctx.lineCap = "round";
ctx.lineWidth = 8;
let i = 0;
const lastTotal = steps[steps.length - 1].time;
const interval = setInterval(() => {
if (config.loaded) {
clearInterval(interval);
}
if (matchMedia('(prefers-color-scheme: dark)').matches) {
ctx.strokeStyle = "white";
} else {
ctx.strokeStyle = "black";
}
ctx.clearRect(0, 0, 64, 64);
ctx.beginPath();
if (steps.length) {
ctx.arc(32, 32, 24, -Math.PI / 2, Math.PI * (2 / lastTotal * (new Date() - config.bootStartTime)) + -Math.PI / 2);
} else {
ctx.arc(32, 32, 24, -Math.PI / 2 + i / 30, i++ / 20);
}
ctx.stroke();
pageIcon.href = canvas.toDataURL();
}, 100);
const step = () => {
bootSteps.push({
time: new Date() - config.bootStartTime,
dlls: (global.DLL ? DLL.loadedModules.map(l => l.path) : [])
});
if (steps.length) {
document.title = "Booting (" + bootSteps.length + "/" + steps.length + ") - " + config.productName;
} else {
document.title = "Booting... - " + config.productName;
}
if (!config.beta) {
globalConsole.unlock();
globalConsole.y = globalConsole.height - 4;
globalConsole.x = 0;
const width = globalConsole.width;
const progress = Math.min(Math.floor(width / steps.length * bootSteps.length), width);
globalConsole.write("█".repeat(progress) + "▌".repeat(width - progress));
globalConsole.y = globalConsole.height - 2;
globalConsole.write(((DLL.modules[DLL.modules.length - 1] || {}).name || "").padEnd(globalConsole.width, " "));
globalConsole.lock();
}
};
let params = [];
step();
if (location.pathname == "/") {
params = await fetch("/config/init").then(r => r.json());
}
step();
const search = decodeURIComponent(location.search || config.injectedQuery || "");
// add query config
if (search.substr(1)) {
if (search[1] == "+") {
params = [];
for (let part of search.substr(2).split("&")) {
if (part[0] == "!") {
params.push({
config: part.substr(1)
});
} else if (part[0] == "*") {
params.push({
start: JSON.parse(part.substr(1))
});
}
}
} else if (search[1] == "!") {
params = [{
config: search.substr(2)
}];
} else {
params = JSON.parse(search.substr(1));
}
}
const reload = async () => {
if (!Array.isArray(params)) {
params = [params];
}
for (let param of params) {
if (!param.loaded) {
if ("config" in param) {
params.push(...(await fetch(param.config + "/config/init").then(r => r.json())));
param.loaded = true;
await reload();
}
if ("rrsp" in param) {
bootLog.action("queryconf", param.name || "ParamRRSP");
param.loaded = true;
config.fs.providers.unshift({
type: "rrsp",
name: param.name || "ParamRRSP",
root: param.rrsp,
deleteList: "rrsp_" + param.rssp + "_dl",
ray: param.rayroot || param.rrsp + "/" + param.ray + "?name=" + param.name + "&root=" + param.rrsp
});
}
if ("release-sim" in param) {
config.beta = false;
}
}
}
}
step();
await reload();
// load fs
step();
await DLL.load("c/windows/lib64/fileSystem.dll", true, [
"path.js",
"hub.js",
"main.js",
"rrsp.js",
"stzr.js",
"lssp.js",
"pmpr.js",
"init.js"
]);
// create fs
step();
// load all config exts
for (let file of await fs.listAll("c/windows/ime/config")) {
bootLog.action("autoconfig", fs.name(file));
step();
await DLL.load(file);
}
// polyfills / runtime
step();
await DLL.load("c/windows/lib64/runtime.dll");
// crypto
step();
await DLL.load("c/windows/lib64/cryptography.dll");
// pmde
step();
await DLL.load("c/windows/lib64/pmde.dll");
// pmde
step();
await DLL.load("c/windows/lib64/ftp.dll");
// icons
step();
await DLL.load("c/windows/lib64/moricons.dll");
// assert testing
step();
await DLL.load("c/windows/lib64/assert.dll");
// power manager
step();
await DLL.load("c/windows/lib64/pwrmgr.dll");
// eventmanager
step();
await DLL.load("c/windows/lib64/evntmg.dll");
// device management
step();
await DLL.load("c/windows/lib64/management.dll");
// process management
step();
await DLL.load("c/windows/lib64/process.dll");
// networking
step();
await DLL.load("c/windows/lib64/netstandard.dll");
// cursor
step();
await DLL.load("c/windows/lib64/cursor.dll");
// ui
step();
await DLL.load("c/windows/lib64/presentationFramework.dll");
// forms
step();
await DLL.load("c/windows/input/forms.dll");
// set webapp attribute if page is viewed in iOS webapp mode
if (navigator.standalone) {
await DLL.load("c/windows/lib64/mobile.dll");
}
// run and wait for installers
await (await Application("c/windows/system32/installer.exe")).startAndWaitForSuccessfulExit();
// run services (will continue while system is already booted)
(await Application("c/windows/system32/services.exe")).start();
// load backres (desktop / taskbar)
step();
await DLL.load("c/windows/lib64/backres.dll");
config.bootTime = new Date() - config.bootStartTime;
config.bootEndTime = new Date();
step();
localStorage[config.version + "_bootsteps"] = JSON.stringify(bootSteps);
for (let param of params) {
if (param.start) {
bootLog.action("start", ...param.start);
Application.run(...param.start);
}
}
config.loaded = true;
};
</script>