@textadventures/quest-viva-wasmplayer 6.0.0-beta.51 → 6.0.0-beta.53

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.
Files changed (191) hide show
  1. package/TranscriptViewer/index.html +136 -0
  2. package/WasmPlayer.runtimeconfig.json +1 -1
  3. package/_framework/Common.wasm +0 -0
  4. package/_framework/Engine.wasm +0 -0
  5. package/_framework/Legacy.wasm +0 -0
  6. package/_framework/Microsoft.CSharp.wasm +0 -0
  7. package/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
  8. package/_framework/Microsoft.VisualBasic.wasm +0 -0
  9. package/_framework/Microsoft.Win32.Primitives.wasm +0 -0
  10. package/_framework/Microsoft.Win32.Registry.wasm +0 -0
  11. package/_framework/PlayerCore.wasm +0 -0
  12. package/_framework/System.AppContext.wasm +0 -0
  13. package/_framework/System.Buffers.wasm +0 -0
  14. package/_framework/System.Collections.Concurrent.wasm +0 -0
  15. package/_framework/System.Collections.Immutable.wasm +0 -0
  16. package/_framework/System.Collections.NonGeneric.wasm +0 -0
  17. package/_framework/System.Collections.Specialized.wasm +0 -0
  18. package/_framework/System.Collections.wasm +0 -0
  19. package/_framework/System.ComponentModel.Annotations.wasm +0 -0
  20. package/_framework/System.ComponentModel.DataAnnotations.wasm +0 -0
  21. package/_framework/System.ComponentModel.EventBasedAsync.wasm +0 -0
  22. package/_framework/System.ComponentModel.Primitives.wasm +0 -0
  23. package/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
  24. package/_framework/System.ComponentModel.wasm +0 -0
  25. package/_framework/System.Configuration.wasm +0 -0
  26. package/_framework/System.Console.wasm +0 -0
  27. package/_framework/System.Core.wasm +0 -0
  28. package/_framework/System.Data.Common.wasm +0 -0
  29. package/_framework/System.Data.DataSetExtensions.wasm +0 -0
  30. package/_framework/System.Data.wasm +0 -0
  31. package/_framework/System.Diagnostics.Contracts.wasm +0 -0
  32. package/_framework/System.Diagnostics.Debug.wasm +0 -0
  33. package/_framework/System.Diagnostics.DiagnosticSource.wasm +0 -0
  34. package/_framework/System.Diagnostics.FileVersionInfo.wasm +0 -0
  35. package/_framework/System.Diagnostics.Process.wasm +0 -0
  36. package/_framework/System.Diagnostics.StackTrace.wasm +0 -0
  37. package/_framework/System.Diagnostics.TextWriterTraceListener.wasm +0 -0
  38. package/_framework/System.Diagnostics.Tools.wasm +0 -0
  39. package/_framework/System.Diagnostics.TraceSource.wasm +0 -0
  40. package/_framework/System.Diagnostics.Tracing.wasm +0 -0
  41. package/_framework/System.Drawing.Primitives.wasm +0 -0
  42. package/_framework/System.Drawing.wasm +0 -0
  43. package/_framework/System.Dynamic.Runtime.wasm +0 -0
  44. package/_framework/System.Formats.Asn1.wasm +0 -0
  45. package/_framework/System.Formats.Tar.wasm +0 -0
  46. package/_framework/System.Globalization.Calendars.wasm +0 -0
  47. package/_framework/System.Globalization.Extensions.wasm +0 -0
  48. package/_framework/System.Globalization.wasm +0 -0
  49. package/_framework/System.IO.Compression.Brotli.wasm +0 -0
  50. package/_framework/System.IO.Compression.FileSystem.wasm +0 -0
  51. package/_framework/System.IO.Compression.ZipFile.wasm +0 -0
  52. package/_framework/System.IO.Compression.wasm +0 -0
  53. package/_framework/System.IO.FileSystem.AccessControl.wasm +0 -0
  54. package/_framework/System.IO.FileSystem.DriveInfo.wasm +0 -0
  55. package/_framework/System.IO.FileSystem.Primitives.wasm +0 -0
  56. package/_framework/System.IO.FileSystem.Watcher.wasm +0 -0
  57. package/_framework/System.IO.FileSystem.wasm +0 -0
  58. package/_framework/System.IO.IsolatedStorage.wasm +0 -0
  59. package/_framework/System.IO.MemoryMappedFiles.wasm +0 -0
  60. package/_framework/System.IO.Pipelines.wasm +0 -0
  61. package/_framework/System.IO.Pipes.AccessControl.wasm +0 -0
  62. package/_framework/System.IO.Pipes.wasm +0 -0
  63. package/_framework/System.IO.UnmanagedMemoryStream.wasm +0 -0
  64. package/_framework/System.IO.wasm +0 -0
  65. package/_framework/System.Linq.AsyncEnumerable.wasm +0 -0
  66. package/_framework/System.Linq.Expressions.wasm +0 -0
  67. package/_framework/System.Linq.Parallel.wasm +0 -0
  68. package/_framework/System.Linq.Queryable.wasm +0 -0
  69. package/_framework/System.Linq.wasm +0 -0
  70. package/_framework/System.Memory.wasm +0 -0
  71. package/_framework/System.Net.Http.Json.wasm +0 -0
  72. package/_framework/System.Net.Http.wasm +0 -0
  73. package/_framework/System.Net.HttpListener.wasm +0 -0
  74. package/_framework/System.Net.Mail.wasm +0 -0
  75. package/_framework/System.Net.NameResolution.wasm +0 -0
  76. package/_framework/System.Net.NetworkInformation.wasm +0 -0
  77. package/_framework/System.Net.Ping.wasm +0 -0
  78. package/_framework/System.Net.Primitives.wasm +0 -0
  79. package/_framework/System.Net.Quic.wasm +0 -0
  80. package/_framework/System.Net.Requests.wasm +0 -0
  81. package/_framework/System.Net.Security.wasm +0 -0
  82. package/_framework/System.Net.ServerSentEvents.wasm +0 -0
  83. package/_framework/System.Net.ServicePoint.wasm +0 -0
  84. package/_framework/System.Net.Sockets.wasm +0 -0
  85. package/_framework/System.Net.WebClient.wasm +0 -0
  86. package/_framework/System.Net.WebHeaderCollection.wasm +0 -0
  87. package/_framework/System.Net.WebProxy.wasm +0 -0
  88. package/_framework/System.Net.WebSockets.Client.wasm +0 -0
  89. package/_framework/System.Net.WebSockets.wasm +0 -0
  90. package/_framework/System.Net.wasm +0 -0
  91. package/_framework/System.Numerics.Vectors.wasm +0 -0
  92. package/_framework/System.Numerics.wasm +0 -0
  93. package/_framework/System.ObjectModel.wasm +0 -0
  94. package/_framework/System.Private.CoreLib.wasm +0 -0
  95. package/_framework/System.Private.DataContractSerialization.wasm +0 -0
  96. package/_framework/System.Private.Uri.wasm +0 -0
  97. package/_framework/System.Private.Xml.Linq.wasm +0 -0
  98. package/_framework/System.Private.Xml.wasm +0 -0
  99. package/_framework/System.Reflection.DispatchProxy.wasm +0 -0
  100. package/_framework/System.Reflection.Emit.ILGeneration.wasm +0 -0
  101. package/_framework/System.Reflection.Emit.Lightweight.wasm +0 -0
  102. package/_framework/System.Reflection.Emit.wasm +0 -0
  103. package/_framework/System.Reflection.Extensions.wasm +0 -0
  104. package/_framework/System.Reflection.Metadata.wasm +0 -0
  105. package/_framework/System.Reflection.Primitives.wasm +0 -0
  106. package/_framework/System.Reflection.TypeExtensions.wasm +0 -0
  107. package/_framework/System.Reflection.wasm +0 -0
  108. package/_framework/System.Resources.Reader.wasm +0 -0
  109. package/_framework/System.Resources.ResourceManager.wasm +0 -0
  110. package/_framework/System.Resources.Writer.wasm +0 -0
  111. package/_framework/System.Runtime.CompilerServices.Unsafe.wasm +0 -0
  112. package/_framework/System.Runtime.CompilerServices.VisualC.wasm +0 -0
  113. package/_framework/System.Runtime.Extensions.wasm +0 -0
  114. package/_framework/System.Runtime.Handles.wasm +0 -0
  115. package/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  116. package/_framework/System.Runtime.InteropServices.RuntimeInformation.wasm +0 -0
  117. package/_framework/System.Runtime.InteropServices.wasm +0 -0
  118. package/_framework/System.Runtime.Intrinsics.wasm +0 -0
  119. package/_framework/System.Runtime.Loader.wasm +0 -0
  120. package/_framework/System.Runtime.Numerics.wasm +0 -0
  121. package/_framework/System.Runtime.Serialization.Formatters.wasm +0 -0
  122. package/_framework/System.Runtime.Serialization.Json.wasm +0 -0
  123. package/_framework/System.Runtime.Serialization.Primitives.wasm +0 -0
  124. package/_framework/System.Runtime.Serialization.Xml.wasm +0 -0
  125. package/_framework/System.Runtime.Serialization.wasm +0 -0
  126. package/_framework/System.Runtime.wasm +0 -0
  127. package/_framework/System.Security.AccessControl.wasm +0 -0
  128. package/_framework/System.Security.Claims.wasm +0 -0
  129. package/_framework/System.Security.Cryptography.Algorithms.wasm +0 -0
  130. package/_framework/System.Security.Cryptography.Cng.wasm +0 -0
  131. package/_framework/System.Security.Cryptography.Csp.wasm +0 -0
  132. package/_framework/System.Security.Cryptography.Encoding.wasm +0 -0
  133. package/_framework/System.Security.Cryptography.OpenSsl.wasm +0 -0
  134. package/_framework/System.Security.Cryptography.Primitives.wasm +0 -0
  135. package/_framework/System.Security.Cryptography.X509Certificates.wasm +0 -0
  136. package/_framework/System.Security.Cryptography.wasm +0 -0
  137. package/_framework/System.Security.Principal.Windows.wasm +0 -0
  138. package/_framework/System.Security.Principal.wasm +0 -0
  139. package/_framework/System.Security.SecureString.wasm +0 -0
  140. package/_framework/System.Security.wasm +0 -0
  141. package/_framework/System.ServiceModel.Web.wasm +0 -0
  142. package/_framework/System.ServiceProcess.wasm +0 -0
  143. package/_framework/System.Text.Encoding.CodePages.wasm +0 -0
  144. package/_framework/System.Text.Encoding.Extensions.wasm +0 -0
  145. package/_framework/System.Text.Encoding.wasm +0 -0
  146. package/_framework/System.Text.Encodings.Web.wasm +0 -0
  147. package/_framework/System.Text.Json.wasm +0 -0
  148. package/_framework/System.Text.RegularExpressions.wasm +0 -0
  149. package/_framework/System.Threading.AccessControl.wasm +0 -0
  150. package/_framework/System.Threading.Channels.wasm +0 -0
  151. package/_framework/System.Threading.Overlapped.wasm +0 -0
  152. package/_framework/System.Threading.Tasks.Dataflow.wasm +0 -0
  153. package/_framework/System.Threading.Tasks.Extensions.wasm +0 -0
  154. package/_framework/System.Threading.Tasks.Parallel.wasm +0 -0
  155. package/_framework/System.Threading.Tasks.wasm +0 -0
  156. package/_framework/System.Threading.Thread.wasm +0 -0
  157. package/_framework/System.Threading.ThreadPool.wasm +0 -0
  158. package/_framework/System.Threading.Timer.wasm +0 -0
  159. package/_framework/System.Threading.wasm +0 -0
  160. package/_framework/System.Transactions.Local.wasm +0 -0
  161. package/_framework/System.Transactions.wasm +0 -0
  162. package/_framework/System.ValueTuple.wasm +0 -0
  163. package/_framework/System.Web.HttpUtility.wasm +0 -0
  164. package/_framework/System.Web.wasm +0 -0
  165. package/_framework/System.Windows.wasm +0 -0
  166. package/_framework/System.Xml.Linq.wasm +0 -0
  167. package/_framework/System.Xml.ReaderWriter.wasm +0 -0
  168. package/_framework/System.Xml.Serialization.wasm +0 -0
  169. package/_framework/System.Xml.XDocument.wasm +0 -0
  170. package/_framework/System.Xml.XPath.XDocument.wasm +0 -0
  171. package/_framework/System.Xml.XPath.wasm +0 -0
  172. package/_framework/System.Xml.XmlDocument.wasm +0 -0
  173. package/_framework/System.Xml.XmlSerializer.wasm +0 -0
  174. package/_framework/System.Xml.wasm +0 -0
  175. package/_framework/System.wasm +0 -0
  176. package/_framework/WasmPlayer.wasm +0 -0
  177. package/_framework/WindowsBase.wasm +0 -0
  178. package/_framework/dotnet.boot.js +179 -179
  179. package/_framework/dotnet.js +1 -1
  180. package/_framework/dotnet.native.js +3 -3
  181. package/_framework/dotnet.native.wasm +0 -0
  182. package/_framework/dotnet.runtime.js +1 -1
  183. package/_framework/mscorlib.wasm +0 -0
  184. package/_framework/netstandard.wasm +0 -0
  185. package/chrome.css +1 -1
  186. package/index.html +9 -9
  187. package/package.json +1 -1
  188. package/player.js +13 -5
  189. package/playercore.htm +1 -1
  190. package/playercore.js +57 -2
  191. package/wasm-player.js +141 -18
package/wasm-player.js CHANGED
@@ -161,6 +161,12 @@ window.addEventListener('pagehide', () => {
161
161
  // and never reassigned by a slot/file load.
162
162
  let originalGameBytes = null;
163
163
  let originalGameFilename = null;
164
+ // Bytes for every custom (non-built-in) Included Library the game's <include ref="..."/>
165
+ // elements need — see startGame's adjacentFiles param. Re-staged via stageAdjacentFiles()
166
+ // before every Bridge.Initialise/InitialiseWithSave call (initial boot and restartGameCore
167
+ // alike), since WasmPlayerBridge's own pending-file dictionary is consumed and cleared on
168
+ // each load.
169
+ let originalAdjacentFiles = null;
164
170
  // The pristine player chrome markup (playercore.htm), fetched once at boot
165
171
  // and reused verbatim by restartGame() so a mid-session restart gets exactly
166
172
  // the same clean slate as the initial boot, instead of the previous game's
@@ -204,6 +210,17 @@ function getResourceUrl(name) {
204
210
  });
205
211
  }
206
212
 
213
+ // Stages every custom Included Library's bytes into WasmPlayerBridge (one at a time — same
214
+ // [JSExport] array-marshalling limit as AddPublishAsset elsewhere) so the next
215
+ // Initialise/InitialiseWithSave call can resolve <include ref="..."/> elements the Editor's
216
+ // save left un-inlined (see WorldModel.GetLibraryStream). A no-op when the game has none.
217
+ function stageAdjacentFiles(files) {
218
+ if (!files) return;
219
+ for (const [name, bytes] of Object.entries(files)) {
220
+ Bridge.AddAdjacentFile(name, bytes);
221
+ }
222
+ }
223
+
207
224
  function ui_init() { }
208
225
 
209
226
  function sendEndWait() {
@@ -318,6 +335,7 @@ async function maybeGateOnActivation(gameBytes) {
318
335
  // and player.js can call into it without modification.
319
336
  window.WebPlayer = {
320
337
  gameId: null,
338
+ chromeStrings: null,
321
339
 
322
340
  initUI() { initPlayerUI(); },
323
341
 
@@ -374,6 +392,19 @@ window.WebPlayer = {
374
392
  // Exported bridge reference — set once WASM is loaded.
375
393
  var Bridge;
376
394
 
395
+ // The engine's load/initialise errors from the most recent Initialise call, if
396
+ // it failed — reads the JSON exported by WasmPlayerBridge.GetInitialiseErrorsJson
397
+ // (empty array when the last load succeeded). Used to put the real reason a game
398
+ // failed to load on the start screen instead of a generic message.
399
+ function getInitialiseErrors() {
400
+ try {
401
+ const parsed = JSON.parse(Bridge.GetInitialiseErrorsJson());
402
+ return Array.isArray(parsed) ? parsed : [];
403
+ } catch {
404
+ return [];
405
+ }
406
+ }
407
+
377
408
  function addPaperScript() {
378
409
  const canvas = document.getElementById('gridCanvas');
379
410
  const gridPanel = document.getElementById('gridPanel');
@@ -443,7 +474,7 @@ function swapInPlayerUi() {
443
474
  // beginning"/Load in an editor-preview session.
444
475
  let currentIsPreview = false;
445
476
 
446
- async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null, isPreview = false, recordWalkthrough = null, runWalkthrough = null) {
477
+ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null, isPreview = false, recordWalkthrough = null, runWalkthrough = null, adjacentFiles = null) {
447
478
  currentIsPreview = isPreview;
448
479
  const dotnetJsUrl = wasmPlayerScriptUrl
449
480
  ? new URL('_framework/dotnet.js', wasmPlayerScriptUrl).href
@@ -529,14 +560,36 @@ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null,
529
560
  // behaviour is unchanged.
530
561
  const startScreenEl = swapInPlayerUi();
531
562
 
563
+ stageAdjacentFiles(adjacentFiles);
532
564
  const ok = saveBytes
533
565
  ? await Bridge.InitialiseWithSave(gameBytes, filename, saveBytes)
534
566
  : await Bridge.Initialise(gameBytes, filename);
535
567
  if (!ok) {
536
- console.error('[Quest] Failed to initialise game');
537
- throw new Error('Failed to initialise game');
568
+ // The game file itself was fine (downloaded/picked), but the engine
569
+ // rejected its contents — same errors the Editor shows on load.
570
+ // Previously this threw, which left #qv-start (with its spinner)
571
+ // covering the screen forever and, on the boot paths without a
572
+ // catch handler (embedded export, editor preview, ?id=, ?url=),
573
+ // never showed the reason at all. Surface the actual errors on the
574
+ // start screen instead and let the caller know the game didn't start.
575
+ const errors = getInitialiseErrors();
576
+ console.error('[Quest] Failed to initialise game', errors);
577
+ // A live app (Play tab / editor preview) handed this game over via bc —
578
+ // it owns the file-picking UI, so don't re-offer the start-screen
579
+ // pickers; just show the error, editor-style.
580
+ showGameLoadError(errors, !bc);
581
+ return false;
538
582
  }
539
583
 
584
+ // Now that a WorldModel is live, resolve the game's own translated chrome
585
+ // strings (falls back to English for any key it doesn't define) and apply
586
+ // them to the dialog markup — this also keeps WebPlayer.chromeStrings
587
+ // current for the shared GameSaver in playercore.js (default save label,
588
+ // and the snapshot it stashes into the save record for next session's
589
+ // boot prompt — see startGame below).
590
+ WebPlayer.chromeStrings = JSON.parse(Bridge.GetChromeStringsJson());
591
+ applyChromeStrings(WebPlayer.chromeStrings);
592
+
540
593
  await maybeGateOnActivation(gameBytes);
541
594
 
542
595
  // Now that startup has actually succeeded, remove the start screen overlay
@@ -580,6 +633,8 @@ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null,
580
633
  } else if (runWalkthrough) {
581
634
  await runWalkthroughStandalone(runWalkthrough);
582
635
  }
636
+
637
+ return true;
583
638
  }
584
639
 
585
640
  // Guards restartGame against overlapping calls — e.g. impatiently clicking
@@ -635,11 +690,19 @@ async function restartGameCore(saveBytes) {
635
690
  await nextPaint();
636
691
 
637
692
  try {
693
+ stageAdjacentFiles(originalAdjacentFiles);
638
694
  const ok = saveBytes
639
695
  ? await Bridge.InitialiseWithSave(originalGameBytes, originalGameFilename, saveBytes)
640
696
  : await Bridge.Initialise(originalGameBytes, originalGameFilename);
641
697
  if (!ok) {
642
- showSavesError('Failed to load that save.');
698
+ // The engine rejected the game's contents again (or the save didn't
699
+ // apply) — include the actual error rather than the old generic
700
+ // "Failed to load that save.", which is wrong for a "Start from the
701
+ // beginning" restart whose failure has nothing to do with a save.
702
+ const errors = getInitialiseErrors();
703
+ showSavesError(errors.length
704
+ ? `Failed to load. ${errors.join(' ')}`
705
+ : 'Failed to load that save.');
643
706
  return;
644
707
  }
645
708
 
@@ -666,9 +729,10 @@ async function restartGameCore(saveBytes) {
666
729
  // Wraps initWasmPlayer with the boot-time "Continue / New Game" prompt: if
667
730
  // saves already exist for this game, ask before committing to either the
668
731
  // fresh game or a chosen save. Used by all boot entry points below.
669
- async function startGame(bytes, filename, bc = null, gameIdOverride = null, isPreview = false, recordWalkthrough = null, runWalkthrough = null) {
732
+ async function startGame(bytes, filename, bc = null, gameIdOverride = null, isPreview = false, recordWalkthrough = null, runWalkthrough = null, adjacentFiles = null) {
670
733
  originalGameBytes = bytes;
671
734
  originalGameFilename = filename;
735
+ originalAdjacentFiles = adjacentFiles;
672
736
  // gameIdOverride lets callers with a stronger identity than the filename
673
737
  // (e.g. the Text Adventures API's stable game id) use it instead.
674
738
  const gameId = gameIdOverride || computeGameId(filename);
@@ -684,6 +748,15 @@ async function startGame(bytes, filename, bc = null, gameIdOverride = null, isPr
684
748
  let saves = [];
685
749
  try { saves = await GameSaver.listSaves(gameId); } catch { saves = []; }
686
750
  if (saves.length > 0) {
751
+ // No WorldModel exists yet at this point (the WASM runtime isn't even
752
+ // booted), so the boot prompt can't resolve chrome strings live -
753
+ // instead, reuse whichever snapshot was captured the last time this
754
+ // game was saved (see GameSaver.save's chromeStrings field).
755
+ const snapshot = saves.find(s => s.chromeStrings)?.chromeStrings;
756
+ if (snapshot) {
757
+ WebPlayer.chromeStrings = snapshot;
758
+ applyChromeStrings(snapshot);
759
+ }
687
760
  const choice = await openSavesDialog('boot', gameId);
688
761
  if (choice.type === 'load') {
689
762
  saveBytes = await GameSaver.load(choice.slotIndex, gameId);
@@ -691,7 +764,12 @@ async function startGame(bytes, filename, bc = null, gameIdOverride = null, isPr
691
764
  }
692
765
  }
693
766
 
694
- await initWasmPlayer(bytes, filename, bc, saveBytes, isPreview, recordWalkthrough, runWalkthrough);
767
+ // Returns true if the game started, false if it downloaded/picked fine but
768
+ // the engine rejected its contents (the error is shown on the start screen
769
+ // by initWasmPlayer in that case) — callers with post-success work (e.g.
770
+ // persisting the active URL) should key off this. Genuine setup failures
771
+ // (fetch, WASM boot) still throw as before.
772
+ return initWasmPlayer(bytes, filename, bc, saveBytes, isPreview, recordWalkthrough, runWalkthrough, adjacentFiles);
695
773
  }
696
774
 
697
775
  // ── Start screen helpers ──────────────────────────────────────────────────────
@@ -758,16 +836,18 @@ function renderSavesList(saves, mode) {
758
836
  const list = document.getElementById('qv-saves-list');
759
837
  if (!list) return;
760
838
  if (!saves.length) {
761
- list.innerHTML = '<li class="text-sm text-surface-500">No saved games yet.</li>';
839
+ const noSavesText = WebPlayer.chromeStrings?.NoSavedGamesYet ?? 'No saved games yet.';
840
+ list.innerHTML = `<li class="text-sm text-surface-500">${_esc(noSavesText)}</li>`;
762
841
  return;
763
842
  }
764
843
  // s.name already carries a human-readable date/time when the user didn't
765
844
  // type a custom one (see GameSaver.save's default label) — don't also
766
845
  // render s.timestamp separately, or the same moment shows up twice in
767
846
  // two different formats.
847
+ const deleteLabel = _esc(WebPlayer.chromeStrings?.DeleteSave ?? 'Delete');
768
848
  list.innerHTML = saves.map(s => {
769
849
  const deleteBtn = mode === 'manage'
770
- ? `<button type="button" class="btn-icon preset-tonal-error" data-delete-slot="${s.slotIndex}" aria-label="Delete">`
850
+ ? `<button type="button" class="btn-icon preset-tonal-error" data-delete-slot="${s.slotIndex}" aria-label="${deleteLabel}">`
771
851
  + `<svg class="qv-icon" aria-hidden="true"><use href="#trash-2"></use></svg></button>`
772
852
  : '';
773
853
  return `<li class="flex items-center justify-between gap-2">`
@@ -830,7 +910,8 @@ async function loadSaveFromFile(file) {
830
910
  const uploadedIdentity = uploadedIfid || (originalAttr && computeGameId(originalAttr));
831
911
 
832
912
  if (!uploadedIdentity || currentIdentity.toLowerCase() !== uploadedIdentity.toLowerCase()) {
833
- showSavesError('This save is for a different game — open that game first, then try again.');
913
+ showSavesError(WebPlayer.chromeStrings?.SaveWrongGame
914
+ ?? 'This save is for a different game — open that game first, then try again.');
834
915
  return;
835
916
  }
836
917
  hideSavesError();
@@ -866,7 +947,7 @@ function ensureSavesDialogWired() {
866
947
  // overlapping calls (see restartInProgress's doc comment), but
867
948
  // without this there was no visible feedback at all inviting
868
949
  // exactly the impatient re-click that guard exists for.
869
- withBusyButton(e.currentTarget, 'Restarting…', () => restartGame(null));
950
+ withBusyButton(e.currentTarget, WebPlayer.chromeStrings?.RestartingBusy ?? 'Restarting…', () => restartGame(null));
870
951
  });
871
952
 
872
953
  document.getElementById('qv-saves-list').addEventListener('click', async (e) => {
@@ -886,8 +967,9 @@ function ensureSavesDialogWired() {
886
967
  }
887
968
  const delBtn = e.target.closest('[data-delete-slot]');
888
969
  if (delBtn) {
889
- const name = delBtn.closest('li')?.querySelector('[data-slot]')?.textContent ?? 'this save';
890
- if (!confirm(`Delete "${name}"? This can't be undone.`)) return;
970
+ const name = delBtn.closest('li')?.querySelector('[data-slot]')?.textContent ?? (WebPlayer.chromeStrings?.UnnamedSave ?? 'this save');
971
+ const confirmTemplate = WebPlayer.chromeStrings?.DeleteSaveConfirm ?? 'Delete "[name]"? This can\'t be undone.';
972
+ if (!confirm(confirmTemplate.replace('[name]', name))) return;
891
973
  await withBusyButton(delBtn, '', async () => {
892
974
  await GameSaver.deleteSlot(Number(delBtn.dataset.deleteSlot), WebPlayer.gameId);
893
975
  });
@@ -897,7 +979,7 @@ function ensureSavesDialogWired() {
897
979
 
898
980
  document.getElementById('qv-saves-save-new').addEventListener('click', async (e) => {
899
981
  const input = document.getElementById('qv-saves-name-input');
900
- await withBusyButton(e.currentTarget, 'Saving…', async () => {
982
+ await withBusyButton(e.currentTarget, WebPlayer.chromeStrings?.SavingBusy ?? 'Saving…', async () => {
901
983
  await GameSaver.save(input.value.trim() || undefined);
902
984
  });
903
985
  input.value = '';
@@ -905,7 +987,7 @@ function ensureSavesDialogWired() {
905
987
  });
906
988
 
907
989
  document.getElementById('qv-saves-download').addEventListener('click', (e) =>
908
- withBusyButton(e.currentTarget, 'Saving…', downloadSaveToFile));
990
+ withBusyButton(e.currentTarget, WebPlayer.chromeStrings?.SavingBusy ?? 'Saving…', downloadSaveToFile));
909
991
 
910
992
  const uploadBtn = document.getElementById('qv-saves-upload-btn');
911
993
  const fileInput = document.getElementById('qv-saves-file-input');
@@ -1814,6 +1896,44 @@ function showError(downloadUrl, isLocalFile, error) {
1814
1896
  wireStartScreen();
1815
1897
  }
1816
1898
 
1899
+ // The game file itself downloaded/picked fine but the engine rejected its
1900
+ // contents — a game-content error (parse failure, unknown function, etc.), the
1901
+ // same list the Editor surfaces on load, not a network/HTTP problem. Shows that
1902
+ // actual error text on the start screen and re-shows the pickers, so the player
1903
+ // doesn't sit on the loading spinner forever (what the old path did: it wrote
1904
+ // the errors to the output pane, which sits hidden under the #qv-start overlay,
1905
+ // then threw before the overlay was removed).
1906
+ //
1907
+ // showPickers=false is for sessions launched by the Quest Viva app itself — the
1908
+ // Play tab (source=local) and editor preview (source=editor) — where the app
1909
+ // owns the file-picking UI, so the start screen's "You can try a different file
1910
+ // below" pickers are irrelevant there. Just the error is shown, in the same
1911
+ // header+bullets format the Editor uses for a load-time error (see
1912
+ // EditorController.cs's "Failed to load game due to the following errors:"),
1913
+ // with a blank line between the header and the error message.
1914
+ function showGameLoadError(errors, showPickers = true) {
1915
+ document.documentElement.classList.remove('qv-booting');
1916
+ const pickers = document.getElementById('qv-pickers');
1917
+ const msg = document.getElementById('qv-loading-msg');
1918
+ const errorEl = document.getElementById('qv-error');
1919
+ if (msg) msg.style.display = 'none';
1920
+ if (pickers) pickers.style.display = showPickers ? 'block' : 'none';
1921
+ if (!errorEl) return;
1922
+ const list = errors.length ? errors : ['Unknown error'];
1923
+ errorEl.style.whiteSpace = showPickers ? '' : 'pre-wrap';
1924
+ if (showPickers) {
1925
+ errorEl.innerHTML = '<strong>This game couldn\'t be started.</strong> '
1926
+ + 'The game file loaded, but Quest Viva reported a problem with its contents:<br/>'
1927
+ + list.map(_esc).join('<br/>')
1928
+ + '<br/>You can try a different file below.';
1929
+ } else {
1930
+ errorEl.innerHTML = _esc('Failed to load game due to the following errors:\n\n'
1931
+ + list.map(e => '* ' + e).join('\n'));
1932
+ }
1933
+ errorEl.style.display = 'block';
1934
+ wireStartScreen();
1935
+ }
1936
+
1817
1937
  // Keeps the address bar in sync with the game that's actually loaded (or being
1818
1938
  // attempted), so a refresh reproduces it. `name`/`value` set the active source
1819
1939
  // param; both `id` and `url` are cleared first since only one can be current.
@@ -1858,8 +1978,11 @@ function wireStartScreen() {
1858
1978
  showLoading();
1859
1979
  try {
1860
1980
  const { bytes, filename } = await fetchGameBytes(url);
1861
- await startGame(bytes, filename);
1862
- setLocationParam('url', url);
1981
+ const ok = await startGame(bytes, filename);
1982
+ // Don't persist the URL if the game itself failed to load — the
1983
+ // engine error is already on screen, and keeping the URL would make
1984
+ // a refresh re-run the same broken load.
1985
+ if (ok) setLocationParam('url', url);
1863
1986
  } catch (err) {
1864
1987
  showError(url, false, err);
1865
1988
  }
@@ -1923,7 +2046,7 @@ async function fetchGameBytes(url) {
1923
2046
  bc.onmessage = async ({ data }) => {
1924
2047
  if (data.type === 'game') {
1925
2048
  bc.onmessage = null;
1926
- await startGame(data.bytes, data.filename, bc, null, true, data.recordWalkthrough ?? null, data.runWalkthrough ?? null);
2049
+ await startGame(data.bytes, data.filename, bc, null, true, data.recordWalkthrough ?? null, data.runWalkthrough ?? null, data.adjacentFiles ?? null);
1927
2050
  }
1928
2051
  };
1929
2052
  return;
@@ -1961,7 +2084,7 @@ async function fetchGameBytes(url) {
1961
2084
  // reassigns bc.onmessage itself to keep answering
1962
2085
  // 'resource-response' messages for the rest of the session.
1963
2086
  bc.onmessage = null;
1964
- await startGame(data.bytes, data.filename, bc);
2087
+ await startGame(data.bytes, data.filename, bc, null, false, null, null, data.adjacentFiles ?? null);
1965
2088
  }
1966
2089
  };
1967
2090
  return;