@mudlet/mudlet-web 0.3.0

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 (242) hide show
  1. package/LICENSE +338 -0
  2. package/README.md +150 -0
  3. package/dist-lib/App.d.ts +1 -0
  4. package/dist-lib/MudletWebApp.d.ts +11 -0
  5. package/dist-lib/ProfileSession.d.ts +15 -0
  6. package/dist-lib/assets/mapParser.worker-t-3rd1zR.js +9 -0
  7. package/dist-lib/branding.d.ts +213 -0
  8. package/dist-lib/core/EventBus.d.ts +29 -0
  9. package/dist-lib/db/sqliteClient.d.ts +25 -0
  10. package/dist-lib/hooks/useEngines.d.ts +12 -0
  11. package/dist-lib/hooks/useMudSession.d.ts +10 -0
  12. package/dist-lib/hooks/useOutput.d.ts +17 -0
  13. package/dist-lib/hooks/useViewportMode.d.ts +14 -0
  14. package/dist-lib/import/applyMudletProfile.d.ts +57 -0
  15. package/dist-lib/import/collectProfileExport.d.ts +16 -0
  16. package/dist-lib/import/defaultPackages.d.ts +81 -0
  17. package/dist-lib/import/defaults/mudlet-mapper.xml +13023 -0
  18. package/dist-lib/import/defaults/run-lua-code.mpackage +0 -0
  19. package/dist-lib/import/mudletHost.d.ts +67 -0
  20. package/dist-lib/import/mudletLink.d.ts +34 -0
  21. package/dist-lib/import/mudletProfileExport.d.ts +49 -0
  22. package/dist-lib/import/mudletProfileImport.d.ts +71 -0
  23. package/dist-lib/import/mudletVariables.d.ts +49 -0
  24. package/dist-lib/import/mudletWriteback.d.ts +12 -0
  25. package/dist-lib/import/mudletXmlExport.d.ts +16 -0
  26. package/dist-lib/import/mudletXmlImport.d.ts +21 -0
  27. package/dist-lib/import/packageInstaller.d.ts +72 -0
  28. package/dist-lib/import/packageRepository.d.ts +54 -0
  29. package/dist-lib/import/remotePackageInstall.d.ts +52 -0
  30. package/dist-lib/index.d.ts +30 -0
  31. package/dist-lib/index.js +42307 -0
  32. package/dist-lib/logging/SessionLogger.d.ts +41 -0
  33. package/dist-lib/main.d.ts +2 -0
  34. package/dist-lib/map/MapSelectionOverlay.d.ts +15 -0
  35. package/dist-lib/map/MapStore.d.ts +1067 -0
  36. package/dist-lib/map/MudixMapReader.d.ts +90 -0
  37. package/dist-lib/map/MudletHighlightOverlay.d.ts +18 -0
  38. package/dist-lib/map/mapImageExport.d.ts +26 -0
  39. package/dist-lib/map/mapParser.worker.d.ts +1 -0
  40. package/dist-lib/map/mapParserClient.d.ts +35 -0
  41. package/dist-lib/map/pathfinding.d.ts +52 -0
  42. package/dist-lib/map/xmlMapImport.d.ts +28 -0
  43. package/dist-lib/mud/MudSession.d.ts +236 -0
  44. package/dist-lib/mud/PatternEngine.d.ts +28 -0
  45. package/dist-lib/mud/aliases/AliasEngine.d.ts +15 -0
  46. package/dist-lib/mud/connection/LineAssembler.d.ts +84 -0
  47. package/dist-lib/mud/connection/MudClient.d.ts +268 -0
  48. package/dist-lib/mud/connection/PingTracker.d.ts +28 -0
  49. package/dist-lib/mud/connection/TelnetNegotiator.d.ts +188 -0
  50. package/dist-lib/mud/connection/telnetDebug.d.ts +54 -0
  51. package/dist-lib/mud/events.d.ts +160 -0
  52. package/dist-lib/mud/keybindings/KeyEngine.d.ts +36 -0
  53. package/dist-lib/mud/keybindings/browserReservedKeys.d.ts +45 -0
  54. package/dist-lib/mud/keybindings/qtKeys.d.ts +33 -0
  55. package/dist-lib/mud/protocol/charset.d.ts +105 -0
  56. package/dist-lib/mud/protocol/constants.d.ts +116 -0
  57. package/dist-lib/mud/protocol/echo.d.ts +63 -0
  58. package/dist-lib/mud/protocol/gmcp.d.ts +28 -0
  59. package/dist-lib/mud/protocol/index.d.ts +11 -0
  60. package/dist-lib/mud/protocol/mccp.d.ts +18 -0
  61. package/dist-lib/mud/protocol/mnes.d.ts +83 -0
  62. package/dist-lib/mud/protocol/msdp.d.ts +19 -0
  63. package/dist-lib/mud/protocol/msp.d.ts +47 -0
  64. package/dist-lib/mud/protocol/mssp.d.ts +25 -0
  65. package/dist-lib/mud/protocol/mxp.d.ts +188 -0
  66. package/dist-lib/mud/protocol/naws.d.ts +7 -0
  67. package/dist-lib/mud/replay/ReplayPlayer.d.ts +31 -0
  68. package/dist-lib/mud/replay/ReplayRecorder.d.ts +18 -0
  69. package/dist-lib/mud/replay/replayFormat.d.ts +49 -0
  70. package/dist-lib/mud/text/Console.d.ts +183 -0
  71. package/dist-lib/mud/text/FormatState.d.ts +256 -0
  72. package/dist-lib/mud/text/ansiEscapes.d.ts +88 -0
  73. package/dist-lib/mud/text/cellRender.d.ts +21 -0
  74. package/dist-lib/mud/text/colorParsers.d.ts +54 -0
  75. package/dist-lib/mud/text/colors.d.ts +31 -0
  76. package/dist-lib/mud/text/controlCharacterMode.d.ts +13 -0
  77. package/dist-lib/mud/text/controlChars.d.ts +31 -0
  78. package/dist-lib/mud/text/hyperlinkConfig.d.ts +164 -0
  79. package/dist-lib/mud/text/hyperlinkVisibility.d.ts +37 -0
  80. package/dist-lib/mud/text/oscLinkManager.d.ts +35 -0
  81. package/dist-lib/mud/text/wcwidth.d.ts +44 -0
  82. package/dist-lib/mud/text/xterm256.d.ts +2 -0
  83. package/dist-lib/mud/timers/TimerEngine.d.ts +61 -0
  84. package/dist-lib/mud/triggers/ChunkProcessor.d.ts +11 -0
  85. package/dist-lib/mud/triggers/TriggerEngine.d.ts +188 -0
  86. package/dist-lib/mud/triggers/pcre/Pcre2.d.ts +26 -0
  87. package/dist-lib/scripting/EngineHost.d.ts +152 -0
  88. package/dist-lib/scripting/GlobalEventChannel.d.ts +36 -0
  89. package/dist-lib/scripting/IScriptingRuntime.d.ts +95 -0
  90. package/dist-lib/scripting/MapOpenNotifier.d.ts +19 -0
  91. package/dist-lib/scripting/ScriptingAPI.d.ts +1691 -0
  92. package/dist-lib/scripting/ScriptingEngine.d.ts +806 -0
  93. package/dist-lib/scripting/StopwatchManager.d.ts +94 -0
  94. package/dist-lib/scripting/heldModifiers.d.ts +3 -0
  95. package/dist-lib/scripting/http/HttpService.d.ts +23 -0
  96. package/dist-lib/scripting/lua/LuaRuntime.d.ts +190 -0
  97. package/dist-lib/scripting/lua/bindings/automation.d.ts +10 -0
  98. package/dist-lib/scripting/lua/bindings/commandLine.d.ts +11 -0
  99. package/dist-lib/scripting/lua/bindings/context.d.ts +87 -0
  100. package/dist-lib/scripting/lua/bindings/cursor.d.ts +10 -0
  101. package/dist-lib/scripting/lua/bindings/diagnostics.d.ts +9 -0
  102. package/dist-lib/scripting/lua/bindings/map.d.ts +14 -0
  103. package/dist-lib/scripting/lua/bindings/media.d.ts +24 -0
  104. package/dist-lib/scripting/lua/bindings/output.d.ts +10 -0
  105. package/dist-lib/scripting/lua/bindings/packages.d.ts +10 -0
  106. package/dist-lib/scripting/lua/bindings/session.d.ts +16 -0
  107. package/dist-lib/scripting/lua/bindings/textEdit.d.ts +9 -0
  108. package/dist-lib/scripting/lua/bindings/userWindows.d.ts +11 -0
  109. package/dist-lib/scripting/lua/bindings/window.d.ts +10 -0
  110. package/dist-lib/scripting/lua/imageSize.d.ts +4 -0
  111. package/dist-lib/scripting/lua/luaCompletions.d.ts +9 -0
  112. package/dist-lib/scripting/lua/mudlet-lua/generic-mapper/generic_mapper.mpackage +0 -0
  113. package/dist-lib/scripting/lua/rex.d.ts +3 -0
  114. package/dist-lib/scripting/lua/sqlRowEncoder.d.ts +1 -0
  115. package/dist-lib/scripting/lua/yajl.d.ts +11 -0
  116. package/dist-lib/scripting/profilesPresence.d.ts +50 -0
  117. package/dist-lib/scripting/vfs/ProfileVFS.d.ts +62 -0
  118. package/dist-lib/scripting/vfs/cssRewrite.d.ts +21 -0
  119. package/dist-lib/scripting/vfs/folderHandleStore.d.ts +16 -0
  120. package/dist-lib/scripting/vfs/folderSync.d.ts +59 -0
  121. package/dist-lib/scripting/vfs/htmlRewrite.d.ts +26 -0
  122. package/dist-lib/scripting/vfs/vfsBridge.d.ts +16 -0
  123. package/dist-lib/services/cloudflare.d.ts +54 -0
  124. package/dist-lib/storage/appStore.d.ts +132 -0
  125. package/dist-lib/storage/crossTabSync.d.ts +3 -0
  126. package/dist-lib/storage/debouncedStorage.d.ts +18 -0
  127. package/dist-lib/storage/hooks.d.ts +17 -0
  128. package/dist-lib/storage/index.d.ts +4 -0
  129. package/dist-lib/storage/logExport.d.ts +32 -0
  130. package/dist-lib/storage/logStorage.d.ts +45 -0
  131. package/dist-lib/storage/mapStorage.d.ts +2 -0
  132. package/dist-lib/storage/profileVfsData.d.ts +47 -0
  133. package/dist-lib/storage/schema.d.ts +638 -0
  134. package/dist-lib/styles.css +2 -0
  135. package/dist-lib/ui/AboutModal.d.ts +8 -0
  136. package/dist-lib/ui/BrandLoginFields.d.ts +25 -0
  137. package/dist-lib/ui/BrandLoginScreen.d.ts +11 -0
  138. package/dist-lib/ui/CharLoginModal.d.ts +32 -0
  139. package/dist-lib/ui/CmdLineMenuRegistry.d.ts +27 -0
  140. package/dist-lib/ui/CodeEditorPreview.d.ts +19 -0
  141. package/dist-lib/ui/CommandBar.d.ts +17 -0
  142. package/dist-lib/ui/ConnectionFormModal.d.ts +13 -0
  143. package/dist-lib/ui/ConnectionGrid.d.ts +18 -0
  144. package/dist-lib/ui/ConnectionScreen.d.ts +14 -0
  145. package/dist-lib/ui/FileBrowserModal.d.ts +20 -0
  146. package/dist-lib/ui/FilePickerModal.d.ts +21 -0
  147. package/dist-lib/ui/FolderPermissionScreen.d.ts +16 -0
  148. package/dist-lib/ui/JsonPreview.d.ts +15 -0
  149. package/dist-lib/ui/LogBrowserModal.d.ts +7 -0
  150. package/dist-lib/ui/MapEditorModal.d.ts +9 -0
  151. package/dist-lib/ui/MarkdownPreview.d.ts +15 -0
  152. package/dist-lib/ui/MergeConflictModal.d.ts +17 -0
  153. package/dist-lib/ui/ModuleResolveModal.d.ts +22 -0
  154. package/dist-lib/ui/MouseEventRegistry.d.ts +31 -0
  155. package/dist-lib/ui/ProfileBusyScreen.d.ts +12 -0
  156. package/dist-lib/ui/ProfileExportModal.d.ts +7 -0
  157. package/dist-lib/ui/ProxyInfoModal.d.ts +6 -0
  158. package/dist-lib/ui/ProxyWhyModal.d.ts +6 -0
  159. package/dist-lib/ui/ProxyWizardModal.d.ts +6 -0
  160. package/dist-lib/ui/QuickOpenPalette.d.ts +8 -0
  161. package/dist-lib/ui/ResizableModal.d.ts +17 -0
  162. package/dist-lib/ui/ScriptingDocsModal.d.ts +12 -0
  163. package/dist-lib/ui/SettingsModal.d.ts +9 -0
  164. package/dist-lib/ui/Toolbar.d.ts +29 -0
  165. package/dist-lib/ui/bufferWords.d.ts +38 -0
  166. package/dist-lib/ui/buttons/ButtonsBar.d.ts +21 -0
  167. package/dist-lib/ui/cmdline/CommandLineManager.d.ts +97 -0
  168. package/dist-lib/ui/cmdline/CommandLineOverlay.d.ts +8 -0
  169. package/dist-lib/ui/codemirror/theme.d.ts +5 -0
  170. package/dist-lib/ui/commandHistory.d.ts +31 -0
  171. package/dist-lib/ui/components/Button.d.ts +9 -0
  172. package/dist-lib/ui/components/ConfirmDialog.d.ts +29 -0
  173. package/dist-lib/ui/components/ContextMenu.d.ts +9 -0
  174. package/dist-lib/ui/components/FontPicker.d.ts +9 -0
  175. package/dist-lib/ui/components/FormField.d.ts +16 -0
  176. package/dist-lib/ui/components/HelpTip.d.ts +7 -0
  177. package/dist-lib/ui/components/Input.d.ts +6 -0
  178. package/dist-lib/ui/components/Toggle.d.ts +10 -0
  179. package/dist-lib/ui/components/index.d.ts +9 -0
  180. package/dist-lib/ui/components/useModalFocus.d.ts +18 -0
  181. package/dist-lib/ui/labels/LabelManager.d.ts +220 -0
  182. package/dist-lib/ui/labels/LabelOverlay.d.ts +9 -0
  183. package/dist-lib/ui/labels/backgroundImageSize.d.ts +10 -0
  184. package/dist-lib/ui/labels/cursorShapes.d.ts +6 -0
  185. package/dist-lib/ui/labels/gifMovie.d.ts +100 -0
  186. package/dist-lib/ui/labels/qtCss.d.ts +57 -0
  187. package/dist-lib/ui/layout/ContentLayout.d.ts +19 -0
  188. package/dist-lib/ui/layout/DockArea.d.ts +14 -0
  189. package/dist-lib/ui/layout/DockedPanel.d.ts +13 -0
  190. package/dist-lib/ui/layout/FloatingWindowLayer.d.ts +10 -0
  191. package/dist-lib/ui/layout/MobileLayout.d.ts +22 -0
  192. package/dist-lib/ui/layout/PopoutWindow.d.ts +35 -0
  193. package/dist-lib/ui/layout/ScriptWindow.d.ts +29 -0
  194. package/dist-lib/ui/layout/SplitGroupPanel.d.ts +17 -0
  195. package/dist-lib/ui/layout/TabGroupPanel.d.ts +12 -0
  196. package/dist-lib/ui/layout/WindowContextMenu.d.ts +11 -0
  197. package/dist-lib/ui/layout/dockDetect.d.ts +26 -0
  198. package/dist-lib/ui/layout/overlayLayerOrder.d.ts +71 -0
  199. package/dist-lib/ui/markdown.d.ts +1 -0
  200. package/dist-lib/ui/output/CaretReviewPanel.d.ts +22 -0
  201. package/dist-lib/ui/output/OutputArea.d.ts +9 -0
  202. package/dist-lib/ui/output/OutputContextMenu.d.ts +23 -0
  203. package/dist-lib/ui/output/OutputRenderer.d.ts +64 -0
  204. package/dist-lib/ui/output/ScreenReaderLog.d.ts +23 -0
  205. package/dist-lib/ui/output/StickyOutputPanel.d.ts +28 -0
  206. package/dist-lib/ui/output/backgroundImageStyle.d.ts +17 -0
  207. package/dist-lib/ui/output/caretMode.d.ts +40 -0
  208. package/dist-lib/ui/output/linkNavigation.d.ts +29 -0
  209. package/dist-lib/ui/output/osc8Menu.d.ts +16 -0
  210. package/dist-lib/ui/output/outputCopy.d.ts +15 -0
  211. package/dist-lib/ui/preventPinchZoom.d.ts +1 -0
  212. package/dist-lib/ui/scrollbox/ScrollBoxManager.d.ts +62 -0
  213. package/dist-lib/ui/scrollbox/ScrollBoxOverlay.d.ts +25 -0
  214. package/dist-lib/ui/sound/SoundManager.d.ts +149 -0
  215. package/dist-lib/ui/sound/closedCaption.d.ts +37 -0
  216. package/dist-lib/ui/textedit/TextEditManager.d.ts +56 -0
  217. package/dist-lib/ui/tts/TtsManager.d.ts +68 -0
  218. package/dist-lib/ui/useBrandLogin.d.ts +19 -0
  219. package/dist-lib/ui/useCommandHistory.d.ts +7 -0
  220. package/dist-lib/ui/video/VideoManager.d.ts +56 -0
  221. package/dist-lib/ui/windows/ScriptEditorModal.d.ts +13 -0
  222. package/dist-lib/ui/windows/WindowManager.d.ts +694 -0
  223. package/dist-lib/ui/windows/panels/HtmlPanel.d.ts +27 -0
  224. package/dist-lib/ui/windows/panels/LuaEditor.d.ts +14 -0
  225. package/dist-lib/ui/windows/panels/MapPanel.d.ts +8 -0
  226. package/dist-lib/ui/windows/panels/PackageRepositoryModal.d.ts +18 -0
  227. package/dist-lib/ui/windows/panels/ScriptEditorPanel.d.ts +24 -0
  228. package/dist-lib/ui/windows/panels/ScriptSearch.d.ts +12 -0
  229. package/dist-lib/ui/windows/panels/TextPanel.d.ts +35 -0
  230. package/dist-lib/ui/windows/panels/VariablesView.d.ts +21 -0
  231. package/dist-lib/ui/windows/panels/VfsModulePickerModal.d.ts +8 -0
  232. package/dist-lib/ui/windows/panels/WindowCmdLine.d.ts +23 -0
  233. package/dist-lib/ui/windows/types.d.ts +145 -0
  234. package/dist-lib/utils/documentTitle.d.ts +33 -0
  235. package/dist-lib/utils/fontLoader.d.ts +52 -0
  236. package/dist-lib/utils/profileLock.d.ts +26 -0
  237. package/dist-lib/utils/sessionCredentials.d.ts +16 -0
  238. package/dist-lib/version.d.ts +39 -0
  239. package/dist-lib/vfs-sw.js +131 -0
  240. package/dist-lib/vite.d.ts +2 -0
  241. package/dist-lib/vite.js +154 -0
  242. package/package.json +93 -0
@@ -0,0 +1,1691 @@
1
+ import type { MudSession, ScriptLogSource } from '../mud/MudSession';
2
+ import type { AliasEngine } from '../mud/aliases/AliasEngine';
3
+ import type { TriggerEngine } from '../mud/triggers/TriggerEngine';
4
+ import type { TimerEngine } from '../mud/timers/TimerEngine';
5
+ import type { KeyEngine } from '../mud/keybindings/KeyEngine';
6
+ import type { WindowHandle, WindowOpenOptions } from '../ui/windows/types';
7
+ import type { LabelManager, LabelCreateOptions, LabelMouseEvent, LabelWheelEvent } from '../ui/labels/LabelManager';
8
+ import type { CommandLineManager } from '../ui/cmdline/CommandLineManager';
9
+ import type { ScrollBoxManager } from '../ui/scrollbox/ScrollBoxManager';
10
+ import { TextEditManager } from '../ui/textedit/TextEditManager';
11
+ import { AnsiAwareBuffer, type FormatStateSnapshot, type FormatHyperlink } from '../mud/text/FormatState';
12
+ import { StopwatchManager } from './StopwatchManager';
13
+ import { MapStore } from '../map/MapStore';
14
+ import { type EngineHost } from './EngineHost';
15
+ declare class ScriptingWindowsAPI {
16
+ private readonly session;
17
+ constructor(session: MudSession);
18
+ open(id: string, options?: WindowOpenOptions): WindowHandle;
19
+ write(id: string, text: string): void;
20
+ clear(id: string): void;
21
+ setTitle(id: string, title?: string): boolean;
22
+ focus(id: string): void;
23
+ hide(id: string): void;
24
+ show(id: string): boolean;
25
+ close(id: string): void;
26
+ has(id: string): boolean;
27
+ isVisible(id: string): boolean;
28
+ isMiniConsole(id: string): boolean;
29
+ move(id: string, x: number, y: number): void;
30
+ setParent(id: string, parent?: string): boolean;
31
+ bringToFront(id: string): void;
32
+ sendToBack(id: string): void;
33
+ resize(id: string, width: number, height: number): void;
34
+ setFontSize(id: string, size: number): boolean;
35
+ getFontSize(id: string): number | null;
36
+ setFont(id: string, family: string): boolean;
37
+ getFont(id: string): string | null;
38
+ setBackgroundColor(id: string, r: number, g: number, b: number, a?: number): boolean;
39
+ getBackgroundColor(id: string): {
40
+ r: number;
41
+ g: number;
42
+ b: number;
43
+ a: number;
44
+ } | null;
45
+ element(id: string): HTMLElement | null;
46
+ enableCommandLine(id: string): boolean;
47
+ disableCommandLine(id: string): boolean;
48
+ setCmdLineStyleSheet(id: string, css: string): boolean;
49
+ setCmdLineAction(id: string, cb: ((text: string) => void) | null): boolean;
50
+ clearCmdLine(id: string): boolean;
51
+ printCmdLine(id: string, text: string): boolean;
52
+ appendCmdLine(id: string, text: string): boolean;
53
+ getCmdLineValue(id: string): string;
54
+ }
55
+ declare class ScriptingLabelsAPI {
56
+ private readonly manager;
57
+ /** Resolves the engine's current VFS-aware CSS rewriter. Read lazily
58
+ * (rather than captured) because the engine is bound after this API is
59
+ * constructed; before that it resolves to an identity rewrite. */
60
+ private readonly cssRewriter;
61
+ /** Same lazy-resolution contract as `cssRewriter`, for the rich-text
62
+ * HTML labels render (`<img src>` and inline `style` url(...) refs). */
63
+ private readonly htmlRewriter;
64
+ constructor(manager: LabelManager,
65
+ /** Resolves the engine's current VFS-aware CSS rewriter. Read lazily
66
+ * (rather than captured) because the engine is bound after this API is
67
+ * constructed; before that it resolves to an identity rewrite. */
68
+ cssRewriter: () => (css: string) => string,
69
+ /** Same lazy-resolution contract as `cssRewriter`, for the rich-text
70
+ * HTML labels render (`<img src>` and inline `style` url(...) refs). */
71
+ htmlRewriter: () => (html: string) => string);
72
+ create(name: string, opts: LabelCreateOptions): boolean;
73
+ has(name: string): boolean;
74
+ /** Read-only state for the geometry/visibility/text getters. */
75
+ get(name: string): Readonly<import("../ui/labels/LabelManager").LabelState> | undefined;
76
+ destroy(name: string): boolean;
77
+ move(name: string, x: number, y: number): boolean;
78
+ setParent(name: string, parent: string): boolean;
79
+ resize(name: string, width: number, height: number): boolean;
80
+ show(name: string): boolean;
81
+ hide(name: string): boolean;
82
+ setHtml(name: string, html: string): boolean;
83
+ setBackgroundColor(name: string, r: number, g: number, b: number, a?: number): boolean;
84
+ getBackgroundColor(name: string): {
85
+ r: number;
86
+ g: number;
87
+ b: number;
88
+ a: number;
89
+ } | null;
90
+ setStyleSheet(name: string, css: string): boolean;
91
+ getStyleSheet(name: string): string | undefined;
92
+ setLinkStyle(name: string, color: string, visitedColor: string, underline: boolean): boolean;
93
+ resetLinkStyle(name: string): boolean;
94
+ getSizeHint(name: string): {
95
+ width: number;
96
+ height: number;
97
+ } | null;
98
+ setClickCallback(name: string, fn: ((e: LabelMouseEvent) => void) | undefined): boolean;
99
+ setMouseUpCallback(name: string, fn: ((e: LabelMouseEvent) => void) | undefined): boolean;
100
+ setDoubleClickCallback(name: string, fn: ((e: LabelMouseEvent) => void) | undefined): boolean;
101
+ setMouseMoveCallback(name: string, fn: ((e: LabelMouseEvent) => void) | undefined): boolean;
102
+ setMouseEnterCallback(name: string, fn: ((e: LabelMouseEvent) => void) | undefined): boolean;
103
+ setMouseLeaveCallback(name: string, fn: ((e: LabelMouseEvent) => void) | undefined): boolean;
104
+ setWheelCallback(name: string, fn: ((e: LabelWheelEvent) => void) | undefined): boolean;
105
+ setTooltip(name: string, text: string | undefined): boolean;
106
+ setClickThrough(name: string, value: boolean): boolean;
107
+ setCursor(name: string, cursor: string | undefined): boolean;
108
+ raise(name: string): boolean;
109
+ lower(name: string): boolean;
110
+ }
111
+ export interface InstallOutcome {
112
+ ok: boolean;
113
+ error: string | null;
114
+ }
115
+ export declare class ScriptingAPI {
116
+ private readonly session;
117
+ private readonly connectionId;
118
+ /** The engine backing this API. ScriptingEngine binds itself in its own
119
+ * constructor, immediately after building this object, so in the real app
120
+ * a live engine is present for essentially the whole lifetime. The inert
121
+ * host covers the two cases where one genuinely isn't: after teardown
122
+ * unbinds (see setHost), and in tests, which construct a ScriptingAPI
123
+ * without an engine at all.
124
+ *
125
+ * This is deliberately NOT session-backed. An earlier version gave the
126
+ * unbound host live fallbacks (dial the session, send, emit flushLines) to
127
+ * preserve pre-engine behaviour from the old nullable-callback design.
128
+ * Once the engine started binding in the constructor those became both
129
+ * unreachable in production and actively wrong: after destroy() calls
130
+ * setHost(null), a `connect()` from a surviving DOM link handler would
131
+ * have dialled the session — defeating the teardown refusal three phases
132
+ * earlier in the same function. Inert is the correct unbound behaviour. */
133
+ private host;
134
+ /** OSC 8 selection-group + visited-link state for this connection. */
135
+ private readonly oscLinks;
136
+ readonly windows: ScriptingWindowsAPI;
137
+ readonly labels: ScriptingLabelsAPI;
138
+ readonly cmdLines: CommandLineManager;
139
+ readonly scrollBoxes: ScrollBoxManager;
140
+ readonly textEdits: TextEditManager;
141
+ readonly aliases: AliasEngine;
142
+ readonly triggers: TriggerEngine;
143
+ profileName: string;
144
+ /** When true, errors routed through {@link printError} are also echoed into
145
+ * the main output window (Mudlet's "Show errors in main console"). Wired
146
+ * from ProfileSettings.showErrorsInMainWindow in ProfileSession. */
147
+ showErrorsInMainWindow: boolean;
148
+ readonly timers: TimerEngine;
149
+ readonly keys: KeyEngine;
150
+ /** Mudlet-compatible stopwatch registry (createStopWatch & friends).
151
+ * Persistent watches survive reloads via localStorage keyed by connection. */
152
+ readonly stopwatches: StopwatchManager;
153
+ /** Cross-tab view of open/connected profiles — backs getProfiles(). */
154
+ private readonly presence;
155
+ /** Teardown for the session subscriptions wired in the constructor. */
156
+ private readonly apiUnsubs;
157
+ private readonly mainConsole;
158
+ private inTriggerProcessing;
159
+ private echoDeferred;
160
+ private isDeferringEcho;
161
+ private echoOnMatchedLine;
162
+ /** Mudlet `startLogging(state)`. Forwarded to ProfileSession, which owns
163
+ * the SessionLogger instance (created/torn-down on this hook). */
164
+ private loggingToggler;
165
+ /** Mudlet `appendLog(text)`. Forwarded to the active SessionLogger (wired by
166
+ * ProfileSession, which owns the logger lifecycle). */
167
+ private logAppender;
168
+ /** Mudlet `closeMudlet()`. mudix maps it to "close the active profile":
169
+ * disconnect, then return to the connection screen. Wired by ProfileSession. */
170
+ private closeProfileCallback;
171
+ private selection;
172
+ private clipboard;
173
+ private clipboardText;
174
+ private buffers;
175
+ constructor(session: MudSession, aliasEngine: AliasEngine, triggerEngine: TriggerEngine, timerEngine: TimerEngine, keyEngine: KeyEngine, connectionId: string);
176
+ /** Bind the engine backing this API. Called once by ScriptingEngine during
177
+ * its own construction; pass null on teardown to revert to the inert host,
178
+ * so anything that outlives the engine (a rendered line's link handler,
179
+ * say) can't drive a disposed one. */
180
+ setHost(host: EngineHost | null): void;
181
+ /** The currently bound host. Exposed so tests can layer a single override
182
+ * over it: `api.setHost({ ...api.engineHost, readFileBytes: fn })`. */
183
+ get engineHost(): EngineHost;
184
+ connect(url: string): void;
185
+ /** Dial through the engine's load gate when wired (deferring a connect made
186
+ * during initial load); the default host connects the session directly. */
187
+ private dialConnect;
188
+ disconnect(): void;
189
+ send(text: string, echo?: boolean): void;
190
+ sendGmcp(message: string): void;
191
+ /** Mudlet `sendMSDP(variable, ...values)`. Frames an MSDP subnegotiation
192
+ * (`IAC SB MSDP MSDP_VAR <var> [MSDP_VAL <val>]... IAC SE`) and sends it. */
193
+ sendMSDP(variable: string, values: string[]): boolean;
194
+ /** Mudlet `sendSocket(data)`. Sends a literal byte-string over the socket
195
+ * with no telnet/encoding processing (each char is one byte). */
196
+ sendSocket(data: string): boolean;
197
+ /** Mudlet `feedTelnet(data)`. Injects raw server bytes into the inbound
198
+ * pipeline as if received from the MUD (telnet stripping → ANSI →
199
+ * triggers → render). */
200
+ /** Mudlet `feedTelnet(data)` — inject imitation server bytes. Refused while
201
+ * a socket exists in any state but unconnected, so replayed data can never
202
+ * interleave with a live stream; the message is returned for the binding to
203
+ * shape into Mudlet's `(nil, errMsg)`, and null means it was fed. */
204
+ feedTelnet(data: string): string | null;
205
+ /** Mudlet `loadReplay(fileName)` core. Starts playback of a Mudlet binary
206
+ * replay (.dat). The LuaRuntime binding reads the bytes from the VFS
207
+ * before calling here. Returns null on success or the failure reason. */
208
+ loadReplay(bytes: Uint8Array): string | null;
209
+ /** Mudlet `receiveMSP(text)`. Parses an MSP payload (`!!SOUND(...)` /
210
+ * `!!MUSIC(...)` tags) as if the server had sent it and dispatches the
211
+ * resulting sound/music commands through the normal `msp` event path
212
+ * (SoundManager). Returns true when at least one command was parsed. */
213
+ receiveMSP(payload: string): boolean;
214
+ /** Whether MSP is live on this connection — negotiated with the server, not
215
+ * merely permitted by the profile's `enableMSP` config. Mudlet gates
216
+ * receiveMSP on this (ctelnet::isMSPEnabled). */
217
+ isMspNegotiated(): boolean;
218
+ /** Mudlet `sendATCP(message)`. Frames + sends an ATCP (telnet 200)
219
+ * subnegotiation; false when the socket isn't open. */
220
+ sendATCP(message: string): boolean;
221
+ /** Mudlet `sendTelnetChannel102(msg)`. Frames + sends a zMUD channel-102
222
+ * (telnet 102) subnegotiation; false when the socket isn't open. */
223
+ sendTelnetChannel102(msg: string): boolean;
224
+ /** Mudlet `reconnect()`. Disconnect and redial the last-connected URL;
225
+ * false when no connection has been made this session. */
226
+ /** Mudlet `reconnect()`. Routed through the host rather than straight to the
227
+ * session so it observes the same teardown gate as connect() — otherwise a
228
+ * sysExitEvent handler calling reconnect() opens a socket that the disposal
229
+ * immediately below it then has to tear down. */
230
+ reconnect(): boolean;
231
+ /** Mudlet `getServerEncoding()`. IANA name of the decoder applied to the
232
+ * inbound stream (default "utf-8"). */
233
+ getServerEncoding(): string;
234
+ /** Mudlet `setServerEncoding(name)`. Switch the server stream decoder to
235
+ * `name` (one of getServerEncodingsList()); false when unsupported or no
236
+ * connection is active. */
237
+ setServerEncoding(name: string): boolean;
238
+ /** Mudlet `getServerEncodingsList()`. The encodings mudix can decode. */
239
+ getServerEncodingsList(): string[];
240
+ /** Mudlet `getCharacterName()`. mudix uses one character per profile, so
241
+ * this returns the active profile name (same value as getProfileName());
242
+ * empty string when unset. */
243
+ getCharacterName(): string;
244
+ /**
245
+ * Mudlet `getProfiles()`. A record keyed by profile name, one entry per
246
+ * configured connection, each `{ host, port, loaded, connected, description }`:
247
+ * - `host`/`port` — the MUD's address (mud-mode: stored host/port; ws-mode:
248
+ * parsed from the endpoint URL), available for every profile.
249
+ * - `loaded` — the profile is open (in some tab) and editable. Cross-tab via
250
+ * the Web Lock each open profile holds.
251
+ * - `connected` — the profile is connected to its game. Own tab: live; other
252
+ * tabs: their last-announced state (BroadcastChannel presence). Always
253
+ * false for a profile that isn't loaded.
254
+ * - `description` — the connection record's free-text description.
255
+ * On a duplicate profile name, last-wins (a Lua table can't hold dup keys).
256
+ */
257
+ getProfiles(): Record<string, {
258
+ host: string;
259
+ port: number;
260
+ loaded: boolean;
261
+ connected: boolean;
262
+ description: string;
263
+ }>;
264
+ /** Mudlet `getMudletInfo()`. Echoes a short diagnostic block to the main
265
+ * window. This is a browser client with no Qt build, so it reports the
266
+ * web-client equivalents (profile, server encoding, platform). The client
267
+ * version is our own release (see src/version.ts), not the Mudlet API
268
+ * level — that's what `getMudletVersion()` reports. */
269
+ getMudletInfo(): void;
270
+ /** Mudlet `loadProfile(name) → bool`. Opens the named profile and connects
271
+ * to it. Each profile lives in its own browser tab (the per-profile lock
272
+ * keeps it to one tab), so this opens a NEW tab at `?profile=<id>&connect=1`
273
+ * rather than switching the current one — the calling profile stays open
274
+ * alongside, mirroring Mudlet's multi-profile model. Returns false for an
275
+ * unknown name, when targeting the profile already open in this tab, or when
276
+ * the browser blocks the popup. NOTE: `window.open` needs a user gesture, so
277
+ * this works from a key/button/alias but a browser may block it from a
278
+ * trigger (no Mudlet equivalent to that limitation). */
279
+ loadProfile(name: string): boolean;
280
+ /** Mudlet `getCommandSeparator()`. Returns the profile's command separator
281
+ * (the string that splits one Enter into multiple commands). Defaults to
282
+ * `;;` when the profile hasn't customised it. */
283
+ getCommandSeparator(): string;
284
+ /** The persisted catch-all config bag for the active profile (never null). */
285
+ private configBag;
286
+ /** Shallow-merge a single key into the persisted config bag. */
287
+ private patchConfigBag;
288
+ private getProtocol;
289
+ private setProtocol;
290
+ private getMapperField;
291
+ private setMapperField;
292
+ /** Applies a Mudlet-space room size (`mRoomSize` — a fraction of a grid
293
+ * cell, same unit as `renderer.settings.roomSize`) while holding the
294
+ * *effective* Mudlet exit size constant.
295
+ *
296
+ * Mudlet's exit pen is `(1 / mLineSize) * cellPx * mRoomSize`
297
+ * (`T2DMap::paintEvent`), i.e. exits scale with the room size; the
298
+ * renderer's `lineWidth` is an independent map-unit width. Rescaling
299
+ * `lineWidth` by the same factor reproduces that coupling — and makes a
300
+ * combined `setConfig{mapRoomSize=…, mapExitSize=…}` order-independent,
301
+ * which matters because `Other.lua` walks the table with `pairs()`. */
302
+ private setMudletRoomSize;
303
+ /** The renderer's `lineWidth` expressed in Mudlet's `mLineSize` space —
304
+ * the inverse-thickness divisor `getConfig("mapExitSize")` reports. */
305
+ private mudletExitSize;
306
+ /** Mudlet `getConfig(key [, useStringFormat])`. Returns the option's value,
307
+ * or `undefined` (→ Lua nil, plus a message from the Bridge wrapper) for an
308
+ * unknown key. `useStringFormat` is Mudlet's opt-in for options that kept a
309
+ * legacy boolean reading alongside a newer enum — currently `showSentText`.
310
+ * The no-arg / table forms are handled by the Lua wrapper in Other.lua,
311
+ * which calls this once per key. */
312
+ getConfig(key: string, useStringFormat?: boolean): unknown;
313
+ /**
314
+ * What kind of value `setConfig(key, …)` takes, or null when the key names
315
+ * no option at all. Mudlet reads each option with a `getVerified*` helper,
316
+ * so a value of the wrong TYPE raises while a value that is merely out of
317
+ * range is a `(nil, errMsg)` return — the Bridge wrapper needs to know which
318
+ * of the two applies before it calls through, and only the type is knowable
319
+ * ahead of the call.
320
+ *
321
+ * `'readonly'` keys exist for `getConfig` but refuse every write.
322
+ */
323
+ configKeyKind(key: string): 'bool' | 'num' | 'str' | 'readonly' | null;
324
+ /** Mudlet `setConfig(key, value)`. Returns true when the key is known and
325
+ * writable, false for unknown or read-only keys. */
326
+ setConfig(key: string, value: unknown): boolean;
327
+ /** Mudlet `getProfileInformation()`. Returns the profile's free-text
328
+ * description, or "" when unset. (mudix is single-profile, so the optional
329
+ * profile-name argument is ignored.) */
330
+ getProfileInformation(): string;
331
+ /** Mudlet `setProfileInformation(text)`. Stores the profile's free-text
332
+ * description on the connection record (also editable from the connection
333
+ * screen). Always succeeds for the active profile. */
334
+ setProfileInformation(text: string): boolean;
335
+ /** Mudlet `clearProfileInformation()`. Resets the profile description to
336
+ * an empty string. */
337
+ clearProfileInformation(): boolean;
338
+ /** Mudlet `getProfileIcon()`. Returns the stored icon as a `data:` URI, or
339
+ * "" when the profile has no custom icon (the connection screen then shows
340
+ * the auto-generated name tile). */
341
+ getProfileIcon(): string;
342
+ /** Mudlet `setProfileIcon(path)`. The LuaRuntime binding reads the VFS image
343
+ * and inlines it as a `data:` URI before calling here, so this method only
344
+ * stores the already-resolved icon string. Returns false for an empty
345
+ * value. */
346
+ setProfileIcon(icon: string): boolean;
347
+ /** Mudlet `resetProfileIcon()`. Clears the custom icon so the connection
348
+ * screen falls back to the auto-generated name tile. */
349
+ resetProfileIcon(): boolean;
350
+ /** Mudlet `holdingModifiers(number)`. True when exactly the given set of
351
+ * keyboard modifiers (Qt::KeyboardModifier bitmask, as in
352
+ * `mudlet.keymodifier`) is currently held — exact equality, matching
353
+ * Mudlet. */
354
+ holdingModifiers(modifiers: number): boolean;
355
+ getPackages(): string[];
356
+ installModule(path: string): InstallOutcome;
357
+ uninstallModule(name: string): boolean;
358
+ syncModule(name: string): Promise<void>;
359
+ reloadModule(name: string): boolean;
360
+ enableModuleSync(name: string): void;
361
+ disableModuleSync(name: string): void;
362
+ getModuleSync(name: string): boolean;
363
+ setModulePriority(name: string, priority: number): boolean;
364
+ getModulePriority(name: string): number;
365
+ getModules(): string[];
366
+ getModuleInfo(name: string): Record<string, unknown> | null;
367
+ /** Mudlet `setModuleInfo(name, key, value)`. Stores a custom info field on a
368
+ * module (visible via getModuleInfo). Always true. */
369
+ setModuleInfo(name: string, key: string, value: string): boolean;
370
+ getModulePath(name: string): string | null;
371
+ /** Mudlet `getPackageInfo(name)`. Merged info table — the package manifest's
372
+ * standard fields overlaid with anything set via setPackageInfo. Empty when
373
+ * the package isn't installed and nothing was set. */
374
+ getPackageInfo(name: string): Record<string, string>;
375
+ /** Mudlet `setPackageInfo(name, key, value)`. Stores a custom info field on a
376
+ * package (visible via getPackageInfo). Always true. */
377
+ setPackageInfo(name: string, key: string, value: string): boolean;
378
+ /**
379
+ * Mudlet `setTriggerStayOpen(name, lines)`. Keeps the named trigger's chain
380
+ * open for `lines` more lines of input for the current run only — it adjusts
381
+ * transient chain state, not the persisted trigger's fire-length. 0 closes
382
+ * the chain after the current line; positive values extend or shorten an
383
+ * already-running chain.
384
+ */
385
+ setTriggerStayOpen(name: string, lines: number): boolean;
386
+ /** Hook for ProfileSession to start/stop the per-connection SessionLogger.
387
+ * Mudlet `startLogging(true|false)` toggles whether new output lines are
388
+ * recorded; the on/off transition is synchronous. */
389
+ setLoggingToggler(fn: ((enabled: boolean) => boolean) | null): void;
390
+ /** Mudlet `startLogging(state)`. Returns true on success, false when
391
+ * the toggle isn't wired up yet (e.g. before ProfileSession mounts). */
392
+ startLogging(enabled: boolean): boolean;
393
+ /** Hook for ProfileSession to forward appendLog text to the live logger. */
394
+ setLogAppender(fn: ((text: string) => void) | null): void;
395
+ /** Mudlet `appendLog(text)`. Appends a line to the current session log.
396
+ * No-op (returns false) when logging isn't active. */
397
+ appendLog(text: string): boolean;
398
+ /** Hook for ProfileSession to close the active profile (return to the
399
+ * connection screen). */
400
+ setCloseProfileCallback(fn: (() => void) | null): void;
401
+ /** Mudlet `closeMudlet()`. mudix maps it to closing the active profile:
402
+ * disconnect, then return to the connection screen. */
403
+ closeMudlet(): void;
404
+ /** Mudlet `resetProfile()` — reload the entire profile as if just opened:
405
+ * clear every UI surface, recreate the Lua runtime, and re-run all scripts.
406
+ * The actual work is deferred by the engine (it closes the Lua VM that is
407
+ * currently executing this call), so this returns immediately. */
408
+ resetProfile(): void;
409
+ /** Mudlet `exportAreaImage(areaID, filePath[, zLevel])` — render the area to a
410
+ * PNG file in the profile VFS. Returns `[true, absolutePath]` on success or
411
+ * `[false, errorMessage]` (e.g. the mapper isn't open, or the area is
412
+ * unknown). The 0-indexed array is unpacked into Mudlet's multi-return by
413
+ * Bridge.lua. */
414
+ exportAreaImage(areaId: number, filePath: string, zLevel?: number): [boolean, string];
415
+ killByName(kind: 'timer' | 'alias' | 'trigger' | 'key', name: string): boolean;
416
+ installPackage(path: string): InstallOutcome;
417
+ uninstallPackage(name: string): boolean;
418
+ enableScript(name: string): boolean;
419
+ disableScript(name: string): boolean;
420
+ enableTrigger(nameOrId: string | number): boolean;
421
+ disableTrigger(nameOrId: string | number): boolean;
422
+ enableTimer(name: string): boolean;
423
+ disableTimer(name: string): boolean;
424
+ enableAlias(nameOrId: string | number): boolean;
425
+ disableAlias(nameOrId: string | number): boolean;
426
+ /** The saved keybinding carrying this numeric id, or null. Backs
427
+ * getKeyCode() for a permanent key referenced by the id permKey returned. */
428
+ keyNodeByNumericId(numericId: number): {
429
+ key: string;
430
+ modifiers: string[];
431
+ } | null;
432
+ enableKey(nameOrId: string | number): boolean;
433
+ disableKey(nameOrId: string | number): boolean;
434
+ /**
435
+ * Mudlet `getOS()` — the platform name scripts branch on. Mudlet returns
436
+ * the native OS ("windows"/"mac"/"linux"/…); in the browser we report the
437
+ * underlying OS sniffed from the user agent so platform-specific scripts
438
+ * (e.g. mac vs. windows keybinding hints, the bundled accessibility
439
+ * stylesheet) behave sensibly. "unknown" when it can't be determined.
440
+ */
441
+ getOS(): string;
442
+ /**
443
+ * Full Mudlet `getOS()` return tuple, ordered as the C++ pushes it:
444
+ * `osName, osVersion, [osType], processor` — where the Linux branch inserts
445
+ * an extra `osType` (the distribution type) before the processor, so Linux
446
+ * yields 4 values and every other platform 3. The Lua-side `getOS()` wrapper
447
+ * (Bridge.lua) unpacks this 0-indexed array into the multi-return.
448
+ *
449
+ * In the browser none of these come from QSysInfo, so each is sniffed from
450
+ * `navigator` and falls back to a non-empty `"unknown"` (Mudlet's contract,
451
+ * and the busted spec, require non-empty strings).
452
+ */
453
+ getOSInfo(): string[];
454
+ /** Best-effort OS version string from the user agent; "unknown" if absent. */
455
+ private getOSVersion;
456
+ /** Processor string in Mudlet's format ("x86 (64-bit)", "arm64", …). */
457
+ private getOSProcessor;
458
+ /**
459
+ * Mudlet `getWindowsCodepage()` — on native Windows this reads the active
460
+ * ANSI code page (ACP) from the registry as a string; the bundled
461
+ * utf8_filenames.lua consults it (when getOS() == "windows") to decide
462
+ * whether to transcode filenames from UTF-8 to a legacy ANSI page. The
463
+ * browser VFS is always UTF-8, whose code page number is 65001, so we report
464
+ * that on every platform. utf8_filenames keys its mapping table by legacy
465
+ * ANSI page numbers (1250/1252/932/…), none of which is 65001 — so reporting
466
+ * 65001 makes it correctly skip transcoding rather than corrupt UTF-8 paths.
467
+ */
468
+ getWindowsCodepage(): string;
469
+ exists(nameOrId: string | number, type: string): number;
470
+ /**
471
+ * Mudlet `isActive(name|id, type [, checkAncestors])` — count of *active*
472
+ * items matching the name (or 1/0 for an id). An item is active when its own
473
+ * enabled flag is set; with `checkAncestors` (default false) every ancestor
474
+ * group must be enabled too. Type strings mirror `exists`.
475
+ */
476
+ isActive(nameOrId: string | number, type: string, checkAncestors?: boolean): number;
477
+ /** Mudlet `ancestors(id, type)`. Ancestor chain (parent→root) of the item,
478
+ * or null when no item of that type has the id. */
479
+ ancestors(id: number, type: string): Array<{
480
+ id: number;
481
+ name: string;
482
+ node: string;
483
+ isActive: boolean;
484
+ }> | null;
485
+ /** Mudlet `findItems(name, type [, exact [, caseSensitive]])`. Numeric ids of
486
+ * matching items/groups. Empty when none match or the type is unknown. */
487
+ findItems(name: string, type: string, exact?: boolean, caseSensitive?: boolean): number[];
488
+ /** Mudlet `isAncestorsActive(id, type)`. True when every ancestor group is
489
+ * enabled; null when no item of that type has the id. */
490
+ isAncestorsActive(id: number, type: string): boolean | null;
491
+ /** Mudlet `getProfileStats()`. Per-family total/active counts (+ trigger
492
+ * patterns). See ScriptingEngine.getProfileStats for mudix's caveats. */
493
+ getProfileStats(): Record<string, unknown>;
494
+ permScript(name: string, parent: string, code: string): number;
495
+ permRegexTrigger(name: string, parent: string, regexes: string[], code: string): number;
496
+ /** Mudlet `permSubstringTrigger(name, parent, patterns, luaCode)`. Same
497
+ * shape as permRegexTrigger but each pattern uses substring matching
498
+ * (`String.prototype.includes` semantics, like the temp variant). An
499
+ * empty patterns array creates a trigger group. Returns the new id, or
500
+ * -1 if `parent` is given but no trigger group of that name exists. */
501
+ permSubstringTrigger(name: string, parent: string, patterns: string[], code: string): number;
502
+ /** Mudlet `permBeginOfLineStringTrigger(name, parent, patterns, luaCode)`.
503
+ * Same shape as permSubstringTrigger but each pattern matches only when it
504
+ * appears at the start of the line (`String.prototype.startsWith`, like the
505
+ * `tempBeginOfLineTrigger` variant). An empty patterns array creates a
506
+ * trigger group. Returns the new id, or -1 if `parent` is given but no
507
+ * trigger group of that name exists. */
508
+ permBeginOfLineStringTrigger(name: string, parent: string, patterns: string[], code: string): number;
509
+ /** Mudlet `permExactMatchTrigger(name, parent, patterns, luaCode)`. Same
510
+ * shape as permSubstringTrigger but each pattern matches only on full-line
511
+ * equality. An empty patterns array creates a trigger group. Returns the
512
+ * new id, or -1 if `parent` is given but no trigger group of that name
513
+ * exists. */
514
+ permExactMatchTrigger(name: string, parent: string, patterns: string[], code: string): number;
515
+ /** Mudlet `permPromptTrigger(name, parent, luaCode)`. Creates a persistent
516
+ * trigger that fires on every server prompt line (GA/EOR), with no text
517
+ * pattern. Returns the new id, or -1 if `parent` is given but no trigger
518
+ * group of that name exists. */
519
+ permPromptTrigger(name: string, parent: string, code: string): number;
520
+ /** Mudlet `permAlias(name, parent, regex, luaCode)`. Creates a persistent
521
+ * alias under the named parent group (empty = root). Returns the new
522
+ * alias id, or -1 when `parent` is non-empty but no alias group of that
523
+ * name exists. */
524
+ permAlias(name: string, parent: string, pattern: string, code: string): number;
525
+ /** Mudlet `permTimer(name, parent, seconds, luaCode)`. Creates a
526
+ * persistent one-shot timer under the parent group (empty = root).
527
+ * Returns the new timer id, or -1 when `parent` is non-empty but no
528
+ * timer group of that name exists. */
529
+ permTimer(name: string, parent: string, delay: number, code: string): number;
530
+ /** Mudlet `permKey(name, parent, modifier, keycode, luaCode)`. Persists a
531
+ * keybinding under the named parent group (empty = root). Returns the new
532
+ * id, or -1 when `parent` is non-empty but no key group of that name
533
+ * exists. `modifier` is the Qt keyboard-modifier int (1=shift, 2=ctrl,
534
+ * 4=alt, 8=meta) — -1 means "no modifier" (Mudlet's convention; used by
535
+ * `permGroup("name","key")`). */
536
+ permKey(name: string, parent: string, modifier: number, key: string | number, code: string): number;
537
+ private readonly warnedReservedTempKeys;
538
+ /**
539
+ * Warn (once per unique combo + call site, for this runtime) when a script
540
+ * binds a browser-reserved key via `tempKey`. The profile-load scan covers
541
+ * permanent keybindings, but temp keys are created at runtime and never hit
542
+ * the store, so the check has to happen here at registration time. `key` is a
543
+ * DOM `KeyboardEvent.code`; `modifiers` the {ctrl,shift,alt,meta} subset;
544
+ * `source` is the caller's "script:line" captured by the Lua wrapper.
545
+ */
546
+ warnReservedTempKey(key: string, modifiers: string[], source?: string): void;
547
+ /** Mudlet `tempButton(toolbarName, name, code [, orientation])`. Appends a
548
+ * transient button under an existing toolbar group; returns the new id, or
549
+ * -1 when the toolbar doesn't exist. `orientation` is Mudlet's int form
550
+ * (0=horizontal/1=vertical) — accepted for compat, applied to the
551
+ * button row inside the toolbar grid. */
552
+ tempButton(toolbar: string, name: string, code: string, orientation: number): number;
553
+ /** Mudlet `tempButtonToolbar(name [, orientation [, location]])`. Creates
554
+ * a transient toolbar (ButtonNode group). `location` int: 0=top, 1=bottom,
555
+ * 2=left, 3=right, 4=floating. Returns the new id or -1 on duplicate
556
+ * name. */
557
+ tempButtonToolbar(name: string, orientation: number, location: number): number;
558
+ /** Mudlet `setButtonState(name, state)`. Sets the pressed state of a
559
+ * two-state (push-down) button by name. Returns false when not found. */
560
+ setButtonState(name: string, state: boolean): boolean;
561
+ /** Mudlet `getButtonState(name)`. Reads the pressed state of a two-state
562
+ * button. Returns nil when not found. */
563
+ getButtonState(name: string): boolean | null;
564
+ /** Mudlet `setButtonStyleSheet(name, css)`. Stores a CSS string on the
565
+ * ButtonNode; the renderer applies it inline. Returns false when not
566
+ * found. */
567
+ setButtonStyleSheet(name: string, css: string): boolean;
568
+ /** Mudlet `showToolBar(name)` / `hideToolBar(name)`. Toggles the toolbar's
569
+ * effective enabled flag — the existing button bar already gates render
570
+ * on `isEffectivelyEnabled`, so flipping the group's `enabled` field is
571
+ * the show/hide hook. Returns true on success, false when not found. */
572
+ setToolBarVisibility(name: string, show: boolean): boolean;
573
+ setScript(name: string, code: string, pos: number): number;
574
+ /** Mudlet `getScript(name [, pos]) → code, count`. Returns the source of the
575
+ * pos-th (1-indexed) script named `name` and how many scripts share that
576
+ * name. Returns null when none exist (Bridge.lua surfaces "", 0). */
577
+ getScript(name: string, pos: number): {
578
+ code: string;
579
+ count: number;
580
+ } | null;
581
+ echo(text: string): void;
582
+ echoToWindow(win: string, text: string): void;
583
+ /**
584
+ * Native fast path for the color-echo family (`decho`/`cecho`/`hecho`).
585
+ * Mudlet's Lua `xEcho` splits the string into color segments and crosses the Lua↔JS
586
+ * boundary twice per segment (`setFgColor` + `echo`); a per-character
587
+ * rainbow line is ~180 crossings. This converts the whole string to ANSI in
588
+ * one pass and appends it as a single buffer — the same path network output
589
+ * uses — so a `decho`-heavy loop pays ~1 crossing per line instead.
590
+ *
591
+ * Returns `false` when the fast path can't preserve exact `xEcho` semantics;
592
+ * the Lua wrapper then falls back to the original `decho`. It bails on:
593
+ * - label targets (xEcho replaces their HTML wholesale),
594
+ * - main-window echo during trigger processing (echo appends to the matched
595
+ * line via a raw, non-ANSI insert the ANSI path can't reproduce),
596
+ * - any input the per-kind guard declines ({@link dechoToAnsiFast} /
597
+ * {@link cechoToAnsiFast} / {@link hechoToAnsiFast}) — style tags,
598
+ * combined fg/bg, backgrounds, unknown color names, unmodeled tokens.
599
+ */
600
+ fastColorEcho(kind: string, win: string, str: string): boolean;
601
+ /**
602
+ * Mudlet `echoLink([win,] text, cmd, hint, [useCurrentFormat])`. With
603
+ * `useCurrentFormat=false` (the default), the link is rendered with
604
+ * Mudlet's built-in style: blue foreground + underline. With
605
+ * `useCurrentFormat=true`, the current pen state on the resolved console
606
+ * is preserved.
607
+ */
608
+ echoLink(text: string, cmd: string, tooltip: string, win?: string, useCurrentFormat?: boolean): void;
609
+ /**
610
+ * Build a {@link FormatHyperlink} whose right-click handler opens a context
611
+ * menu listing `cmds` (labelled by `hints`, falling back to the command
612
+ * text). Shared by `echoPopup`/`insertPopup`/`setPopup` — those three differ
613
+ * only in whether the styled span is appended, inserted at the cursor, or
614
+ * applied to the current selection.
615
+ */
616
+ private buildPopupHyperlink;
617
+ /**
618
+ * Build a {@link FormatHyperlink} for an MXP `<SEND>`/`<A>` link. Unlike the
619
+ * popup/link APIs above (whose actions run Lua via `host.runLinkCode`), MXP link
620
+ * targets are MUD commands or URLs:
621
+ * - `kind === 'url'` → left-click opens the URL in a new browser tab.
622
+ * - `kind === 'command'` → left-click sends the command to the MUD (echoed
623
+ * like a typed command).
624
+ * - `promptCmds` (a `cmd1|cmd2|…` list) → right-click shows a popup menu of
625
+ * the commands, each sending to the MUD.
626
+ * Used by ScriptingEngine when rendering MXP-parsed lines.
627
+ */
628
+ createMxpHyperlink(kind: 'command' | 'url', payload: string, hint?: string, promptCmds?: string[], promptHints?: string[]): FormatHyperlink;
629
+ /** Execute an OSC 8 link URI — a primary action or a menu item. The scheme
630
+ * decides the behaviour (send / prompt / open URL); anything else is a
631
+ * no-op (it was already rejected at parse time). */
632
+ private runHyperlinkUri;
633
+ /**
634
+ * Build a {@link FormatHyperlink} for an OSC 8 link URI. The scheme decides
635
+ * the behaviour, mirroring Mudlet: `send:` fires the command immediately,
636
+ * `prompt:` drops it into the command bar for editing, and the web schemes
637
+ * open externally. Returns `undefined` for a disallowed scheme so the link
638
+ * is dropped (the text renders without a click handler).
639
+ */
640
+ createOsc8Hyperlink(uri: string, link?: FormatHyperlink): FormatHyperlink | undefined;
641
+ echoPopup(text: string, cmds: string[], hints: string[], win?: string, useCurrentFormat?: boolean): void;
642
+ /**
643
+ * Mudlet `insertPopup([window,] text, {commands}, {hints})`. Like
644
+ * `insertText`/`insertLink`, but the inserted span carries a right-click
645
+ * popup menu of `cmds`. Inserts at the cursor on the current line and
646
+ * preserves the surrounding pen state; degrades to `echoPopup` when no
647
+ * backing buffer is available (empty console / sub-window without a buffer).
648
+ */
649
+ insertPopup(text: string, cmds: string[], hints: string[], win?: string, useCurrentFormat?: boolean): void;
650
+ /**
651
+ * Mudlet `setPopup([window,] {commands}, {hints})`. Attaches a right-click
652
+ * popup menu to the current selection — preserves the selection's existing
653
+ * colors/attributes (like `setLink`, unlike the homogenizing color setters).
654
+ * `commands` are Lua code strings run when the matching menu entry is
655
+ * chosen. Returns false when there is no selection (or it belongs to a
656
+ * different window).
657
+ */
658
+ setPopup(cmds: string[], hints: string[], win?: string): boolean;
659
+ expandAlias(text: string, echo: boolean): void;
660
+ setFgColor(r: number, g: number, b: number, win?: string): void;
661
+ setBgColor(r: number, g: number, b: number, a?: number, win?: string): void;
662
+ setBold(v: boolean, win?: string): void;
663
+ setItalic(v: boolean, win?: string): void;
664
+ setUnderline(v: boolean, win?: string): void;
665
+ setStrikethrough(v: boolean, win?: string): void;
666
+ /** Mudlet `setOverline([window,] bool)`. Renders a line above the text
667
+ * (CSS `text-decoration: overline`, ANSI SGR 53). Mirrors the other style
668
+ * setters: applies to the active selection when one matches, and updates
669
+ * the resolved console's pen for subsequent echo. */
670
+ setOverline(v: boolean, win?: string): void;
671
+ /**
672
+ * Mudlet `setReverse([window,] bool)`. Toggles reverse-video — the renderer
673
+ * swaps the fg/bg pair when `inverse` is set (see Console rendering). Mirrors
674
+ * the other style setters: applies to the active selection when one matches,
675
+ * and updates the resolved console's pen for subsequent echo.
676
+ */
677
+ setReverse(v: boolean, win?: string): void;
678
+ /**
679
+ * Mudlet `setTextFormat(windowName, r1, g1, b1, r2, g2, b2, bold, underline,
680
+ * italics, [strikeout], [overline], [reverse], [blinkMode]) → bool`. Sets
681
+ * the full pen state in one call. r1/g1/b1 is BACKGROUND, r2/g2/b2 is
682
+ * FOREGROUND (a Mudlet quirk — preserved here for parity). `blinkMode` is
683
+ * "none" / "slow" / "fast". Returns false when the named window doesn't
684
+ * resolve. Mirrors setFgColor & friends: the pen is updated on the resolved
685
+ * console AND applied to the current selection when one is active on it.
686
+ */
687
+ setTextFormat(windowName: string | undefined, bg: {
688
+ r: number;
689
+ g: number;
690
+ b: number;
691
+ }, fg: {
692
+ r: number;
693
+ g: number;
694
+ b: number;
695
+ }, bold: boolean, underline: boolean, italics: boolean, strikeout: boolean, overline: boolean, reverse: boolean, blinkMode: 'none' | 'slow' | 'fast'): boolean;
696
+ fg(name: string, win?: string): void;
697
+ bg(name: string, win?: string): void;
698
+ resetFormat(windowName?: string): boolean;
699
+ selectString(str: string, occurrence: number, windowName?: string): number;
700
+ /**
701
+ * Mudlet `selectSection([window,] from, length) → bool`. `from` is 0-indexed.
702
+ * Negative `from` is rejected (Mudlet behavior); zero/negative lengths
703
+ * register a no-op selection but still report success in Mudlet — we match
704
+ * that, but reject when the resolved buffer doesn't exist.
705
+ */
706
+ selectSection(from: number, length: number, windowName?: string): boolean;
707
+ /**
708
+ * Mudlet `selectCurrentLine([window])`. Selects the entire cursor line —
709
+ * equivalent to `selectSection(0, #getCurrentLine())`. Returns false when
710
+ * the named window doesn't exist; true otherwise (the main window always
711
+ * exists, even with no history yet).
712
+ */
713
+ selectCurrentLine(windowName?: string): boolean;
714
+ /**
715
+ * Mudlet `deselect([windowName])`. With a window name, only clears the
716
+ * selection if it belongs to that window — selections in other consoles
717
+ * remain intact. Without an arg, clears unconditionally.
718
+ */
719
+ deselect(windowName?: string): void;
720
+ /**
721
+ * Mudlet `getSelection([windowName])`. Returns the currently selected text
722
+ * along with its 0-based start column and length on the active line. Returns
723
+ * null when no selection is set, or when `windowName` is given and doesn't
724
+ * match the selection's window — the Lua wrapper translates null into
725
+ * Mudlet's `false, "no selection"` 2-tuple.
726
+ */
727
+ getSelection(windowName?: string): {
728
+ text: string;
729
+ start: number;
730
+ length: number;
731
+ } | null;
732
+ /**
733
+ * Mudlet `getFgColor([window])` / `getBgColor([window])`. Reads the fg/bg
734
+ * color at the current selection's start position (Mudlet's P_begin). Each
735
+ * console tracks its own selection in Mudlet; mudix has a single global
736
+ * selection, so when `window` is given it must match the selection's
737
+ * owning window — otherwise we treat it as "no selection in that window"
738
+ * and return null (Mudlet's "no values" shape, surfaced as nil/nil/nil in
739
+ * Lua via the Bridge wrapper).
740
+ *
741
+ * Mudlet returns 0 values when the cursor sits past the end of the line;
742
+ * we mirror that for an empty buffer or a selection whose start is at/
743
+ * past the buffer length. For valid positions where the segment carries
744
+ * no explicit color, we resolve to the profile's default text/background
745
+ * (matching Mudlet's behavior that every TChar carries baked-in colors).
746
+ */
747
+ getFgColor(windowName?: string): [number, number, number] | null;
748
+ getBgColor(windowName?: string): [number, number, number] | null;
749
+ /**
750
+ * Mudlet `isAnsiFgColor(ansiColor)` / `isAnsiBgColor(ansiColor)`. True when
751
+ * the foreground/background color at the current selection's start equals
752
+ * ANSI/xterm color index `ansiColor` (0..7 normal, 8..15 bright, 16..255 the
753
+ * xterm-256 palette). mudix stores rendered RGB rather than the original
754
+ * ANSI index, so the comparison is against the palette entry's RGB — exact
755
+ * for the 256 standard slots. Returns false when there's no selection (or it
756
+ * belongs to another window) or `ansiColor` is out of range.
757
+ */
758
+ isAnsiFgColor(ansiColor: number): boolean;
759
+ isAnsiBgColor(ansiColor: number): boolean;
760
+ private matchesAnsiColor;
761
+ private readSelectionColor;
762
+ /**
763
+ * Resolve the rgb of `channel` for the character at `pos` in `buf`, falling
764
+ * back to the profile's configured default when the run carries no explicit
765
+ * colour. Shared by getFgColor/getBgColor (selection) and getTextFormat
766
+ * (selection or cursor).
767
+ */
768
+ private readColorAt;
769
+ /**
770
+ * Mudlet `getTextFormat([windowName]) → table | nil, errMsg`. Reads the full
771
+ * set of display attributes of the character at the current selection's start
772
+ * position (Mudlet's "char under cursor or selection"). Mirrors getFgColor /
773
+ * getBgColor: requires an active selection that, when `windowName` is given,
774
+ * belongs to that window, and whose start is within the buffer — otherwise
775
+ * returns null (surfaced as nil + reason by the Bridge wrapper).
776
+ *
777
+ * `foreground`/`background` resolve through the same logic as getFgColor /
778
+ * getBgColor (falling back to the profile defaults for unstyled segments).
779
+ * `overline`, `concealed`, and `alternateFont` have no equivalent in mudix's
780
+ * FormatState, so they report Mudlet's "off" values (false / 0) for parity.
781
+ */
782
+ getTextFormat(windowName?: string): {
783
+ bold: boolean;
784
+ italic: boolean;
785
+ underline: boolean;
786
+ strikeout: boolean;
787
+ reverse: boolean;
788
+ overline: boolean;
789
+ concealed: boolean;
790
+ alternateFont: number;
791
+ blinking: 'none' | 'slow' | 'fast';
792
+ foreground: [number, number, number];
793
+ background: [number, number, number];
794
+ } | null;
795
+ applyFormatToSelection(state: FormatStateSnapshot): void;
796
+ /**
797
+ * Mudlet `setLink([windowName], command, hint)`. Applies a clickable
798
+ * hyperlink to the current selection — preserves existing colors/attributes
799
+ * on each segment (unlike setFgColor & friends which homogenize). `command`
800
+ * is the Lua code run on click; the Bridge.lua wrapper converts function
801
+ * arguments into a `__mudix_call_link(id)` string before reaching here.
802
+ * Returns false if there is no selection (or it doesn't belong to `win`).
803
+ */
804
+ setLink(cmd: string, tooltip: string, win?: string): boolean;
805
+ /**
806
+ * Called before trigger processing for each incoming line. Pushes the
807
+ * matching line into mainConsole.history so cursor-driven APIs see it as
808
+ * a regular addressable line (Mudlet's TBuffer holds the matching line
809
+ * during trigger processing — the cursor is just an (x,y) into that
810
+ * single buffer). The cursor is automatically positioned on the new line
811
+ * at column 0 by Console.appendLine. Also enables echo deferral so
812
+ * trigger-emitted echoes appear after the rendered line.
813
+ */
814
+ beginLine(buffer: AnsiAwareBuffer, isPrompt?: boolean): void;
815
+ /**
816
+ * Called after all triggers for a line have run (but before render).
817
+ * Drops the trigger-active flag; echo deferral stays on until
818
+ * flushDeferredEcho() is called.
819
+ */
820
+ endLine(): void;
821
+ /**
822
+ * Mudlet `tempColorTrigger(fg, bg)` colour-scan helper. Walks the
823
+ * just-appended line buffer (the one beginLine() seeded mainConsole with)
824
+ * and returns true if any segment carries the requested ANSI palette
825
+ * indices. `wantFg`/`wantBg` accept -1 as "any colour"; non-indexed
826
+ * (RGB) segments never match a positive index, matching Mudlet's
827
+ * palette-only semantics.
828
+ */
829
+ currentLineMatchesColor(wantFg: number, wantBg: number): boolean;
830
+ /**
831
+ * The text of the first run on the current line carrying the wanted ANSI
832
+ * colours, or null when none does. A colour trigger reports that run as
833
+ * `matches[1]` — Mudlet matches a contiguous same-coloured run, not the
834
+ * whole line — so adjacent segments sharing the colours are joined.
835
+ *
836
+ * Reads the snapshot beginLine took, not the live buffer: an earlier trigger
837
+ * may already have recoloured the line, and Mudlet still matches against the
838
+ * colours the server sent.
839
+ */
840
+ currentLineColorMatch(wantFg: number, wantBg: number): string | null;
841
+ /** Per-segment ANSI palette indices (and text) of each line currently being
842
+ * processed, as it arrived — see {@link beginLine}. -2 marks a segment with
843
+ * no palette colour (RGB or default), which never matches a requested
844
+ * index. A stack, because a trigger can feedTriggers another line. */
845
+ private lineColorSnapshots;
846
+ /**
847
+ * Flush echo output collected during the just-processed line's trigger run.
848
+ * Called once per line (right after that line is rendered) so a trigger's
849
+ * `echo`/`cecho` lands immediately after the line it fired on — matching
850
+ * Mudlet, where the trigger cursor sits on the matching line and echoed text
851
+ * is inserted there, not piled at the end of the whole flush batch.
852
+ *
853
+ * Emits the completed echo lines, then promotes any trailing partial (an
854
+ * echo without a closing newline, e.g. `cecho("\n text")`) into its own
855
+ * line via `completePartialLine` — which preserves history so later lines in
856
+ * the batch keep correct line numbers, unlike the old wholesale `clear()`.
857
+ */
858
+ flushDeferredEcho(): void;
859
+ /** Raw tail of the last {@link feedTriggers} call that had no trailing
860
+ * newline, carried into the next one — see there. */
861
+ private feedTriggersRemainder;
862
+ /**
863
+ * Feed `text` through the trigger pipeline as if it arrived from the MUD.
864
+ * Routes complete lines through ScriptingEngine.processFlushBatch (same
865
+ * code path as network-driven flushLines) so trigger ordering, ANSI carry,
866
+ * and deferred-echo placement match exactly.
867
+ */
868
+ feedTriggers(text: string): boolean;
869
+ /**
870
+ * Mudlet `getCurrentLine([window])`. Returns the text on the cursor's
871
+ * current line, or `null` when the named window doesn't exist — the Lua
872
+ * binding turns that into Mudlet's `(nil, errMsg)` 2-tuple. Falls back to
873
+ * an empty string for the main window (always present, may have no line yet).
874
+ */
875
+ getCurrentLine(windowName?: string): string | null;
876
+ getLineNumber(windowName?: string): number;
877
+ getLineCount(windowName?: string): number;
878
+ getLastLineNumber(windowName?: string): number;
879
+ disableScrollBar(windowName?: string): void;
880
+ enableScrollBar(windowName?: string): void;
881
+ disableHorizontalScrollBar(windowName?: string): void;
882
+ enableHorizontalScrollBar(windowName?: string): void;
883
+ disableScrolling(windowName?: string): boolean;
884
+ enableScrolling(windowName?: string): boolean;
885
+ /** Mudlet getScroll — 0-indexed buffer line at the top of the viewport. In
886
+ * tail mode reports the last line (Mudlet's mCursorY behaviour at end). */
887
+ getScroll(windowName?: string): number;
888
+ /** Mudlet scrollTo. With no line (or a line past end), resume tail mode.
889
+ * Negative line counts back from the buffer end. */
890
+ scrollTo(windowName: string | undefined, lineNumber: number | undefined): boolean;
891
+ getLines(from: number, to: number, windowName?: string): string[];
892
+ /**
893
+ * Mudlet `getTimestamp([window,] lineNumber)` — the wall-clock time the line
894
+ * entered the buffer, formatted "HH:MM:SS.mmm" (Mudlet's "hh:mm:ss.zzz").
895
+ * `lineNumber` is 1-based to match `getLines`; omit it for the current
896
+ * cursor line. Returns null when the window or line doesn't exist — the Lua
897
+ * binding maps that to Mudlet's `(nil, errMsg)` shape.
898
+ */
899
+ getTimestamp(lineNumber?: number, windowName?: string): string | null;
900
+ /**
901
+ * Mudlet `wrapLine([window,] lineNumber)`. Re-displays the line at
902
+ * `lineNumber` (0-indexed, like getLineNumber/getLineCount), re-interpreting
903
+ * its embedded `\n` and re-wrapping to the current width. Returns false when
904
+ * the window or line doesn't exist.
905
+ */
906
+ wrapLine(lineNumber: number, windowName?: string): boolean;
907
+ /**
908
+ * Mudlet `getConsoleBufferSize([consoleName])` → (linesLimit, batchSize).
909
+ * Returns `null` when the named console doesn't exist so the Lua binding can
910
+ * hand back nil.
911
+ */
912
+ getConsoleBufferSize(windowName?: string): [number, number] | null;
913
+ /**
914
+ * Mudlet `setConsoleBufferSize([consoleName], linesLimit, sizeOfBatchDeletion)`.
915
+ * Sets the scrollback cap (and the round-tripped batch-deletion size).
916
+ * Returns false when the named console doesn't exist.
917
+ */
918
+ setConsoleBufferSize(windowName: string | undefined, linesLimit: number, batchSize?: number): boolean;
919
+ getColumnNumber(windowName?: string): number;
920
+ /** Mudlet `isPrompt()` — reports the per-line prompt flag at the current
921
+ * cursor position. Lines pushed via beginLine carry the flag, so
922
+ * moveCursor + isPrompt can inspect historical lines, not just the most
923
+ * recent one. Defaults to false for the main window when no history exists. */
924
+ isPrompt(windowName?: string): boolean;
925
+ /**
926
+ * Mudlet getColumnCount. Reports the displayable column capacity of the
927
+ * rendered output area — how many monospace characters fit horizontally.
928
+ * Unaffected by setWindowWrap; that controls where lines wrap when text is
929
+ * appended to the buffer, not the screen width. Returning the wrap value
930
+ * would break the canonical Mudlet idiom
931
+ * setWindowWrap(name, getColumnCount(name) - 1)
932
+ * called from a sysUserWindowResizeEvent handler, where each resize would
933
+ * otherwise feed the stored wrap back in and decrement it by one.
934
+ *
935
+ * Fallback path: scripts that just called openUserWindow + resizeWindow
936
+ * commonly busy-loop on getColumnCount in the same JS turn — React can't
937
+ * render the new panel until the loop yields, so a pure DOM measurement
938
+ * stays at 0 forever and the loop hangs. When the window exists but the
939
+ * element hasn't mounted (or measures zero), derive an estimate from the
940
+ * window's logical pixel width and the active font's cell width, so the
941
+ * reported column count tracks resizeWindow even before layout commits.
942
+ */
943
+ getColumnCount(windowName?: string): number;
944
+ /**
945
+ * Mudlet getRowCount(name). Reports the displayable row capacity of the
946
+ * named window (or "main") — how many text lines fit vertically in the
947
+ * rendered area. Mirrors getColumnCount: measures the live element, and
948
+ * falls back to a font-derived estimate from the stored window height when
949
+ * the panel hasn't mounted yet (so resize+busy-loop scripts don't hang).
950
+ */
951
+ getRowCount(windowName?: string): number;
952
+ /**
953
+ * Mudlet setWindowWrap(name, charsPerLine). Sets the visual wrap width
954
+ * (in monospace columns) for the named window or "main". 0 clears the
955
+ * setting. Returns false when the named window does not exist; main always
956
+ * succeeds (persisted on the active profile).
957
+ */
958
+ setWindowWrap(name: string, wrapAt: number): boolean;
959
+ /**
960
+ * Mudlet `getWindowWrap(name) → cols`. Reports the visual wrap width set by
961
+ * setWindowWrap (0 when unset). For "main" reads the profile's stored
962
+ * override; for a named window reads the WindowManager hint. Returns -1 when
963
+ * the named window does not exist (Mudlet's invalid-window sentinel).
964
+ */
965
+ getWindowWrap(name: string): number;
966
+ /**
967
+ * Mudlet `setWindowWrapIndent(name, indent)`. Sets the indent (in
968
+ * characters) applied to newline-started lines in the named window or
969
+ * "main". Returns false when the named window does not exist.
970
+ */
971
+ setWindowWrapIndent(name: string, indent: number): boolean;
972
+ /**
973
+ * Mudlet `setWindowWrapHangingIndent(name, indent)`. Sets the indent (in
974
+ * characters) applied to wrapped continuation lines in the named window or
975
+ * "main". Returns false when the named window does not exist.
976
+ */
977
+ setWindowWrapHangingIndent(name: string, indent: number): boolean;
978
+ /**
979
+ * Mudlet `setMapWindowTitle(title)`. Sets the dockable map panel's tab
980
+ * title; an empty string resets it to the default ("Map"). Returns false
981
+ * when the map widget isn't open.
982
+ */
983
+ setMapWindowTitle(title: string): boolean;
984
+ /**
985
+ * Mudlet `insertText([window,] text)`. Inserts `text` at the cursor on
986
+ * the cursor's current line — works the same way during trigger processing
987
+ * (cursor is on the just-appended matching line) and outside (cursor is
988
+ * wherever moveCursor put it). Falls back to an end-of-buffer echo only
989
+ * when the cursor isn't on a valid line yet (empty buffer / sub-window
990
+ * without a backing buffer).
991
+ */
992
+ insertText(text: string, windowName?: string): void;
993
+ /**
994
+ * Mudlet `insertLink([window,] text, cmd, hint, [useCurrentFormat])`.
995
+ * Like `insertText` but the inserted span is a clickable link bound to
996
+ * `cmd`. With `useCurrentFormat=false` (the default) the link inherits
997
+ * Mudlet's built-in style — blue foreground + underline — layered on top
998
+ * of the current pen state. If no buffer is available (empty console,
999
+ * sub-window without backing buffer) the call degrades to `echoLink` so
1000
+ * the text isn't lost.
1001
+ */
1002
+ insertLink(text: string, cmd: string, tooltip: string, windowName?: string, useCurrentFormat?: boolean): void;
1003
+ /**
1004
+ * Mudlet `moveCursorUp([window,] [lines=1,] [keepHorizontal=false]) → bool`.
1005
+ * `keepHorizontal=true` preserves the column across the vertical move; the
1006
+ * default (false) resets the column to 0.
1007
+ */
1008
+ moveCursorUp(windowName?: string, lines?: number, keepHorizontal?: boolean): boolean;
1009
+ moveCursorDown(windowName?: string, lines?: number, keepHorizontal?: boolean): boolean;
1010
+ /**
1011
+ * Mudlet `moveCursor([window,] x, y) → bool`. The cursor is just an (x,y)
1012
+ * into the central buffer — works the same way during trigger processing
1013
+ * and outside, because the matching line is pushed into Console.history
1014
+ * before triggers fire (Mudlet has the same model: matching line is the
1015
+ * last line in TBuffer; cursor.y is its index). Returns true on a
1016
+ * successful move.
1017
+ */
1018
+ moveCursor(windowName: string | undefined, x: number, y: number): boolean;
1019
+ moveCursorEnd(windowName?: string): void;
1020
+ clearWindow(name?: string): void;
1021
+ /**
1022
+ * Mudlet `createMiniConsole([parent,] name, x, y, width, height)`. Creates
1023
+ * a positioned text panel inside the given parent (defaults to `main`), or
1024
+ * repositions it if it already exists (Mudlet 3.0+ semantics). When parent
1025
+ * is a userwindow, the miniconsole renders inside that parent's viewport
1026
+ * at parent-relative coordinates and follows parent moves/resizes.
1027
+ * Returns true on success.
1028
+ */
1029
+ createMiniConsole(name: string, x: number, y: number, width: number, height: number, parent?: string): boolean;
1030
+ /**
1031
+ * Mudlet `deleteMiniConsole(name)`. Destroys a mini-console created by
1032
+ * createMiniConsole, freeing its registry/buffer/console state. Restricted
1033
+ * to mini-consoles (mirrors Mudlet's CONSOLE-only check) — returns false
1034
+ * for the main window, dockable panels, or an unknown name.
1035
+ */
1036
+ deleteMiniConsole(name: string): boolean;
1037
+ /**
1038
+ * MXP `<FRAME>` (Mudlet 4.21). Maps an MXP frame onto a mini-console — the
1039
+ * browser has no OS-level child/floating windows, so internal, external and
1040
+ * floating frames all become overlay mini-consoles. `attrs` keys are
1041
+ * upper-cased (see `MxpFrameCommand`). `ACTION=close` deletes the frame;
1042
+ * anything else opens it (or repositions it if it already exists). Geometry
1043
+ * (`LEFT`/`TOP`/`WIDTH`/`HEIGHT`) accepts pixels, `N%` of the main window, or
1044
+ * `Nc` character cells.
1045
+ */
1046
+ mxpFrame(name: string, attrs: Record<string, string>): void;
1047
+ /**
1048
+ * Write an MXP `<DEST>` redirected line into a frame's mini-console. Returns
1049
+ * false when no mini-console of that name exists (the caller then renders the
1050
+ * text inline in the main window, matching Mudlet). `eof` clears the frame
1051
+ * first — the status-frame "replace contents" idiom.
1052
+ */
1053
+ mxpWriteToFrame(name: string, buffer: AnsiAwareBuffer, eof: boolean): boolean;
1054
+ /** Parse an MXP geometry dimension: `N%` → fraction of `ref`, `Nc` → N
1055
+ * character cells (approximate), bare number → pixels. null when absent. */
1056
+ private parseMxpDim;
1057
+ /**
1058
+ * Mudlet `createBuffer(name)`. Registers a named off-screen console for
1059
+ * formatting and storing rich text — like a miniconsole, but never shown
1060
+ * on screen (no dock panel). echo/cecho/format/selection target it by name;
1061
+ * `copy` + `appendBuffer` move formatted text in and out. Idempotent and a
1062
+ * no-op when the name is taken by `main` or an existing on-screen window.
1063
+ */
1064
+ createBuffer(name: string): void;
1065
+ /** True when `name` is an off-screen buffer created via createBuffer. */
1066
+ isBuffer(name: string): boolean;
1067
+ /**
1068
+ * Mudlet `copy([window])`. Copies the current selection of the resolved
1069
+ * console — including all formatting — into the session clipboard, a single
1070
+ * rich-text buffer shared with `paste`/`appendBuffer` (Mudlet's host-global
1071
+ * mClipboard). No-op when there's no selection, or when `window` is given
1072
+ * but doesn't own the active selection.
1073
+ */
1074
+ copy(windowName?: string): void;
1075
+ /**
1076
+ * Mudlet `appendBuffer([window])`. Appends the clipboard's rich text (from
1077
+ * the last `copy()`) as a new line at the end of the named console's buffer.
1078
+ * No-op until something has been copied. Mirrors TConsole::appendBuffer.
1079
+ */
1080
+ appendBuffer(windowName?: string): void;
1081
+ /**
1082
+ * Mudlet `paste([window])`. Inserts the clipboard at the cursor's current
1083
+ * column when the cursor sits above the last line; otherwise appends it as
1084
+ * a new line at the end (TConsole::paste semantics). No-op without a prior
1085
+ * copy().
1086
+ */
1087
+ paste(windowName?: string): void;
1088
+ /**
1089
+ * Mudlet `createMapper([parent,] x, y, width, height)`. Creates a positioned
1090
+ * mapper widget inside the given parent (defaults to `main`), or repositions
1091
+ * it if it already exists. Singleton: Mudlet allows only one in-console
1092
+ * mapper at a time, so we reuse a fixed id (`mapper`) — distinct from the
1093
+ * dockable map widget opened by `openMapWidget` (id `map`). Both render the
1094
+ * same MapStore and stay in sync. Returns true on success.
1095
+ */
1096
+ createMapper(x: number, y: number, width: number, height: number, parent?: string): boolean;
1097
+ /**
1098
+ * Mudlet `setWindow(windowName, name[, x, y, show])` — move an element
1099
+ * (label, overlay command line, text edit, scroll box, or a miniconsole /
1100
+ * mapper panel) into another parent window: `main`, a userwindow /
1101
+ * miniconsole, or a scroll box. Mirrors Qt's reparenting semantics: the
1102
+ * element lands at (x, y) in the new parent and is only visible when
1103
+ * `show` is true. Userwindow bases themselves can't be moved (as in
1104
+ * Mudlet, where they anchor a dock widget).
1105
+ */
1106
+ /**
1107
+ * Mudlet `getWindowGeometry(name)` → x, y, width, height. Reads back the
1108
+ * stored geometry the move/resizeWindow setters write, following the same
1109
+ * routing precedence they use (labels → command lines → text edits →
1110
+ * scroll boxes → user windows/miniconsoles). Null when no widget of any
1111
+ * kind owns the name; `"main"` is deliberately excluded because
1112
+ * moveWindow/resizeWindow don't act on it either.
1113
+ */
1114
+ getWindowGeometry(name: string): {
1115
+ x: number;
1116
+ y: number;
1117
+ width: number;
1118
+ height: number;
1119
+ } | null;
1120
+ /**
1121
+ * Mudlet `windowVisible(name)` — *effective* visibility: a widget whose
1122
+ * own flag is set still reports false when any ancestor is hidden. Walks
1123
+ * the parent chain (overlay widgets carry a `parent` name, user windows
1124
+ * resolve theirs through WindowManager) up to `"main"`, which is always
1125
+ * visible. Null when the name belongs to no widget, or is `"main"`.
1126
+ */
1127
+ windowVisible(name: string): boolean | null;
1128
+ /** A widget's own visible flag, ignoring ancestors. Null when unknown. */
1129
+ private ownVisibility;
1130
+ /** The name a widget is nested under, or null once the chain reaches a root. */
1131
+ private parentOf;
1132
+ /**
1133
+ * Mudlet `getLabelText(name)` — the HTML/text last written to a label via
1134
+ * echo()/setLabelText. Null when the name is unknown *or* names a non-label
1135
+ * widget, which Mudlet reports as an error rather than an empty string.
1136
+ */
1137
+ getLabelText(name: string): string | null;
1138
+ setWindow(windowName: string, name: string, x?: number, y?: number, show?: boolean): boolean;
1139
+ /**
1140
+ * Mudlet `replace([win,] with, [keepcolor])`. Default (`keepcolor=false`)
1141
+ * applies the resolved console's current pen state (set via
1142
+ * setFgColor/setBgColor/etc.) to the replacement text. With
1143
+ * `keepcolor=true`, the replacement inherits the selection's existing
1144
+ * format — same as our previous behavior.
1145
+ */
1146
+ replace(newText: string, windowName?: string, keepColor?: boolean): void;
1147
+ /**
1148
+ * Mudlet `deleteLine([window])`. Marks the cursor's current buffer as
1149
+ * deleted. When that buffer is the matching line of an in-flight trigger,
1150
+ * the renderer skips emitting it; when it's a rendered history line,
1151
+ * Console.deleteLine removes it from the DOM.
1152
+ */
1153
+ deleteLine(windowName?: string): void;
1154
+ appendCmdLine(text: string): void;
1155
+ printCmdLine(text: string): void;
1156
+ clearCmdLine(): void;
1157
+ /**
1158
+ * Mudlet selectCmdLineText([commandLine]). Selects (highlights) all text in
1159
+ * the command bar so the next keystroke overtypes it. mudix has a single
1160
+ * main command bar; a named overlay command-line arg is accepted for
1161
+ * compatibility but only "main"/omitted is acted upon. The actual DOM
1162
+ * selection happens in ProfileSession, which owns the input ref.
1163
+ */
1164
+ selectCmdLineText(name?: string): void;
1165
+ /**
1166
+ * Mudlet setCommandBackgroundColor([windowName], r, g, b, [transparency]).
1167
+ * Recolors the command bar's background. mudix only has the main command
1168
+ * bar, so a non-"main" windowName is ignored. `a` is Mudlet's 0..255 alpha;
1169
+ * the CommandBar reads the `inputBackground` profile field as a CSS color.
1170
+ */
1171
+ setCommandBackgroundColor(r: number, g: number, b: number, a?: number, name?: string): boolean;
1172
+ /** Mudlet setCommandForegroundColor — recolors the command bar text. */
1173
+ setCommandForegroundColor(r: number, g: number, b: number, a?: number, name?: string): boolean;
1174
+ private cmdLineValue;
1175
+ private cmdLineProvider;
1176
+ /** Registered by ProfileSession while a command bar is mounted; read only
1177
+ * before the first {@link setCmdLineValue} has mirrored anything. */
1178
+ setCmdLineProvider(fn: (() => string) | null): void;
1179
+ /** Mirror a command-bar edit (user typing, history recall, submit-clear). */
1180
+ setCmdLineValue(text: string): void;
1181
+ getCmdLine(): string;
1182
+ private cmdLineSuggestions;
1183
+ addCmdLineSuggestion(suggestion: string): void;
1184
+ removeCmdLineSuggestion(suggestion: string): void;
1185
+ clearCmdLineSuggestions(): void;
1186
+ getCmdLineSuggestions(): string[];
1187
+ private emitCmdLineSuggestions;
1188
+ /**
1189
+ * Mudlet `openUrl(url) → bool`. Opens a URL in a new browser tab. Special
1190
+ * case: a `file:` prefix (as in `openUrl("file:" .. getMudletHomeDir())`)
1191
+ * routes to the in-app VFS file browser at the given path, since web pages
1192
+ * can't navigate to `file:` URLs.
1193
+ */
1194
+ openUrl(url: string): boolean;
1195
+ /**
1196
+ * Mudlet `invokeFileDialog(fileOrFolder, title[, location])` — UI side.
1197
+ * Emits a `script.filedialog` request; ProfileSession shows the in-app VFS
1198
+ * picker and resolves it. The calling Lua handler is parked on its
1199
+ * coroutine until `onPick` runs (see LuaRuntime.parkDialogThread), so if
1200
+ * nothing is listening (headless runtime, tests) the request is cancelled
1201
+ * immediately — a handler must never stay suspended forever.
1202
+ */
1203
+ invokeFileDialog(request: {
1204
+ mode: 'file' | 'folder';
1205
+ title: string;
1206
+ location: string;
1207
+ }, onPick: (path: string) => void): void;
1208
+ private cmdLineAction;
1209
+ setCmdLineAction(fn: ((text: string) => void) | null): void;
1210
+ /** Engine-side accessor: returns the currently registered action, or null. */
1211
+ getCmdLineAction(): ((text: string) => void) | null;
1212
+ /**
1213
+ * Get (or create) a `<style>` tag in `document.head` owned by this profile.
1214
+ *
1215
+ * Every tag mudix installs on a script's behalf is stamped with the owning
1216
+ * connection id, both in its element id and in `data-mudix-style-owner`, so
1217
+ * {@link destroy} can take them all down again. Mudlet's `setAppStyleSheet`
1218
+ * is genuinely application-wide (a QApplication stylesheet shared by every
1219
+ * open profile), but a mudix tab hosts one profile at a time: leaving a
1220
+ * closed profile's CSS installed silently restyled the *next* profile opened
1221
+ * in that tab. So all three setters — app, profile and per-window — are
1222
+ * profile-local here, and torn down with the profile.
1223
+ */
1224
+ private styleTag;
1225
+ /** Remove every `<style>` tag this profile's scripts installed. */
1226
+ private removeOwnedStyleTags;
1227
+ setAppStyleSheet(css: string, tag?: string): boolean;
1228
+ setUserWindowStyleSheet(name: string, css: string): boolean;
1229
+ /**
1230
+ * Mudlet `setProfileStyleSheet(stylesheet)`. Installs (or replaces) a
1231
+ * profile-wide CSS block. In Mudlet this themes the whole profile's
1232
+ * widgets; the browser analogue is a single `<style>` tag in document.head,
1233
+ * keyed separately from setAppStyleSheet's blocks so the two don't clobber
1234
+ * each other. Raises sysAppStyleSheetChange (tag "profile") for parity with
1235
+ * the app-level setter. Always returns true.
1236
+ */
1237
+ setProfileStyleSheet(css: string): boolean;
1238
+ /**
1239
+ * Mudlet `setClipboardText(textContent)`. Updates the session text
1240
+ * clipboard and best-effort writes it to the OS clipboard via
1241
+ * navigator.clipboard (which may reject without a user gesture or in an
1242
+ * insecure context — the in-process mirror is authoritative regardless).
1243
+ * Always returns true.
1244
+ */
1245
+ setClipboardText(text: string): boolean;
1246
+ /**
1247
+ * Mudlet `getClipboardText()`. Returns the session text clipboard. Because
1248
+ * the OS clipboard can only be read asynchronously in the browser, we kick
1249
+ * off a best-effort refresh (so a subsequent call reflects an external copy)
1250
+ * and return the current mirror synchronously, matching Mudlet's signature.
1251
+ */
1252
+ getClipboardText(): string;
1253
+ centerView(roomId: number): boolean;
1254
+ /** Mudlet `createMapView([areaID])` → the new view id, or the refusal
1255
+ * message when the areaID names no area. */
1256
+ createMapView(areaId: number): number | string;
1257
+ /** Mudlet `closeMapView(viewID)`. False when no view has that id. */
1258
+ closeMapView(viewId: number): boolean;
1259
+ /** Mudlet `closeAllMapViews()` → how many were closed. */
1260
+ closeAllMapViews(): number;
1261
+ /** Mudlet `getMapViewIds()` — every open view, in creation order. */
1262
+ getMapViewIds(): number[];
1263
+ /** Mudlet `getMapViewInfo(viewID)` → `{areaId, centeredRoomId, zoom, zLevel}`,
1264
+ * or undefined when no view has that id. */
1265
+ getMapViewInfo(viewId: number): {
1266
+ areaId: number;
1267
+ zoom: number;
1268
+ zLevel: number;
1269
+ centeredRoomId: number;
1270
+ } | undefined;
1271
+ /**
1272
+ * Mudlet `getMapZoom([areaID])` — the number of map units visible across the
1273
+ * viewport's shorter edge. Mudlet keeps this on the area (TArea's
1274
+ * `mLast2DMapZoom`, reached via TRoomDB::get2DMapZoom), so it answers with
1275
+ * no mapper mounted and each area remembers its own; mudix stores it the
1276
+ * same way. Without an areaID the live renderer's current zoom wins when one
1277
+ * is mounted. Undefined for an areaID that doesn't exist — the binding
1278
+ * reports that as `(nil, errMsg)`.
1279
+ */
1280
+ getMapZoom(areaID?: number): number | undefined;
1281
+ /**
1282
+ * Mudlet `setMapZoom(zoom [, areaID])`. Like Mudlet the zoom must be at
1283
+ * least 3.0, and an areaID that doesn't exist is refused. Stored on the area
1284
+ * and pushed to the live renderer when one is mounted. Returns the refusal
1285
+ * message, or null on success, for the binding to shape.
1286
+ */
1287
+ setMapZoom(zoom: number, areaID?: number): string | null;
1288
+ /** The area the 2D view is showing — the player's room's area, falling back
1289
+ * to the default area when there is no player room yet. */
1290
+ private currentMapArea;
1291
+ /** Mudlet `updateMap()` — force the map to re-read MapStore and redraw. */
1292
+ updateMap(): void;
1293
+ getRoomIDbyHash(hash: string): number | undefined;
1294
+ get map(): MapStore;
1295
+ get cmdLineMenu(): import("../ui/CmdLineMenuRegistry").CmdLineMenuRegistry;
1296
+ get mouseEvents(): import("../ui/MouseEventRegistry").MouseEventRegistry;
1297
+ get sounds(): import("../ui/sound/SoundManager").SoundManager;
1298
+ get videos(): import("../ui/video/VideoManager").VideoManager;
1299
+ /** Mudlet `setMapBackgroundColor(r, g, b)`. Persists into the profile
1300
+ * mapper settings so MapPanel picks it up on its next render pass. */
1301
+ setMapBackgroundColor(r: number, g: number, b: number): boolean;
1302
+ /** Mudlet `setMapRoomSize(size)`. Maps to renderer.settings.roomSize via
1303
+ * the profile mapper field. Returns false for non-positive values. */
1304
+ setMapRoomSize(size: number): boolean;
1305
+ /** Mudlet `getMapRoomSize()`. Reads the active room-size value. Falls back
1306
+ * to the MAPPER_DEFAULTS.roomSize when unset. */
1307
+ getMapRoomSize(): number;
1308
+ /**
1309
+ * Mudlet `loadMap([location])`. Persists the bytes (when given) to the
1310
+ * connection's binary-map IndexedDB slot and re-renders any open MapPanel.
1311
+ * The Lua binding in LuaRuntime reads the VFS path before calling here so
1312
+ * this method only deals in already-decoded bytes. Returns true unless the
1313
+ * panel reported a parse failure for the given buffer.
1314
+ */
1315
+ loadMap(buf?: Uint8Array): boolean;
1316
+ /**
1317
+ * Mudlet `saveMap([location])`. Serialises the current MapStore to the
1318
+ * Mudlet binary `.dat` format and persists it to the connection's default
1319
+ * IndexedDB slot (so it survives reload). Returns the bytes so the Lua
1320
+ * binding can also write them to a VFS path when one is supplied. Returns
1321
+ * null when serialisation fails.
1322
+ */
1323
+ saveMap(): Uint8Array | null;
1324
+ /** Mudlet `loadMap("...xml")` backbone — import an IRE-style XML map
1325
+ * (XMLimport::readMap) and replace the current map. The Lua binding
1326
+ * reads the VFS file before calling here. Returns false when the text
1327
+ * is not a well-formed XML map. */
1328
+ loadMapXml(xmlText: string): boolean;
1329
+ /** Mudlet `saveJsonMap(path)` backbone — serialises the current MapStore
1330
+ * as JSON. The Lua binding writes the result to the supplied VFS path. */
1331
+ saveJsonMap(): string;
1332
+ /** Mudlet `loadJsonMap(path)` backbone — parse a JSON payload previously
1333
+ * produced by saveJsonMap and reload the map. Returns false when the
1334
+ * JSON is malformed or doesn't match the MudletMap shape. */
1335
+ loadJsonMap(json: string): boolean;
1336
+ /** Mudlet `addSupportedTelnetOption(option)`. Forwarded to the session
1337
+ * client so the next IAC WILL/DO from the server can be auto-accepted. */
1338
+ addSupportedTelnetOption(option: number): boolean;
1339
+ /**
1340
+ * Mudlet `saveWindowLayout()` — capture the current layout (window hints
1341
+ * + dock area extents) into a per-connection snapshot in the persisted
1342
+ * app store. A later `loadWindowLayout()` re-applies the captured state.
1343
+ * Returns true on success, false when no connectionId is bound.
1344
+ */
1345
+ saveWindowLayout(): boolean;
1346
+ /**
1347
+ * Mudlet `loadWindowLayout()` — restore the most recently saved snapshot
1348
+ * for this connection. Re-applies geometry, dock state, font/colour, and
1349
+ * visibility to live windows; opens windows that the snapshot had visible
1350
+ * but are not currently mounted. Returns false when no snapshot exists.
1351
+ */
1352
+ loadWindowLayout(): boolean;
1353
+ /**
1354
+ * Mudlet `getTime()` — current local time as a record. The Bridge.lua wrapper
1355
+ * picks fields off this object for the `{year, month, day, hour, min, sec,
1356
+ * msec}` table form, and uses `wday` (0=Sun..6=Sat) to format `ddd`/`dddd`
1357
+ * tokens when the script asks for a formatted string.
1358
+ */
1359
+ getTime(): {
1360
+ year: number;
1361
+ month: number;
1362
+ day: number;
1363
+ hour: number;
1364
+ min: number;
1365
+ sec: number;
1366
+ msec: number;
1367
+ wday: number;
1368
+ };
1369
+ /**
1370
+ * Mudlet `getNetworkLatency()` — round-trip time of the most recent
1371
+ * keep-alive ping. Returns the last measured value (in ms) for as long as
1372
+ * the connection is up; -1 when no measurement has been made yet (mirrors
1373
+ * Mudlet's "not yet measured" sentinel — better than a fake 0 which would
1374
+ * read as "instant" in scripts charting latency).
1375
+ */
1376
+ getNetworkLatency(): number;
1377
+ private lastPingMs;
1378
+ getMainWindowSize(): [number, number];
1379
+ /**
1380
+ * Mudlet `hasFocus([window])` → bool. Reports whether the named console (or
1381
+ * the main command bar / output area when omitted) currently holds keyboard
1382
+ * focus. mudix maps "main"/omitted to the command input, and a named window
1383
+ * to its registered overlay element. Returns false when nothing matches.
1384
+ */
1385
+ hasFocus(windowName?: string): boolean;
1386
+ /**
1387
+ * Mudlet `alert([seconds])`. Mudlet flashes the taskbar entry to grab the
1388
+ * user's attention; browsers have no taskbar-flash API, so we flash the
1389
+ * document title (alternating with a "● " bell prefix) for `seconds`
1390
+ * (default 10, Mudlet's default), and skip the flash entirely while the tab
1391
+ * is already focused — matching Mudlet, which no-ops when the window is
1392
+ * active.
1393
+ */
1394
+ alert(seconds?: number): void;
1395
+ /**
1396
+ * Mudlet `getMainConsoleWidth()` — pixel width of the main console's text
1397
+ * area. Mudlet computes `averageCharWidth * (wrapAt + 1)`; we mirror that
1398
+ * with a canvas-measured monospace cell for the profile's output font, and
1399
+ * resolve the wrap column from the profile's `outputWrapAt` override (the
1400
+ * value `setWindowWrap("main", n)` writes), falling back to the live
1401
+ * measured column count when no explicit wrap is set.
1402
+ */
1403
+ getMainConsoleWidth(): number;
1404
+ /**
1405
+ * Mudlet `getConnectionInfo()` → `host, port, connected`. Mudlet reports the
1406
+ * MUD's telnet host/port; mudix reads them off the active connection config.
1407
+ * For a `mud`-mode connection those are the stored host/port; for a raw
1408
+ * `websocket` connection we parse them out of the endpoint URL (port falls
1409
+ * back to the ws/wss default). `connected` reflects the live session status.
1410
+ */
1411
+ getConnectionInfo(): {
1412
+ host: string;
1413
+ port: number;
1414
+ connected: boolean;
1415
+ };
1416
+ /**
1417
+ * Mudlet `connectToServer(host, port [, save])`. mudix tunnels MUD traffic
1418
+ * through a WebSocket proxy, so this builds the same `proxy?host=&port=` URL
1419
+ * the connection screen uses and (re)connects the live session. With `save`,
1420
+ * the host/port are persisted onto the active connection (switching it to
1421
+ * mud-mode) so they survive a reload — the analogue of Mudlet's profile
1422
+ * write. Returns false for an out-of-range port.
1423
+ */
1424
+ connectToServer(host: string, port?: number, save?: boolean): boolean;
1425
+ /**
1426
+ * Mudlet `getLabelSizeHint(name)` → `width, height` (the label's preferred
1427
+ * content size). Returns null when no such label — the Lua binding maps that
1428
+ * to Mudlet's `(nil, errMsg)` shape.
1429
+ */
1430
+ getLabelSizeHint(name: string): {
1431
+ width: number;
1432
+ height: number;
1433
+ } | null;
1434
+ /**
1435
+ * Mudlet `announce(text [, processing])` — push `text` to assistive tech.
1436
+ * Mudlet raises a Qt accessibility announcement; the browser equivalent is
1437
+ * an ARIA live region. `processing` maps to live-region politeness exactly
1438
+ * as Mudlet does: `importantall`/`importantmostrecent` → `assertive`, every
1439
+ * other value → `polite`. Two persistent off-screen regions are reused so
1440
+ * repeated calls don't pile up DOM nodes. The text is cleared then re-set on
1441
+ * a microtask so screen readers re-announce even identical consecutive
1442
+ * messages (a live region that doesn't change is not spoken again).
1443
+ */
1444
+ announce(text: string, processing?: string): void;
1445
+ /**
1446
+ * Mudlet `showNotification(title [, content [, expiryInSeconds]])` → true.
1447
+ * Mudlet pops a system tray notification; the browser equivalent is the Web
1448
+ * Notifications API. `content` defaults to `title` (matching Mudlet). `expiry`
1449
+ * (when given, ≥1s) auto-closes the notification.
1450
+ *
1451
+ * Gated on the user having opted in via Settings (`client.notificationsEnabled`),
1452
+ * which is also where the browser permission prompt is raised — so we never
1453
+ * trigger a permission pop-up from a script call here, and silently no-op
1454
+ * unless the user enabled notifications AND the browser granted permission.
1455
+ * Mudlet always returns true regardless of whether anything is shown, so we
1456
+ * match that — the return value reflects "the call was accepted", not "a
1457
+ * notification appeared".
1458
+ */
1459
+ showNotification(title: string, content?: string, expirySeconds?: number): boolean;
1460
+ /**
1461
+ * Mudlet getMousePosition() → x, y in main-console-local pixels. Tracked
1462
+ * passively via document-level pointermove/mousedown — before any input
1463
+ * has been seen returns 0,0. When the cursor is outside the main viewport
1464
+ * the result is negative or past the viewport bounds (same as Qt's
1465
+ * mapFromGlobal). Falls back to viewport coords if the main element
1466
+ * isn't mounted.
1467
+ */
1468
+ getMousePosition(): [number, number];
1469
+ /**
1470
+ * Mudlet getUserWindowSize(name). Returns the rendered [width, height] of a
1471
+ * userwindow / miniconsole in pixels. Reports the live element box when the
1472
+ * panel is mounted (so docked panels reflect their actual on-screen size),
1473
+ * otherwise falls back to the stored window hint. Returns [0, 0] when the
1474
+ * window doesn't exist.
1475
+ */
1476
+ getUserWindowSize(name: string): [number, number];
1477
+ /**
1478
+ * Mudlet setFontSize. Without `win` (or "main"), persists the size on the
1479
+ * active profile so the main output picks it up. With a window name, sets
1480
+ * the per-window output font size on WindowManager (saved into the hint).
1481
+ */
1482
+ setFontSize(size: number, win?: string): boolean;
1483
+ /**
1484
+ * Mudlet setMiniConsoleFontSize. Strictly targets miniconsoles (created via
1485
+ * createMiniConsole / createConsole) — userwindows and labels are rejected
1486
+ * the same way Mudlet's CONSOLE-only lookup rejects them.
1487
+ */
1488
+ setMiniConsoleFontSize(name: string, size: number): boolean;
1489
+ /**
1490
+ * Mudlet getFontSize. Returns the configured font size in pixels for the
1491
+ * main window (when no name passed) or for a specific window. Returns null
1492
+ * if a named window doesn't exist or has no override.
1493
+ */
1494
+ getFontSize(win?: string): number | null;
1495
+ /**
1496
+ * Mudlet setBackgroundColor. With no name (or "main") sets the main window
1497
+ * background; otherwise dispatches to the matching label or userwindow/
1498
+ * miniconsole. Channels are 0..255; alpha defaults to 255.
1499
+ */
1500
+ setBackgroundColor(name: string | undefined, r: number, g: number, b: number, a?: number): boolean;
1501
+ /**
1502
+ * Mudlet getBackgroundColor. Without a name (or "main") returns the main
1503
+ * window background; otherwise looks up the named window/miniconsole. Labels
1504
+ * fall through here too — their fill color is reported. Returns null when
1505
+ * the name doesn't resolve to anything; callers (Lua wrapper) translate that
1506
+ * to a 4-tuple of zeros.
1507
+ */
1508
+ getBackgroundColor(name?: string): {
1509
+ r: number;
1510
+ g: number;
1511
+ b: number;
1512
+ a: number;
1513
+ } | null;
1514
+ /**
1515
+ * Mudlet `setBackgroundImage`. Dispatcher across labels, miniconsoles /
1516
+ * userwindows, and the main window — matches Mudlet's overload set:
1517
+ *
1518
+ * setBackgroundImage(labelName, imageLocation) → label
1519
+ * setBackgroundImage(imageLocation, [mode]) → main console
1520
+ * setBackgroundImage(windowName, imageLocation, [mode]) → miniconsole / userwindow
1521
+ *
1522
+ * Disambiguation matches Mudlet's C++ semantics — label lookup wins when
1523
+ * the named widget is a label; otherwise the call is treated as a console
1524
+ * form. `mode` arrives already coerced to a number by the GUIUtils.lua
1525
+ * wrapper (string mode like "center" → 2 via `mudlet.BgImageMode`). For
1526
+ * label form `imageLocation` is a VFS path, resolved through the same
1527
+ * rewriter that powers setLabelStyleSheet so package-bundled images work
1528
+ * without scripts knowing about the vfs:// scheme.
1529
+ */
1530
+ setBackgroundImage(a: string, b?: string | number, c?: number): boolean;
1531
+ /**
1532
+ * Mudlet `resetBackgroundImage([windowName])`. Without a name (or "main")
1533
+ * clears the main window background image; otherwise looks up the named
1534
+ * label or window and clears its image. Returns true on success.
1535
+ */
1536
+ resetBackgroundImage(name?: string): boolean;
1537
+ /**
1538
+ * Mudlet `setLabelCustomCursor(labelName, cursorPath, [hotX, hotY])`. Points
1539
+ * the label's mouse cursor at a custom image. The path is run through the
1540
+ * VFS-aware URL resolver (same as setBackgroundImage) so package-relative
1541
+ * paths resolve, then composed into a CSS `cursor: url(...) hotX hotY, auto`
1542
+ * value. hotX/hotY are the cursor hotspot in pixels (default 0,0). Returns
1543
+ * false when the label doesn't exist.
1544
+ */
1545
+ setLabelCustomCursor(name: string, path: string, hotX?: number, hotY?: number): boolean;
1546
+ /**
1547
+ * Mudlet `setMovie(labelName, path)` — decode the animation at `path`,
1548
+ * install it on the label, and start playing (Mudlet starts immediately
1549
+ * too). GIFs decode synchronously via the bundled decoder (every
1550
+ * browser); WebP/APNG go through the WebCodecs ImageDecoder where
1551
+ * available (Chromium/Safari) — for those a pending player is installed
1552
+ * immediately (so follow-up scaleMovie/startMovie calls work, matching
1553
+ * the Mudlet idiom) and frames land when the async decode completes.
1554
+ * False when the label doesn't exist or the file isn't decodable.
1555
+ */
1556
+ setMovie(name: string, path: string): boolean;
1557
+ /** Mudlet `startMovie(labelName)` — resume a paused/finished animation. */
1558
+ startMovie(name: string): boolean;
1559
+ /** Mudlet `pauseMovie(labelName)` — freeze on the current frame. */
1560
+ pauseMovie(name: string): boolean;
1561
+ /** Mudlet `setMovieFrame(labelName, n)` — jump to frame n (0-based, like
1562
+ * QMovie::jumpToFrame). False when the frame doesn't exist. */
1563
+ setMovieFrame(name: string, frame: number): boolean;
1564
+ /** Mudlet `setMovieSpeed(labelName, percent)` — 100 = recorded speed. */
1565
+ setMovieSpeed(name: string, percent: number): boolean;
1566
+ /** Mudlet `scaleMovie(labelName, [autoscale=true])` — size the GIF to the
1567
+ * label; with autoscale it keeps tracking label resizes. */
1568
+ scaleMovie(name: string, autoscale: boolean): boolean;
1569
+ /** Label form of setBackgroundImage — mirrors Mudlet's `pL->setPixmap()`,
1570
+ * which shows the image at its native pixel size rather than scaling it
1571
+ * to the label. CSS already does that for raster formats; SVGs without a
1572
+ * `width`/`height` have no CSS intrinsic size and get stretched, so once
1573
+ * the image loads we resolve its real size (viewBox fallback, matching
1574
+ * Qt's QSvgRenderer::defaultSize()) and patch it in. */
1575
+ private applyLabelBackgroundImage;
1576
+ private applyBackgroundImage;
1577
+ /** Runs `path` through the active VFS-aware CSS rewriter so package paths
1578
+ * (e.g. `MyPackage/bg.png`) resolve to vfs:// URLs the renderer can load.
1579
+ * Absolute http(s):/data:/blob: URIs pass through untouched. */
1580
+ private resolveImageUrl;
1581
+ setBorderTop(size: number): void;
1582
+ setBorderBottom(size: number): void;
1583
+ setBorderLeft(size: number): void;
1584
+ setBorderRight(size: number): void;
1585
+ /**
1586
+ * Mudlet setBorderSizes — CSS-shorthand-style overloads:
1587
+ * 1 arg → uniform (all = a)
1588
+ * 2 args → (vertical, horizontal) (top=bottom=a, left=right=b)
1589
+ * 3 args → (top, horizontal, bot) (left=right=b)
1590
+ * 4 args → CSS top/right/bottom/left
1591
+ * Other arities no-op (matches Mudlet's silent reject).
1592
+ */
1593
+ setBorderSizes(a?: number, b?: number, c?: number, d?: number): void;
1594
+ getBorderTop(): number;
1595
+ getBorderBottom(): number;
1596
+ getBorderLeft(): number;
1597
+ getBorderRight(): number;
1598
+ getBorderSizes(): {
1599
+ top: number;
1600
+ right: number;
1601
+ bottom: number;
1602
+ left: number;
1603
+ };
1604
+ /** Mudlet setBorderColor. Channels are 0..255; alpha defaults to 255. */
1605
+ setBorderColor(r: number, g: number, b: number, a?: number): void;
1606
+ /** Mudlet resetBorderColor — clears the override so the border tracks the page background again. */
1607
+ resetBorderColor(): void;
1608
+ /** Mudlet getBorderColor — RGB of the main console frame border. Returns the
1609
+ * explicit setBorderColor override when set; otherwise the main window
1610
+ * background (which the border visually inherits), falling back to black. */
1611
+ getBorderColor(): [number, number, number];
1612
+ /** Mudlet `getProcessMemoryUsage()` → process RSS in Kb. The browser sandbox
1613
+ * exposes no whole-process RSS, so this returns the JS heap currently in use
1614
+ * (`performance.memory`, Chromium only) as the closest analogue, or 0 when
1615
+ * the API is unavailable (Firefox/Safari). */
1616
+ getProcessMemoryUsage(): number;
1617
+ /** Mudlet `getSubsystemMemoryStats()` → a diagnostic table of heap metrics
1618
+ * plus per-subsystem counts. Browser-adapted: heap figures come from
1619
+ * `performance.memory` (Chromium; 0 elsewhere); the Lua GC figure
1620
+ * (`luaMemoryKb`) is added by the Bridge.lua wrapper via
1621
+ * `collectgarbage("count")`. Counts are best-effort snapshots. */
1622
+ getSubsystemMemoryStats(): Record<string, number>;
1623
+ private patchBorders;
1624
+ private applyBorders;
1625
+ private normalizeBorder;
1626
+ /**
1627
+ * Mudlet setFont. Without `win` (or "main"), updates the active profile's
1628
+ * outputFont so the App-level applyOutputFont effect re-applies the
1629
+ * --font-output CSS variable.
1630
+ * With a window name, sets the per-window override on WindowManager.
1631
+ * Empty `family` clears the override (main → unset, window → inherit).
1632
+ */
1633
+ setFont(family: string, win?: string): boolean;
1634
+ /**
1635
+ * Mudlet getFont. Returns the configured font family for the main window
1636
+ * (or empty string if none set) or for a specific window. Returns null if
1637
+ * the named window doesn't exist.
1638
+ */
1639
+ getFont(win?: string): string | null;
1640
+ /**
1641
+ * Mudlet `calcFontSize(window_or_fontsize [, fontname])` — returns the
1642
+ * `[width, height]` of an average character cell in pixels. Two overloads:
1643
+ *
1644
+ * • `calcFontSize(size [, family])` — measure `family` (or the main
1645
+ * output font when omitted) at `size` points (Qt point sizes, like
1646
+ * every font size in the Mudlet API).
1647
+ * • `calcFontSize("WindowName")` — measure the named window/miniconsole
1648
+ * using its configured font+size. Use `"main"` for the main output.
1649
+ *
1650
+ * Returns `null` when the size is invalid or the named window doesn't
1651
+ * exist; the Lua wrapper turns that into Mudlet's `(nil, errMsg)` shape.
1652
+ */
1653
+ calcFontSize(arg: number | string, fontName?: string): [number, number] | null;
1654
+ /**
1655
+ * Mudlet `getAvailableFonts()` — set-style table whose keys are font
1656
+ * family names usable from scripts. The browser cannot enumerate the
1657
+ * system font list without an explicit Local Font Access permission, so
1658
+ * this is a best-effort union of what we *do* know:
1659
+ * - Universal web-safe families that work everywhere.
1660
+ * - Every family the FontFaceSet has materialized (URL- or VFS-loaded
1661
+ * fonts go in here once the browser has registered the @font-face).
1662
+ * - The profile's currently configured output font, if any.
1663
+ * - Locally installed system fonts, but only when the user has already
1664
+ * granted Local Font Access in this browser profile — we never prompt
1665
+ * from inside this getter. A silent prime kicks off here so the next
1666
+ * call sees the result.
1667
+ */
1668
+ getAvailableFonts(): Record<string, boolean>;
1669
+ /** Flush any buffered partial lines to the main output and all open windows. Called after each event dispatch. */
1670
+ flushOutput(): void;
1671
+ /** @deprecated use echo() */
1672
+ print(text: string): void;
1673
+ printError(text: string, source?: ScriptLogSource): void;
1674
+ destroy(): void;
1675
+ private getConsole;
1676
+ /**
1677
+ * Whether `windowName` is addressable for text/selection ops. True for the
1678
+ * main window, any on-screen window, and off-screen buffers (createBuffer) —
1679
+ * all of which back a Console. Used by the read/select methods instead of a
1680
+ * bare `windows.has`, which is false for buffers (they have no panel).
1681
+ */
1682
+ private consoleExists;
1683
+ /** Returns the Console for a window, creating and registering one on demand. */
1684
+ private outputConsole;
1685
+ private drainWindowConsole;
1686
+ private resolveBuffer;
1687
+ private selectionMatches;
1688
+ private applyStateToSelection;
1689
+ private drainMain;
1690
+ }
1691
+ export {};