@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,90 @@
1
+ import type { MapReader, IArea, IMapReader, ViewportBounds, ViewportDataSource, HashLookupCapable } from 'mudlet-map-renderer';
2
+ import type { MapStore } from './MapStore';
3
+ type RoomShape = ReturnType<MapReader['getRoom']>;
4
+ /**
5
+ * Live {@link IMapReader} backed by Mudix's {@link MapStore}.
6
+ *
7
+ * The renderer is constructed once on panel mount and held for the lifetime of
8
+ * the panel. Whenever the store mutates (script-built rooms, binary load,
9
+ * setRoomCoordinates, …) the panel calls {@link refresh}; this rebuilds the
10
+ * inner reader from the store's current snapshot. The renderer's `MapState`
11
+ * notices the new `IArea` instance via reference inequality and rebuilds the
12
+ * scene — no Konva stage / event listener teardown.
13
+ *
14
+ * The inner reader is a {@link SkeletonMapReader}: rooms live in compact
15
+ * typed-array columns and are materialised per viewport, instead of the
16
+ * concrete `MapReader`'s full object graph. Nothing is dropped — the skeleton
17
+ * is built from the complete map and keeps every room, with rooms carrying
18
+ * visual detail (symbols, custom lines, special exits, doors, stubs, exit
19
+ * locks) materialised in full — it only changes how the *renderer* holds them.
20
+ * That matters because the concrete reader's costs scale with the whole plane
21
+ * rather than what's on screen: on a 250k-room map, constructing it took ~7s
22
+ * and the first scene build ~9s, all synchronous on the main thread.
23
+ *
24
+ * Being a {@link ViewportDataSource} is what unlocks that: the interactive
25
+ * backend pushes padded camera bounds before every scene build and only
26
+ * rebuilds when the camera leaves the padding. The capability is detected by
27
+ * duck-typing (`viewportAware === true`), so this wrapper has to re-declare it
28
+ * and forward — a plain `IMapReader` facade would silently opt out of the
29
+ * virtualization and fall back to materialising everything.
30
+ *
31
+ * The renderer's wire format (`{mapData, colors}`) is produced via
32
+ * `readerExport(store.toMudletMap())` — the same transformation Mudlet's own
33
+ * binary-reader pipeline applies. Doing it inside the reader (instead of in
34
+ * the panel) keeps `MapPanel` pure-view: it never sees the wire format.
35
+ */
36
+ export declare class MudixMapReader implements IMapReader, ViewportDataSource, HashLookupCapable {
37
+ private readonly store;
38
+ readonly viewportAware: true;
39
+ readonly hashLookupCapable: true;
40
+ private inner;
41
+ private snapshotVersion;
42
+ /** Last viewport the renderer pushed. Held here because a store-driven
43
+ * rebuild replaces the inner reader, and a fresh one defaults to
44
+ * unbounded — re-applying keeps the next scene build scoped to where the
45
+ * camera actually is instead of materialising the whole plane once. */
46
+ private viewport;
47
+ constructor(store: MapStore);
48
+ /** Rebuild the inner reader from MapStore's current snapshot. Safe to
49
+ * call from a store-change subscriber — cheap when the store is empty
50
+ * and idempotent when no mutation has happened since the last refresh. */
51
+ refresh(): void;
52
+ /**
53
+ * Stale-check before every public read. The renderer can ask for a room
54
+ * synchronously after a script mutation (e.g. addRoom → centerview),
55
+ * before MapStore's microtask-delayed notify fires. Running the version
56
+ * check on every call is O(1); a real rebuild only happens when the
57
+ * store has actually mutated since the last snapshot.
58
+ */
59
+ private ensureFresh;
60
+ /** True once the store has at least one room; the panel's empty-state
61
+ * overlay stays up until this flips. */
62
+ hasData(): boolean;
63
+ private buildInner;
64
+ getArea(areaId: number): IArea;
65
+ getAreas(): IArea[];
66
+ /** Note: a viewport-virtualized reader deliberately returns an empty list
67
+ * here rather than materialising every room — callers that want rooms go
68
+ * through a plane (which is viewport-scoped) or {@link getRoom} by id. */
69
+ getRooms(): RoomShape[];
70
+ getRoom(roomId: number): RoomShape;
71
+ getColorValue(envId: number): string;
72
+ getSymbolColor(envId: number, opacity?: number): string;
73
+ setViewport(bounds: ViewportBounds): void;
74
+ getViewport(): ViewportBounds;
75
+ getPlaneRoomCount(areaId: number, z: number): number;
76
+ estimateVisibleCount(areaId: number, z: number, bounds: ViewportBounds): number;
77
+ forEachInBounds(areaId: number, z: number, bounds: ViewportBounds, fn: (x: number, y: number, envId: number) => void): void;
78
+ /** O(1) hash → id. Needed because `getRooms()` is empty on a virtualized
79
+ * reader, so the scan-based fallback the renderer would otherwise use can
80
+ * never resolve anything. */
81
+ getRoomIdByHash(hash: string): number | undefined;
82
+ /**
83
+ * Drop any viewport narrowing, so subsequent reads materialise the whole
84
+ * map again. The export path needs this: an exporter driven by a reader
85
+ * still scoped to the on-screen camera would silently render only the
86
+ * rooms that happen to be visible.
87
+ */
88
+ clearViewport(): void;
89
+ }
90
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { MapState, SceneOverlay, SceneOverlayContext, Shape, ViewportBounds } from 'mudlet-map-renderer';
2
+ import type { MapStore } from './MapStore';
3
+ import type { MudixMapReader } from './MudixMapReader';
4
+ export declare class MudletHighlightOverlay implements SceneOverlay {
5
+ private readonly mapStore;
6
+ private readonly reader;
7
+ private ctx?;
8
+ private mapStoreUnsub?;
9
+ private areaHandler?;
10
+ constructor(mapStore: MapStore, reader: MudixMapReader);
11
+ attach(ctx: SceneOverlayContext): void;
12
+ detach(): void;
13
+ /** Force a re-render from outside. The renderer's `refresh()` doesn't
14
+ * emit any state event we listen to, but a change to settings.roomSize
15
+ * moves every highlight circle's radius. */
16
+ refresh(): void;
17
+ render(state: MapState, _bounds: ViewportBounds): Shape[] | void;
18
+ }
@@ -0,0 +1,26 @@
1
+ import type { Settings as MapRendererSettings } from 'mudlet-map-renderer';
2
+ import type { MapStore } from './MapStore';
3
+ import type { MapperSettings } from '../storage';
4
+ /**
5
+ * Copy user-set fields from MapperSettings onto a live renderer settings
6
+ * object. Anything left undefined in `mapper` is intentionally not touched
7
+ * so the renderer's own createSettings() defaults stay in effect.
8
+ */
9
+ export declare function applyMapperSettings(target: MapRendererSettings, mapper: MapperSettings | undefined): void;
10
+ /**
11
+ * Mudlet `exportAreaImage` — render one area (optionally a single z-level) to
12
+ * PNG bytes. Returns null when the area is unknown or the render fails.
13
+ *
14
+ * Deliberately standalone: the export builds its own reader, settings and
15
+ * off-screen container, so it never touches — or needs — a mounted map panel.
16
+ * The live panel's reader is scoped to the camera's viewport (that is what
17
+ * keeps big maps fast), so an export driven through it would contain only the
18
+ * rooms currently on screen; and requiring a panel would make the API
19
+ * unreachable from a script that runs before React has mounted one. (Mudlet
20
+ * does require its mapper open, but that is a Qt artefact of where its
21
+ * renderer lives, not part of the API's meaning.)
22
+ *
23
+ * The off-screen container only exists to give the Konva backend real
24
+ * dimensions so getAreaBounds can resolve an aspect ratio.
25
+ */
26
+ export declare function exportAreaImage(mapStore: MapStore, mapper: MapperSettings | undefined, areaId: number, zLevel?: number): Uint8Array | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import type { MudletMap, MudletMapHeader, MudletRoom } from 'mudlet-map-binary-reader';
2
+ /** Callbacks driving a streamed parse. `onHeader` fires once before any room,
3
+ * `onRooms` once per batch, in map order; the returned promise settles after
4
+ * the last batch has been handed over. */
5
+ export interface MapStreamSink {
6
+ onHeader(header: MudletMapHeader, totalRooms: number): void;
7
+ onRooms(rooms: [number, MudletRoom][]): void;
8
+ /** Rooms ingested so far / the header's total (0 when the total is unknown). */
9
+ onProgress?(loaded: number, total: number): void;
10
+ }
11
+ /**
12
+ * Parse a Mudlet binary map off the main thread. The buffer is transferred —
13
+ * caller must not reuse it after the call. Resolves with the parsed MudletMap
14
+ * (deep-cloned by structured-clone on its way back).
15
+ */
16
+ export declare function parseMapInWorker(buf: ArrayBuffer): Promise<MudletMap>;
17
+ /**
18
+ * Streaming sibling of {@link parseMapInWorker}: the worker walks the map
19
+ * room-by-room and pushes the header, then batches of rooms, into `sink`
20
+ * instead of materialising the whole graph and cloning it back in one piece.
21
+ * Peak memory is roughly halved (the graph no longer exists on both sides at
22
+ * once) and the batch counter gives a progress signal for large maps.
23
+ *
24
+ * The buffer is transferred — the caller must not reuse it. Resolves once the
25
+ * last batch has been delivered; rejects if the worker fails mid-stream, in
26
+ * which case the sink has seen a partial map and the caller owns the cleanup.
27
+ */
28
+ export declare function streamMapInWorker(buf: ArrayBuffer, sink: MapStreamSink): Promise<void>;
29
+ /**
30
+ * Serialise a MudletMap to the Mudlet binary `.dat` format off the main thread.
31
+ * The map is structured-cloned to the worker (so the caller's object isn't
32
+ * touched); the resulting bytes are transferred back as a standalone
33
+ * ArrayBuffer the caller owns.
34
+ */
35
+ export declare function serializeMapInWorker(map: MudletMap): Promise<ArrayBuffer>;
@@ -0,0 +1,52 @@
1
+ import type { MudletRoom } from 'mudlet-map-binary-reader';
2
+ /**
3
+ * Verdict from a `setExitWeightFilter` callback for one candidate exit.
4
+ * `blocked` drops the edge from the graph entirely; `weightOverride` replaces
5
+ * the edge cost that the exit weight / target room weight would have given.
6
+ * Both unset means "leave this exit alone".
7
+ */
8
+ export interface ExitWeightFilterResult {
9
+ blocked?: boolean;
10
+ weightOverride?: number;
11
+ }
12
+ /**
13
+ * Called once per candidate exit while the graph is explored, with the room
14
+ * being expanded and the exit's key — the short direction name ("e", "up") for
15
+ * stock exits, or the verbatim command for special exits. Mirrors Mudlet's
16
+ * `applyExitWeightFilter(source, exitKey)` (TMap.cpp).
17
+ */
18
+ export type ExitWeightFilter = (roomId: number, exitCommand: string) => ExitWeightFilterResult;
19
+ export interface PathfindResult {
20
+ /** Room ids visited in order, excluding the start room. Matches Mudlet's
21
+ * speedWalkPath, which prepends each step until reaching `from` but never
22
+ * prepends `from` itself. */
23
+ path: number[];
24
+ /** Direction taken at each step — short name ("n"/"ne"/"up"/"down"/"in"/"out")
25
+ * for stock exits or the verbatim command string for special exits. Same
26
+ * length as `path` / `weights`. */
27
+ dirs: string[];
28
+ /** Edge cost per step (target room weight, or per-exit weight override). */
29
+ weights: number[];
30
+ /** Sum of `weights` — Mudlet's getPath returns this alongside the bool. */
31
+ totalWeight: number;
32
+ }
33
+ /**
34
+ * Mudlet `findPath(from, to)` — A* shortest path. Heuristic mirrors Mudlet's
35
+ * TAstar.h: 3D Euclidean distance when both rooms share an area, constant 1
36
+ * (equivalent to Dijkstra) when they don't — Mudlet falls back because raw
37
+ * coordinates aren't comparable across areas. Edge cost is the per-exit
38
+ * override in `exitWeights[key]` if set, otherwise the target room's `weight`
39
+ * (clamped to ≥1 to keep the heap monotonic).
40
+ *
41
+ * Skips locked rooms (`isLocked`), locked stock-direction exits (`exitLocks`
42
+ * carries the 1-12 dir codes), and locked special exits. Special-exit locks are
43
+ * per COMMAND in Mudlet; pass `isSpecialExitLocked` to resolve them that way.
44
+ * Without it the room's `mSpecialExitLocks` is used, which the binary reader
45
+ * keys by destination room id — that loses per-command resolution when several
46
+ * commands share a destination, but it is the on-disk representation.
47
+ *
48
+ * Trivial `from == to` returns an empty path with totalWeight 0 (also
49
+ * Mudlet's behavior). Returns null when either room is missing or no route
50
+ * exists.
51
+ */
52
+ export declare function findPath(rooms: ReadonlyMap<number, MudletRoom>, from: number, to: number, exitFilter?: ExitWeightFilter | null, isSpecialExitLocked?: (roomId: number, command: string) => boolean): PathfindResult | null;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Mudlet XML map import — the IRE-style `map.xml` format games publish via
3
+ * GMCP `Client.Map` (MMP) and that Mudlet's `loadMap("...xml")` accepts.
4
+ * Faithful port of XMLimport::readMap/readArea/readRoom/readEnvColor
5
+ * (Mudlet src/XMLimport.cpp), producing the same in-memory `MudletMap` shape
6
+ * the binary reader yields so `MapStore.loadFromBinary` can ingest it.
7
+ *
8
+ * Format sketch:
9
+ *
10
+ * <map>
11
+ * <areas><area id="2" name="Riverside"/></areas>
12
+ * <rooms>
13
+ * <room id="1" area="2" title="On a hill" environment="3">
14
+ * <coord x="0" y="0" z="0"/>
15
+ * <exit direction="north" target="2" door="1"/>
16
+ * <exit special="1" command="enter hole" target="7" hidden="1"/>
17
+ * </room>
18
+ * </rooms>
19
+ * <environments><environment id="3" color="4"/></environments>
20
+ * </map>
21
+ */
22
+ import type { MudletMap } from 'mudlet-map-binary-reader';
23
+ /**
24
+ * Parse an XML map document into the `MudletMap` shape `loadFromBinary`
25
+ * ingests. Returns null when the text isn't well-formed XML or the root
26
+ * element isn't `<map>` (e.g. an HTML error page served for the map URL).
27
+ */
28
+ export declare function parseXmlMap(xmlText: string): MudletMap | null;
@@ -0,0 +1,236 @@
1
+ import { EventBus } from '../core/EventBus';
2
+ import { WindowManager } from '../ui/windows/WindowManager';
3
+ import { LabelManager } from '../ui/labels/LabelManager';
4
+ import { CommandLineManager } from '../ui/cmdline/CommandLineManager';
5
+ import { ScrollBoxManager } from '../ui/scrollbox/ScrollBoxManager';
6
+ import { SoundManager } from '../ui/sound/SoundManager';
7
+ import { VideoManager } from '../ui/video/VideoManager';
8
+ import { CmdLineMenuRegistry } from '../ui/CmdLineMenuRegistry';
9
+ import { MouseEventRegistry } from '../ui/MouseEventRegistry';
10
+ import { type MudClientOptions } from './connection/MudClient';
11
+ import { type MudEvents, type SessionStatus } from './events';
12
+ import type { Console } from './text/Console';
13
+ import { type ControlCharacterMode } from './text/controlCharacterMode';
14
+ export type { SessionStatus, MudEvents } from './events';
15
+ export type { ControlCharacterMode } from './text/controlCharacterMode';
16
+ export type MudSessionOptions = Omit<MudClientOptions, 'url'>;
17
+ /** Mudlet `showSentText` modes — controls local echo of commands you send.
18
+ * `never`: never echo. `script`: echo unless a script passes `send(cmd, false)`
19
+ * (the default). `always`: echo even when a script passes `send(cmd, false)`. */
20
+ export type ShowSentTextMode = 'never' | 'script' | 'always';
21
+ /** Mudlet `blankLinesBehaviour` modes — controls how empty server lines render.
22
+ * `show`: render the blank line as-is (default). `hide`: suppress it entirely.
23
+ * `replacewithspace`: render it as a single space (so screen readers announce
24
+ * it — Mudlet's QTBUG-105035 workaround). */
25
+ export type BlankLinesBehaviour = 'show' | 'hide' | 'replacewithspace';
26
+ export type ScriptLogSourceKind = 'script' | 'alias' | 'trigger' | 'timer' | 'key' | 'button';
27
+ export interface ScriptLogSource {
28
+ kind: ScriptLogSourceKind;
29
+ id: string;
30
+ name: string;
31
+ line?: number;
32
+ }
33
+ export interface ScriptLogEntry {
34
+ text: string;
35
+ level: 'error' | 'info';
36
+ timestamp: number;
37
+ source?: ScriptLogSource;
38
+ }
39
+ export declare class MudSession {
40
+ readonly events: EventBus<MudEvents>;
41
+ private readonly overlayLayerOrder;
42
+ readonly windows: WindowManager;
43
+ readonly labels: LabelManager;
44
+ readonly cmdLines: CommandLineManager;
45
+ readonly scrollBoxes: ScrollBoxManager;
46
+ readonly sounds: SoundManager;
47
+ readonly videos: VideoManager;
48
+ readonly cmdLineMenu: CmdLineMenuRegistry;
49
+ readonly mouseEvents: MouseEventRegistry;
50
+ /** Per-window Console instances. 'main' registered by ScriptingAPI; named windows by WindowManager. */
51
+ readonly consoles: Map<string, Console>;
52
+ private client;
53
+ /** The most recent URL passed to connect() — replayed by reconnect(). */
54
+ private lastUrl;
55
+ private pingTracker;
56
+ private stateUnsubs;
57
+ private _status;
58
+ private _ping;
59
+ private _outputReady;
60
+ private _destroyed;
61
+ /** Latest main output area character grid (columns × rows), tracked here so
62
+ * it survives client teardown and seeds a freshly-created client on the
63
+ * next connect(). Fed by the WindowManager's main-console resize callback
64
+ * and forwarded to the live client for NAWS (telnet option 31). */
65
+ private windowSize;
66
+ /** Active Mudlet-format replay recording, or null. Fed from the
67
+ * `socket.incoming` tap in the constructor — the post-MCCP,
68
+ * pre-telnet-parsing stream, the same point Mudlet records at. */
69
+ private replayRecorder;
70
+ /** Active replay playback, or null. */
71
+ private replayPlayer;
72
+ /** Playback speed divisor (1..1024). Read per-chunk, so changing it
73
+ * mid-replay affects the remaining chunks — matching Mudlet. */
74
+ private _replaySpeed;
75
+ /** Colors for the local echo of sent commands. Re-applied from the active
76
+ * profile by ProfileSession. `fg` defaults to Mudlet's olive; `bg` empty =
77
+ * no background. Consumed by echoCommand() to wrap the echo in ANSI. */
78
+ commandEchoColor: {
79
+ fg: string;
80
+ bg: string;
81
+ };
82
+ /** Mudlet `setConfig("showSentText", ...)`. Controls local echo of sent
83
+ * commands (the server-side ECHO suppression in `shouldEchoCommand` still
84
+ * applies independently). `script` (the default) echoes only when send()'s
85
+ * `echo` flag is set, so scripts can suppress per command via
86
+ * `send(cmd, false)`; `always` echoes even then; `never` never echoes.
87
+ * Toggled live by the config registry in ScriptingAPI. */
88
+ showSentText: ShowSentTextMode;
89
+ /** Mudlet `setConfig("blankLinesBehaviour", ...)`. Controls how empty server
90
+ * lines render in the main output. Read by ScriptingEngine.processFlushBatch
91
+ * per line; toggled live (and persisted) by the config registry in
92
+ * ScriptingAPI. */
93
+ blankLinesBehaviour: BlankLinesBehaviour;
94
+ /** Bounded script.log buffer so the editor panel can backfill entries that
95
+ * arrived before it was first opened (e.g. errors during initial load). */
96
+ private static readonly SCRIPT_LOG_LIMIT;
97
+ private _scriptLog;
98
+ private readonly options;
99
+ /** Warn before the tab closes while a connection is live. Owned here rather
100
+ * than by MudClient — a fresh client is created on every connect(), so a
101
+ * per-client listener would accumulate one leaked closure per reconnect. */
102
+ private readonly beforeUnload;
103
+ constructor(options?: MudSessionOptions);
104
+ get scriptLog(): readonly ScriptLogEntry[];
105
+ clearScriptLog(): void;
106
+ get status(): SessionStatus;
107
+ get ping(): number | null;
108
+ get outputReady(): boolean;
109
+ markOutputReady(): void;
110
+ markOutputGone(): void;
111
+ connect(url: string): void;
112
+ disconnect(): void;
113
+ /** Whether a send() carrying the given per-call `echo` flag should produce a
114
+ * local echo, under the current showSentText mode. `script` defers to the
115
+ * flag; `always`/`never` ignore it. */
116
+ private shouldEchoSentText;
117
+ echoCommand(text: string): void;
118
+ /** Wrap the echoed command in ANSI truecolor escapes from commandEchoColor
119
+ * so it renders in the configured foreground (and optional background). */
120
+ private styleEchoCommand;
121
+ send(text: string, echo?: boolean): void;
122
+ /** Send credentials/secrets that must NEVER be echoed locally — regardless of
123
+ * the showSentText mode (including `always`) or the server-echo state. Used
124
+ * for auto-login passwords. The normal `send(text, false)` only suppresses
125
+ * the echo in `script` mode; `always` would override it, so a password must
126
+ * take this path instead of relying on the per-call echo flag. */
127
+ sendSecret(text: string): void;
128
+ sendGmcpRaw(message: string): void;
129
+ /** Reply to a GMCP `Char.Login.Default` request. Pass an account + password
130
+ * to authenticate, or no arguments to send the empty "fall back to text
131
+ * login" reply (the credentials popup's Cancel). The password is relayed
132
+ * straight to the wire and never persisted. */
133
+ sendCharLoginCredentials(account?: string, password?: string): void;
134
+ sendMSDP(variable: string, values: string[]): boolean;
135
+ sendSocket(data: string): boolean;
136
+ /** True when there is no live socket — see MudClient.isSocketUnconnected. */
137
+ isSocketUnconnected(): boolean;
138
+ feedTelnet(data: string): void;
139
+ sendATCP(message: string): boolean;
140
+ sendTelnetChannel102(msg: string): boolean;
141
+ /** Whether MSP was negotiated on the live connection. False with no client,
142
+ * which is what a never-connected profile should report. */
143
+ isMspNegotiated(): boolean;
144
+ get replaySpeed(): number;
145
+ get isReplayRecording(): boolean;
146
+ get isReplaying(): boolean;
147
+ /** Set the playback speed divisor, clamped to Mudlet's 1..1024 range.
148
+ * Takes effect from the next chunk of an active replay. */
149
+ setReplaySpeed(speed: number): void;
150
+ /** Start recording the inbound stream to Mudlet's replay format. Returns
151
+ * false when a recording is already running. */
152
+ startReplayRecording(): boolean;
153
+ /** Stop recording and return the captured stream as a Mudlet .dat file's
154
+ * bytes, or null when no recording was running. The caller decides where
155
+ * the bytes go (profile VFS, browser download, …). */
156
+ stopReplayRecording(): Uint8Array | null;
157
+ /** Start playing a Mudlet-format replay (the Lua `loadReplay` core).
158
+ * Works offline — with no live connection the chunks feed a detached
159
+ * client's parsing pipeline. Returns null on success or a human-readable
160
+ * failure reason (mirroring Mudlet's loadReplay error strings). */
161
+ loadReplayData(bytes: Uint8Array): string | null;
162
+ /** Stop the active replay without delivering its remaining chunks.
163
+ * Returns false when no replay is running. */
164
+ abortReplay(): boolean;
165
+ /** The client whose parsing pipeline replay chunks feed into. Reuses the
166
+ * live client when one exists; otherwise creates a detached MudClient
167
+ * that is never connect()ed — the inbound pipeline works without a
168
+ * socket, and any replies the replayed IAC traffic provokes are dropped
169
+ * by the readyState guards, which is exactly right for playback. */
170
+ private ensureReplayClient;
171
+ private postReplayInfo;
172
+ /** Mudlet `reconnect()`. Disconnect and redial the most recently connected
173
+ * URL (set by connect(), so it covers both the app and Lua connect paths).
174
+ * Returns false when nothing has been dialed yet. */
175
+ reconnect(): boolean;
176
+ /** Mudlet `getServerEncoding()`. The live client's inbound decoder name;
177
+ * 'utf-8' when no client is attached. */
178
+ getServerEncoding(): string;
179
+ /** Mudlet `setServerEncoding(name)`. Returns false when no client is
180
+ * attached or the name isn't supported. */
181
+ setServerEncoding(name: string): boolean;
182
+ /** Mudlet `getServerEncodingsList()`. The fixed set of encodings mudix can
183
+ * decode — available even before a connection is dialed. */
184
+ getServerEncodingsList(): string[];
185
+ /** Mudlet `addSupportedTelnetOption(option)`. Forwards to the live
186
+ * MudClient when one is attached so the option will be auto-negotiated
187
+ * on the next IAC WILL/DO from the server. Returns false when no client
188
+ * is wired up yet. */
189
+ addSupportedTelnetOption(option: number): boolean;
190
+ /** Updates both the active client (if any) and the stored options so the
191
+ * setting survives a reconnect. */
192
+ setPromptTimeoutMs(ms: number): void;
193
+ getPromptTimeoutMs(): number | null;
194
+ /** Mudlet `setConfig("fixUnnecessaryLinebreaks", …)`. Updates the live client
195
+ * and the stored options so the setting survives a reconnect. */
196
+ setFixUnnecessaryLinebreaks(enabled: boolean): void;
197
+ /** Mudlet `setConfig("controlCharacterHandling", …)`. Applies immediately —
198
+ * every console/text window re-renders control characters (and tab-stops)
199
+ * under the new mode on their next paint. */
200
+ setControlCharacterMode(mode: ControlCharacterMode): void;
201
+ /** Update the telnet protocol toggles applied on the next connect.
202
+ * Mid-session changes do not retroactively renegotiate — the values are
203
+ * read by MudClient's constructor, so the next dial sees them. */
204
+ setProtocolOptions(opts: {
205
+ gmcpEnabled?: boolean;
206
+ mttsEnabled?: boolean;
207
+ msdpEnabled?: boolean;
208
+ msspEnabled?: boolean;
209
+ charsetEnabled?: boolean;
210
+ mspEnabled?: boolean;
211
+ mccpEnabled?: boolean;
212
+ mxpEnabled?: boolean;
213
+ mnesEnabled?: boolean;
214
+ newEnvironEnabled?: boolean;
215
+ secureTransport?: boolean;
216
+ screenReaderAdvertised?: boolean;
217
+ nawsEnabled?: boolean;
218
+ subprotocols?: string[];
219
+ }): void;
220
+ /** Record the main output area's character grid (columns × rows) and forward
221
+ * it to the live client for NAWS. Stored on the session so a client created
222
+ * on a later connect() is seeded with the current size. Called by the
223
+ * WindowManager whenever the main console's grid changes. */
224
+ setWindowSize(cols: number, rows: number): void;
225
+ private teardownClient;
226
+ get destroyed(): boolean;
227
+ /** Release resources that live outside the JS heap. In-memory state (maps,
228
+ * arrays, sub-managers) is reclaimed by GC once the instance is dropped, so
229
+ * this only handles the three things that don't self-clean: the WebSocket
230
+ * + ping timer (via `teardownClient`), Web Audio nodes, and any EventBus
231
+ * listeners with an AbortSignal cleanup still pending. Idempotent. */
232
+ destroy(): void;
233
+ private setStatus;
234
+ private setPing;
235
+ private reportConnectionError;
236
+ }
@@ -0,0 +1,28 @@
1
+ type TempFn = (matches: RegExpMatchArray) => void;
2
+ type PatternItem = {
3
+ id: string;
4
+ name: string;
5
+ pattern: string;
6
+ code: string;
7
+ language: 'lua' | 'js';
8
+ enabled: boolean;
9
+ isGroup: boolean;
10
+ parentId: string | null;
11
+ };
12
+ export declare class PatternEngine<T extends PatternItem> {
13
+ protected readonly temp: Map<number, {
14
+ pattern: RegExp;
15
+ fn: TempFn;
16
+ }>;
17
+ protected nextId: number;
18
+ protected permCompiled: Array<{
19
+ item: T;
20
+ re: RegExp;
21
+ }>;
22
+ /** Number of live session-scoped temp items (Mudlet `getProfileStats` temp count). */
23
+ get tempCount(): number;
24
+ addTemp(pattern: string | RegExp, fn: TempFn): () => void;
25
+ loadPerm(items: T[]): void;
26
+ destroy(): void;
27
+ }
28
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { AliasNode } from '../../storage/schema';
2
+ import { PatternEngine } from '../PatternEngine';
3
+ export type { AliasNode };
4
+ export declare class AliasEngine extends PatternEngine<AliasNode> {
5
+ /** Returns true and fires the first matching temp alias. Stops at first match. */
6
+ processTemp(input: string): boolean;
7
+ /** Returns the first matching perm alias, or null. `matchedText` is the
8
+ * portion of `input` the regex actually matched (Mudlet's `matches[1]`),
9
+ * which differs from the whole input for an unanchored pattern. */
10
+ matchPerm(input: string): {
11
+ alias: AliasNode;
12
+ matchedText: string;
13
+ captures: string[];
14
+ } | null;
15
+ }
@@ -0,0 +1,84 @@
1
+ export declare const DEFAULT_PROMPT_TIMEOUT_MS = 300;
2
+ /**
3
+ * Keep prompt-flush timeouts in a sane range. 0 disables the safety net (only
4
+ * a real GA/EOR or the next chunk's newline will flush a partial tail) — handy
5
+ * for tests but risky for GA-less MUDs. The upper bound stops a typo from
6
+ * stalling output for minutes.
7
+ */
8
+ export declare function clampPromptTimeout(ms: number): number;
9
+ export interface LineAssemblerCallbacks {
10
+ /** Deliver assembled whole lines (or a flushed prompt tail) downstream —
11
+ * the trigger pipeline and rendering treat each chunk as complete lines. */
12
+ onChunk(text: string, ts: number): void;
13
+ /** Fired after a prompt marker (IAC GA/EOR) flushed the held tail — the
14
+ * owner emits its `prompt` event here. */
15
+ onPrompt(): void;
16
+ /** Fired after an idle-timer flush so the owner can render any messages
17
+ * the flushed chunk produced (MudClient.flushMessageBuffer). */
18
+ onIdleFlush(): void;
19
+ }
20
+ export interface LineAssemblerOptions {
21
+ promptTimeoutMs?: number;
22
+ /** Mudlet `mUSE_IRE_DRIVER_BUGFIX` — strip a spurious leading newline from
23
+ * GA-driven prompt blocks. Off by default; toggled live via
24
+ * setFixUnnecessaryLinebreaks (setConfig). */
25
+ fixUnnecessaryLinebreaks?: boolean;
26
+ }
27
+ /**
28
+ * Assembles the decoded MUD text stream into whole lines. WebSocket frames can
29
+ * split a long line at an arbitrary byte (mid-word, mid-ANSI-escape), so the
30
+ * trailing partial line of each frame is held back until the next frame
31
+ * supplies the rest, a prompt marker (IAC GA/EOR) flushes it, or the idle
32
+ * timer fires. Our render path finalizes every emitted chunk and has no
33
+ * downstream open-line carry (unlike Mudlet's TBuffer), so the "line ends only
34
+ * at \n or GA" invariant is enforced here. The live-partial parity work is
35
+ * deferred — see docs/line-assembly-tbuffer-port.md.
36
+ */
37
+ export declare class LineAssembler {
38
+ private readonly callbacks;
39
+ /** Trailing text (after the last `\n`) held back from rendering until either
40
+ * the next frame supplies the rest of the line, a prompt marker arrives, or
41
+ * the idle-flush timer fires. Prevents spurious line breaks when a long MUD
42
+ * line is split across multiple WebSocket frames. */
43
+ private pendingLineTail;
44
+ private pendingTailTimer;
45
+ private promptTimeoutMs;
46
+ /** Set true once the server has sent IAC GA / IAC EOR at least once.
47
+ * Mirrors Mudlet's `mGA_Driver` latch (`cTelnet::gotRest`). From then on
48
+ * the held partial tail is flushed by the prompt marker rather than the
49
+ * idle timer. Note: unlike Mudlet's cTelnet — which posts GA-mode chunks
50
+ * verbatim and reassembles split lines in TBuffer — we keep buffering
51
+ * partial lines here, because our render path finalizes every emitted
52
+ * chunk and has no downstream open-line carry. */
53
+ private _gaDriver;
54
+ /** True at the start of a GA-driven data block — i.e. before any content of
55
+ * the current post-GA transmission has been seen. Drives the
56
+ * `fixUnnecessaryLinebreaks` leading-newline strip, which fires at most once
57
+ * per block. Set true on connect and after each prompt flush, cleared once
58
+ * the block's leading-newline question has been settled. */
59
+ private atPromptBlockStart;
60
+ private fixUnnecessaryLinebreaks;
61
+ constructor(callbacks: LineAssemblerCallbacks, options?: LineAssemblerOptions);
62
+ /** True once the session has latched into GA-driven prompt mode. */
63
+ get gaDriver(): boolean;
64
+ setPromptTimeoutMs(ms: number): void;
65
+ getPromptTimeoutMs(): number;
66
+ /** Mudlet `setConfig("fixUnnecessaryLinebreaks", …)`. Takes effect on the
67
+ * next GA-driven block; never retroactive. */
68
+ setFixUnnecessaryLinebreaks(enabled: boolean): void;
69
+ /** Drop all held state (call on connect and after close). */
70
+ reset(): void;
71
+ /** Feed one frame's decoded text plus whether the frame carried a prompt
72
+ * marker (IAC GA/EOR). Emits only whole lines (text up to and including
73
+ * the last `\n`) and holds the trailing partial in `pendingLineTail`
74
+ * until the rest of the line arrives, a prompt marker flushes it, or the
75
+ * idle timer fires. */
76
+ feed(decoded: string, hasPrompt: boolean, ts: number): void;
77
+ /** Flush a held-back partial line (text after the final `\n` of a frame).
78
+ * Triggered by prompt markers (IAC GA/EOR), the idle-flush timer, or
79
+ * socket close. Pushes the tail through the normal chunk path so triggers
80
+ * and rendering treat it as a complete line. */
81
+ flush(ts: number, final?: boolean): void;
82
+ private scheduleTailFlush;
83
+ private clearTailTimer;
84
+ }