@textadventures/quest-viva-wasmplayer 6.0.0-beta.57 → 6.0.0-beta.58
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/_framework/Common.wasm +0 -0
- package/_framework/Engine.wasm +0 -0
- package/_framework/Legacy.wasm +0 -0
- package/_framework/PlayerCore.wasm +0 -0
- package/_framework/WasmPlayer.wasm +0 -0
- package/_framework/dotnet.boot.js +6 -6
- package/index.html +24 -14
- package/package.json +1 -1
- package/wasm-player.js +94 -9
package/_framework/Common.wasm
CHANGED
|
Binary file
|
package/_framework/Engine.wasm
CHANGED
|
Binary file
|
package/_framework/Legacy.wasm
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const config = /*json-start*/{
|
|
2
2
|
"mainAssemblyName": "WasmPlayer.dll",
|
|
3
3
|
"resources": {
|
|
4
|
-
"hash": "sha256-
|
|
4
|
+
"hash": "sha256-Yr09rmXNYGN6LcUDHJDg8OAU0PZSyBfmT1qNKu+62lE=",
|
|
5
5
|
"jsModuleNative": [
|
|
6
6
|
{
|
|
7
7
|
"name": "dotnet.native.js"
|
|
@@ -939,27 +939,27 @@ export const config = /*json-start*/{
|
|
|
939
939
|
{
|
|
940
940
|
"virtualPath": "Common.wasm",
|
|
941
941
|
"name": "Common.wasm",
|
|
942
|
-
"hash": "sha256-
|
|
942
|
+
"hash": "sha256-m6pByI3t+ZrZagdIA53USHNp4tIfWIQAhqdgbfKaj3w="
|
|
943
943
|
},
|
|
944
944
|
{
|
|
945
945
|
"virtualPath": "Engine.wasm",
|
|
946
946
|
"name": "Engine.wasm",
|
|
947
|
-
"hash": "sha256-
|
|
947
|
+
"hash": "sha256-L0mtyQI1/XB93G/9yGkhHszg1DxVKm+ZxKyxe3zljb0="
|
|
948
948
|
},
|
|
949
949
|
{
|
|
950
950
|
"virtualPath": "Legacy.wasm",
|
|
951
951
|
"name": "Legacy.wasm",
|
|
952
|
-
"hash": "sha256-
|
|
952
|
+
"hash": "sha256-W+XViOuDToAx7QgTzts0p92LeUke1ElkiI/fwNRLbFM="
|
|
953
953
|
},
|
|
954
954
|
{
|
|
955
955
|
"virtualPath": "PlayerCore.wasm",
|
|
956
956
|
"name": "PlayerCore.wasm",
|
|
957
|
-
"hash": "sha256-
|
|
957
|
+
"hash": "sha256-KSuWIsi9gMvS2f5fOMm+S1Mkg2hVwyrsCDjRVaL/O4U="
|
|
958
958
|
},
|
|
959
959
|
{
|
|
960
960
|
"virtualPath": "WasmPlayer.wasm",
|
|
961
961
|
"name": "WasmPlayer.wasm",
|
|
962
|
-
"hash": "sha256-
|
|
962
|
+
"hash": "sha256-Xxdi8yATS8X6Gfj2zGg5lXZ7itn9PMp3tNIRxCvSviE="
|
|
963
963
|
}
|
|
964
964
|
],
|
|
965
965
|
"assembly": []
|
package/index.html
CHANGED
|
@@ -4,8 +4,18 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Quest Viva</title>
|
|
7
|
-
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
|
|
8
|
-
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="favicon.svg?v=6.0.0-beta.58" />
|
|
8
|
+
<!-- Lets the preload scanner start the runtime loader before the parser has
|
|
9
|
+
even reached wasm-player.js, which as the last script in this head only
|
|
10
|
+
executes once jQuery/jQuery UI/paper.js have all downloaded *and* run.
|
|
11
|
+
It's 37 KB, so it's unconditional rather than gated on a game actually
|
|
12
|
+
being on its way — the ~10.6 MB the loader then pulls is what's gated,
|
|
13
|
+
in wasm-player.js's boot IIFE. Stamped with ?v= like every other asset
|
|
14
|
+
here (scripts/inject-version.mjs), which is also what makes the
|
|
15
|
+
preload and wasm-player.js's own import() agree on one URL and share a
|
|
16
|
+
single fetch. -->
|
|
17
|
+
<link rel="modulepreload" href="_framework/dotnet.js?v=6.0.0-beta.58" />
|
|
18
|
+
<script type="text/javascript" src="quest-config.js?v=6.0.0-beta.58"></script>
|
|
9
19
|
<script type="text/javascript">
|
|
10
20
|
// Runs before the start screen is parsed, so when a game is specified via the
|
|
11
21
|
// URL (or a defaultGameUrl is configured) we paint straight into the loading
|
|
@@ -23,28 +33,28 @@
|
|
|
23
33
|
html.qv-booting #qv-pickers { display: none; }
|
|
24
34
|
html.qv-booting #qv-loading-msg { display: flex; }
|
|
25
35
|
</style>
|
|
26
|
-
<script type="text/javascript" src="lib/jquery-2.1.1.min.js"></script>
|
|
27
|
-
<script type="text/javascript" src="lib/jquery-ui.min.js"></script>
|
|
28
|
-
<script type="text/javascript" src="lib/jquery.multi-open-accordion-1.5.3.js"></script>
|
|
29
|
-
<link rel="stylesheet" type="text/css" href="lib/jquery-ui.min.css" />
|
|
30
|
-
<link rel="stylesheet" type="text/css" href="playercore.css" />
|
|
36
|
+
<script type="text/javascript" src="lib/jquery-2.1.1.min.js?v=6.0.0-beta.58"></script>
|
|
37
|
+
<script type="text/javascript" src="lib/jquery-ui.min.js?v=6.0.0-beta.58"></script>
|
|
38
|
+
<script type="text/javascript" src="lib/jquery.multi-open-accordion-1.5.3.js?v=6.0.0-beta.58"></script>
|
|
39
|
+
<link rel="stylesheet" type="text/css" href="lib/jquery-ui.min.css?v=6.0.0-beta.58" />
|
|
40
|
+
<link rel="stylesheet" type="text/css" href="playercore.css?v=6.0.0-beta.58" />
|
|
31
41
|
<!-- App-chrome styles (start screen, debugger, save-slot manager). Built from
|
|
32
42
|
styles/chrome.css via `npm run build` — see WasmPlayer/package.json. All of
|
|
33
43
|
its rules are contained to `.qv-chrome` subtrees so they can't affect the
|
|
34
44
|
game UI above (playercore.css / jQuery UI). -->
|
|
35
|
-
<link rel="stylesheet" type="text/css" href="chrome.css" />
|
|
36
|
-
<script type="text/javascript" src="playercore.js"></script>
|
|
37
|
-
<script type="text/javascript" src="player.js"></script>
|
|
38
|
-
<script type="text/javascript" src="lib/paper.js"></script>
|
|
39
|
-
<script>window.QuestVivaVersion = "6.0.0-beta.
|
|
40
|
-
<script type="text/javascript" src="wasm-player.js"></script>
|
|
45
|
+
<link rel="stylesheet" type="text/css" href="chrome.css?v=6.0.0-beta.58" />
|
|
46
|
+
<script type="text/javascript" src="playercore.js?v=6.0.0-beta.58"></script>
|
|
47
|
+
<script type="text/javascript" src="player.js?v=6.0.0-beta.58"></script>
|
|
48
|
+
<script type="text/javascript" src="lib/paper.js?v=6.0.0-beta.58"></script>
|
|
49
|
+
<script>window.QuestVivaVersion = "6.0.0-beta.58";</script>
|
|
50
|
+
<script type="text/javascript" src="wasm-player.js?v=6.0.0-beta.58"></script>
|
|
41
51
|
</head>
|
|
42
52
|
<body>
|
|
43
53
|
<div id="qv-start" class="qv-chrome">
|
|
44
54
|
<div class="card preset-filled-surface-100-900 w-full max-w-md p-8 space-y-6" data-theme="wintry">
|
|
45
55
|
<div>
|
|
46
56
|
<h1 class="h2 flex items-center gap-4">
|
|
47
|
-
<img src="logo.svg" alt="" class="h-7" />
|
|
57
|
+
<img src="logo.svg?v=6.0.0-beta.58" alt="" class="h-7" />
|
|
48
58
|
Quest Viva
|
|
49
59
|
</h1>
|
|
50
60
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textadventures/quest-viva-wasmplayer",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.58",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Quest Viva WasmPlayer runtime (browser-WASM text adventure player), published for CDN-linked single-file game exports.",
|
|
6
6
|
"license": "MIT",
|
package/wasm-player.js
CHANGED
|
@@ -27,6 +27,28 @@ console.log(
|
|
|
27
27
|
// relative resolution entirely, so it works either way.
|
|
28
28
|
const wasmPlayerScriptUrl = document.currentScript?.src;
|
|
29
29
|
|
|
30
|
+
// Cache key for this build's own static assets, matching the `?v=` that
|
|
31
|
+
// scripts/inject-version.mjs stamps onto every asset URL in the markup —
|
|
32
|
+
// window.QuestVivaVersion is spliced in by that same script. This covers the
|
|
33
|
+
// assets fetched from JS instead (playercore.htm, grid.js, and everything
|
|
34
|
+
// under _framework/), so a deploy changes every URL and play.questviva.com can
|
|
35
|
+
// serve them `immutable` rather than revalidating ~210 files on each load.
|
|
36
|
+
//
|
|
37
|
+
// For _framework/ specifically the version is also what makes `immutable`
|
|
38
|
+
// *safe*. None of those filenames are content-hashed and AOT output isn't
|
|
39
|
+
// byte-reproducible, so a browser holding dotnet.boot.js (the manifest of
|
|
40
|
+
// per-file SHA-256 hashes) from one deploy alongside a binary from the next
|
|
41
|
+
// gets an SRI mismatch and the resource is blocked. Stamping manifest and
|
|
42
|
+
// binaries with the same version means they can never come from different
|
|
43
|
+
// deploys — which is what the blanket `Cache-Control: no-cache` on
|
|
44
|
+
// _framework/* used to buy, at the cost of ~190 revalidations per page load.
|
|
45
|
+
//
|
|
46
|
+
// Empty when the version is unknown (which also leaves the runtime's own
|
|
47
|
+
// no-cache fetching alone, below) — nothing then depends on cache keys.
|
|
48
|
+
const assetVersion = window.QuestVivaVersion || '';
|
|
49
|
+
const assetVersionQuery = assetVersion ? `?v=${encodeURIComponent(assetVersion)}` : '';
|
|
50
|
+
const versioned = (url) => (assetVersionQuery && !url.includes('?') ? url + assetVersionQuery : url);
|
|
51
|
+
|
|
30
52
|
var _audio = null;
|
|
31
53
|
|
|
32
54
|
const pendingResources = new Map();
|
|
@@ -426,7 +448,7 @@ async function setupPaperJs() {
|
|
|
426
448
|
canvas.style.display = 'none';
|
|
427
449
|
document.body.appendChild(canvas);
|
|
428
450
|
paper.setup(canvas);
|
|
429
|
-
const code = await fetch('grid.js').then(r => r.text());
|
|
451
|
+
const code = await fetch(versioned('grid.js')).then(r => r.text());
|
|
430
452
|
paper.PaperScript.evaluate(code, paper);
|
|
431
453
|
}
|
|
432
454
|
|
|
@@ -479,19 +501,75 @@ let currentIsPreview = false;
|
|
|
479
501
|
// must NOT also disable Save or add the Restart button the way isPreview does.
|
|
480
502
|
let currentAllowDebug = false;
|
|
481
503
|
|
|
504
|
+
// ── .NET runtime bootstrap ───────────────────────────────────────────────────
|
|
505
|
+
//
|
|
506
|
+
// The runtime is ~10.6 MB spread over ~190 files, and which game is being
|
|
507
|
+
// played has no bearing on any of it. It used to be imported and instantiated
|
|
508
|
+
// inside initWasmPlayer() — i.e. only once the game bytes were already in
|
|
509
|
+
// hand, which for a ?id= link means after a textadventures API round trip and
|
|
510
|
+
// then the game download, neither of which it depends on. Splitting the
|
|
511
|
+
// download away from create() lets the boot IIFE start it up front instead, in
|
|
512
|
+
// parallel with those two fetches. See issue #2186.
|
|
513
|
+
let runtimeBuilderPromise = null;
|
|
514
|
+
|
|
515
|
+
// Resolves to the configured — but not yet instantiated — host builder.
|
|
516
|
+
function loadRuntimeBuilder() {
|
|
517
|
+
if (runtimeBuilderPromise) return runtimeBuilderPromise;
|
|
518
|
+
// A relative specifier fails here when this script is loaded cross-origin
|
|
519
|
+
// (the CDN-linked single-file export) — see wasmPlayerScriptUrl's comment.
|
|
520
|
+
// The version query is load-bearing beyond its own cache key too: the
|
|
521
|
+
// loader reads it back off its own import.meta.url and propagates it to
|
|
522
|
+
// the JS modules it imports and to dotnet.boot.js (`modulesUniqueQuery`),
|
|
523
|
+
// so those need no further handling in withResourceLoader below.
|
|
524
|
+
const dotnetJsUrl = versioned(wasmPlayerScriptUrl
|
|
525
|
+
? new URL('_framework/dotnet.js', wasmPlayerScriptUrl).href
|
|
526
|
+
: './_framework/dotnet.js');
|
|
527
|
+
runtimeBuilderPromise = import(dotnetJsUrl).then(({ dotnet }) => dotnet
|
|
528
|
+
// The loader otherwise passes `cache: "no-cache"` on every asset fetch,
|
|
529
|
+
// which forces a conditional request regardless of how long the CDN
|
|
530
|
+
// said the response was fresh for — so without this, `immutable` on
|
|
531
|
+
// _framework/* buys nothing at all. Only safe to turn off because the
|
|
532
|
+
// URLs are version-stamped (see assetVersionQuery); left alone when
|
|
533
|
+
// there's no version to stamp with.
|
|
534
|
+
.withConfig({ disableNoCacheFetch: !!assetVersionQuery })
|
|
535
|
+
// Stamps the remaining assets — the assemblies, dotnet.native.wasm and
|
|
536
|
+
// the ICU data. Returning null means "use the default URL", which is
|
|
537
|
+
// what the JS modules and the manifest want: modulesUniqueQuery has
|
|
538
|
+
// already appended the same query to those, and doing it here as well
|
|
539
|
+
// would produce a doubled `?v=...?v=...`.
|
|
540
|
+
.withResourceLoader((type, name, defaultUri) =>
|
|
541
|
+
!assetVersionQuery || type === 'manifest' || type === 'dotnetjs'
|
|
542
|
+
? null
|
|
543
|
+
: versioned(defaultUri)));
|
|
544
|
+
return runtimeBuilderPromise;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Pulls every runtime asset into the browser cache without instantiating
|
|
548
|
+
// anything, so the create() in initWasmPlayer has nothing left to fetch.
|
|
549
|
+
// Fire-and-forget by design: it's started before we know the game will even
|
|
550
|
+
// load, and its result is not what anyone waits on. The runtime's own
|
|
551
|
+
// bookkeeping makes create() reuse this exact work rather than repeat it
|
|
552
|
+
// (mono_download_assets is one-shot), and a failure here resurfaces from
|
|
553
|
+
// create() where startGame already turns it into a visible error — so the
|
|
554
|
+
// catch here only exists to keep it from becoming an unhandled rejection.
|
|
555
|
+
//
|
|
556
|
+
// The trade is that a game that turns out not to exist (a bad ?id=) now
|
|
557
|
+
// downloads some of a runtime it won't use. That costs a failed load some
|
|
558
|
+
// bandwidth; not doing it costs every successful load ~1.7s.
|
|
559
|
+
function preloadRuntime() {
|
|
560
|
+
loadRuntimeBuilder().then(builder => builder.download()).catch(() => {});
|
|
561
|
+
}
|
|
562
|
+
|
|
482
563
|
async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null, isPreview = false, recordWalkthrough = null, runWalkthrough = null, adjacentFiles = null, allowDebug = false) {
|
|
483
564
|
currentIsPreview = isPreview;
|
|
484
565
|
currentAllowDebug = allowDebug;
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const [htmResponse, { dotnet }] = await Promise.all([
|
|
489
|
-
fetch('playercore.htm'),
|
|
490
|
-
import(dotnetJsUrl),
|
|
566
|
+
const [htmResponse, builder] = await Promise.all([
|
|
567
|
+
fetch(versioned('playercore.htm')),
|
|
568
|
+
loadRuntimeBuilder(),
|
|
491
569
|
]);
|
|
492
570
|
originalPlayerHtml = await htmResponse.text();
|
|
493
571
|
|
|
494
|
-
const runtime = await
|
|
572
|
+
const runtime = await builder.create();
|
|
495
573
|
const { setModuleImports, getAssemblyExports, getConfig } = runtime;
|
|
496
574
|
|
|
497
575
|
setModuleImports("wasm-player", {
|
|
@@ -2060,6 +2138,7 @@ async function fetchGameBytes(url) {
|
|
|
2060
2138
|
// other boot source converges on. Checked first since, unlike the sources
|
|
2061
2139
|
// below, an embedded export never carries any of their query params.
|
|
2062
2140
|
if (window.QuestVivaEmbeddedGame) {
|
|
2141
|
+
preloadRuntime();
|
|
2063
2142
|
const bytes = Uint8Array.from(atob(window.QuestVivaEmbeddedGame), c => c.charCodeAt(0));
|
|
2064
2143
|
const filename = window.QuestVivaEmbeddedGameFilename || 'game.quest';
|
|
2065
2144
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
@@ -2072,6 +2151,7 @@ async function fetchGameBytes(url) {
|
|
|
2072
2151
|
const params = new URLSearchParams(window.location.search);
|
|
2073
2152
|
|
|
2074
2153
|
if (params.get('source') === 'editor') {
|
|
2154
|
+
preloadRuntime();
|
|
2075
2155
|
const bc = new BroadcastChannel('quest-preview');
|
|
2076
2156
|
bc.postMessage({ type: 'ready' });
|
|
2077
2157
|
bc.onmessage = async ({ data }) => {
|
|
@@ -2097,6 +2177,7 @@ async function fetchGameBytes(url) {
|
|
|
2097
2177
|
// distinct channel name keeps this from cross-talking with a real
|
|
2098
2178
|
// editor-preview tab open at the same time.
|
|
2099
2179
|
if (params.get('source') === 'local') {
|
|
2180
|
+
preloadRuntime();
|
|
2100
2181
|
const bc = new BroadcastChannel('quest-play-local');
|
|
2101
2182
|
bc.postMessage({ type: 'ready' });
|
|
2102
2183
|
// Covers the case where nothing ever answers — see
|
|
@@ -2135,7 +2216,10 @@ async function fetchGameBytes(url) {
|
|
|
2135
2216
|
const gameUrl = params.get('url') || window.QuestVivaConfig?.defaultGameUrl;
|
|
2136
2217
|
|
|
2137
2218
|
if (id) {
|
|
2138
|
-
// Start API fetch immediately; wire DOM once it's ready.
|
|
2219
|
+
// Start API fetch immediately; wire DOM once it's ready. The runtime
|
|
2220
|
+
// download runs alongside it rather than behind it — the API response
|
|
2221
|
+
// and the game file it points at are what used to gate it.
|
|
2222
|
+
preloadRuntime();
|
|
2139
2223
|
let resolvedSourceUrl = null;
|
|
2140
2224
|
const gamePromise = (async () => {
|
|
2141
2225
|
const apiRoot = window.QuestVivaConfig?.textAdventuresApiRoot
|
|
@@ -2167,6 +2251,7 @@ async function fetchGameBytes(url) {
|
|
|
2167
2251
|
|
|
2168
2252
|
if (gameUrl) {
|
|
2169
2253
|
// Start fetch immediately; wire DOM once it's ready.
|
|
2254
|
+
preloadRuntime();
|
|
2170
2255
|
const gamePromise = fetchGameBytes(gameUrl);
|
|
2171
2256
|
|
|
2172
2257
|
document.addEventListener('DOMContentLoaded', async () => {
|