-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·114 lines (114 loc) · 5.03 KB
/
Copy pathindex.html
File metadata and controls
executable file
·114 lines (114 loc) · 5.03 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MSFS Package Viewer</title>
<link rel="icon" href="data:," />
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
</style>
</head>
<body>
<script>
(() => {
const installedAt = performance.now()
const getLoadStage = () => {
const value = globalThis.__msfsLoadStage
return value && typeof value === 'object' ? value : null
}
const getStartupBenchmark = () => {
const history = Array.isArray(globalThis.__msfsLoadStageHistory)
? globalThis.__msfsLoadStageHistory
: []
const first = history[0] || null
const latest = history[history.length - 1] || null
const firstNowMs = first && typeof first.nowMs === 'number' ? first.nowMs : null
const latestNowMs = latest && typeof latest.nowMs === 'number' ? latest.nowMs : null
return {
ready: latest && typeof latest.stage === 'string' && latest.stage !== 'init:error',
totalElapsedMs: firstNowMs != null && latestNowMs != null ? latestNowMs - firstNowMs : null,
currentElapsedMs: firstNowMs != null ? performance.now() - firstNowMs : null,
currentStage: latest,
stageCount: history.length,
stages: history
}
}
const response = (ok, summary, data, warnings) => ({
ok,
summary,
data,
...(warnings && warnings.length ? { warnings } : {})
})
const loadingData = () => ({
ready: false,
loadStage: getLoadStage(),
elapsedMs: performance.now() - installedAt,
location: window.location.href
})
const unavailable = method => response(
false,
'Viewer module is still loading; full DevApi is not ready yet.',
{ ...loadingData(), method },
['Use __DevApi.status() or __DevApi.diagnostics() to inspect boot progress, then retry after __DevApi.ready().']
)
let bootProxy
const bootApi = {
__bootPhase: 'html',
ready: async () => {
while (window.__DevApi === bootProxy) {
await new Promise(resolve => window.setTimeout(resolve, 250))
}
return window.__DevApi && typeof window.__DevApi.ready === 'function'
? window.__DevApi.ready()
: unavailable('ready')
},
status: () => response(true, 'Viewer module is still loading.', loadingData()),
diagnostics: () => response(true, 'Returned boot diagnostics.', { ...loadingData(), diagnostics: [] }),
report: () => response(true, 'Returned boot report.', { ...loadingData(), diagnostics: [], performance: { fps: null } }),
help: () => response(true, 'Boot DevApi is available while the viewer module loads.', {
methods: ['__DevApi.status()', '__DevApi.diagnostics()', '__DevApi.bench.startup()', 'await __DevApi.bench.all()', '__DevApi.bench.history()', 'await __DevApi.ready()'],
note: 'Interaction, camera, gauge, and runtime helpers become available after the viewer module and model loading complete.'
}),
schema: () => response(true, 'Returned boot DevApi schema summary.', {
ready: false,
methods: ['ready', 'status', 'help', 'schema', 'diagnostics', 'report', 'bench.startup', 'bench.all', 'bench.history']
}),
bench: {
startup: () => response(true, 'Collected startup benchmark.', getStartupBenchmark()),
cockpitLod0: () => unavailable('bench.cockpitLod0'),
all: () => unavailable('bench.all'),
history: () => response(true, 'Collected stored benchmark history.', {
storageKey: 'msfs.devapi.bench.history.v1',
entries: JSON.parse(window.localStorage.getItem('msfs.devapi.bench.history.v1') || '[]')
}),
clearHistory: () => {
window.localStorage.removeItem('msfs.devapi.bench.history.v1')
return response(true, 'Cleared stored benchmark history.', {
storageKey: 'msfs.devapi.bench.history.v1'
})
}
}
}
bootProxy = new Proxy(bootApi, {
get(target, property, receiver) {
if (property in target) {
return Reflect.get(target, property, receiver)
}
if (typeof property === 'string') {
return () => unavailable(property)
}
return undefined
}
})
window.__DevApi = bootProxy
globalThis.__DevApi = window.__DevApi
if (globalThis.GPUShaderStage == null) {
globalThis.GPUShaderStage = { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 }
}
})()
</script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>