@textadventures/quest-viva-wasmplayer 6.2.0-beta.1 → 6.2.0-beta.2
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/System.Collections.wasm +0 -0
- package/_framework/System.Private.CoreLib.wasm +0 -0
- package/_framework/System.Text.Json.wasm +0 -0
- package/_framework/WasmPlayer.wasm +0 -0
- package/_framework/dotnet.js +16 -16
- package/_framework/dotnet.native.wasm +0 -0
- package/chrome.css +1 -1
- package/index.html +11 -11
- package/package.json +1 -1
- package/v2/map.js +1 -1
- package/v2/v2.css +1 -1
- package/v2/v2.js +1 -1
- package/wasm-player.js +91 -7
package/wasm-player.js
CHANGED
|
@@ -110,6 +110,24 @@ function playBlockedMedia() {
|
|
|
110
110
|
|
|
111
111
|
const pendingResources = new Map();
|
|
112
112
|
let editorChannel = null;
|
|
113
|
+
|
|
114
|
+
// The "Show in editor" link the Editor's play-test puts after a script error
|
|
115
|
+
// (WasmPlayerBridge.ScriptErrorLocationHtml): the Editor selects the element
|
|
116
|
+
// and shows the attribute, as it does for a Check game problem.
|
|
117
|
+
document.addEventListener('click', (event) => {
|
|
118
|
+
const link = event.target instanceof Element ? event.target.closest('a.qv-show-in-editor') : null;
|
|
119
|
+
if (!link) return;
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
if (!editorChannel) return;
|
|
122
|
+
editorChannel.postMessage({
|
|
123
|
+
type: 'show-in-editor',
|
|
124
|
+
element: link.dataset.element,
|
|
125
|
+
attribute: link.dataset.attribute ?? null,
|
|
126
|
+
});
|
|
127
|
+
// The play-test opened in its own tab: bring the Editor's back to the front, where the
|
|
128
|
+
// browser lets it.
|
|
129
|
+
try { window.opener?.focus(); } catch { /* no opener, or not allowed */ }
|
|
130
|
+
});
|
|
113
131
|
let resourceRoot = null;
|
|
114
132
|
|
|
115
133
|
// ── Walkthrough recording/playback status banner ────────────────────────────
|
|
@@ -811,7 +829,6 @@ window.WebPlayer = {
|
|
|
811
829
|
await playerTurn(() => Bridge.SendCommand(command, tickCount, metadataJson));
|
|
812
830
|
canSendCommand = true;
|
|
813
831
|
recordStep(command);
|
|
814
|
-
refreshDebuggerAfterTurn();
|
|
815
832
|
},
|
|
816
833
|
|
|
817
834
|
async uiChoice(choice) { await playerTurn(() => Bridge.SetMenuResponse(choice)); recordStep(`menu:${choice}`); },
|
|
@@ -820,12 +837,16 @@ window.WebPlayer = {
|
|
|
820
837
|
// A timer firing mid-change would run its script against a half-built UI.
|
|
821
838
|
await interfaceChangesApplied;
|
|
822
839
|
turnsInFlight++;
|
|
840
|
+
const errorsBefore = Bridge.GetRecentErrorCount();
|
|
823
841
|
try {
|
|
824
842
|
await Bridge.Tick(tickCount);
|
|
825
843
|
} finally {
|
|
826
844
|
turnsInFlight--;
|
|
827
845
|
scheduleInterfaceChanges();
|
|
828
846
|
notifyIfTurnOver();
|
|
847
|
+
// Only when a timer's script failed: this runs every second, and redrawing an open
|
|
848
|
+
// Debugger that often would lose what's being typed in its search or override box.
|
|
849
|
+
if (Bridge.GetRecentErrorCount() !== errorsBefore) refreshDebuggerAfterTurn();
|
|
829
850
|
}
|
|
830
851
|
},
|
|
831
852
|
async uiEndWait() { await playerTurn(() => Bridge.FinishWait()); },
|
|
@@ -836,7 +857,6 @@ window.WebPlayer = {
|
|
|
836
857
|
await playerTurn(() => Bridge.SendEvent(eventName, param));
|
|
837
858
|
canSendCommand = true;
|
|
838
859
|
recordStep(`event:${eventName};${param ?? ''}`);
|
|
839
|
-
refreshDebuggerAfterTurn();
|
|
840
860
|
},
|
|
841
861
|
|
|
842
862
|
async uiSaveGame(html) {
|
|
@@ -866,6 +886,9 @@ async function playerTurn(run) {
|
|
|
866
886
|
window.notifyQuestUITurn?.(false);
|
|
867
887
|
scheduleInterfaceChanges();
|
|
868
888
|
notifyIfTurnOver();
|
|
889
|
+
// Every kind of turn (a command, a menu choice, the end of a wait or pause, an answer)
|
|
890
|
+
// can change what the Debugger shows, and above all add to its Errors tab.
|
|
891
|
+
refreshDebuggerAfterTurn();
|
|
869
892
|
}
|
|
870
893
|
}
|
|
871
894
|
|
|
@@ -1355,6 +1378,7 @@ async function initWasmPlayer(gameBytes, filename, bc = null, saveBytes = null,
|
|
|
1355
1378
|
const seed = Number.parseInt(testParams.get('seed') ?? '', 10);
|
|
1356
1379
|
if (Number.isInteger(seed)) Bridge.SetRandomSeed(seed);
|
|
1357
1380
|
if (testParams.has('transcript')) Bridge.StartTranscriptCapture();
|
|
1381
|
+
if (isPreview) Bridge.SetEditorPlayTest();
|
|
1358
1382
|
manualClock = testParams.get('clock') === 'manual';
|
|
1359
1383
|
window.QuestVivaTest = {
|
|
1360
1384
|
takeTranscript: () => JSON.parse(Bridge.TakeTranscriptJson()),
|
|
@@ -1631,6 +1655,8 @@ async function restartGameCore(saveBytes) {
|
|
|
1631
1655
|
WebPlayer.setCanSave(!currentIsPreview);
|
|
1632
1656
|
WebPlayer.setCanDebug((currentIsPreview || currentAllowDebug) && Bridge.IsDebugEnabled());
|
|
1633
1657
|
await Bridge.Begin();
|
|
1658
|
+
// An open Debugger would otherwise show the old session until the next turn.
|
|
1659
|
+
refreshDebuggerAfterTurn();
|
|
1634
1660
|
} finally {
|
|
1635
1661
|
restartingEl?.classList.add('hidden');
|
|
1636
1662
|
}
|
|
@@ -2582,12 +2608,57 @@ function wireDebuggerColumnResize(startEvent) {
|
|
|
2582
2608
|
// renderDebuggerOverridePanel).
|
|
2583
2609
|
const DEBUGGER_OVERRIDE_HINT = 'Edit and Apply to change this value for the rest of the session';
|
|
2584
2610
|
|
|
2611
|
+
// The Errors tab lists the script errors printed this session (#2335), from
|
|
2612
|
+
// WasmPlayerBridge.GetRecentErrorsJson: { Total, Errors } with Errors oldest
|
|
2613
|
+
// first, each a RuntimeError (Message, Element, Attribute, Object, Filename,
|
|
2614
|
+
// Statement; only Message for an error outside a script, such as one from
|
|
2615
|
+
// handling a command). It has no object list, so it takes the whole width.
|
|
2616
|
+
const DEBUGGER_ERRORS_TAB = 'Errors';
|
|
2617
|
+
|
|
2585
2618
|
function renderDebuggerTabs(types) {
|
|
2586
2619
|
const tabs = document.getElementById('qv-debugger-tabs');
|
|
2587
|
-
const allTabs = ['Walkthrough', ...types];
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2620
|
+
const allTabs = ['Walkthrough', DEBUGGER_ERRORS_TAB, ...types];
|
|
2621
|
+
const errorCount = Bridge.GetRecentErrorCount();
|
|
2622
|
+
tabs.innerHTML = allTabs.map(tab => {
|
|
2623
|
+
const label = tab === DEBUGGER_ERRORS_TAB && errorCount ? `${tab} (${errorCount})` : tab;
|
|
2624
|
+
return `<button type="button" class="btn btn-sm ${tab === debuggerActiveTab ? 'preset-filled-primary-700-300' : 'preset-tonal-surface'}" data-tab="${_esc(tab)}">${_esc(label)}</button>`;
|
|
2625
|
+
}).join('');
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
// Newest first. In the Editor's play-test (editorChannel is set), each error
|
|
2629
|
+
// with a known element gets the same "Show in editor" link the play-test
|
|
2630
|
+
// prints after the error itself; the document click handler near the top of
|
|
2631
|
+
// this file sends it to the Editor.
|
|
2632
|
+
function renderDebuggerErrorsDetail() {
|
|
2633
|
+
const detail = document.getElementById('qv-debugger-detail');
|
|
2634
|
+
const { Total: total, Errors: errors } = JSON.parse(Bridge.GetRecentErrorsJson());
|
|
2635
|
+
if (!errors.length) {
|
|
2636
|
+
detail.innerHTML = '<p class="text-surface-700-300">No script errors so far.</p>';
|
|
2637
|
+
return;
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
const rows = errors.slice().reverse().map(error => {
|
|
2641
|
+
let where = '';
|
|
2642
|
+
if (error.Element) {
|
|
2643
|
+
where = `In <b>${_esc(error.Attribute ? `${error.Element} › ${error.Attribute}` : error.Element)}</b>`;
|
|
2644
|
+
if (error.Object) where += ` (for ${_esc(error.Object)})`;
|
|
2645
|
+
if (error.Filename) where += ` in ${_esc(error.Filename)}`;
|
|
2646
|
+
if (editorChannel) {
|
|
2647
|
+
where += ` · <a href="#" class="qv-show-in-editor" data-element="${_esc(error.Element)}"`
|
|
2648
|
+
+ (error.Attribute ? ` data-attribute="${_esc(error.Attribute)}"` : '')
|
|
2649
|
+
+ '>Show in editor</a>';
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
return '<li class="qv-debugger-error">'
|
|
2653
|
+
+ `<div class="qv-debugger-error-message">${_esc(error.Message)}</div>`
|
|
2654
|
+
+ (where ? `<div class="qv-debugger-error-where">${where}</div>` : '')
|
|
2655
|
+
+ (error.Statement ? `<div class="qv-debugger-error-statement">at: <code>${_esc(error.Statement)}</code></div>` : '')
|
|
2656
|
+
+ '</li>';
|
|
2657
|
+
}).join('');
|
|
2658
|
+
const note = total > errors.length
|
|
2659
|
+
? `<p class="text-xs text-surface-700-300 mb-2">Showing the last ${errors.length} of ${total} errors.</p>`
|
|
2660
|
+
: '';
|
|
2661
|
+
detail.innerHTML = `<div class="qv-debugger-scroll">${note}<ol class="qv-debugger-errors">${rows}</ol></div>`;
|
|
2591
2662
|
}
|
|
2592
2663
|
|
|
2593
2664
|
// Returns the rendered items — refreshDebuggerAfterTurn uses this to notice
|
|
@@ -2598,6 +2669,13 @@ function renderDebuggerList() {
|
|
|
2598
2669
|
const sortLabel = document.querySelector('#qv-debugger-list-sort .qv-debugger-sort-label');
|
|
2599
2670
|
if (sortLabel) sortLabel.textContent = 'Name' + (debuggerListSortAscending ? ' ▲' : ' ▼');
|
|
2600
2671
|
|
|
2672
|
+
const errorsView = debuggerActiveTab === DEBUGGER_ERRORS_TAB;
|
|
2673
|
+
document.getElementById('qv-debugger-panes').classList.toggle('qv-debugger-errors-view', errorsView);
|
|
2674
|
+
if (errorsView) {
|
|
2675
|
+
list.innerHTML = '';
|
|
2676
|
+
return [];
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2601
2679
|
const items = debuggerActiveTab === 'Walkthrough'
|
|
2602
2680
|
? JSON.parse(Bridge.GetWalkthroughNamesJson())
|
|
2603
2681
|
: JSON.parse(Bridge.GetDebugObjectsJson(debuggerActiveTab));
|
|
@@ -2794,6 +2872,11 @@ function renderDebuggerOverridePanel(attr, item) {
|
|
|
2794
2872
|
|
|
2795
2873
|
function renderDebuggerDetail() {
|
|
2796
2874
|
const detail = document.getElementById('qv-debugger-detail');
|
|
2875
|
+
if (debuggerActiveTab === DEBUGGER_ERRORS_TAB) {
|
|
2876
|
+
renderDebuggerErrorsDetail();
|
|
2877
|
+
return;
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2797
2880
|
if (!debuggerSelectedItem) {
|
|
2798
2881
|
detail.innerHTML = '<p class="text-surface-700-300">Select an item to view details.</p>';
|
|
2799
2882
|
return;
|
|
@@ -2806,7 +2889,8 @@ function renderDebuggerDetail() {
|
|
|
2806
2889
|
}
|
|
2807
2890
|
}
|
|
2808
2891
|
|
|
2809
|
-
// Called after every turn (
|
|
2892
|
+
// Called after every turn (playerTurn, and a timer tick that reported an
|
|
2893
|
+
// error), and after a restart, now that
|
|
2810
2894
|
// the dialog is non-modal and can be left open while playing (see
|
|
2811
2895
|
// wireDebuggerButton's doc comment) — without this, it only ever reflected
|
|
2812
2896
|
// whatever the game's state was at the moment an object/tab was last
|