@textadventures/quest-viva-wasmplayer 6.0.4 → 6.1.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.
Files changed (156) hide show
  1. package/_framework/Common.wasm +0 -0
  2. package/_framework/Engine.wasm +0 -0
  3. package/_framework/ExtendedNumerics.BigDecimal.wasm +0 -0
  4. package/_framework/Legacy.wasm +0 -0
  5. package/_framework/Microsoft.Extensions.Logging.Abstractions.wasm +0 -0
  6. package/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
  7. package/_framework/NCalc.Core.wasm +0 -0
  8. package/_framework/NCalc.Domain.wasm +0 -0
  9. package/_framework/NCalc.Parser.wasm +0 -0
  10. package/_framework/Parlot.wasm +0 -0
  11. package/_framework/PlayerCore.wasm +0 -0
  12. package/_framework/System.Collections.Immutable.wasm +0 -0
  13. package/_framework/System.Collections.NonGeneric.wasm +0 -0
  14. package/_framework/System.Collections.Specialized.wasm +0 -0
  15. package/_framework/System.Collections.wasm +0 -0
  16. package/_framework/System.ComponentModel.Annotations.wasm +0 -0
  17. package/_framework/System.ComponentModel.Primitives.wasm +0 -0
  18. package/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
  19. package/_framework/System.ComponentModel.wasm +0 -0
  20. package/_framework/System.IO.Compression.wasm +0 -0
  21. package/_framework/System.IO.Pipelines.wasm +0 -0
  22. package/_framework/System.Linq.Expressions.wasm +0 -0
  23. package/_framework/System.Linq.wasm +0 -0
  24. package/_framework/System.Memory.wasm +0 -0
  25. package/_framework/System.Net.Http.wasm +0 -0
  26. package/_framework/System.Net.Primitives.wasm +0 -0
  27. package/_framework/System.ObjectModel.wasm +0 -0
  28. package/_framework/System.Private.CoreLib.wasm +0 -0
  29. package/_framework/System.Private.Uri.wasm +0 -0
  30. package/_framework/System.Private.Xml.Linq.wasm +0 -0
  31. package/_framework/System.Private.Xml.wasm +0 -0
  32. package/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  33. package/_framework/System.Runtime.Numerics.wasm +0 -0
  34. package/_framework/System.Security.Cryptography.wasm +0 -0
  35. package/_framework/System.Text.Encoding.CodePages.wasm +0 -0
  36. package/_framework/System.Text.Encodings.Web.wasm +0 -0
  37. package/_framework/System.Text.Json.wasm +0 -0
  38. package/_framework/System.Text.RegularExpressions.wasm +0 -0
  39. package/_framework/System.Xml.Linq.wasm +0 -0
  40. package/_framework/System.wasm +0 -0
  41. package/_framework/WasmPlayer.wasm +0 -0
  42. package/_framework/dotnet.js +328 -2
  43. package/_framework/dotnet.native.js +1919 -2049
  44. package/_framework/dotnet.native.wasm +0 -0
  45. package/_framework/dotnet.runtime.js +1 -1
  46. package/_framework/icudt_CJK.dat +0 -0
  47. package/_framework/icudt_EFIGS.dat +0 -0
  48. package/_framework/icudt_no_CJK.dat +0 -0
  49. package/chrome.css +20 -2
  50. package/export-manifest.json +1 -1
  51. package/fonts/courier-prime/LICENSE.txt +93 -0
  52. package/fonts/courier-prime/latin-400-italic.woff2 +0 -0
  53. package/fonts/courier-prime/latin-400-normal.woff2 +0 -0
  54. package/fonts/courier-prime/latin-700-italic.woff2 +0 -0
  55. package/fonts/courier-prime/latin-700-normal.woff2 +0 -0
  56. package/fonts/courier-prime/latin-ext-400-italic.woff2 +0 -0
  57. package/fonts/courier-prime/latin-ext-400-normal.woff2 +0 -0
  58. package/fonts/courier-prime/latin-ext-700-italic.woff2 +0 -0
  59. package/fonts/courier-prime/latin-ext-700-normal.woff2 +0 -0
  60. package/fonts/fonts.css +500 -0
  61. package/fonts/literata/LICENSE.txt +93 -0
  62. package/fonts/literata/cyrillic-400-italic.woff2 +0 -0
  63. package/fonts/literata/cyrillic-400-normal.woff2 +0 -0
  64. package/fonts/literata/cyrillic-700-italic.woff2 +0 -0
  65. package/fonts/literata/cyrillic-700-normal.woff2 +0 -0
  66. package/fonts/literata/cyrillic-ext-400-italic.woff2 +0 -0
  67. package/fonts/literata/cyrillic-ext-400-normal.woff2 +0 -0
  68. package/fonts/literata/cyrillic-ext-700-italic.woff2 +0 -0
  69. package/fonts/literata/cyrillic-ext-700-normal.woff2 +0 -0
  70. package/fonts/literata/greek-400-italic.woff2 +0 -0
  71. package/fonts/literata/greek-400-normal.woff2 +0 -0
  72. package/fonts/literata/greek-700-italic.woff2 +0 -0
  73. package/fonts/literata/greek-700-normal.woff2 +0 -0
  74. package/fonts/literata/greek-ext-400-italic.woff2 +0 -0
  75. package/fonts/literata/greek-ext-400-normal.woff2 +0 -0
  76. package/fonts/literata/greek-ext-700-italic.woff2 +0 -0
  77. package/fonts/literata/greek-ext-700-normal.woff2 +0 -0
  78. package/fonts/literata/latin-400-italic.woff2 +0 -0
  79. package/fonts/literata/latin-400-normal.woff2 +0 -0
  80. package/fonts/literata/latin-700-italic.woff2 +0 -0
  81. package/fonts/literata/latin-700-normal.woff2 +0 -0
  82. package/fonts/literata/latin-ext-400-italic.woff2 +0 -0
  83. package/fonts/literata/latin-ext-400-normal.woff2 +0 -0
  84. package/fonts/literata/latin-ext-700-italic.woff2 +0 -0
  85. package/fonts/literata/latin-ext-700-normal.woff2 +0 -0
  86. package/fonts/literata/vietnamese-400-italic.woff2 +0 -0
  87. package/fonts/literata/vietnamese-400-normal.woff2 +0 -0
  88. package/fonts/literata/vietnamese-700-italic.woff2 +0 -0
  89. package/fonts/literata/vietnamese-700-normal.woff2 +0 -0
  90. package/fonts/nunito/LICENSE.txt +93 -0
  91. package/fonts/nunito/cyrillic-400-italic.woff2 +0 -0
  92. package/fonts/nunito/cyrillic-400-normal.woff2 +0 -0
  93. package/fonts/nunito/cyrillic-700-italic.woff2 +0 -0
  94. package/fonts/nunito/cyrillic-700-normal.woff2 +0 -0
  95. package/fonts/nunito/cyrillic-ext-400-italic.woff2 +0 -0
  96. package/fonts/nunito/cyrillic-ext-400-normal.woff2 +0 -0
  97. package/fonts/nunito/cyrillic-ext-700-italic.woff2 +0 -0
  98. package/fonts/nunito/cyrillic-ext-700-normal.woff2 +0 -0
  99. package/fonts/nunito/latin-400-italic.woff2 +0 -0
  100. package/fonts/nunito/latin-400-normal.woff2 +0 -0
  101. package/fonts/nunito/latin-700-italic.woff2 +0 -0
  102. package/fonts/nunito/latin-700-normal.woff2 +0 -0
  103. package/fonts/nunito/latin-ext-400-italic.woff2 +0 -0
  104. package/fonts/nunito/latin-ext-400-normal.woff2 +0 -0
  105. package/fonts/nunito/latin-ext-700-italic.woff2 +0 -0
  106. package/fonts/nunito/latin-ext-700-normal.woff2 +0 -0
  107. package/fonts/nunito/vietnamese-400-italic.woff2 +0 -0
  108. package/fonts/nunito/vietnamese-400-normal.woff2 +0 -0
  109. package/fonts/nunito/vietnamese-700-italic.woff2 +0 -0
  110. package/fonts/nunito/vietnamese-700-normal.woff2 +0 -0
  111. package/fonts/special-elite/LICENSE.txt +201 -0
  112. package/fonts/special-elite/latin-400-normal.woff2 +0 -0
  113. package/fonts/special-elite/latin-ext-400-normal.woff2 +0 -0
  114. package/fonts/vt323/LICENSE.txt +93 -0
  115. package/fonts/vt323/latin-400-normal.woff2 +0 -0
  116. package/fonts/vt323/latin-ext-400-normal.woff2 +0 -0
  117. package/fonts/vt323/vietnamese-400-normal.woff2 +0 -0
  118. package/game-saver.js +211 -0
  119. package/index.html +140 -52
  120. package/legacy/adapter.js +107 -0
  121. package/{grid.js → legacy/grid.js} +3 -0
  122. package/{player.js → legacy/player.js} +37 -62
  123. package/{playercore.css → legacy/playercore.css} +115 -0
  124. package/{playercore.htm → legacy/playercore.htm} +14 -13
  125. package/{playercore.js → legacy/playercore.js} +188 -252
  126. package/legacy/questui.js +515 -0
  127. package/package.json +1 -1
  128. package/v2/map.js +1 -0
  129. package/v2/player.htm +59 -0
  130. package/v2/v2.css +1 -0
  131. package/v2/v2.js +1 -0
  132. package/wasm-player.js +1359 -284
  133. package/.stamp +0 -0
  134. package/WasmPlayer.runtimeconfig.json +0 -46
  135. package/_framework/System.Collections.Concurrent.wasm +0 -0
  136. package/_framework/dotnet.boot.js +0 -284
  137. /package/{lib → legacy/lib}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  138. /package/{lib → legacy/lib}/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  139. /package/{lib → legacy/lib}/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  140. /package/{lib → legacy/lib}/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  141. /package/{lib → legacy/lib}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  142. /package/{lib → legacy/lib}/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  143. /package/{lib → legacy/lib}/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  144. /package/{lib → legacy/lib}/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  145. /package/{lib → legacy/lib}/images/ui-icons_217bc0_256x240.png +0 -0
  146. /package/{lib → legacy/lib}/images/ui-icons_2e83ff_256x240.png +0 -0
  147. /package/{lib → legacy/lib}/images/ui-icons_469bdd_256x240.png +0 -0
  148. /package/{lib → legacy/lib}/images/ui-icons_6da8d5_256x240.png +0 -0
  149. /package/{lib → legacy/lib}/images/ui-icons_cd0a0a_256x240.png +0 -0
  150. /package/{lib → legacy/lib}/images/ui-icons_d8e7f3_256x240.png +0 -0
  151. /package/{lib → legacy/lib}/images/ui-icons_f9bd01_256x240.png +0 -0
  152. /package/{lib → legacy/lib}/jquery-2.1.1.min.js +0 -0
  153. /package/{lib → legacy/lib}/jquery-ui.min.css +0 -0
  154. /package/{lib → legacy/lib}/jquery-ui.min.js +0 -0
  155. /package/{lib → legacy/lib}/jquery.multi-open-accordion-1.5.3.js +0 -0
  156. /package/{lib → legacy/lib}/paper.js +0 -0
@@ -0,0 +1,515 @@
1
+ // QuestUI for the legacy UI: the 610 UI contract (docs/ui-v2-contract.md) implemented as a thin
2
+ // layer over playercore.js/player.js. 610 games play on this UI until v2 becomes their default,
3
+ // and games with game.classicinterface play on it for good, so 610 Core's JS.QuestUI.* calls must
4
+ // work here too.
5
+ //
6
+ // Contract rules that shape this file:
7
+ // - Unknown names (parts, panes, tokens, kinds, events) are ignored, never an error.
8
+ // - Calls describe intent. Where legacy has no equivalent (e.g. the status-bar part), the call is
9
+ // accepted and does nothing.
10
+ // - Additions only: nothing here may be removed or change meaning once 6.1 ships.
11
+ //
12
+ // Legacy's existing behaviour doesn't change: pre-610 games never call QuestUI. The only edits
13
+ // outside this file are the data-qv-part attributes in playercore.htm, the map-interaction check
14
+ // in grid.js, and wasm-player.js's reset and turn hooks.
15
+
16
+ (function () {
17
+ "use strict";
18
+
19
+ // Each pane is a label/accordion pair, or a single div for the command and custom status
20
+ // panes. Author panes from addPane() are added to this map.
21
+ var builtInPanes = {
22
+ inventory: ["#inventoryLabel", "#inventoryAccordion"],
23
+ objects: ["#placesObjectsLabel", "#placesObjectsAccordion"],
24
+ status: ["#statusVarsLabel", "#statusVarsAccordion"],
25
+ compass: ["#compassLabel", "#compassAccordion"],
26
+ commands: ["#commandPane"],
27
+ customstatus: ["#customStatusPane"]
28
+ };
29
+ var authorPanes = {};
30
+
31
+ function paneSelectors(name) {
32
+ return builtInPanes[name] || authorPanes[name] || null;
33
+ }
34
+
35
+ // jQuery's .show() sets an inline display, which a stylesheet rule can't beat unless it's
36
+ // !important. So a part the game hid stays hidden even when legacy code later re-shows it
37
+ // (updateStatus re-showing the status pane, setPanelContents the picture frame, ...).
38
+ var forceHiddenClass = "qv-force-hidden";
39
+ var forceHiddenStyle = document.createElement("style");
40
+ forceHiddenStyle.textContent = "." + forceHiddenClass + " { display: none !important; }";
41
+ document.head.appendChild(forceHiddenStyle);
42
+
43
+ var simpleParts = {
44
+ output: "#divOutput",
45
+ exits: "#qv-exits",
46
+ "picture-frame": "#gamePanel",
47
+ map: "#gridPanel"
48
+ };
49
+
50
+ function setForceHidden(selector, hidden) {
51
+ $(selector).toggleClass(forceHiddenClass, hidden);
52
+ }
53
+
54
+ // ── Events ──────────────────────────────────────────────────────────────
55
+
56
+ var listeners = {};
57
+
58
+ function emit(event, detail) {
59
+ var set = listeners[event];
60
+ if (!set) return;
61
+ set.forEach(function (fn) {
62
+ try {
63
+ fn(detail);
64
+ } catch (e) {
65
+ console.error(e);
66
+ }
67
+ });
68
+ }
69
+
70
+ // Wrapping the globals rather than editing each call site: playercore.js and the host's JS
71
+ // imports look these up by name at call time, so the wrappers see every call.
72
+ function wrapGlobal(name, after) {
73
+ var original = window[name];
74
+ if (typeof original !== "function") return;
75
+ window[name] = function () {
76
+ var result = original.apply(this, arguments);
77
+ after.apply(this, arguments);
78
+ return result;
79
+ };
80
+ }
81
+
82
+ var autoScroll = true;
83
+ var fadeOutput = false;
84
+
85
+ // Called by wasm-player.js around each engine round trip the player starts: a command, an
86
+ // event, or answering a wait, menu or question. Timer ticks don't count as turns.
87
+ window.notifyQuestUITurn = function (started) {
88
+ if (started) {
89
+ if (fadeOutput) $("#divOutput").children().addClass("qv-previous-output");
90
+ emit("turnStarted");
91
+ } else {
92
+ emit("turnEnded");
93
+ }
94
+ };
95
+ wrapGlobal("addText", function (html) {
96
+ emit("outputAdded", { html: html });
97
+ });
98
+ wrapGlobal("updateLocation", function (text) {
99
+ emit("locationChanged", { location: text });
100
+ });
101
+
102
+ // The lists the panes show, for a game's own JavaScript to draw its own way: QuestUI.lists()
103
+ // and an event each time one changes. The engine sends them after every turn and timer tick.
104
+ var listEvents = { inventory: "inventoryChanged", objects: "objectsChanged", exits: "exitsChanged", status: "statusChanged" };
105
+ var lists, receivedLists;
106
+ function resetLists() {
107
+ lists = { inventory: [], objects: [], exits: [], status: [] };
108
+ receivedLists = {};
109
+ }
110
+ resetLists();
111
+ function copy(value) {
112
+ return JSON.parse(JSON.stringify(value));
113
+ }
114
+ function setList(name, value) {
115
+ // Status is sent every turn whether it changed or not, and a game only wants to hear of a change.
116
+ if (receivedLists[name] && JSON.stringify(value) === JSON.stringify(lists[name])) return;
117
+ receivedLists[name] = true;
118
+ lists[name] = value;
119
+ emit(listEvents[name], name === "exits" ? { exits: copy(value) } : { items: copy(value) });
120
+ }
121
+ wrapGlobal("updateList", function (listName, listData) {
122
+ if (listName !== "inventory" && listName !== "placesobjects") return;
123
+ var items = [];
124
+ $.each(listData, function (key, value) {
125
+ var data = JSON.parse(value);
126
+ // As the pane does, places and objects leaves out the exits the compass has.
127
+ if (listName === "placesobjects" && $.inArray(data.Text, _compassDirs) !== -1) return;
128
+ items.push({
129
+ text: String(data.Text == null ? "" : data.Text),
130
+ name: String(data.ElementName == null ? "" : data.ElementName),
131
+ elementId: String(data.ElementId == null ? "" : data.ElementId),
132
+ verbs: (data.Verbs || []).map(String)
133
+ });
134
+ });
135
+ setList(listName === "inventory" ? "inventory" : "objects", items);
136
+ });
137
+ wrapGlobal("updateCompass", function (data) {
138
+ setList("exits", String(data == null ? "" : data).split("/").filter(Boolean));
139
+ });
140
+ // setStatusAttributes passes its structured items to updateStatus as text, so it leaves them
141
+ // here for updateStatus's wrapper; an older game's status is only ever text.
142
+ var pendingStatus = null;
143
+ wrapGlobal("updateStatus", function (text) {
144
+ var items = pendingStatus || String(text == null ? "" : text).split(/\r?\n|<br\s*\/?>/i)
145
+ .filter(function (line) { return line.trim(); })
146
+ .map(function (line) { return { text: line }; });
147
+ pendingStatus = null;
148
+ setList("status", items);
149
+ });
150
+
151
+ var originalScrollToEnd = window.scrollToEnd;
152
+ window.scrollToEnd = function () {
153
+ if (autoScroll) originalScrollToEnd.apply(this, arguments);
154
+ };
155
+
156
+ var continueOnClick = false;
157
+ document.addEventListener("click", function (e) {
158
+ // A click on a link or control inside the output keeps its own meaning.
159
+ if (!continueOnClick || !_waitMode) return;
160
+ if ($(e.target).closest("a, button, input, textarea, select").length) return;
161
+ endWait();
162
+ });
163
+
164
+ // ── Link markup ─────────────────────────────────────────────────────────
165
+
166
+ // ShowMenu's fallback links in 610 Core: <a class="cmdlink" data-qv-event="..." data-qv-param="...">.
167
+ // Bound now, before playercore.js's document-ready handlers, so it runs ahead of the
168
+ // "disable every bare ShowMenu link" handler, which would otherwise mark this link disabled
169
+ // before it could fire.
170
+ $(document).on("click", "a[data-qv-event]", function (e) {
171
+ e.preventDefault();
172
+ var $this = $(this);
173
+ if ($this.hasClass("disabled")) return;
174
+ ASLEvent($this.attr("data-qv-event"), $this.attr("data-qv-param") || "");
175
+ });
176
+
177
+ // {popup:} in 610 Core: a trigger button plus a content element, with no inline handlers.
178
+ $(document).on("click", "[data-qv-popup]", function (e) {
179
+ e.preventDefault();
180
+ $(document.getElementById($(this).attr("data-qv-popup"))).addClass("qv-popup-open");
181
+ });
182
+ $(document).on("click", "[data-qv-popup-content]", function () {
183
+ $(this).removeClass("qv-popup-open");
184
+ });
185
+
186
+ // ── Theming ─────────────────────────────────────────────────────────────
187
+
188
+ function px(value) {
189
+ return /^-?[\d.]+$/.test(value) ? value + "px" : value;
190
+ }
191
+
192
+ // Each recognised token is also translated into the legacy call that styled the same thing
193
+ // before the contract existed. Order matters where legacy's calls depend on each other:
194
+ // setBackground reads the opacity SetBackgroundOpacity stored.
195
+ function applyLegacyTokens(t) {
196
+ var body = $("body");
197
+ if (t["--qv-bg-opacity"]) SetBackgroundOpacity(parseFloat(t["--qv-bg-opacity"]));
198
+ if (t["--qv-bg"]) setBackground(t["--qv-bg"]);
199
+ if (t["--qv-text"]) body.css("color", t["--qv-text"]);
200
+ if (t["--qv-font-body"]) body.css("font-family", t["--qv-font-body"]);
201
+ if (t["--qv-font-size"]) body.css("font-size", t["--qv-font-size"]);
202
+ if (t["--qv-link"]) addCSSRule("a.cmdlink").style.color = t["--qv-link"];
203
+ if (t["--qv-link-decoration"]) addCSSRule("a.cmdlink").style.textDecoration = t["--qv-link-decoration"];
204
+ if (t["--qv-page-bg"]) body.css("background-color", t["--qv-page-bg"]);
205
+ if (t["--qv-bg-image"]) body.css("background-image", t["--qv-bg-image"]);
206
+ if (t["--qv-bg-blend-top"] && t["--qv-bg-blend-bottom"]) {
207
+ colourBlend(t["--qv-bg-blend-top"], t["--qv-bg-blend-bottom"]);
208
+ }
209
+ if (t["--qv-output-width"]) setGameWidth(parseFloat(t["--qv-output-width"]));
210
+ ["top", "bottom", "left", "right"].forEach(function (side) {
211
+ var value = t["--qv-padding-" + side];
212
+ if (value) $("#gameContent").css("padding-" + side, px(value));
213
+ });
214
+ if (t["--qv-border-colour"]) {
215
+ $("#gameBorder").css({
216
+ "border-left": "1px solid " + t["--qv-border-colour"],
217
+ "border-right": "1px solid " + t["--qv-border-colour"]
218
+ });
219
+ }
220
+
221
+ // setPanes takes 2, 4 or 5 colours: with 2 it swaps them for the headings, and below 5
222
+ // it defaults the highlight to orange.
223
+ if (t["--qv-pane-fg"] && t["--qv-pane-bg"]) {
224
+ var paneArgs = [t["--qv-pane-fg"], t["--qv-pane-bg"]];
225
+ var headingFg = t["--qv-pane-heading-fg"] || t["--qv-pane-bg"];
226
+ var headingBg = t["--qv-pane-heading-bg"] || t["--qv-pane-fg"];
227
+ if (t["--qv-pane-heading-fg"] || t["--qv-pane-heading-bg"] || t["--qv-pane-highlight"]) {
228
+ paneArgs.push(headingFg, headingBg);
229
+ }
230
+ if (t["--qv-pane-highlight"]) paneArgs.push(t["--qv-pane-highlight"]);
231
+ setPanes.apply(null, paneArgs);
232
+ }
233
+
234
+ var status = $("#qv-status");
235
+ if (t["--qv-status-bg"]) status.css("background", t["--qv-status-bg"]);
236
+ if (t["--qv-status-fg"]) status.css("color", t["--qv-status-fg"]);
237
+ if (t["--qv-status-border"]) status.css("border", t["--qv-status-border"]);
238
+ if (t["--qv-status-image"]) {
239
+ if (t["--qv-status-image"] === "none") {
240
+ status.css("background-image", "none");
241
+ } else {
242
+ // As the location bar image always did: on every jQuery UI header, so the pane
243
+ // headings get it too.
244
+ $(".ui-widget-header").css("background-image", t["--qv-status-image"]);
245
+ }
246
+ }
247
+
248
+ if (t["--qv-menu-bg"]) SetMenuBackground(t["--qv-menu-bg"]);
249
+ if (t["--qv-menu-fg"]) SetMenuForeground(t["--qv-menu-fg"]);
250
+ if (t["--qv-menu-hover-bg"]) SetMenuHoverBackground(t["--qv-menu-hover-bg"]);
251
+ if (t["--qv-menu-hover-fg"]) SetMenuHoverForeground(t["--qv-menu-hover-fg"]);
252
+ if (t["--qv-menu-font"]) SetMenuFontName(t["--qv-menu-font"]);
253
+ if (t["--qv-menu-font-size"]) SetMenuFontSize(t["--qv-menu-font-size"]);
254
+
255
+ if (t["--qv-command-fg"]) $("#txtCommandDiv, #txtCommand").css("color", t["--qv-command-fg"]);
256
+ if (t["--qv-command-bg"]) $("#txtCommand").css("background-color", t["--qv-command-bg"]);
257
+ }
258
+
259
+ var commandBarPresets = {
260
+ // These rely on outline:none and on playercore.css keeping its focus style below a plain
261
+ // #txtCommand rule, as Core up to 6.0's own inline styles do.
262
+ borderless: "#txtCommand { outline:none; border:none; margin:0; padding:0; width:100px; background-color:transparent; }",
263
+ shadow: "#txtCommand { outline:none; border:none; margin:2px; padding:7px; box-shadow: 0px 0px 15px 5px #888; }"
264
+ };
265
+
266
+ // ── Map ─────────────────────────────────────────────────────────────────
267
+
268
+ // Same arguments as the Grid_* functions, in the same order: frozen as they are today.
269
+ var map = {
270
+ show: function (size) { ShowGrid(size); },
271
+ setInteractive: function (on) { setMapInteractive(on); },
272
+ respondToClicks: function (on) { respondToGridClicks(!!on); },
273
+ setScale: function () { Grid_SetScale.apply(null, arguments); },
274
+ setCentre: function () { Grid_SetCentre.apply(null, arguments); },
275
+ drawBox: function () { Grid_DrawBox.apply(null, arguments); },
276
+ drawLabel: function () { Grid_DrawLabel.apply(null, arguments); },
277
+ drawPlayer: function () { Grid_DrawPlayer.apply(null, arguments); },
278
+ drawLine: function () { Grid_DrawLine.apply(null, arguments); },
279
+ drawArrow: function () { Grid_DrawArrow.apply(null, arguments); },
280
+ drawSquare: function () { Grid_DrawSquare.apply(null, arguments); },
281
+ drawShape: function () { Grid_DrawShape.apply(null, arguments); },
282
+ addShapePoint: function () { Grid_AddNewShapePoint.apply(null, arguments); },
283
+ drawImage: function () { Grid_DrawImage.apply(null, arguments); },
284
+ drawSvg: function () { Grid_DrawSvg.apply(null, arguments); },
285
+ loadSvg: function () { Grid_LoadSvg.apply(null, arguments); },
286
+ drawGridLines: function () { Grid_DrawGridLines.apply(null, arguments); },
287
+ showCustomLayer: function (visible) { Grid_ShowCustomLayer(visible); },
288
+ clearCustomLayer: function () { Grid_ClearCustomLayer(); },
289
+ clearAllLayers: function () { Grid_ClearAllLayers(); }
290
+ };
291
+
292
+ function setMapInteractive(on) {
293
+ // Checked by grid.js's zoom and drag handlers.
294
+ window._qvMapInteractive = !!on;
295
+ }
296
+
297
+ // ── Transcript ──────────────────────────────────────────────────────────
298
+
299
+ var transcript = {
300
+ write: function (html) { writeToTranscript(html); },
301
+ enable: function (name) { enableTranscript(name); },
302
+ disable: function () { disableTranscript(); },
303
+ kill: function () { killTranscript(); },
304
+ revive: function () { reviveTranscript(); },
305
+ // playercore.js's transcriptName is an implicit global, which strict code can't assign
306
+ // by its bare name.
307
+ setName: function (name) { window.transcriptName = name; },
308
+ setPrefix: function (text) { replaceTranscriptString(text); },
309
+ stampDateAndTime: function () { printTranscriptDateAndTime(); },
310
+ // 610 Core doesn't seed transcriptName as older Core did (through JS.eval), so offer the
311
+ // game's name until there is one, as v2 does.
312
+ promptForName: function () { $("#txtCommand").val(window.transcriptName || gameName); },
313
+ show: function (message, linkText) { showTranscript(message, linkText); }
314
+ };
315
+
316
+ // ── Panes ───────────────────────────────────────────────────────────────
317
+
318
+ function paneDomId(id) {
319
+ return "qv-pane-" + String(id).replace(/[^A-Za-z0-9_-]/g, "_");
320
+ }
321
+
322
+ // Built like the stock panes (see playercore.htm), taking jQuery UI's classes from the
323
+ // inventory pane, so an author pane looks and behaves like its neighbours.
324
+ function addPane(id, title, html) {
325
+ if (!id || paneSelectors(id)) return;
326
+ var domId = paneDomId(id);
327
+ var label = $("<h3/>", { id: domId + "-label", "class": $("#inventoryLabel").attr("class") });
328
+ var button = $("<button/>", {
329
+ type: "button",
330
+ "class": "accordion-header-text",
331
+ "aria-controls": domId,
332
+ "aria-expanded": "true"
333
+ }).text(title || id);
334
+ label.append(button);
335
+ var content = $("<div/>", {
336
+ id: domId,
337
+ "class": $("#inventoryAccordion").attr("class"),
338
+ "data-qv-part": "pane",
339
+ "data-qv-pane": id
340
+ }).html(html || "");
341
+ button.on("click", function () {
342
+ var open = button.attr("aria-expanded") === "true";
343
+ button.attr("aria-expanded", open ? "false" : "true");
344
+ content.toggle(!open);
345
+ });
346
+ $("#gamePanesRunning").append(label, content);
347
+ authorPanes[id] = ["#" + domId + "-label", "#" + domId];
348
+ }
349
+
350
+ // ── QuestUI ─────────────────────────────────────────────────────────────
351
+
352
+ window.QuestUI = {
353
+ // Engine
354
+ sendCommand: function (text) { sendCommand(text); },
355
+ sendEvent: function (name, param) { ASLEvent(name, param); },
356
+ restart: function () { RestartGame(); },
357
+
358
+ // Output
359
+ addText: function (html) { addText(html); },
360
+ clearScreen: function () { clearScreen(); },
361
+ setAlignment: function (align) { createNewDiv(align); },
362
+ startSection: function (name) { StartOutputSection(name); },
363
+ endSection: function (name) { EndOutputSection(name); },
364
+ hideSection: function (name) { HideOutputSection(name); },
365
+ disableSection: function (name) { disableMenuOutputSection(name); },
366
+ disableCommandLinks: function () { disableAllCommandLinks(); },
367
+ updateLinks: function (kind, data) {
368
+ if (kind === "object") updateObjectLinks(data);
369
+ else if (kind === "exit") updateExitLinks(data);
370
+ else if (kind === "command") updateCommandLinks(data);
371
+ },
372
+ scrollToEnd: function () { scrollToEnd(); },
373
+ addYouTube: function (id) { AddYouTube(id); },
374
+ addVimeo: function (id) { AddVimeo(id); },
375
+ textEffect: function (kind) {
376
+ var args = Array.prototype.slice.call(arguments, 1);
377
+ if (kind === "typewriter") TextFX.Typewriter.apply(TextFX, args);
378
+ else if (kind === "unscramble") TextFX.Unscramble.apply(TextFX, args);
379
+ },
380
+
381
+ // Layout and panes
382
+ setVisible: function (part, visible) {
383
+ visible = !!visible;
384
+ if (part === "panes") {
385
+ panesVisible(visible);
386
+ } else if (part === "location") {
387
+ visible ? uiShow("#location") : uiHide("#location");
388
+ } else if (part === "command-bar") {
389
+ visible ? uiShow("#txtCommandDiv") : uiHide("#txtCommandDiv");
390
+ } else if (part === "border") {
391
+ $("#gameBorder").css("border", visible ? "" : "none");
392
+ } else if (simpleParts[part]) {
393
+ setForceHidden(simpleParts[part], !visible);
394
+ } else {
395
+ var selectors = paneSelectors(part);
396
+ if (!selectors) return;
397
+ var all = selectors.join(", ");
398
+ setForceHidden(all, !visible);
399
+ // The status pane shows itself whenever there's status text, so showing it
400
+ // only lifts the override; the others start hidden and need showing.
401
+ if (visible && part !== "status") $(all).show();
402
+ }
403
+ updateExitStrip();
404
+ },
405
+ setPaneOrder: function (parts) {
406
+ if (typeof parts === "string") parts = parts.split(";");
407
+ var container = $("#gamePanesRunning");
408
+ for (var i = parts.length - 1; i >= 0; i--) {
409
+ var selectors = paneSelectors(parts[i]);
410
+ if (selectors) container.prepend($(selectors.join(", ")));
411
+ }
412
+ },
413
+ setLayoutPreset: function (name, narrow) {
414
+ if (name === "gamebook") {
415
+ // playercore.css spaces a gamebook page from this class.
416
+ $("body").addClass("qv-gamebook");
417
+ panesVisible(false);
418
+ uiHide("#location");
419
+ uiHide("#txtCommandDiv");
420
+ }
421
+ // Legacy has one layout for every width, so of the other presets only "no panes at
422
+ // any width" means anything here.
423
+ else if (name === "nopanes" && (narrow == null || narrow === "nopanes")) {
424
+ panesVisible(false);
425
+ }
426
+ },
427
+ // Legacy has one place for the map.
428
+ setMapPosition: function () { },
429
+ setPictureFrame: function (html) { setPanelContents(html); },
430
+ setInterfaceString: function (name, text) { setInterfaceString(name, text); },
431
+ setCompassDirections: function (list) { setCompassDirections(list); },
432
+ setLocation: function (text) { updateLocation(text); },
433
+ setStatusAttributes: function (items) {
434
+ if (typeof items === "string") items = JSON.parse(items);
435
+ pendingStatus = (items || []).filter(function (item) { return item && typeof item === "object"; });
436
+ updateStatus((items || []).map(function (item) {
437
+ return item.text != null ? item.text : "";
438
+ }).join("<br/>"));
439
+ },
440
+
441
+ // Theming
442
+ setTokens: function (tokens) {
443
+ if (typeof tokens === "string") tokens = JSON.parse(tokens);
444
+ var root = document.documentElement;
445
+ var applied = {};
446
+ Object.keys(tokens || {}).forEach(function (name) {
447
+ var value = tokens[name] == null ? "" : String(tokens[name]);
448
+ if (name.indexOf("--") !== 0) return;
449
+ if (value === "") {
450
+ root.style.removeProperty(name);
451
+ } else {
452
+ root.style.setProperty(name, value);
453
+ applied[name] = value;
454
+ }
455
+ });
456
+ applyLegacyTokens(applied);
457
+ },
458
+ setCommandBarStyle: function (css) { setCommandBarStyle(css); },
459
+ setCommandBarPreset: function (name) {
460
+ if (commandBarPresets[name]) addScript("<style>" + commandBarPresets[name] + "</style>");
461
+ },
462
+ setCommandPrompt: function (text) { $("#txtCommandPrompt").html(text); },
463
+ addStylesheet: function (url) { addExternalStylesheet(url); },
464
+
465
+ map: map,
466
+ transcript: transcript,
467
+
468
+ // Author hooks
469
+ addPane: addPane,
470
+ setPaneContent: function (id, html) {
471
+ if (id === "customstatus") {
472
+ setCustomStatus(html);
473
+ } else if (authorPanes[id]) {
474
+ $("#" + paneDomId(id)).html(html);
475
+ }
476
+ },
477
+ setCommands: function (list) {
478
+ setCommands(Array.isArray(list) ? list.join(";") : list);
479
+ },
480
+ setAutoScroll: function (on) { autoScroll = !!on; },
481
+ setContinueOnClick: function (on) { continueOnClick = !!on; },
482
+ fadePreviousOutput: function (on) {
483
+ fadeOutput = !!on;
484
+ if (!fadeOutput) $("#divOutput .qv-previous-output").removeClass("qv-previous-output");
485
+ },
486
+ setCommandPlaceholder: function (text) { $("#txtCommand").attr("placeholder", text); },
487
+ setMapInteractive: setMapInteractive,
488
+ lists: function () { return copy(lists); },
489
+ on: function (event, fn) {
490
+ if (typeof fn !== "function") return;
491
+ (listeners[event] = listeners[event] || new Set()).add(fn);
492
+ },
493
+ off: function (event, fn) {
494
+ if (listeners[event]) listeners[event].delete(fn);
495
+ }
496
+ };
497
+
498
+ // Called by wasm-player.js whenever it swaps in a fresh playercore.htm for a new game or a
499
+ // restart. The game's InitInterface and its own scripts run again afterwards and set all of
500
+ // this up afresh, so anything kept from the previous run would be applied twice.
501
+ window.resetQuestUIState = function () {
502
+ authorPanes = {};
503
+ listeners = {};
504
+ resetLists();
505
+ autoScroll = true;
506
+ fadeOutput = false;
507
+ continueOnClick = false;
508
+ window._qvMapInteractive = true;
509
+ var root = document.documentElement;
510
+ for (var i = root.style.length - 1; i >= 0; i--) {
511
+ var name = root.style[i];
512
+ if (name.indexOf("--") === 0) root.style.removeProperty(name);
513
+ }
514
+ };
515
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textadventures/quest-viva-wasmplayer",
3
- "version": "6.0.4",
3
+ "version": "6.1.0-beta.2",
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/v2/map.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(()=>{var $="http://www.w3.org/2000/svg";var _=0;function o(u){let t=typeof u=="number"?u:parseFloat(String(u));return Number.isFinite(t)?t:0}function p(u,t="none"){let s=u==null?"":String(u).trim();return s===""?t:s}function a(u,t={}){let s=document.createElementNS($,u);for(let[e,i]of Object.entries(t))s.setAttribute(e,String(i));return s}var x=class{constructor(t){this.z=t;this.g.append(this.grid,this.fills,this.shapes,this.lines,this.labels),this.g.dataset.z=String(t)}z;g=a("g");grid=a("g");fills=a("g");shapes=a("g");lines=a("g",{"stroke-linecap":"round","stroke-linejoin":"miter",fill:"none"});labels=a("g",{class:"qv-map-labels"});clear(){for(let t of[this.grid,this.fills,this.shapes,this.lines,this.labels])t.replaceChildren()}},A=class{#S;#t;#E=a("defs");#P=a("g");#N=a("g");#d=new Map;#u=new x(NaN);#y;#Z=`qv-map-${++_}`;#h=30;#L=0;#$=!1;#R=!0;#_=!1;#a=!0;#m={objects:new Map,svg:new Map,images:new Map};#O=new Map;#F=0;#q=[];#s={x:0,y:0};#n=1;#l=null;#I={x:0,y:0};#f=null;#w=0;#i=new Map;#r=null;#o=null;constructor(t,s){this.#S=s;let e=s.strings();this.#t=a("svg",{class:"qv-map-svg",role:"group"}),this.#t.setAttribute("aria-label",e.map),this.#u.g.classList.add("qv-map-custom"),this.#u.g.setAttribute("display","none"),this.#P.append(this.#N,this.#u.g),this.#t.append(this.#E,this.#P),this.#y=document.createElement("div"),this.#y.className="qv-map-zoom",this.#y.append(this.#B("+",e.zoomIn,()=>this.#p(1.25)),this.#B("\u2212",e.zoomOut,()=>this.#p(1/1.25))),t.replaceChildren(this.#t,this.#y),this.#t.addEventListener("pointerdown",i=>this.#ot(i)),this.#t.addEventListener("pointermove",i=>this.#ht(i)),this.#t.addEventListener("pointerup",i=>this.#at(i)),this.#t.addEventListener("pointercancel",i=>this.#Y(i)),this.#t.addEventListener("wheel",i=>this.#lt(i),{passive:!1}),this.#t.addEventListener("keydown",i=>this.#ct(i)),new ResizeObserver(()=>this.#M()).observe(this.#t),this.#z(!0),this.#b(0)}call(t,s){let e=s;switch(t){case"setScale":{let i=o(e[0]);i>0&&(this.#h=i);break}case"setCentre":this.#g(),this.#x(this.#e(e[0],e[1]));break;case"setInteractive":this.#z(!!e[0]&&e[0]!=="false");break;case"respondToClicks":this.#_=!!e[0]&&e[0]!=="false",this.#t.classList.toggle("qv-map-clickable",this.#_);break;case"drawBox":this.#W(e);break;case"drawLabel":this.#U(e);break;case"drawPlayer":this.#Q(e);break;case"drawLine":this.#c().lines.append(this.#H(e[0],e[1],e[2],e[3],e[4],e[5]));break;case"drawArrow":this.#J(e);break;case"drawGridLines":this.#tt(e);break;case"drawSquare":this.#et(e);break;case"addShapePoint":this.#q.push({x:o(e[0]),y:o(e[1])});break;case"drawShape":this.#st(e);break;case"loadSvg":this.#it(e[0],e[1]);break;case"drawSvg":this.#nt(e);break;case"drawImage":this.#rt(e);break;case"showCustomLayer":{let i=e[0]===!0||e[0]==="true";this.#u.g.setAttribute("display",i?"inline":"none"),this.#$=i;break}case"clearCustomLayer":this.#u.clear(),this.#K();break;case"clearAllLayers":for(let i of this.#d.values())i.g.remove();this.#d.clear(),this.#l=null,this.#g(),this.#K(),this.#b(this.#L);break}}#e(t,s){return{x:o(t)*this.#h,y:o(s)*this.#h}}#T(t){let s=this.#d.get(t);if(!s){s=new x(t),this.#d.set(t,s);let e=[...this.#d.values()].filter(i=>i.z>t).sort((i,n)=>i.z-n.z)[0];this.#N.insertBefore(s.g,e?.g??null)}return s}#b(t){this.#L=t,this.#$=!1;let s=this.#T(t);for(let e of this.#d.values())e.g.setAttribute("opacity",e===s?"1":String(.2));return s}#c(){return this.#$?this.#u:this.#T(this.#L)}#H(t,s,e,i,n,r){let h=this.#e(t,s),l=this.#e(e,i);return a("line",{x1:h.x,y1:h.y,x2:l.x,y2:l.y,stroke:p(n),"stroke-width":o(r)})}#W(t){let[s,e,i,n,r]=[o(t[0]),o(t[1]),o(t[2]),o(t[3]),o(t[4])],h=this.#b(i);this.#R&&(this.#R=!1,this.#x(this.#e(s+n/2,e+r/2)));let l=[this.#e(s,e),this.#e(s+n,e),this.#e(s+n,e+r),this.#e(s,e+r)],[c,d]=[l[0],l[2]],g={x:c.x,y:c.y,width:d.x-c.x,height:d.y-c.y};h.fills.append(a("rect",{...g,fill:p(t[7])}));let S=t[9]==null?"":String(t[9]).trim();S&&h.fills.append(a("image",{...g,href:S,preserveAspectRatio:"xMidYMid slice"}));let E=o(t[6]);if(E<=0)return;let m=o(t[8]),w=[m&8,m&4,m&2,m&1],f="";if(w.every(Boolean))f=`M${l.map(b=>`${b.x},${b.y}`).join("L")}Z`;else{let b=w.findIndex(y=>!y),k=!1;for(let y=1;y<=4;y++){let M=(b+y)%4;if(w[M]){let P=l[M],v=l[(M+1)%4];f+=k?`L${v.x},${v.y}`:`M${P.x},${P.y}L${v.x},${v.y}`,k=!0}else k=!1}}f&&h.lines.append(a("path",{d:f,stroke:p(t[5]),"stroke-width":E}))}#U(t){let s=this.#b(o(t[2])),e=this.#e(t[0],t[1]),i=a("text",{x:e.x,y:e.y,"text-anchor":"middle",fill:p(t[4],"black")});i.textContent=t[3]==null?"":String(t[3]),s.labels.append(i)}#Q(t){let s=this.#b(o(t[2])),e=this.#e(t[0],t[1]);if(!this.#l){this.#l=a("circle",{class:"qv-map-player",r:o(t[3]),stroke:p(t[4]),"stroke-width":o(t[5]),fill:p(t[6])}),s.g.append(this.#l),this.#k(e),this.#g(),this.#x(e);return}if(s.g.append(this.#l),!this.#S.animate()){this.#g(),this.#k(e),this.#x(e);return}this.#V("player",{...this.#I},e)}#k(t){this.#I=t,this.#l?.setAttribute("cx",String(t.x)),this.#l?.setAttribute("cy",String(t.y))}#J(t){let s=this.#e(t[1],t[2]),e=this.#e(t[3],t[4]),i=a("g",{stroke:p(t[5]),"stroke-width":o(t[6])});i.append(this.#H(t[1],t[2],t[3],t[4],t[5],t[6]));let n=Math.hypot(e.x-s.x,e.y-s.y);if(n>0){let r=(e.x-s.x)/n*10,h=(e.y-s.y)/n*10,l=c=>{let d=c*Math.PI/180;return`${e.x+r*Math.cos(d)-h*Math.sin(d)},${e.y+r*Math.sin(d)+h*Math.cos(d)}`};i.append(a("path",{d:`M${l(150)}L${e.x},${e.y}L${l(-150)}`}))}this.#v("objects",t[0],i,this.#c().lines)}#tt(t){let[s,e,i,n]=[o(t[0]),o(t[1]),o(t[2]),o(t[3])],r="";for(let h=s;h<=i;h++){let[l,c]=[this.#e(h,e),this.#e(h,n)];r+=`M${l.x},${l.y}L${c.x},${c.y}`}for(let h=e;h<=n;h++){let[l,c]=[this.#e(s,h),this.#e(i,h)];r+=`M${l.x},${l.y}L${c.x},${c.y}`}r&&this.#c().grid.append(a("path",{d:r,stroke:p(t[4]),"stroke-width":1,fill:"none"}))}#et(t){let[s,e,i,n]=[o(t[1]),o(t[2]),o(t[3]),o(t[4])],r=this.#e(s,e),h=this.#e(s+i,e+n),l=p(t[6]),c=a("g");if(c.append(a("rect",{x:r.x+1,y:r.y+1,width:Math.max(0,h.x-r.x-2),height:Math.max(0,h.y-r.y-2),fill:l,stroke:l})),t[5]!=null&&String(t[5])!==""){let d=this.#e(s+i/2,e+n/2),g=a("text",{x:d.x,y:d.y,"text-anchor":"middle",fill:"black",class:"qv-map-label"});g.textContent=String(t[5]),c.append(g)}this.#v("objects",t[0],c,this.#c().shapes)}#st(t){let s=this.#q.map(i=>this.#e(i.x,i.y));this.#q=[];let e=a("polygon",{points:s.map(i=>`${i.x},${i.y}`).join(" "),stroke:p(t[1]),fill:p(t[2])});t[3]!=null&&String(t[3])!==""&&e.setAttribute("opacity",String(o(t[3]))),this.#v("objects",t[0],e,this.#c().shapes)}#it(t,s){let e=new DOMParser().parseFromString(String(t??""),"image/svg+xml"),i=e.documentElement;if(i.nodeName!=="svg"||e.querySelector("parsererror"))return;for(let c of i.querySelectorAll("script, foreignObject"))c.remove();for(let c of[i,...i.querySelectorAll("*")])for(let d of[...c.attributes])(/^on/i.test(d.name)||/href$/i.test(d.name)&&/^\s*javascript:/i.test(d.value))&&c.removeAttribute(d.name);let n=`${this.#Z}-symbol-${++this.#F}`,r=a("symbol",{id:n,preserveAspectRatio:"none"}),h=i.getAttribute("viewBox")??(i.hasAttribute("width")&&i.hasAttribute("height")?`0 0 ${o(i.getAttribute("width"))} ${o(i.getAttribute("height"))}`:null);h&&r.setAttribute("viewBox",h);for(let c of[...i.childNodes])r.append(document.importNode(c,!0));let l=this.#O.get(String(s));l&&this.#E.querySelector(`#${l}`)?.remove(),this.#E.append(r),this.#O.set(String(s),n)}#nt(t){let s=this.#O.get(String(t[1]));if(!s){console.log(`No symbol loaded with id '${String(t[1])}'`);return}let e=this.#m.svg.get(String(t[0])),i=e??a("use");i.setAttribute("href",`#${s}`),this.#G(i,t[2],t[3],t[4],t[5]),e||this.#v("svg",t[0],i,this.#c().shapes)}#rt(t){let s=this.#m.images.get(String(t[0])),e=s??a("image",{preserveAspectRatio:"none"});e.setAttribute("href",String(t[1]??"")),this.#G(e,t[2],t[3],t[4],t[5]),s||this.#v("images",t[0],e,this.#c().shapes)}#G(t,s,e,i,n){let r=this.#e(s,e);t.setAttribute("x",String(r.x)),t.setAttribute("y",String(r.y)),t.setAttribute("width",String(Math.max(0,o(i)*this.#h))),t.setAttribute("height",String(Math.max(0,o(n)*this.#h)))}#v(t,s,e,i){let n=String(s??"");this.#m[t].get(n)?.remove(),this.#m[t].set(n,e),i.append(e)}#K(){for(let t of Object.values(this.#m))for(let[s,e]of t)e.isConnected||t.delete(s)}#x(t){this.#s={...t},this.#M()}#M(){let t=this.#t.clientWidth,s=this.#t.clientHeight,e=t/2-this.#n*this.#s.x,i=s/2-this.#n*this.#s.y;this.#P.setAttribute("transform",`translate(${e} ${i}) scale(${this.#n})`)}#C(t,s){return{x:this.#s.x+(t-this.#t.clientWidth/2)/this.#n,y:this.#s.y+(s-this.#t.clientHeight/2)/this.#n}}#D(t,s){this.#g(),this.#s={x:this.#s.x-t/this.#n,y:this.#s.y-s/this.#n},this.#M()}#p(t,s,e){if(!this.#a)return;this.#g();let i=Math.min(10,Math.max(.1,this.#n*t));if(s!=null&&e!=null){let n=this.#C(s,e);this.#n=i;let r=this.#C(s,e);this.#s={x:this.#s.x+n.x-r.x,y:this.#s.y+n.y-r.y}}else this.#n=i;this.#M()}#z(t){this.#a=t,this.#y.hidden=!t,this.#t.classList.toggle("qv-map-interactive",t),t?(this.#t.setAttribute("tabindex","0"),this.#t.setAttribute("aria-keyshortcuts","ArrowUp ArrowDown ArrowLeft ArrowRight + -")):(this.#t.removeAttribute("tabindex"),this.#t.removeAttribute("aria-keyshortcuts"),this.#r=null,this.#o=null)}#B(t,s,e){let i=document.createElement("button");return i.type="button",i.textContent=t,i.setAttribute("aria-label",s),i.addEventListener("click",e),i}#V(t,s,e){this.#f={kind:t,from:s,to:e,start:performance.now()},this.#w||(this.#w=requestAnimationFrame(i=>this.#X(i)))}#X(t){this.#w=0;let s=this.#f;if(!s)return;let e=Math.min(1,(t-s.start)/170),i={x:s.from.x+(s.to.x-s.from.x)*e,y:s.from.y+(s.to.y-s.from.y)*e};s.kind==="player"?this.#k(i):this.#x(i),e<1?this.#w=requestAnimationFrame(n=>this.#X(n)):s.kind==="player"?this.#V("centre",{...this.#s},{...this.#I}):this.#f=null}#g(){let t=this.#f;t&&(this.#f=null,t.kind==="player"&&this.#k(t.to))}#A(t){let s=this.#t.getBoundingClientRect();return{x:t.clientX-s.left,y:t.clientY-s.top}}#ot(t){t.pointerType==="mouse"&&t.button!==0||(this.#i.set(t.pointerId,this.#A(t)),this.#i.size===1?this.#r={start:this.#A(t),dragged:!1}:this.#i.size===2&&this.#a&&(this.#r=null,this.#o={distance:this.#j()}),this.#a&&this.#t.setPointerCapture(t.pointerId))}#ht(t){let s=this.#i.get(t.pointerId);if(!s)return;let e=this.#A(t);if(this.#i.set(t.pointerId,e),!this.#a){this.#r&&Math.hypot(e.x-this.#r.start.x,e.y-this.#r.start.y)>4&&(this.#r.dragged=!0);return}if(this.#o&&this.#i.size===2){let n=this.#j();if(this.#o.distance>0){let[r,h]=[...this.#i.values()];this.#p(n/this.#o.distance,(r.x+h.x)/2,(r.y+h.y)/2)}this.#o.distance=n;return}let i=this.#r;i&&(!i.dragged&&Math.hypot(e.x-i.start.x,e.y-i.start.y)<=4||(i.dragged?this.#D(e.x-s.x,e.y-s.y):(i.dragged=!0,this.#t.classList.add("qv-map-dragging"),this.#D(e.x-i.start.x,e.y-i.start.y))))}#at(t){let s=this.#r,e=!!this.#o;if(this.#Y(t),!s||s.dragged||e||!this.#_)return;let i=this.#C(s.start.x,s.start.y);this.#S.gridSquareClicked(Math.floor(i.x/this.#h),Math.floor(i.y/this.#h))}#Y(t){this.#i.delete(t.pointerId),this.#i.size<2&&(this.#o=null),this.#i.size===0&&(this.#r=null,this.#t.classList.remove("qv-map-dragging"))}#j(){let[t,s]=[...this.#i.values()];return t&&s?Math.hypot(t.x-s.x,t.y-s.y):0}#lt(t){if(!this.#a)return;t.preventDefault();let s=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*33:t.deltaY,e=this.#A(t);this.#p(1.1**(-s/100),e.x,e.y)}#ct(t){if(!this.#a||t.altKey||t.ctrlKey||t.metaKey)return;let s={ArrowUp:[0,40],ArrowDown:[0,-40],ArrowLeft:[40,0],ArrowRight:[-40,0]};if(s[t.key])this.#D(...s[t.key]);else if(t.key==="+"||t.key==="=")this.#p(1.25);else if(t.key==="-"||t.key==="_")this.#p(1/1.25);else return;t.preventDefault(),t.stopPropagation()}};function L(u,t){return new A(u,t)}window.QuestUIV2Map={create:L};})();
package/v2/player.htm ADDED
@@ -0,0 +1,59 @@
1
+ <qv-player>
2
+ <div class="qv-layout">
3
+ <main data-qv-part="border">
4
+ <div class="qv-header">
5
+ <header class="qv-topbar">
6
+ <div data-qv-part="location" class="qv-empty"></div>
7
+ <div class="qv-toolbar">
8
+ <!-- Icon buttons, each named by a visually hidden label (also its tooltip, player.ts).
9
+ The host shows these as the session allows (WebPlayer.setCanDebug/setCanSave, and
10
+ Transcripts once there's one to view),
11
+ adds a Restart button after Debug in editor previews (given an icon by
12
+ player.ts), and translates the labels (data-chrome-key*). -->
13
+ <button id="cmdDebug" type="button" style="display: none"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg><span class="qv-button-label">Debug</span></button>
14
+ <button id="cmdSave" type="button"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"/><path d="M7 3v4a1 1 0 0 0 1 1h7"/></svg><span class="qv-button-label" data-chrome-key="SaveLoadTitle">Save / Load</span></button>
15
+ <!-- Opens the transcript viewer. The host shows it once there's a transcript to
16
+ view (wasm-player.js's updateTranscriptsButton). -->
17
+ <button id="cmdTranscripts" type="button" style="display: none"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M15 12h-5"/><path d="M15 8h-5"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3"/></svg><span class="qv-button-label" data-chrome-key="TranscriptViewerLinkText">Your Transcripts</span></button>
18
+ <!-- The player's light or dark choice (scheme.ts), shown only while the game has
19
+ colours for both. Its icon is the choice's. -->
20
+ <div class="qv-scheme" hidden>
21
+ <button class="qv-scheme-button" type="button" aria-haspopup="menu" aria-expanded="false" aria-controls="qv-scheme-menu"><span class="qv-scheme-icon" data-qv-scheme-icon="system"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2v2"/><path d="M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715"/><path d="M16 12a4 4 0 0 0-4-4"/><path d="m19 5-1.256 1.256"/><path d="M20 12h2"/></svg></span><span class="qv-scheme-icon" data-qv-scheme-icon="light"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg></span><span class="qv-scheme-icon" data-qv-scheme-icon="dark"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/></svg></span><span class="qv-button-label" data-chrome-key="ColourSchemeButton">Light or dark</span></button>
22
+ <div id="qv-scheme-menu" class="qv-scheme-menu" role="menu" data-chrome-key-aria-label="ColourSchemeButton" aria-label="Light or dark" hidden>
23
+ <button type="button" role="menuitemradio" aria-checked="false" data-qv-scheme-choice="system"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2v2"/><path d="M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715"/><path d="M16 12a4 4 0 0 0-4-4"/><path d="m19 5-1.256 1.256"/><path d="M20 12h2"/></svg><span data-chrome-key="ColourSchemeSystem">Match my device</span><svg class="qv-icon qv-scheme-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></button>
24
+ <button type="button" role="menuitemradio" aria-checked="false" data-qv-scheme-choice="light"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg><span data-chrome-key="ColourSchemeLight">Light</span><svg class="qv-icon qv-scheme-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></button>
25
+ <button type="button" role="menuitemradio" aria-checked="false" data-qv-scheme-choice="dark"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/></svg><span data-chrome-key="ColourSchemeDark">Dark</span><svg class="qv-icon qv-scheme-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></button>
26
+ </div>
27
+ </div>
28
+ <!-- Collapses the map on a narrow layout (map.ts). -->
29
+ <button class="qv-map-button" type="button" aria-expanded="true" aria-controls="qv-map" hidden><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/></svg><span class="qv-button-label" data-chrome-key="MapLabel">Map</span></button>
30
+ <button class="qv-panes-button" type="button" aria-expanded="false"
31
+ data-chrome-key-aria-label="ShowPanesButton" aria-label="Show panels"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16"/><path d="M4 12h16"/><path d="M4 18h16"/></svg></button>
32
+ </div>
33
+ <div class="qv-status-bar" data-qv-part="status-bar"></div>
34
+ </header>
35
+ <div class="qv-picture-frame qv-empty" data-qv-part="picture-frame"></div>
36
+ <div id="qv-map" class="qv-map" data-qv-part="map" hidden><div class="qv-map-view"></div></div>
37
+ </div>
38
+ <qv-output data-qv-part="output"></qv-output>
39
+ <div class="qv-footer">
40
+ <nav class="qv-exits" data-qv-part="exits" data-chrome-key-aria-label="CompassLabel" aria-label="Compass"></nav>
41
+ <div class="qv-footer-bar">
42
+ <qv-command-bar data-qv-part="command-bar"></qv-command-bar>
43
+ <!-- The bottom bar layout's panes button (bottombar); the top bar's is for the drawer. -->
44
+ <button class="qv-panes-button qv-panes-button-bottom" type="button" aria-expanded="false"
45
+ data-chrome-key-aria-label="ShowPanesButton" aria-label="Show panels"><svg class="qv-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16"/><path d="M4 12h16"/><path d="M4 18h16"/></svg></button>
46
+ </div>
47
+ </div>
48
+ </main>
49
+ <aside class="qv-panes" data-qv-part="panes">
50
+ <qv-pane data-qv-pane="inventory" label="Inventory"></qv-pane>
51
+ <qv-pane data-qv-pane="status" label="Status" data-qv-empty></qv-pane>
52
+ <qv-pane data-qv-pane="objects" label="Places and Objects"></qv-pane>
53
+ <qv-pane data-qv-pane="compass" label="Compass"></qv-pane>
54
+ <qv-pane data-qv-pane="commands" hidden></qv-pane>
55
+ <qv-pane data-qv-pane="customstatus" hidden></qv-pane>
56
+ </aside>
57
+ </div>
58
+ <qv-verb-menu data-qv-part="menu"></qv-verb-menu>
59
+ </qv-player>