@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.
- package/LICENSE +338 -0
- package/README.md +150 -0
- package/dist-lib/App.d.ts +1 -0
- package/dist-lib/MudletWebApp.d.ts +11 -0
- package/dist-lib/ProfileSession.d.ts +15 -0
- package/dist-lib/assets/mapParser.worker-t-3rd1zR.js +9 -0
- package/dist-lib/branding.d.ts +213 -0
- package/dist-lib/core/EventBus.d.ts +29 -0
- package/dist-lib/db/sqliteClient.d.ts +25 -0
- package/dist-lib/hooks/useEngines.d.ts +12 -0
- package/dist-lib/hooks/useMudSession.d.ts +10 -0
- package/dist-lib/hooks/useOutput.d.ts +17 -0
- package/dist-lib/hooks/useViewportMode.d.ts +14 -0
- package/dist-lib/import/applyMudletProfile.d.ts +57 -0
- package/dist-lib/import/collectProfileExport.d.ts +16 -0
- package/dist-lib/import/defaultPackages.d.ts +81 -0
- package/dist-lib/import/defaults/mudlet-mapper.xml +13023 -0
- package/dist-lib/import/defaults/run-lua-code.mpackage +0 -0
- package/dist-lib/import/mudletHost.d.ts +67 -0
- package/dist-lib/import/mudletLink.d.ts +34 -0
- package/dist-lib/import/mudletProfileExport.d.ts +49 -0
- package/dist-lib/import/mudletProfileImport.d.ts +71 -0
- package/dist-lib/import/mudletVariables.d.ts +49 -0
- package/dist-lib/import/mudletWriteback.d.ts +12 -0
- package/dist-lib/import/mudletXmlExport.d.ts +16 -0
- package/dist-lib/import/mudletXmlImport.d.ts +21 -0
- package/dist-lib/import/packageInstaller.d.ts +72 -0
- package/dist-lib/import/packageRepository.d.ts +54 -0
- package/dist-lib/import/remotePackageInstall.d.ts +52 -0
- package/dist-lib/index.d.ts +30 -0
- package/dist-lib/index.js +42307 -0
- package/dist-lib/logging/SessionLogger.d.ts +41 -0
- package/dist-lib/main.d.ts +2 -0
- package/dist-lib/map/MapSelectionOverlay.d.ts +15 -0
- package/dist-lib/map/MapStore.d.ts +1067 -0
- package/dist-lib/map/MudixMapReader.d.ts +90 -0
- package/dist-lib/map/MudletHighlightOverlay.d.ts +18 -0
- package/dist-lib/map/mapImageExport.d.ts +26 -0
- package/dist-lib/map/mapParser.worker.d.ts +1 -0
- package/dist-lib/map/mapParserClient.d.ts +35 -0
- package/dist-lib/map/pathfinding.d.ts +52 -0
- package/dist-lib/map/xmlMapImport.d.ts +28 -0
- package/dist-lib/mud/MudSession.d.ts +236 -0
- package/dist-lib/mud/PatternEngine.d.ts +28 -0
- package/dist-lib/mud/aliases/AliasEngine.d.ts +15 -0
- package/dist-lib/mud/connection/LineAssembler.d.ts +84 -0
- package/dist-lib/mud/connection/MudClient.d.ts +268 -0
- package/dist-lib/mud/connection/PingTracker.d.ts +28 -0
- package/dist-lib/mud/connection/TelnetNegotiator.d.ts +188 -0
- package/dist-lib/mud/connection/telnetDebug.d.ts +54 -0
- package/dist-lib/mud/events.d.ts +160 -0
- package/dist-lib/mud/keybindings/KeyEngine.d.ts +36 -0
- package/dist-lib/mud/keybindings/browserReservedKeys.d.ts +45 -0
- package/dist-lib/mud/keybindings/qtKeys.d.ts +33 -0
- package/dist-lib/mud/protocol/charset.d.ts +105 -0
- package/dist-lib/mud/protocol/constants.d.ts +116 -0
- package/dist-lib/mud/protocol/echo.d.ts +63 -0
- package/dist-lib/mud/protocol/gmcp.d.ts +28 -0
- package/dist-lib/mud/protocol/index.d.ts +11 -0
- package/dist-lib/mud/protocol/mccp.d.ts +18 -0
- package/dist-lib/mud/protocol/mnes.d.ts +83 -0
- package/dist-lib/mud/protocol/msdp.d.ts +19 -0
- package/dist-lib/mud/protocol/msp.d.ts +47 -0
- package/dist-lib/mud/protocol/mssp.d.ts +25 -0
- package/dist-lib/mud/protocol/mxp.d.ts +188 -0
- package/dist-lib/mud/protocol/naws.d.ts +7 -0
- package/dist-lib/mud/replay/ReplayPlayer.d.ts +31 -0
- package/dist-lib/mud/replay/ReplayRecorder.d.ts +18 -0
- package/dist-lib/mud/replay/replayFormat.d.ts +49 -0
- package/dist-lib/mud/text/Console.d.ts +183 -0
- package/dist-lib/mud/text/FormatState.d.ts +256 -0
- package/dist-lib/mud/text/ansiEscapes.d.ts +88 -0
- package/dist-lib/mud/text/cellRender.d.ts +21 -0
- package/dist-lib/mud/text/colorParsers.d.ts +54 -0
- package/dist-lib/mud/text/colors.d.ts +31 -0
- package/dist-lib/mud/text/controlCharacterMode.d.ts +13 -0
- package/dist-lib/mud/text/controlChars.d.ts +31 -0
- package/dist-lib/mud/text/hyperlinkConfig.d.ts +164 -0
- package/dist-lib/mud/text/hyperlinkVisibility.d.ts +37 -0
- package/dist-lib/mud/text/oscLinkManager.d.ts +35 -0
- package/dist-lib/mud/text/wcwidth.d.ts +44 -0
- package/dist-lib/mud/text/xterm256.d.ts +2 -0
- package/dist-lib/mud/timers/TimerEngine.d.ts +61 -0
- package/dist-lib/mud/triggers/ChunkProcessor.d.ts +11 -0
- package/dist-lib/mud/triggers/TriggerEngine.d.ts +188 -0
- package/dist-lib/mud/triggers/pcre/Pcre2.d.ts +26 -0
- package/dist-lib/scripting/EngineHost.d.ts +152 -0
- package/dist-lib/scripting/GlobalEventChannel.d.ts +36 -0
- package/dist-lib/scripting/IScriptingRuntime.d.ts +95 -0
- package/dist-lib/scripting/MapOpenNotifier.d.ts +19 -0
- package/dist-lib/scripting/ScriptingAPI.d.ts +1691 -0
- package/dist-lib/scripting/ScriptingEngine.d.ts +806 -0
- package/dist-lib/scripting/StopwatchManager.d.ts +94 -0
- package/dist-lib/scripting/heldModifiers.d.ts +3 -0
- package/dist-lib/scripting/http/HttpService.d.ts +23 -0
- package/dist-lib/scripting/lua/LuaRuntime.d.ts +190 -0
- package/dist-lib/scripting/lua/bindings/automation.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/commandLine.d.ts +11 -0
- package/dist-lib/scripting/lua/bindings/context.d.ts +87 -0
- package/dist-lib/scripting/lua/bindings/cursor.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/diagnostics.d.ts +9 -0
- package/dist-lib/scripting/lua/bindings/map.d.ts +14 -0
- package/dist-lib/scripting/lua/bindings/media.d.ts +24 -0
- package/dist-lib/scripting/lua/bindings/output.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/packages.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/session.d.ts +16 -0
- package/dist-lib/scripting/lua/bindings/textEdit.d.ts +9 -0
- package/dist-lib/scripting/lua/bindings/userWindows.d.ts +11 -0
- package/dist-lib/scripting/lua/bindings/window.d.ts +10 -0
- package/dist-lib/scripting/lua/imageSize.d.ts +4 -0
- package/dist-lib/scripting/lua/luaCompletions.d.ts +9 -0
- package/dist-lib/scripting/lua/mudlet-lua/generic-mapper/generic_mapper.mpackage +0 -0
- package/dist-lib/scripting/lua/rex.d.ts +3 -0
- package/dist-lib/scripting/lua/sqlRowEncoder.d.ts +1 -0
- package/dist-lib/scripting/lua/yajl.d.ts +11 -0
- package/dist-lib/scripting/profilesPresence.d.ts +50 -0
- package/dist-lib/scripting/vfs/ProfileVFS.d.ts +62 -0
- package/dist-lib/scripting/vfs/cssRewrite.d.ts +21 -0
- package/dist-lib/scripting/vfs/folderHandleStore.d.ts +16 -0
- package/dist-lib/scripting/vfs/folderSync.d.ts +59 -0
- package/dist-lib/scripting/vfs/htmlRewrite.d.ts +26 -0
- package/dist-lib/scripting/vfs/vfsBridge.d.ts +16 -0
- package/dist-lib/services/cloudflare.d.ts +54 -0
- package/dist-lib/storage/appStore.d.ts +132 -0
- package/dist-lib/storage/crossTabSync.d.ts +3 -0
- package/dist-lib/storage/debouncedStorage.d.ts +18 -0
- package/dist-lib/storage/hooks.d.ts +17 -0
- package/dist-lib/storage/index.d.ts +4 -0
- package/dist-lib/storage/logExport.d.ts +32 -0
- package/dist-lib/storage/logStorage.d.ts +45 -0
- package/dist-lib/storage/mapStorage.d.ts +2 -0
- package/dist-lib/storage/profileVfsData.d.ts +47 -0
- package/dist-lib/storage/schema.d.ts +638 -0
- package/dist-lib/styles.css +2 -0
- package/dist-lib/ui/AboutModal.d.ts +8 -0
- package/dist-lib/ui/BrandLoginFields.d.ts +25 -0
- package/dist-lib/ui/BrandLoginScreen.d.ts +11 -0
- package/dist-lib/ui/CharLoginModal.d.ts +32 -0
- package/dist-lib/ui/CmdLineMenuRegistry.d.ts +27 -0
- package/dist-lib/ui/CodeEditorPreview.d.ts +19 -0
- package/dist-lib/ui/CommandBar.d.ts +17 -0
- package/dist-lib/ui/ConnectionFormModal.d.ts +13 -0
- package/dist-lib/ui/ConnectionGrid.d.ts +18 -0
- package/dist-lib/ui/ConnectionScreen.d.ts +14 -0
- package/dist-lib/ui/FileBrowserModal.d.ts +20 -0
- package/dist-lib/ui/FilePickerModal.d.ts +21 -0
- package/dist-lib/ui/FolderPermissionScreen.d.ts +16 -0
- package/dist-lib/ui/JsonPreview.d.ts +15 -0
- package/dist-lib/ui/LogBrowserModal.d.ts +7 -0
- package/dist-lib/ui/MapEditorModal.d.ts +9 -0
- package/dist-lib/ui/MarkdownPreview.d.ts +15 -0
- package/dist-lib/ui/MergeConflictModal.d.ts +17 -0
- package/dist-lib/ui/ModuleResolveModal.d.ts +22 -0
- package/dist-lib/ui/MouseEventRegistry.d.ts +31 -0
- package/dist-lib/ui/ProfileBusyScreen.d.ts +12 -0
- package/dist-lib/ui/ProfileExportModal.d.ts +7 -0
- package/dist-lib/ui/ProxyInfoModal.d.ts +6 -0
- package/dist-lib/ui/ProxyWhyModal.d.ts +6 -0
- package/dist-lib/ui/ProxyWizardModal.d.ts +6 -0
- package/dist-lib/ui/QuickOpenPalette.d.ts +8 -0
- package/dist-lib/ui/ResizableModal.d.ts +17 -0
- package/dist-lib/ui/ScriptingDocsModal.d.ts +12 -0
- package/dist-lib/ui/SettingsModal.d.ts +9 -0
- package/dist-lib/ui/Toolbar.d.ts +29 -0
- package/dist-lib/ui/bufferWords.d.ts +38 -0
- package/dist-lib/ui/buttons/ButtonsBar.d.ts +21 -0
- package/dist-lib/ui/cmdline/CommandLineManager.d.ts +97 -0
- package/dist-lib/ui/cmdline/CommandLineOverlay.d.ts +8 -0
- package/dist-lib/ui/codemirror/theme.d.ts +5 -0
- package/dist-lib/ui/commandHistory.d.ts +31 -0
- package/dist-lib/ui/components/Button.d.ts +9 -0
- package/dist-lib/ui/components/ConfirmDialog.d.ts +29 -0
- package/dist-lib/ui/components/ContextMenu.d.ts +9 -0
- package/dist-lib/ui/components/FontPicker.d.ts +9 -0
- package/dist-lib/ui/components/FormField.d.ts +16 -0
- package/dist-lib/ui/components/HelpTip.d.ts +7 -0
- package/dist-lib/ui/components/Input.d.ts +6 -0
- package/dist-lib/ui/components/Toggle.d.ts +10 -0
- package/dist-lib/ui/components/index.d.ts +9 -0
- package/dist-lib/ui/components/useModalFocus.d.ts +18 -0
- package/dist-lib/ui/labels/LabelManager.d.ts +220 -0
- package/dist-lib/ui/labels/LabelOverlay.d.ts +9 -0
- package/dist-lib/ui/labels/backgroundImageSize.d.ts +10 -0
- package/dist-lib/ui/labels/cursorShapes.d.ts +6 -0
- package/dist-lib/ui/labels/gifMovie.d.ts +100 -0
- package/dist-lib/ui/labels/qtCss.d.ts +57 -0
- package/dist-lib/ui/layout/ContentLayout.d.ts +19 -0
- package/dist-lib/ui/layout/DockArea.d.ts +14 -0
- package/dist-lib/ui/layout/DockedPanel.d.ts +13 -0
- package/dist-lib/ui/layout/FloatingWindowLayer.d.ts +10 -0
- package/dist-lib/ui/layout/MobileLayout.d.ts +22 -0
- package/dist-lib/ui/layout/PopoutWindow.d.ts +35 -0
- package/dist-lib/ui/layout/ScriptWindow.d.ts +29 -0
- package/dist-lib/ui/layout/SplitGroupPanel.d.ts +17 -0
- package/dist-lib/ui/layout/TabGroupPanel.d.ts +12 -0
- package/dist-lib/ui/layout/WindowContextMenu.d.ts +11 -0
- package/dist-lib/ui/layout/dockDetect.d.ts +26 -0
- package/dist-lib/ui/layout/overlayLayerOrder.d.ts +71 -0
- package/dist-lib/ui/markdown.d.ts +1 -0
- package/dist-lib/ui/output/CaretReviewPanel.d.ts +22 -0
- package/dist-lib/ui/output/OutputArea.d.ts +9 -0
- package/dist-lib/ui/output/OutputContextMenu.d.ts +23 -0
- package/dist-lib/ui/output/OutputRenderer.d.ts +64 -0
- package/dist-lib/ui/output/ScreenReaderLog.d.ts +23 -0
- package/dist-lib/ui/output/StickyOutputPanel.d.ts +28 -0
- package/dist-lib/ui/output/backgroundImageStyle.d.ts +17 -0
- package/dist-lib/ui/output/caretMode.d.ts +40 -0
- package/dist-lib/ui/output/linkNavigation.d.ts +29 -0
- package/dist-lib/ui/output/osc8Menu.d.ts +16 -0
- package/dist-lib/ui/output/outputCopy.d.ts +15 -0
- package/dist-lib/ui/preventPinchZoom.d.ts +1 -0
- package/dist-lib/ui/scrollbox/ScrollBoxManager.d.ts +62 -0
- package/dist-lib/ui/scrollbox/ScrollBoxOverlay.d.ts +25 -0
- package/dist-lib/ui/sound/SoundManager.d.ts +149 -0
- package/dist-lib/ui/sound/closedCaption.d.ts +37 -0
- package/dist-lib/ui/textedit/TextEditManager.d.ts +56 -0
- package/dist-lib/ui/tts/TtsManager.d.ts +68 -0
- package/dist-lib/ui/useBrandLogin.d.ts +19 -0
- package/dist-lib/ui/useCommandHistory.d.ts +7 -0
- package/dist-lib/ui/video/VideoManager.d.ts +56 -0
- package/dist-lib/ui/windows/ScriptEditorModal.d.ts +13 -0
- package/dist-lib/ui/windows/WindowManager.d.ts +694 -0
- package/dist-lib/ui/windows/panels/HtmlPanel.d.ts +27 -0
- package/dist-lib/ui/windows/panels/LuaEditor.d.ts +14 -0
- package/dist-lib/ui/windows/panels/MapPanel.d.ts +8 -0
- package/dist-lib/ui/windows/panels/PackageRepositoryModal.d.ts +18 -0
- package/dist-lib/ui/windows/panels/ScriptEditorPanel.d.ts +24 -0
- package/dist-lib/ui/windows/panels/ScriptSearch.d.ts +12 -0
- package/dist-lib/ui/windows/panels/TextPanel.d.ts +35 -0
- package/dist-lib/ui/windows/panels/VariablesView.d.ts +21 -0
- package/dist-lib/ui/windows/panels/VfsModulePickerModal.d.ts +8 -0
- package/dist-lib/ui/windows/panels/WindowCmdLine.d.ts +23 -0
- package/dist-lib/ui/windows/types.d.ts +145 -0
- package/dist-lib/utils/documentTitle.d.ts +33 -0
- package/dist-lib/utils/fontLoader.d.ts +52 -0
- package/dist-lib/utils/profileLock.d.ts +26 -0
- package/dist-lib/utils/sessionCredentials.d.ts +16 -0
- package/dist-lib/version.d.ts +39 -0
- package/dist-lib/vfs-sw.js +131 -0
- package/dist-lib/vite.d.ts +2 -0
- package/dist-lib/vite.js +154 -0
- package/package.json +93 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import { type OutputRendererControls } from '../output/OutputRenderer';
|
|
2
|
+
import type { Console } from '../../mud/text/Console';
|
|
3
|
+
import type { AnsiAwareBuffer } from '../../mud/text/FormatState';
|
|
4
|
+
import type { DockSide, WindowHandle, WindowOpenOptions, ScriptWindowRenderData } from './types';
|
|
5
|
+
import { MapStore } from '../../map/MapStore';
|
|
6
|
+
import { OverlayLayerOrder } from '../layout/overlayLayerOrder';
|
|
7
|
+
/** Live handle onto a mounted map renderer, registered by MapPanel. Backs the
|
|
8
|
+
* Lua getMapZoom/setMapZoom/updateMap APIs, which need to read and drive the
|
|
9
|
+
* renderer state that lives inside the React component. */
|
|
10
|
+
export interface MapControl {
|
|
11
|
+
getZoom: () => number | null;
|
|
12
|
+
setZoom: (zoom: number) => void;
|
|
13
|
+
redraw: () => void;
|
|
14
|
+
/** Mudlet `exportAreaImage` — render an area (optionally a single z-level) to
|
|
15
|
+
* PNG bytes via a headless renderer, leaving the live view untouched.
|
|
16
|
+
* Returns null when the area is unknown / unrenderable. */
|
|
17
|
+
exportArea: (areaId: number, zLevel?: number) => Uint8Array | null;
|
|
18
|
+
}
|
|
19
|
+
/** Progress of an in-flight streamed map load, as published by
|
|
20
|
+
* {@link WindowManager.subscribeMapLoadProgress}.
|
|
21
|
+
*
|
|
22
|
+
* `total` is 0 until the worker has decoded the map header (the room count is
|
|
23
|
+
* summed from the areas' room-id lists, which the header carries) — until then
|
|
24
|
+
* the load is genuinely indeterminate and the UI should say so rather than
|
|
25
|
+
* guess a denominator. */
|
|
26
|
+
export interface MapLoadProgress {
|
|
27
|
+
/** Rooms folded into the store so far. */
|
|
28
|
+
loaded: number;
|
|
29
|
+
/** Total rooms the map declares, or 0 while the header is still decoding. */
|
|
30
|
+
total: number;
|
|
31
|
+
/**
|
|
32
|
+
* `rooms` — streaming rooms into the store; `loaded`/`total` advance.
|
|
33
|
+
*
|
|
34
|
+
* `building` — every room has landed and the renderer is indexing the map
|
|
35
|
+
* and building its first scene. That work is synchronous and, on a large
|
|
36
|
+
* map, by far the longest part of the wait, so it gets its own phase rather
|
|
37
|
+
* than leaving the bar parked at 99% looking hung.
|
|
38
|
+
*/
|
|
39
|
+
phase: 'rooms' | 'building';
|
|
40
|
+
}
|
|
41
|
+
export type WindowsChangedFn = (windows: ScriptWindowRenderData[], dockExtents: Record<DockSide, number>) => void;
|
|
42
|
+
export declare class WindowManager {
|
|
43
|
+
readonly overlayZ: OverlayLayerOrder;
|
|
44
|
+
readonly mapStore: MapStore;
|
|
45
|
+
private readonly windows;
|
|
46
|
+
private readonly controls;
|
|
47
|
+
private readonly elements;
|
|
48
|
+
/** Outer panel element used by getSize / sysUserWindowResizeEvent. Distinct
|
|
49
|
+
* from `elements` (the writable text/HTML target) so size queries report the
|
|
50
|
+
* full user-window box that labels live in, not the inner output area. */
|
|
51
|
+
private readonly viewports;
|
|
52
|
+
private readonly lineBuffers;
|
|
53
|
+
/** Per-window scroll/scrollbar overrides applied via CSS classes when the
|
|
54
|
+
* console's wrapper element registers. Mudlet's enable/disable Scrolling
|
|
55
|
+
* and (Horizontal)ScrollBar APIs back into this. */
|
|
56
|
+
private readonly scrollState;
|
|
57
|
+
private readonly portalTargets;
|
|
58
|
+
/** Hidden, detached div in the *main* document used as a temporary parking
|
|
59
|
+
* spot for a portal target while a popout window is torn down — re-adopting
|
|
60
|
+
* the node here before the child window closes keeps its content alive (a
|
|
61
|
+
* node orphaned in a closed window's document would be lost). */
|
|
62
|
+
private portalHolding;
|
|
63
|
+
private readonly resizeObservers;
|
|
64
|
+
private readonly lastEmittedSize;
|
|
65
|
+
/** Per-window last reported character grid (cols, rows) — used to gate
|
|
66
|
+
* sysConsoleSizeChanged so the event fires only on actual grid changes. */
|
|
67
|
+
private readonly lastEmittedGrid;
|
|
68
|
+
private readonly activeTabGroups;
|
|
69
|
+
/** Per-window command-line state. Keyed by window id; entry exists only
|
|
70
|
+
* after enableCommandLine. The actual rendered <input> lives in TextPanel
|
|
71
|
+
* /HtmlPanel and pulls its enabled/css/value from the ScriptWindowRenderData
|
|
72
|
+
* payload that notify() emits — this map only carries non-serializable
|
|
73
|
+
* state (the Lua callback). */
|
|
74
|
+
private readonly cmdLineState;
|
|
75
|
+
private readonly mapCallbacks;
|
|
76
|
+
private readonly mapControls;
|
|
77
|
+
/** Per-window teardown for the mousedown/mouseup listeners observeMouse
|
|
78
|
+
* attaches. Keyed by window id ('main' for the central output). */
|
|
79
|
+
private readonly mouseCleanups;
|
|
80
|
+
/** Per-window teardown for the dragenter/dragover/drop listeners
|
|
81
|
+
* observeDrop attaches — these power Mudlet's sysDropEvent /
|
|
82
|
+
* sysDropUrlEvent on viewports. */
|
|
83
|
+
private readonly dropCleanups;
|
|
84
|
+
private mapLoadCallback;
|
|
85
|
+
/** Live progress of a streamed map load, or null when none is running.
|
|
86
|
+
* Held here (rather than pushed only to subscribers) so a MapPanel that
|
|
87
|
+
* mounts mid-load — the normal case at cold start, where bootstrapMap
|
|
88
|
+
* begins before the panel exists — can render the bar straight away. */
|
|
89
|
+
private mapLoadProgress;
|
|
90
|
+
private readonly mapProgressSubscribers;
|
|
91
|
+
/** Single in-flight bootstrap promise — both ScriptingEngine.start (which
|
|
92
|
+
* awaits the map before applying scripts, Mudlet parity) and MapPanel on
|
|
93
|
+
* mount call into this; whichever lands first triggers the work. */
|
|
94
|
+
private mapBootstrapInflight;
|
|
95
|
+
private mapSaveTimer;
|
|
96
|
+
private mapSavePending;
|
|
97
|
+
/** MMP map URL announced by the game via GMCP `Client.Map` (Mudlet
|
|
98
|
+
* TMap::mMmpMapLocation). Lives here rather than on ScriptingEngine so it
|
|
99
|
+
* survives script reloads, like Mudlet's TMap does. */
|
|
100
|
+
private _mmpMapLocation;
|
|
101
|
+
private _connectionId;
|
|
102
|
+
/** Names of windows created by Lua createMiniConsole — distinguishes them
|
|
103
|
+
* from openUserWindow panels for windowType() reporting. */
|
|
104
|
+
private mainViewportEl;
|
|
105
|
+
private readonly miniConsoles;
|
|
106
|
+
private consoleRegistry;
|
|
107
|
+
private windowHints;
|
|
108
|
+
private nextZ;
|
|
109
|
+
private nextDockOrder;
|
|
110
|
+
private readonly dockExtents;
|
|
111
|
+
constructor(overlayZ?: OverlayLayerOrder);
|
|
112
|
+
/** Resolves the same "nested under which parent" id FloatingWindowLayer's
|
|
113
|
+
* resolveParent uses: an explicit non-'main' parent, else 'main' when this
|
|
114
|
+
* is a mini-console (createMiniConsole/createMapper without an explicit
|
|
115
|
+
* parent still nests under the main viewport), else null for a genuine
|
|
116
|
+
* root floating window — which shares no stacking context with any
|
|
117
|
+
* parent's labels, so there's nothing to touch. */
|
|
118
|
+
private overlayParentId;
|
|
119
|
+
private touchOverlayWindows;
|
|
120
|
+
private sinkOverlayWindows;
|
|
121
|
+
onWindowsChange?: WindowsChangedFn;
|
|
122
|
+
onWindowHint?: (id: string, hint: WindowOpenOptions) => void;
|
|
123
|
+
/** Called when a window is explicitly closed — use to clear its auto-open flag. */
|
|
124
|
+
onWindowClosed?: (id: string) => void;
|
|
125
|
+
/** Called when a dock side's extent changes — use to persist it. */
|
|
126
|
+
onDockExtentsChange?: (extents: Record<DockSide, number>) => void;
|
|
127
|
+
/** Called when a map window is opened or made visible. */
|
|
128
|
+
onMapOpen?: (id: string) => void;
|
|
129
|
+
/** Bridge to ScriptingEngine.raiseEvent — used to fire system events
|
|
130
|
+
* (e.g. sysUserWindowResizeEvent) from window-lifecycle code. */
|
|
131
|
+
onRaiseEvent?: (event: string, args: unknown[]) => void;
|
|
132
|
+
/** Called when a real File is dropped on a window. The handler (wired by
|
|
133
|
+
* ScriptingEngine) writes the bytes into the profile VFS and then raises
|
|
134
|
+
* Mudlet's sysDropEvent with a readable path — browsers don't expose a
|
|
135
|
+
* filesystem path on the dropped File, so we can't raise it inline here. */
|
|
136
|
+
onFileDrop?: (file: File, x: number, y: number, id: string) => void;
|
|
137
|
+
/** Called whenever the *main* console's character grid changes (columns ×
|
|
138
|
+
* rows). MudSession wires this to the client so NAWS (telnet window size)
|
|
139
|
+
* tracks the output area. Distinct from onRaiseEvent (which drives Lua
|
|
140
|
+
* sysConsoleSizeChanged) so window-size reporting doesn't depend on the
|
|
141
|
+
* scripting layer being attached. */
|
|
142
|
+
onMainConsoleResize?: (cols: number, rows: number) => void;
|
|
143
|
+
/** Set by MapPanel — mirrors Mudlet's signal_mmpMapLocationChanged, which
|
|
144
|
+
* drives the mapper's "download map" affordance appearing/disappearing. */
|
|
145
|
+
onMmpMapLocationChanged?: (url: string) => void;
|
|
146
|
+
/** Bridge to ScriptingEngine.downloadMap — the map UI's "download map from
|
|
147
|
+
* game" action (Mudlet dlgMapper's Download button). */
|
|
148
|
+
onDownloadMap?: () => void;
|
|
149
|
+
/** The MMP map URL from GMCP `Client.Map`, or '' when none announced. */
|
|
150
|
+
get mmpMapLocation(): string;
|
|
151
|
+
/** Record the game-announced map URL (Mudlet TMap::setMmpMapLocation). */
|
|
152
|
+
setMmpMapLocation(url: string): void;
|
|
153
|
+
setConsoleRegistry(registry: Map<string, Console>): void;
|
|
154
|
+
setWindowHints(hints: Record<string, WindowOpenOptions>): void;
|
|
155
|
+
/** Restore saved dock extents from storage (called on connect, before setWindowHints). */
|
|
156
|
+
setDockExtentsFromStorage(extents: Record<string, number>): void;
|
|
157
|
+
/** Call after setting onWindowsChange to deliver current state immediately.
|
|
158
|
+
* Needed because windows may have been opened (e.g. autoOpen) before the
|
|
159
|
+
* React subscriber mounted. */
|
|
160
|
+
initialize(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Snapshot the current window hints + dock extents. Returned object is a
|
|
163
|
+
* deep copy — safe to persist without aliasing the live state. Backs
|
|
164
|
+
* Mudlet's `saveWindowLayout()`.
|
|
165
|
+
*/
|
|
166
|
+
captureLayoutSnapshot(): {
|
|
167
|
+
hints: Record<string, WindowOpenOptions>;
|
|
168
|
+
dockExtents: Record<DockSide, number>;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Re-apply a previously captured snapshot to the live state. Backs
|
|
172
|
+
* Mudlet's `loadWindowLayout()`. Behaviour:
|
|
173
|
+
* - Replaces the stored windowHints + dockExtents with the snapshot.
|
|
174
|
+
* - For each currently open window with a snapshot entry, rewrites its
|
|
175
|
+
* geometry / dock state / style fields in place (keeps pendingText,
|
|
176
|
+
* controls, miniconsole content intact).
|
|
177
|
+
* - For each snapshot hint with no current window, opens the window when
|
|
178
|
+
* the snapshot recorded it as visible (hidden !== true).
|
|
179
|
+
* `onWindowHint` / `onDockExtentsChange` callbacks fire so the persistence
|
|
180
|
+
* layer mirrors the restored state.
|
|
181
|
+
*/
|
|
182
|
+
applyLayoutSnapshot(snapshot: {
|
|
183
|
+
hints: Record<string, WindowOpenOptions>;
|
|
184
|
+
dockExtents: Record<string, number>;
|
|
185
|
+
}): void;
|
|
186
|
+
/** Returns the stable portal-target div for a window, creating it on first call.
|
|
187
|
+
* This div is physically moved between dock slots and floating frames — the
|
|
188
|
+
* panel component rendered into it never unmounts during transitions. */
|
|
189
|
+
getOrCreatePortalTarget(id: string): HTMLDivElement;
|
|
190
|
+
getPortalTarget(id: string): HTMLDivElement | undefined;
|
|
191
|
+
/** A hidden, detached holding element in the main document. PopoutWindow
|
|
192
|
+
* re-parents a portal target here before closing its child window so the
|
|
193
|
+
* panel's DOM survives the teardown; the next docked/floating frame to
|
|
194
|
+
* mount appendChilds it back out. Lazily created. */
|
|
195
|
+
getPortalHolding(): HTMLDivElement;
|
|
196
|
+
/** Detach a panel into its own browser window. Layout fields (docked side /
|
|
197
|
+
* floating rect) are left untouched so popIn() restores the panel in place.
|
|
198
|
+
* The PopoutWindow component reacts to the state change and opens the window. */
|
|
199
|
+
popOut(id: string): void;
|
|
200
|
+
/** Re-dock/re-float a popped-out panel back into the main window. Triggered
|
|
201
|
+
* explicitly or automatically when the popout window closes. */
|
|
202
|
+
popIn(id: string): void;
|
|
203
|
+
isPoppedOut(id: string): boolean;
|
|
204
|
+
registerTextPanel(id: string, controls: OutputRendererControls, element: HTMLElement): void;
|
|
205
|
+
/** Registers the outer panel element for size queries and sysUserWindowResizeEvent.
|
|
206
|
+
* Distinct from the writable element registered via registerTextPanel /
|
|
207
|
+
* register('html'): labels position against this rectangle, so getUserWindowSize
|
|
208
|
+
* must report it (not the inner output area). */
|
|
209
|
+
registerViewport(id: string, element: HTMLElement): void;
|
|
210
|
+
getViewport(id: string): HTMLElement | undefined;
|
|
211
|
+
/** OutputArea registers the main `.output-wrapper` here so getColumnCount()
|
|
212
|
+
* can measure character width against the actual rendered element. */
|
|
213
|
+
registerMainOutput(element: HTMLElement | null): void;
|
|
214
|
+
/**
|
|
215
|
+
* Registers the full main-viewport element (the one that spans the entire
|
|
216
|
+
* console area including any setBorderTop/Bottom/Left/Right insets). Used
|
|
217
|
+
* by getMainWindowSize so label-positioning scripts always see the full
|
|
218
|
+
* window bounds, matching Mudlet semantics where labels live in window
|
|
219
|
+
* coordinates and borders carve space *out of* them.
|
|
220
|
+
*/
|
|
221
|
+
registerMainViewport(element: HTMLElement | null): void;
|
|
222
|
+
getMainViewportElement(): HTMLElement | null;
|
|
223
|
+
/**
|
|
224
|
+
* The DOM element main-parented nested windows (mini-consoles, embedded
|
|
225
|
+
* mapper) portal into. This is `.main-overlay-root` — the SAME wrapper the
|
|
226
|
+
* main labels / command lines / scroll boxes render into — so a window's
|
|
227
|
+
* z-index and a label's z-index compete in one CSS stacking context and the
|
|
228
|
+
* overlayZ ordinals actually take visual effect. It must NOT be a separate
|
|
229
|
+
* sibling of the label overlay: `.main-overlay-root` carries an explicit
|
|
230
|
+
* `z-index` (a stacking context that keeps all overlay content below
|
|
231
|
+
* floating windows / modals), so a nested window portaled anywhere else
|
|
232
|
+
* would either be trapped in a different context or leak its z above the
|
|
233
|
+
* labels — which was the long-standing "map paints over every label" bug.
|
|
234
|
+
* Both `.main-overlay-root` and the console viewport are `inset:0` over the
|
|
235
|
+
* same main-viewport, so the portal target swap doesn't shift coordinates.
|
|
236
|
+
* Falls back to the console viewport if the host hasn't registered yet.
|
|
237
|
+
*/
|
|
238
|
+
private mainOverlayHostEl;
|
|
239
|
+
registerMainOverlayHost(element: HTMLElement | null): void;
|
|
240
|
+
getMainOverlayHost(): HTMLElement | null;
|
|
241
|
+
/** The overlay host element that widgets under `parentId` (labels AND
|
|
242
|
+
* nested windows) share so their z-indices compete in one stacking
|
|
243
|
+
* context: `.main-overlay-root` for 'main', else the userwindow's own
|
|
244
|
+
* viewport (where its panel already renders the label overlays). */
|
|
245
|
+
getOverlayHost(parentId: string): HTMLElement | null;
|
|
246
|
+
register(id: string, element: HTMLElement, _kind: 'html'): void;
|
|
247
|
+
pushBuffer(id: string, buffer: AnsiAwareBuffer): void;
|
|
248
|
+
/** Push the current partial-line buffer (script echo without a trailing
|
|
249
|
+
* newline) so the renderer can paint it in-place via the 'script-partial'
|
|
250
|
+
* path. Repeated calls update the same DOM element; a subsequent
|
|
251
|
+
* pushBuffer completes the partial. Pre-mount, the latest partial is
|
|
252
|
+
* cached on the window and flushed by registerTextPanel. */
|
|
253
|
+
pushPartialBuffer(id: string, buffer: AnsiAwareBuffer): void;
|
|
254
|
+
registerConsole(id: string, console: Console): void;
|
|
255
|
+
unregister(id: string): void;
|
|
256
|
+
/** Watch `element` for size changes and raise sysUserWindowResizeEvent
|
|
257
|
+
* whenever its rendered dimensions differ from the last reported pair.
|
|
258
|
+
* Catches both floating-window user drags and dock splitter drags through
|
|
259
|
+
* the same DOM-level signal, so script-driven setSize() calls also fire
|
|
260
|
+
* the event once the layout settles. */
|
|
261
|
+
private observeResize;
|
|
262
|
+
/** Force an immediate measure-and-emit for the main viewport, if it's
|
|
263
|
+
* registered. ResizeObserver's own first callback is spec-deferred (never
|
|
264
|
+
* synchronous with observe()) — registerMainViewport runs from
|
|
265
|
+
* OutputArea's mount effect, which commits before ScriptingEngine's
|
|
266
|
+
* constructor exists to wire up onRaiseEvent, so that deferred callback
|
|
267
|
+
* can easily land *after* Lua bootstrap has already dispatched
|
|
268
|
+
* sysLoadEvent/sysInstallPackage and run scripts that build
|
|
269
|
+
* percentage-positioned Geyser containers. GeyserReposition (the bundled
|
|
270
|
+
* Mudlet Lua that actually resolves that percentage geometry into pixels)
|
|
271
|
+
* only runs in response to sysWindowResizeEvent, so those containers —
|
|
272
|
+
* and anything gated on their resolved get_x()/get_width(), e.g.
|
|
273
|
+
* Adjustable.Container:attachToBorder's validAttachPositions() check —
|
|
274
|
+
* silently see stale/unresolved geometry and fail with no error. Called
|
|
275
|
+
* by ScriptingEngine right after it wires up onRaiseEvent (and after the
|
|
276
|
+
* Lua runtime exists to receive the event — see the guard in
|
|
277
|
+
* measureAndEmitResize), guaranteeing at least one sysWindowResizeEvent
|
|
278
|
+
* has already landed before any script-load event fires. The dedup check
|
|
279
|
+
* inside measureAndEmitResize makes the real (later) ResizeObserver tick
|
|
280
|
+
* a same-size no-op rather than a duplicate event. */
|
|
281
|
+
primeMainResize(): void;
|
|
282
|
+
/** Shared by observeResize's ResizeObserver callback and primeMainResize's
|
|
283
|
+
* eager call — measures `element`, and raises sysWindowResizeEvent/
|
|
284
|
+
* sysUserWindowResizeEvent plus the console-grid and overflow events when
|
|
285
|
+
* the size actually changed since last reported. */
|
|
286
|
+
private measureAndEmitResize;
|
|
287
|
+
/** Measure one monospace cell (px) by probing `el` with its own inherited
|
|
288
|
+
* font — the same technique getColumnCount uses, so the NAWS grid and
|
|
289
|
+
* getColumnCount agree. Falls back to a fontSize estimate when the probe
|
|
290
|
+
* can't measure (detached element / happy-dom tests). */
|
|
291
|
+
private measureCharCell;
|
|
292
|
+
/** Synchronously re-measure the main console's char grid and emit it
|
|
293
|
+
* (sysConsoleSizeChanged + onMainConsoleResize) so NAWS can seed with the
|
|
294
|
+
* real on-screen size at connect time, rather than whatever the async
|
|
295
|
+
* resize observer last reported — which on a fast/mobile connect may be
|
|
296
|
+
* stale or not yet fired. No-op when the main element isn't mounted, or
|
|
297
|
+
* when the size is unchanged (the dedup guard in emitConsoleGridIfChanged). */
|
|
298
|
+
remeasureMainGrid(): void;
|
|
299
|
+
/** Compute the rendered char-grid for `id` and emit sysConsoleSizeChanged
|
|
300
|
+
* when (cols, rows) changes. Metrics are measured against the registered
|
|
301
|
+
* text element (which carries the MUD output font), not the observed
|
|
302
|
+
* viewport — the viewport's computed font is the app's base font, so
|
|
303
|
+
* estimating cells off it reports the wrong column count and, through
|
|
304
|
+
* onMainConsoleResize → NAWS, hands the server the wrong window width (so
|
|
305
|
+
* MOTDs / room art don't fit the screen). This matches getColumnCount,
|
|
306
|
+
* which probes the same element. Falls back to the viewport box when the
|
|
307
|
+
* text element isn't mounted yet. */
|
|
308
|
+
private emitConsoleGridIfChanged;
|
|
309
|
+
/** Mudlet sysWindowOverflowEvent(name, overflowLines). Fires when a console
|
|
310
|
+
* whose scrolling is disabled has more content than fits in the viewport.
|
|
311
|
+
* scrollHeight − clientHeight gives the pixel overflow; dividing by the
|
|
312
|
+
* estimated line height converts it to lines for the event payload. */
|
|
313
|
+
private emitWindowOverflowIfPresent;
|
|
314
|
+
/** Raise Mudlet's sysWindowMousePress/ReleaseEvent for clicks anywhere on a
|
|
315
|
+
* window's box. Args mirror Mudlet: (button, x, y, name) where button is
|
|
316
|
+
* 1=left, 2=right, 3=middle, 4=back, 5=forward (0 = anything else), x/y are
|
|
317
|
+
* pixel coordinates relative to the window, and name is the window id
|
|
318
|
+
* ('main' for the central output). */
|
|
319
|
+
private observeMouse;
|
|
320
|
+
/** Mudlet `sysDropEvent(filepath, suffix, x, y, name)` and
|
|
321
|
+
* `sysDropUrlEvent(url, schema, x, y, name)` — fired when the user drags
|
|
322
|
+
* a file or URL onto a window. We only acknowledge drops we can identify
|
|
323
|
+
* (a real File for sysDropEvent, a textual URL for sysDropUrlEvent); the
|
|
324
|
+
* default DragEvent behaviour is suppressed in both cases so the browser
|
|
325
|
+
* doesn't navigate away from the page. */
|
|
326
|
+
private observeDrop;
|
|
327
|
+
registerMapCallback(id: string, cb: (roomId: number) => void): void;
|
|
328
|
+
unregisterMapCallback(id: string): void;
|
|
329
|
+
centerView(roomId: number): boolean;
|
|
330
|
+
registerMapControl(id: string, ctrl: MapControl): void;
|
|
331
|
+
unregisterMapControl(id: string): void;
|
|
332
|
+
/** Live zoom of the displayed 2D map, or null when no map panel is mounted.
|
|
333
|
+
* mudix shows one area at a time through a single shared renderer, so the
|
|
334
|
+
* Mudlet `areaID` argument has no per-area analogue here — callers get the
|
|
335
|
+
* current view's zoom regardless. */
|
|
336
|
+
getMapZoom(): number | null;
|
|
337
|
+
/** Set the displayed map's zoom and redraw. Returns false when no map panel
|
|
338
|
+
* is mounted to receive the change. */
|
|
339
|
+
setMapZoom(zoom: number): boolean;
|
|
340
|
+
/** Force the map to re-read MapStore and redraw (Mudlet `updateMap`). */
|
|
341
|
+
updateMap(): boolean;
|
|
342
|
+
private readonly mapViews;
|
|
343
|
+
/** View ids start at 1 — Mudlet treats 0 as "no view". */
|
|
344
|
+
private nextMapViewId;
|
|
345
|
+
/** The window id backing a map view. */
|
|
346
|
+
private static mapViewWindowId;
|
|
347
|
+
/**
|
|
348
|
+
* Mudlet `createMapView([areaID])` — open a secondary map window. Returns
|
|
349
|
+
* the new view id, or a message when the areaID doesn't name an area (0 or
|
|
350
|
+
* omitted means "wherever the player is").
|
|
351
|
+
*/
|
|
352
|
+
createMapView(areaId: number): number | string;
|
|
353
|
+
/** Mudlet `closeMapView(viewID)`. False when no view has that id. */
|
|
354
|
+
closeMapView(viewId: number): boolean;
|
|
355
|
+
/** Mudlet `closeAllMapViews()` → how many were closed. */
|
|
356
|
+
closeAllMapViews(): number;
|
|
357
|
+
/** Mudlet `getMapViewIds()` — every open view, in creation order. */
|
|
358
|
+
getMapViewIds(): number[];
|
|
359
|
+
/** Mudlet `getMapViewInfo(viewID)`. Undefined when no view has that id. */
|
|
360
|
+
getMapViewInfo(viewId: number): {
|
|
361
|
+
areaId: number;
|
|
362
|
+
zoom: number;
|
|
363
|
+
zLevel: number;
|
|
364
|
+
centeredRoomId: number;
|
|
365
|
+
} | undefined;
|
|
366
|
+
/** The area a map window should show, when it is a secondary view rather
|
|
367
|
+
* than the primary mapper. Undefined for the primary one, which follows the
|
|
368
|
+
* player as before. */
|
|
369
|
+
mapViewAreaFor(windowId: string): number | undefined;
|
|
370
|
+
/** Record what a mounted secondary view is actually showing, so
|
|
371
|
+
* getMapViewInfo reports the live state rather than the creation-time one. */
|
|
372
|
+
noteMapViewState(windowId: string, state: {
|
|
373
|
+
areaId?: number;
|
|
374
|
+
zoom?: number;
|
|
375
|
+
zLevel?: number;
|
|
376
|
+
centeredRoomId?: number;
|
|
377
|
+
}): void;
|
|
378
|
+
/** Mudlet `exportAreaImage(areaID, filePath[, zLevel])` — render an area to
|
|
379
|
+
* PNG bytes. Prefers a mounted map widget so the export picks up that
|
|
380
|
+
* panel's live Mapper settings, but falls back to a standalone render off
|
|
381
|
+
* the same MapStore: the export never needed a panel (see mapImageExport),
|
|
382
|
+
* and requiring one would make the API unreachable from a script that runs
|
|
383
|
+
* before React has mounted the widget. Null when the area is unknown or the
|
|
384
|
+
* render fails. */
|
|
385
|
+
exportAreaImage(areaId: number, zLevel?: number): Uint8Array | null;
|
|
386
|
+
/** Set by MapPanel on mount; cleared on unmount. The callback parses+renders
|
|
387
|
+
* a buffer (when given) or reloads from IndexedDB (when omitted). */
|
|
388
|
+
registerMapLoadCallback(cb: (buf?: ArrayBuffer) => boolean): void;
|
|
389
|
+
unregisterMapLoadCallback(): void;
|
|
390
|
+
/**
|
|
391
|
+
* Subscribe to streamed map-load progress. The callback fires on every
|
|
392
|
+
* ingested batch and once with `null` when the load ends (either way), so a
|
|
393
|
+
* progress UI can drive itself entirely off this channel. Fires immediately
|
|
394
|
+
* with the current value on subscribe, so a panel mounting mid-load doesn't
|
|
395
|
+
* have to wait for the next batch to render something.
|
|
396
|
+
*/
|
|
397
|
+
subscribeMapLoadProgress(cb: (progress: MapLoadProgress | null) => void): () => void;
|
|
398
|
+
/** Current streamed-load progress, or null when no load is running. */
|
|
399
|
+
getMapLoadProgress(): MapLoadProgress | null;
|
|
400
|
+
private publishMapLoadProgress;
|
|
401
|
+
setConnectionId(id: string): void;
|
|
402
|
+
/**
|
|
403
|
+
* Parse a Mudlet `.dat` buffer and apply it to this session's MapStore.
|
|
404
|
+
* Rooms / areas / hashes / labels / env colours / map-level user data all
|
|
405
|
+
* land in {@link MapStore} via {@link MapStore.loadFromBinary}; the
|
|
406
|
+
* renderer reads it back through the live {@link MudixMapReader}. Throws
|
|
407
|
+
* on parse failure so callers can surface the error (the file-upload path
|
|
408
|
+
* in MapPanel turns it into status='error'; bootstrap logs and moves on).
|
|
409
|
+
*/
|
|
410
|
+
ingestMapBuffer(buf: ArrayBuffer): void;
|
|
411
|
+
/**
|
|
412
|
+
* Async sibling of {@link ingestMapBuffer} that parses in a worker so the
|
|
413
|
+
* main thread stays free for paint. `buf` is transferred — callers that
|
|
414
|
+
* also need the bytes (e.g. IndexedDB persistence) must clone first.
|
|
415
|
+
*
|
|
416
|
+
* The worker streams the map room-by-room and the store folds each batch in
|
|
417
|
+
* as it lands, so neither side ever holds two copies of the room graph.
|
|
418
|
+
* Subscribers see nothing until the load completes (one notification, from
|
|
419
|
+
* `endBinaryLoad`) — a half-populated store would have the renderer draw a
|
|
420
|
+
* map with dangling exits.
|
|
421
|
+
*
|
|
422
|
+
* Batch progress is published on {@link subscribeMapLoadProgress} for the
|
|
423
|
+
* map panel's progress bar; `onProgress` is an extra per-call hook.
|
|
424
|
+
*/
|
|
425
|
+
ingestMapBufferAsync(buf: ArrayBuffer, onProgress?: (loaded: number, total: number) => void): Promise<void>;
|
|
426
|
+
/**
|
|
427
|
+
* Mudlet parity: a map is available to scripts before `sysLoadEvent` fires.
|
|
428
|
+
* ScriptingEngine awaits this in its start() path so the initial script
|
|
429
|
+
* load runs against an initialized MapStore (and the binary's hashes + user
|
|
430
|
+
* data when one is persisted). Idempotent — the first caller kicks off the
|
|
431
|
+
* IndexedDB fetch, everyone else awaits the same promise. Returns true
|
|
432
|
+
* when a persisted map was successfully ingested.
|
|
433
|
+
*/
|
|
434
|
+
bootstrapMap(): Promise<boolean>;
|
|
435
|
+
/**
|
|
436
|
+
* Mudlet `loadMap([location])`. With a buffer the bytes are persisted to
|
|
437
|
+
* IndexedDB (so the map survives panel close/reopen and reload), parsed
|
|
438
|
+
* into the manager/store, and any open MapPanel is asked to re-render.
|
|
439
|
+
* Without a buffer the panel is told to reload from cache. Returns false
|
|
440
|
+
* on synchronous parse failure; the IndexedDB write is fire-and-forget
|
|
441
|
+
* (failures appear in console.warn). Fires sysMapLoadEvent on success.
|
|
442
|
+
*/
|
|
443
|
+
loadMap(buf?: ArrayBuffer): boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Async sibling of {@link loadMap} with identical effects — IndexedDB
|
|
446
|
+
* persistence, store ingest, panel re-render, `sysMapLoadEvent` — but the
|
|
447
|
+
* parse runs in the worker and streams into the store, publishing progress
|
|
448
|
+
* as it goes.
|
|
449
|
+
*
|
|
450
|
+
* Use this for every UI-driven load (file picker, map download, editor
|
|
451
|
+
* hand-back): the synchronous {@link loadMap} blocks the main thread for the
|
|
452
|
+
* whole parse, which on a large map means a frozen window and a progress bar
|
|
453
|
+
* that could never paint. `loadMap` stays for Lua's synchronous
|
|
454
|
+
* `loadMap()` contract.
|
|
455
|
+
*
|
|
456
|
+
* `buf` is transferred to the worker and must not be reused by the caller.
|
|
457
|
+
*/
|
|
458
|
+
loadMapAsync(buf: ArrayBuffer): Promise<boolean>;
|
|
459
|
+
/**
|
|
460
|
+
* Mudlet `saveMap([location])`. Serialises the in-memory MapStore to the
|
|
461
|
+
* Mudlet binary `.dat` format and persists it to this connection's
|
|
462
|
+
* IndexedDB slot — the equivalent of Mudlet's default profile map path,
|
|
463
|
+
* picked up by {@link bootstrapMap} on next session start. Returns the
|
|
464
|
+
* serialised bytes so the Lua binding can also write them to a VFS path
|
|
465
|
+
* when the caller supplies one. Returns null when there is no connection
|
|
466
|
+
* or serialisation fails.
|
|
467
|
+
*/
|
|
468
|
+
saveMap(): ArrayBuffer | null;
|
|
469
|
+
/**
|
|
470
|
+
* Background counterpart to {@link saveMap}: serialise the map to the binary
|
|
471
|
+
* format in a worker (so the encode never blocks the main thread) and persist
|
|
472
|
+
* it to this connection's IndexedDB slot. Used for automatic saves — notably
|
|
473
|
+
* to persist the per-area zoom held in the map's area userData — so they can
|
|
474
|
+
* run frequently without jank. Returns true on success.
|
|
475
|
+
*/
|
|
476
|
+
saveMapAsync(): Promise<boolean>;
|
|
477
|
+
/**
|
|
478
|
+
* Request a debounced background map save. Multiple calls within `delayMs`
|
|
479
|
+
* collapse into a single {@link saveMapAsync}. Used by the map panel when the
|
|
480
|
+
* per-area zoom changes so the view is persisted shortly after the user stops
|
|
481
|
+
* adjusting it, without serialising on every wheel tick.
|
|
482
|
+
*/
|
|
483
|
+
scheduleMapSave(delayMs?: number): void;
|
|
484
|
+
/**
|
|
485
|
+
* Drain a pending debounced save immediately — called on session close so a
|
|
486
|
+
* zoom change made just before disconnecting/switching profiles isn't lost.
|
|
487
|
+
* The write is still async (worker + IndexedDB); on an in-app close it
|
|
488
|
+
* completes because the worker and IDB outlive the session instance.
|
|
489
|
+
*/
|
|
490
|
+
flushMapSave(): void;
|
|
491
|
+
/**
|
|
492
|
+
* Mudlet `saveJsonMap(path)` backbone — serialise the current MapStore
|
|
493
|
+
* to a JSON string. Used by the Lua binding, which writes the result to
|
|
494
|
+
* the VFS path the script provided.
|
|
495
|
+
*/
|
|
496
|
+
saveJsonMap(): string;
|
|
497
|
+
/**
|
|
498
|
+
* Mudlet `loadJsonMap(path)` backbone — parse a JSON payload previously
|
|
499
|
+
* produced by `saveJsonMap` and replace MapStore's contents, then ask any
|
|
500
|
+
* open map panel to re-render. Returns false on parse failure or when the
|
|
501
|
+
* JSON doesn't carry the expected MudletMap shape.
|
|
502
|
+
*/
|
|
503
|
+
loadJsonMap(json: string): boolean;
|
|
504
|
+
/**
|
|
505
|
+
* Import an IRE-style XML map (Mudlet TConsole::importMap →
|
|
506
|
+
* XMLimport::readMap) — the format `loadMap("...xml")` and MMP map
|
|
507
|
+
* downloads deliver. Replaces the MapStore contents, persists in the
|
|
508
|
+
* canonical binary form so the next session bootstraps it from IndexedDB,
|
|
509
|
+
* and asks any open MapPanel to re-render. Returns false when the text is
|
|
510
|
+
* not a well-formed XML map.
|
|
511
|
+
*/
|
|
512
|
+
loadMapXml(xmlText: string): boolean;
|
|
513
|
+
markAsMiniConsole(id: string): void;
|
|
514
|
+
isMiniConsole(id: string): boolean;
|
|
515
|
+
getRoomIDbyHash(hash: string): number | undefined;
|
|
516
|
+
setPosition(id: string, x: number, y: number): void;
|
|
517
|
+
/** Mudlet setWindow for miniconsole / mapper panels — re-portal the panel
|
|
518
|
+
* into another window's viewport; `undefined` re-attaches it to the main
|
|
519
|
+
* viewport. Parent is runtime-only state (deliberately not part of the
|
|
520
|
+
* saved hint): scripts re-establish it on every load, matching Mudlet. */
|
|
521
|
+
setParent(id: string, parent?: string): boolean;
|
|
522
|
+
/** Mudlet setFontSize for a userwindow / miniconsole. Returns false if the
|
|
523
|
+
* window doesn't exist. Mudlet clamps font size between 1 and 99. */
|
|
524
|
+
setFontSize(id: string, size: number): boolean;
|
|
525
|
+
getFontSize(id: string): number | null;
|
|
526
|
+
/** Mudlet setFont for a userwindow / miniconsole. Empty string clears the
|
|
527
|
+
* override and lets the inherited font take over. */
|
|
528
|
+
setFont(id: string, family: string): boolean;
|
|
529
|
+
getFont(id: string): string | null;
|
|
530
|
+
/** Mudlet setWindowWrap. 0 (or any non-positive value) clears the override. */
|
|
531
|
+
setWrap(id: string, wrapAt: number): boolean;
|
|
532
|
+
getWrap(id: string): number | null;
|
|
533
|
+
/** Companions to {@link getWrap} for the two indents — read by wrapLine,
|
|
534
|
+
* which has to re-wrap to the same shape the renderer would. */
|
|
535
|
+
getWrapIndent(id: string): number;
|
|
536
|
+
getWrapHangingIndent(id: string): number;
|
|
537
|
+
/** Mudlet setWindowWrapIndent — indent (in characters) of newline-started
|
|
538
|
+
* lines. 0 (or negative) clears the override. */
|
|
539
|
+
setWrapIndent(id: string, indent: number): boolean;
|
|
540
|
+
/** Mudlet setWindowWrapHangingIndent — indent (in characters) of wrapped
|
|
541
|
+
* continuation lines. 0 (or negative) clears the override. */
|
|
542
|
+
setWrapHangingIndent(id: string, indent: number): boolean;
|
|
543
|
+
/** Mudlet enable/disableScrollBar — toggle the vertical scrollbar's visibility
|
|
544
|
+
* on a console wrapper. Wheel/keyboard scrolling continues regardless; only
|
|
545
|
+
* the gutter rendering is affected. Persists across mounts; idempotent. */
|
|
546
|
+
setScrollBarVisible(id: string, visible: boolean): void;
|
|
547
|
+
/** Mudlet enable/disableHorizontalScrollBar — toggle a horizontal scrollbar
|
|
548
|
+
* on a console wrapper. mudix wraps long lines by default so this is rarely
|
|
549
|
+
* needed; included for parity. */
|
|
550
|
+
setHorizontalScrollBarVisible(id: string, visible: boolean): void;
|
|
551
|
+
/** Mudlet enable/disableScrolling — when disabled, the wrapper sticks to the
|
|
552
|
+
* bottom (wheel/touch/keys cannot scroll back). Mudlet forbids this on the
|
|
553
|
+
* main window; we follow that policy. Returns false on 'main', true otherwise. */
|
|
554
|
+
setScrollingEnabled(id: string, enabled: boolean): boolean;
|
|
555
|
+
/** Buffer-line index of the topmost visible line in `id`'s wrapper. In tail
|
|
556
|
+
* mode returns the last line number (matching Mudlet's mCursorY behaviour at
|
|
557
|
+
* the end of the buffer). Returns 0 if the element is unmounted or empty.
|
|
558
|
+
*
|
|
559
|
+
* Uses getBoundingClientRect rather than offsetTop because `.output-container`
|
|
560
|
+
* is `position: relative` — child offsetTop is relative to *that*, not to the
|
|
561
|
+
* scroll-container `.output-wrapper`, so the rectangles are the unambiguous
|
|
562
|
+
* way to relate child position to the scroll viewport. */
|
|
563
|
+
getScrollLine(id: string): number;
|
|
564
|
+
/** Scroll `id`'s wrapper so `line` (0-indexed) sits at the top. `undefined`
|
|
565
|
+
* resumes tail mode (scroll-to-bottom); negative values count from the end
|
|
566
|
+
* (Mudlet semantics). Returns false if the wrapper is not mounted. */
|
|
567
|
+
scrollToLine(id: string, line: number | undefined): boolean;
|
|
568
|
+
private getScrollStateMut;
|
|
569
|
+
private applyScrollClasses;
|
|
570
|
+
/** Direct line-element children of the wrapper (skips the sticky-output
|
|
571
|
+
* sentinel, which sits at the end with height: 0). */
|
|
572
|
+
private lineElements;
|
|
573
|
+
/** Mudlet setBackgroundColor for a userwindow / miniconsole. */
|
|
574
|
+
setBackgroundColor(id: string, r: number, g: number, b: number, a?: number): boolean;
|
|
575
|
+
getBackgroundColor(id: string): {
|
|
576
|
+
r: number;
|
|
577
|
+
g: number;
|
|
578
|
+
b: number;
|
|
579
|
+
a: number;
|
|
580
|
+
} | null;
|
|
581
|
+
/** Mudlet setBackgroundImage for a userwindow / miniconsole. */
|
|
582
|
+
setBackgroundImage(id: string, url: string, mode: number): boolean;
|
|
583
|
+
/** Mudlet resetBackgroundImage for a userwindow / miniconsole. */
|
|
584
|
+
resetBackgroundImage(id: string): boolean;
|
|
585
|
+
setSize(id: string, width: number, height: number): void;
|
|
586
|
+
/** Mudlet enableCommandLine(name). Idempotent. Returns false when the
|
|
587
|
+
* window doesn't exist. */
|
|
588
|
+
enableCommandLine(id: string): boolean;
|
|
589
|
+
/** Mudlet disableCommandLine(name). Idempotent. Returns false when the
|
|
590
|
+
* window doesn't exist. The action callback is kept so re-enabling
|
|
591
|
+
* resumes the same binding (matches Mudlet's behaviour). */
|
|
592
|
+
disableCommandLine(id: string): boolean;
|
|
593
|
+
/** Mudlet setCmdLineStyleSheet(name, qss). Stored as raw QSS; the panel
|
|
594
|
+
* translates it through cmdLineQssToScopedCss at render time. Returns
|
|
595
|
+
* false when the window doesn't exist. */
|
|
596
|
+
setCmdLineStyleSheet(id: string, qss: string): boolean;
|
|
597
|
+
/** Bind the Lua callback fired when the user presses Enter in this
|
|
598
|
+
* window's command line. Pass null to clear. Returns false when the
|
|
599
|
+
* window doesn't exist. */
|
|
600
|
+
setCmdLineAction(id: string, cb: ((text: string) => void) | null): boolean;
|
|
601
|
+
/** Whether a script has bound a per-window Enter handler. */
|
|
602
|
+
hasCmdLineAction(id: string): boolean;
|
|
603
|
+
/** Read the bound callback (or null). The TextPanel input invokes this
|
|
604
|
+
* directly on Enter so the React tree never sees the function. */
|
|
605
|
+
getCmdLineAction(id: string): ((text: string) => void) | null;
|
|
606
|
+
/** Mudlet clearCmdLine([name]) when name is a userwindow — wipes the
|
|
607
|
+
* input contents. The seq bump forces React to apply the seed even
|
|
608
|
+
* when the value didn't change. Returns false when the window doesn't
|
|
609
|
+
* exist or has no command line. */
|
|
610
|
+
clearWindowCmdLine(id: string): boolean;
|
|
611
|
+
/** Mudlet printCmdLine([name], text) when name is a userwindow — replaces
|
|
612
|
+
* the input contents and moves the caret to the end (React side). */
|
|
613
|
+
printWindowCmdLine(id: string, text: string): boolean;
|
|
614
|
+
/** Mudlet appendCmdLine([name], text) when name is a userwindow — pushes
|
|
615
|
+
* `text` onto the end of the current contents. */
|
|
616
|
+
appendWindowCmdLine(id: string, text: string): boolean;
|
|
617
|
+
/** Used by ScriptingAPI.getCmdLine([name]) when the name targets a window;
|
|
618
|
+
* returns the cached value last seeded. The actual live input value is
|
|
619
|
+
* reported by the TextPanel through a register callback (see
|
|
620
|
+
* registerCmdLineValueProbe). */
|
|
621
|
+
private cmdLineValueProbes;
|
|
622
|
+
registerCmdLineValueProbe(id: string, probe: () => string): () => void;
|
|
623
|
+
getCmdLineValue(id: string): string;
|
|
624
|
+
bringToFront(id: string): void;
|
|
625
|
+
/** Mudlet lowerWindow for a userwindow — drop below every other floating
|
|
626
|
+
* window. Computes a fresh below-min zIndex so successive lowerWindow
|
|
627
|
+
* calls maintain relative order. */
|
|
628
|
+
sendToBack(id: string): void;
|
|
629
|
+
dock(id: string, side: DockSide, slotIndex?: number): void;
|
|
630
|
+
/** Stack panel `id` as a tab with panel `targetId` (or into its existing group). */
|
|
631
|
+
tabIntoGroup(id: string, targetId: string): void;
|
|
632
|
+
setActiveTab(panelId: string): void;
|
|
633
|
+
/** Split panel `id` above or below `targetId` (cross-axis within the same dock slot). */
|
|
634
|
+
splitIntoGroup(id: string, targetId: string, splitBefore: boolean): void;
|
|
635
|
+
setSplitFlex(panelId: string, flex: number): void;
|
|
636
|
+
/** Undock. Pass the panel's screen rect so the floating window appears in-place. */
|
|
637
|
+
undock(id: string, visualWidth?: number, visualHeight?: number, screenX?: number, screenY?: number): void;
|
|
638
|
+
getDockExtent(side: DockSide): number;
|
|
639
|
+
setDockExtent(side: DockSide, size: number): void;
|
|
640
|
+
setDockFlex(id: string, flex: number): void;
|
|
641
|
+
/** Set flex for all panels in the same slot (by panel ID, tab-group ID, or split-group ID). */
|
|
642
|
+
setSlotFlex(slotId: string, flex: number): void;
|
|
643
|
+
open(id: string, options?: WindowOpenOptions): WindowHandle;
|
|
644
|
+
close(id: string): void;
|
|
645
|
+
clearAll(): void;
|
|
646
|
+
hide(id: string): void;
|
|
647
|
+
show(id: string): boolean;
|
|
648
|
+
isVisible(id: string): boolean;
|
|
649
|
+
/** Stored geometry for a user window / miniconsole — deliberately the saved
|
|
650
|
+
* x/y/width/height rather than {@link getSize}'s live DOM rect, so it is an
|
|
651
|
+
* exact inverse of moveWindow/resizeWindow (Mudlet's getWindowGeometry
|
|
652
|
+
* reads back through the dock widget the same way). Null if unknown. */
|
|
653
|
+
getGeometry(id: string): {
|
|
654
|
+
x: number;
|
|
655
|
+
y: number;
|
|
656
|
+
width: number;
|
|
657
|
+
height: number;
|
|
658
|
+
} | null;
|
|
659
|
+
/** The window this one nests inside, or null for a root floating window.
|
|
660
|
+
* Used by the ancestor-aware windowVisible walk. */
|
|
661
|
+
parentOf(id: string): string | null;
|
|
662
|
+
write(id: string, text: string): void;
|
|
663
|
+
flushLine(id: string): void;
|
|
664
|
+
flushAllLines(): void;
|
|
665
|
+
clear(id: string): void;
|
|
666
|
+
/**
|
|
667
|
+
* Mudlet setUserWindowTitle(name, [title]) → bool. With a non-empty title
|
|
668
|
+
* the panel header shows that string; with an empty/missing title the
|
|
669
|
+
* window's id is used as the title (matches Mudlet's "reset to default"
|
|
670
|
+
* behaviour). Returns false when the named window doesn't exist.
|
|
671
|
+
*/
|
|
672
|
+
setTitle(id: string, title?: string): boolean;
|
|
673
|
+
focus(id: string): void;
|
|
674
|
+
has(id: string): boolean;
|
|
675
|
+
getElement(id: string): HTMLElement | null;
|
|
676
|
+
/** Mudlet getUserWindowSize. Reports the live rendered size of a userwindow
|
|
677
|
+
* / miniconsole when mounted (so docked panels return their actual on-screen
|
|
678
|
+
* pixels rather than the stored hint), else falls back to the saved width
|
|
679
|
+
* /height. Returns null if the window doesn't exist. Prefers the viewport
|
|
680
|
+
* element so the reported box matches the rectangle labels position against —
|
|
681
|
+
* not the inner output area, which has paddings and a scrollbar gutter. */
|
|
682
|
+
getSize(id: string): {
|
|
683
|
+
width: number;
|
|
684
|
+
height: number;
|
|
685
|
+
} | null;
|
|
686
|
+
private pushLine;
|
|
687
|
+
private defaultX;
|
|
688
|
+
private defaultY;
|
|
689
|
+
private notify;
|
|
690
|
+
private saveHint;
|
|
691
|
+
private removeFromSplitGroup;
|
|
692
|
+
private removeFromGroup;
|
|
693
|
+
private makeHandle;
|
|
694
|
+
}
|