@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,256 @@
1
+ import { type OscPaletteOp } from "./ansiEscapes";
2
+ import { HyperlinkPresetRegistry, type HyperlinkConfig } from "./hyperlinkConfig";
3
+ /** Apply OSC 4/104 palette operations to the global colour tables. Palette
4
+ * changes affect text parsed *after* this point — which is exactly document
5
+ * order, since lines are fed to the parser in the order the server sent them. */
6
+ export declare function applyOscPaletteOps(ops: ReadonlyArray<OscPaletteOp>): void;
7
+ export interface FormatHyperlink {
8
+ onClick?: (ev: MouseEvent) => void;
9
+ onContextMenu?: (ev: MouseEvent) => void;
10
+ onMouseEnter?: (ev: MouseEvent) => void;
11
+ onMouseLeave?: (ev: MouseEvent) => void;
12
+ title?: string;
13
+ /**
14
+ * Raw link target recorded by the low-level ANSI parser for OSC 8 links.
15
+ * The parser has no access to the scripting API, so it stores the URI here
16
+ * and the engine later wires the click behaviour via `bindUrlHyperlinks`.
17
+ * For OSC 8 links this is the *cleaned* command (extension query stripped).
18
+ */
19
+ url?: string;
20
+ /** Parsed Mudlet OSC 8 extension config (styling, states, tooltip, menu,
21
+ * spoiler, disabled, visibility, selection), resolved at parse time. */
22
+ config?: HyperlinkConfig;
23
+ /** OSC 8 `id=` parameter — groups split runs of one logical link so hover
24
+ * can highlight them together. */
25
+ linkId?: string;
26
+ /**
27
+ * Document-style link that should render with an underline cue by default,
28
+ * the way a web browser underlines anchors. Set on MXP `<send>`/`<a>` links
29
+ * only. Scripted Mudlet-API links (`echoLink`, `echoPopup`, `setLink`) leave
30
+ * this unset — they underline only when the script sets the real `underline`
31
+ * attribute (Mudlet's `useCurrentFormat=false` default), so a
32
+ * `useCurrentFormat=true` link keeps the current pen with no underline.
33
+ *
34
+ * OSC 8 links also leave it unset: Mudlet's `HyperlinkStyling::isUnderlined`
35
+ * defaults to false, so they underline only when their `config` style asks
36
+ * for it (`{"style":{"underline":true}}` / a matching pseudo-class state).
37
+ */
38
+ autoUnderline?: boolean;
39
+ }
40
+ export interface IndexedColor {
41
+ space: "indexed";
42
+ index: number;
43
+ }
44
+ export interface RgbColor {
45
+ space: "rgb";
46
+ r: number;
47
+ g: number;
48
+ b: number;
49
+ a?: number;
50
+ }
51
+ export interface HexColor {
52
+ space: "hex";
53
+ color: string;
54
+ }
55
+ export type FormatColor = IndexedColor | RgbColor | HexColor;
56
+ export type DimEasing = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';
57
+ export interface DimEffect {
58
+ startOpacity: number;
59
+ endOpacity: number;
60
+ duration: number;
61
+ easing?: DimEasing;
62
+ }
63
+ export interface FormatStateSnapshot {
64
+ foreground?: FormatColor;
65
+ background?: FormatColor;
66
+ bold?: boolean;
67
+ italic?: boolean;
68
+ underline?: boolean;
69
+ inverse?: boolean;
70
+ strikethrough?: boolean;
71
+ overline?: boolean;
72
+ slowBlink?: boolean;
73
+ rapidBlink?: boolean;
74
+ dim?: DimEffect;
75
+ hyperlink?: FormatHyperlink;
76
+ cssClass?: string;
77
+ }
78
+ export type TextRange = [start: number, end: number];
79
+ export interface BufferSegment {
80
+ text: string;
81
+ state?: FormatStateSnapshot;
82
+ }
83
+ declare function cloneState(state?: FormatStateSnapshot): FormatStateSnapshot | undefined;
84
+ declare function statesEqual(a?: FormatStateSnapshot, b?: FormatStateSnapshot): boolean;
85
+ export declare class FormatState {
86
+ static DEFAULT: {};
87
+ foreground?: FormatColor;
88
+ background?: FormatColor;
89
+ bold?: boolean;
90
+ italic?: boolean;
91
+ underline?: boolean;
92
+ inverse?: boolean;
93
+ strikethrough?: boolean;
94
+ overline?: boolean;
95
+ slowBlink?: boolean;
96
+ rapidBlink?: boolean;
97
+ dim?: DimEffect;
98
+ hyperlink?: FormatHyperlink;
99
+ constructor(initial?: FormatStateSnapshot);
100
+ private applySnapshot;
101
+ reset(): void;
102
+ toSnapshot(): FormatStateSnapshot;
103
+ applySgr(params: number[]): void;
104
+ setHyperlink(link?: FormatHyperlink): void;
105
+ }
106
+ /**
107
+ * A run of text with its visual attributes resolved to concrete CSS colour
108
+ * strings — the shape a canvas/image renderer wants. `color`/`background` are
109
+ * undefined when the run uses the console default (the renderer fills in its
110
+ * own default for those).
111
+ */
112
+ export interface OutputStyledRun {
113
+ text: string;
114
+ color?: string;
115
+ background?: string;
116
+ bold: boolean;
117
+ italic: boolean;
118
+ underline: boolean;
119
+ }
120
+ /**
121
+ * Buffer of text aware of ANSI formatting codes and hyperlink metadata.
122
+ */
123
+ export declare class AnsiAwareBuffer {
124
+ private segments;
125
+ private _deleted;
126
+ private _onRender?;
127
+ private _textCache;
128
+ private _renderContainer;
129
+ constructor(initial?: string | BufferSegment[], state?: FormatStateSnapshot, presets?: HyperlinkPresetRegistry);
130
+ get deleted(): boolean;
131
+ markAsDeleted(): this;
132
+ /** Per-line prompt flag. Mudlet's TBuffer tracks isPrompt on each line so
133
+ * the matching `isPrompt()` script primitive reflects the prompt status of
134
+ * whatever line the cursor is currently on (not just the last). Set by the
135
+ * trigger pipeline before triggers run; defaults to false. */
136
+ isPrompt: boolean;
137
+ /** Wall-clock time (epoch ms) the line was created. Mudlet stamps every
138
+ * buffer line with a QTime; `getTimestamp(lineNumber)` reads it back. A
139
+ * buffer is built right as its line is echoed/received, so construction
140
+ * time is the line's timestamp. */
141
+ timestamp: number;
142
+ removeFromDom(): void;
143
+ onRender(callback: (container: HTMLElement) => void): this;
144
+ /** @internal */
145
+ notifyRender(container: HTMLElement): void;
146
+ /** Re-renders the buffer into its previously notified container. No-op if not yet rendered. */
147
+ rerender(): void;
148
+ /** Removes all formatting from a range (clears colors, bold, etc.). */
149
+ clearFormat(range: TextRange): this;
150
+ clone(): AnsiAwareBuffer;
151
+ get text(): string;
152
+ get length(): number;
153
+ clear(): this;
154
+ replace(range: [number, number], text: string, state?: FormatStateSnapshot): this;
155
+ replaceBuffer(range: [number, number], buffer: AnsiAwareBuffer): this;
156
+ insert(index: number, text: string, state?: FormatStateSnapshot): this;
157
+ insertBuffer(index: number, buffer: AnsiAwareBuffer): this;
158
+ prefix(text: string, state?: FormatStateSnapshot): this;
159
+ suffix(text: string, state?: FormatStateSnapshot): this;
160
+ private insertInternal;
161
+ append(text: string, state?: FormatStateSnapshot): this;
162
+ appendBuffer(buffer: AnsiAwareBuffer): this;
163
+ prepend(text: string, state?: FormatStateSnapshot): this;
164
+ prependBuffer(buffer: AnsiAwareBuffer): this;
165
+ remove(range: [number, number]): this;
166
+ /** @internal */
167
+ getSegments(): BufferSegment[];
168
+ toHyperlinkSegments(): {
169
+ text: string;
170
+ hyperlink?: FormatHyperlink;
171
+ }[];
172
+ color(range: TextRange, color: number | FormatStateSnapshot): this;
173
+ applyFormat(range: TextRange, format: FormatStateSnapshot): this;
174
+ /**
175
+ * Overlays a hyperlink on every segment in `range`, preserving each
176
+ * segment's existing colors/attributes. Pass `undefined` to clear any
177
+ * hyperlinks in the range. Unlike `applyFormat` (which homogenizes
178
+ * formatting across the range), this is segment-wise — used by Mudlet
179
+ * `setLink` so coloured selections remain coloured after becoming clickable.
180
+ */
181
+ setHyperlink(range: TextRange, hyperlink?: FormatHyperlink): this;
182
+ /**
183
+ * Wire deferred URL hyperlinks (recorded by the ANSI parser for OSC 8 links
184
+ * as a bare `url` with no handlers) into live, clickable links. `factory`
185
+ * turns a URI into a {@link FormatHyperlink} with the right click behaviour
186
+ * (or `undefined` to drop the link). Segments that already have a handler —
187
+ * e.g. an MXP `<SEND>` link overlaid on the same range — are left alone.
188
+ */
189
+ bindUrlHyperlinks(factory: (url: string, link: FormatHyperlink) => FormatHyperlink | undefined): this;
190
+ colorWords(words: string | string[], color: number | FormatStateSnapshot, options?: {
191
+ caseInsensitive?: boolean;
192
+ }): this;
193
+ splitLines(): AnsiAwareBuffer[];
194
+ /** Returns the format state at the end of this buffer, for carrying into the next line. */
195
+ trailingState(): FormatStateSnapshot | undefined;
196
+ /**
197
+ * Build the CSS visual declarations (colour, weight, decorations) for a
198
+ * segment. When `overlay` is given (an OSC 8 link style for a state), its set
199
+ * fields win over the segment's own SGR attributes — that's how a link's
200
+ * configured colour/decoration paints over the underlying run. With no
201
+ * overlay this reproduces the plain SGR rendering exactly.
202
+ */
203
+ private visualDecls;
204
+ toHtml(): string;
205
+ /**
206
+ * Resolve the buffer's segments to styled runs with concrete CSS colours,
207
+ * for rendering to a canvas (copy-as-image). Mirrors {@link toHtml}'s colour
208
+ * handling, including reverse-video on default colours — there the swap
209
+ * yields no explicit colour, so we hand back the console default of the
210
+ * opposite role for the renderer to paint.
211
+ */
212
+ toStyledRuns(): OutputStyledRun[];
213
+ toDom(): DocumentFragment;
214
+ private escapeHtml;
215
+ private colorToHex;
216
+ private prepareStyle;
217
+ private appendSegmentAtEnd;
218
+ private createSegmentsFromText;
219
+ private resolveIndex;
220
+ private resolveBoundaryIndex;
221
+ private inferState;
222
+ private splitSegment;
223
+ private normalizeSegments;
224
+ private assertRange;
225
+ getStateAt(index: number): FormatStateSnapshot | undefined;
226
+ applyMudletColors(): this;
227
+ createLink(range: TextRange, options: {
228
+ onClick?: (ev: MouseEvent) => void;
229
+ onContextMenu?: (ev: MouseEvent) => void;
230
+ onMouseEnter?: (ev: MouseEvent) => void;
231
+ onMouseLeave?: (ev: MouseEvent) => void;
232
+ title?: string;
233
+ }): this;
234
+ createLinksForText(text: string, options: {
235
+ onClick?: (ev: MouseEvent) => void;
236
+ onContextMenu?: (ev: MouseEvent) => void;
237
+ onMouseEnter?: (ev: MouseEvent) => void;
238
+ onMouseLeave?: (ev: MouseEvent) => void;
239
+ title?: string;
240
+ }, searchOptions?: {
241
+ caseInsensitive?: boolean;
242
+ }): this;
243
+ private assertIndex;
244
+ }
245
+ export { cloneState as cloneFormatState, statesEqual as formatStatesEqual };
246
+ /**
247
+ * Walks ANSI SGR escapes in `text` starting from `baseState` and returns the
248
+ * SGR state that would apply *after* the last byte of `text`. Unlike
249
+ * `AnsiAwareBuffer.trailingState()` (which returns the state of the last
250
+ * non-empty text segment), this reflects the actual end-of-stream state:
251
+ * - empty `text` → returns `baseState`, so blank lines preserve carry
252
+ * - text ending in `\e[0m` → returns default (undefined), not the pre-reset color
253
+ * - text with no ANSI codes → returns `baseState` unchanged
254
+ * Used to carry SGR state across line breaks the way Mudlet's TBuffer does.
255
+ */
256
+ export declare function computeTrailingState(text: string, baseState?: FormatStateSnapshot): FormatStateSnapshot | undefined;
@@ -0,0 +1,88 @@
1
+ /** CSI final bytes are 0x40–0x7E (`@`…`~`). */
2
+ export declare function isCsiFinal(c: string): boolean;
3
+ export interface EscapeScan {
4
+ /**
5
+ * - `csi` — `ESC [ <params> <final>` (SGR, cursor moves, erase, …)
6
+ * - `osc` — `ESC ] <payload> ST` (OSC 8 hyperlinks, window title, …)
7
+ * - `string` — DCS/SOS/PM/APC (`ESC P/X/^/_ … ST`); opaque, always ignored
8
+ * - `esc` — a short `ESC <intermediates> <final>` escape (charset, RIS, …)
9
+ * - `incomplete` — the sequence runs off the end of `text`
10
+ */
11
+ kind: "csi" | "osc" | "string" | "esc" | "incomplete";
12
+ /** Index one past the end of the sequence (exclusive). For `incomplete`,
13
+ * equals `text.length`. */
14
+ end: number;
15
+ /** CSI only: the final byte. */
16
+ finalByte?: string;
17
+ /** CSI only: the parameter + intermediate bytes between `ESC [` and the final. */
18
+ params?: string;
19
+ /** OSC only: the payload between `ESC ]` and the ST terminator. */
20
+ oscPayload?: string;
21
+ }
22
+ /**
23
+ * Scan a single escape sequence beginning at `text[start]` (which must be ESC).
24
+ * Classifies the sequence and reports where it ends so callers can act on the
25
+ * ones they understand and skip the rest. When the sequence is cut off by the
26
+ * end of input the result is `incomplete` — callers either drop it or hold it
27
+ * for the next line.
28
+ */
29
+ export declare function scanEscape(text: string, start: number): EscapeScan;
30
+ export interface Osc8Link {
31
+ /** The link target. An empty string means "close the current hyperlink". */
32
+ uri: string;
33
+ /** The optional `id=` parameter, used to group multi-run links. */
34
+ id?: string;
35
+ }
36
+ /**
37
+ * Parse an OSC payload (the bytes between `ESC ]` and the terminator) as an
38
+ * OSC 8 hyperlink. Returns `null` when the payload is some other OSC command
39
+ * (window title `0;…`, clipboard `52;…`, …) or is malformed — callers then
40
+ * treat it the same as any other ignored escape.
41
+ */
42
+ export declare function parseOsc8Payload(payload: string): Osc8Link | null;
43
+ /**
44
+ * The action a clickable hyperlink performs, derived from its URI scheme. This
45
+ * mirrors Mudlet's OSC 8 schemes — `send:`/`prompt:` drive the game, while the
46
+ * web schemes open externally. The URI comes from an untrusted MUD server, so
47
+ * any other scheme (`javascript:`, `data:`, `file:`, …) is rejected and the
48
+ * link is dropped rather than made clickable.
49
+ */
50
+ export type HyperlinkAction = {
51
+ kind: "send";
52
+ command: string;
53
+ } | {
54
+ kind: "prompt";
55
+ command: string;
56
+ } | {
57
+ kind: "url";
58
+ url: string;
59
+ };
60
+ /** URI schemes mudix is willing to make clickable from server output. */
61
+ export declare const ALLOWED_HYPERLINK_SCHEMES: readonly ["send", "prompt", "http", "https", "ftp"];
62
+ /** Percent-decode a send/prompt command, like Mudlet's `QUrl::fromPercentEncoding`,
63
+ * so `cast%20fireball` reaches the MUD as `cast fireball`. Malformed escapes are
64
+ * left as-is rather than throwing. */
65
+ export declare function decodePercent(s: string): string;
66
+ export declare function classifyHyperlinkUri(uri: string): HyperlinkAction | null;
67
+ export type OscPaletteOp = {
68
+ kind: "set";
69
+ index: number;
70
+ color: string;
71
+ } | {
72
+ kind: "reset";
73
+ index: number;
74
+ } | {
75
+ kind: "reset-all";
76
+ };
77
+ /**
78
+ * Parse an XParseColor spec into a `#rrggbb` string, or null if unrecognised.
79
+ * Handles the two forms MUDs use in practice — `rgb:r/g/b` and `#`-hex — and
80
+ * rejects named colours and other X forms (`rgbi:`, `cmyk:`, …).
81
+ */
82
+ export declare function parseXColorSpec(spec: string): string | null;
83
+ /**
84
+ * Parse an OSC payload as an OSC 4 (set) or OSC 104 (reset) palette command.
85
+ * Returns the ordered list of operations, or null if the payload is neither.
86
+ * Malformed index/spec pairs are skipped rather than aborting the whole list.
87
+ */
88
+ export declare function parseOscColorPalette(payload: string): OscPaletteOp[] | null;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Renders text onto the monospace grid. Pure-ASCII runs are emitted as plain
3
+ * text (the font lays them out at exactly 1ch each); every other grapheme is
4
+ * boxed into a fixed `Nch` inline-block cell so wide/combining/font-fallback
5
+ * glyphs can't drift the column grid. See `wcwidth.ts` for the width tables.
6
+ */
7
+ import { type ControlCharacterMode } from "./controlCharacterMode";
8
+ export declare const CELL_CLASS = "ocell";
9
+ /** Append `text` to a DOM node as plain-text runs interleaved with cell spans,
10
+ * starting at column `column` (for tab-stop math). Returns the column after
11
+ * `text` — pass it into the next segment's call to keep tab stops correct
12
+ * across a whole logical line. */
13
+ export declare function appendCells(parent: Node, text: string, column?: number, mode?: ControlCharacterMode): number;
14
+ /** String equivalent of {@link appendCells} for the `toHtml()` path. Unlike
15
+ * `appendCells`, this keeps returning a plain string — use {@link columnAfter}
16
+ * to carry the running column across segments. */
17
+ export declare function cellsToHtml(text: string, escape: (s: string) => string, column?: number, mode?: ControlCharacterMode): string;
18
+ /** Column after rendering `text` starting at `column` — mirrors `cellsToHtml`'s
19
+ * width math without building output, so `toHtml()` can advance its running
20
+ * column between segments while `cellsToHtml` keeps returning a plain string. */
21
+ export declare function columnAfter(text: string, column: number, mode?: ControlCharacterMode): number;
@@ -0,0 +1,54 @@
1
+ import type { FormatColor, FormatStateSnapshot } from './FormatState';
2
+ /** Resolve an MXP color spec — an HTML named color, `#RGB`, `#RRGGBB`, or
3
+ * `rgb(r,g,b)` — into a {@link FormatColor}, or null when unrecognized.
4
+ * Used by the MXP parser for `<COLOR>`/`<FONT>` foreground and background. */
5
+ export declare function mxpColor(spec: string): FormatColor | null;
6
+ export declare function namedColorToAnsi(name: string, bg?: boolean): string;
7
+ /** Converts a named Mudlet color to a FormatStateSnapshot for buffer-level coloring. */
8
+ export declare function namedColorToState(name: string, bg?: boolean): FormatStateSnapshot | null;
9
+ /** cecho: <color_name>text<r> or <b:color_name>text for background */
10
+ export declare function parseCecho(text: string): string;
11
+ /** decho: <r,g,b>text or <:r,g,b>text for background, <r> to reset */
12
+ export declare function parseDecho(text: string): string;
13
+ /**
14
+ * Fast-path for `decho`: the ANSI-escape equivalent of `str`, or `null` when the
15
+ * string uses any decho feature {@link parseDecho} does NOT reproduce exactly as
16
+ * Mudlet's Lua `xEcho` would. Callers (the native `decho` fast path) fall back to
17
+ * the Lua `xEcho` on `null`, so output stays identical to Mudlet.
18
+ *
19
+ * Handled here (and only here): foreground `<r,g,b>`, background `<:r,g,b>` with
20
+ * channels in 0..255, and the `<r>` reset. Deferred to Lua: combined `<fg:bg>`,
21
+ * background alpha `<:r,g,b,a>`, text-style tags (`<b>`/`<i>`/`<u>`/`<s>`/`<o>`),
22
+ * out-of-range channels, and any other `<...>` token — the conservative guard
23
+ * from our design discussion, so a decho grammar we don't model degrades to
24
+ * slow-but-correct rather than wrong.
25
+ */
26
+ export declare function dechoToAnsiFast(str: string): string | null;
27
+ /**
28
+ * Fast-path for `cecho` — see {@link dechoToAnsiFast}. Handles ONLY a plain
29
+ * foreground `<name>` (resolvable in the Mudlet colour table) and the
30
+ * `<r>`/`<reset>` reset. Everything else falls back to Lua `xEcho`, because
31
+ * {@link parseCecho}'s grammar and name resolution diverge from Mudlet's:
32
+ * - style tags `<b>`/`<i>`/`<u>`/`<s>`/`<o>` (parseCecho would treat `b` as a
33
+ * colour name),
34
+ * - combined `<fg:bg>` / `<fg,bg>` and `<:bg>` backgrounds, and the `<b:…>`
35
+ * form (Mudlet reads `<b:red>` as fg=b, bg=red — not "background red"),
36
+ * - unknown names (parseCecho drops the tag; Mudlet leaves it literal).
37
+ *
38
+ * The `ansi_NNN` / `ansiXxx` family IS fast-pathed: this palette and the runtime
39
+ * `color_table` (seeded from {@link ../text/xterm256}) agree, verified by the
40
+ * full-palette sweep in the parity test — which also fails loudly if they ever
41
+ * drift again.
42
+ */
43
+ export declare function cechoToAnsiFast(str: string): string | null;
44
+ /**
45
+ * Fast-path for `hecho` — see {@link dechoToAnsiFast}. Handles ONLY a plain
46
+ * foreground `#RRGGBB` and the `#r` reset. Falls back to Lua `xEcho` for
47
+ * everything {@link parseHecho} can't reproduce as Mudlet does:
48
+ * - the `|c…` / `|b` pipe forms and `\#` escapes,
49
+ * - `#:…` (not Mudlet syntax) and `#,…` / `#RRGGBB,…` backgrounds/combined,
50
+ * - style tags `#b`/`#i`/`#u`/`#s`/`#o`.
51
+ */
52
+ export declare function hechoToAnsiFast(str: string): string | null;
53
+ /** hecho: #RRGGBBtext or #:RRGGBBtext for background, #r to reset */
54
+ export declare function parseHecho(text: string): string;
@@ -0,0 +1,31 @@
1
+ export declare const colorCodes: {
2
+ xterm: string[];
3
+ ansi: {
4
+ bright: string[];
5
+ dark: string[];
6
+ };
7
+ };
8
+ /** Built-in 16-color ANSI palette. Index 0–7 dark, 8–15 bright. The Settings
9
+ * modal uses this as the fallback when a profile hasn't overridden a slot. */
10
+ export declare const DEFAULT_ANSI_PALETTE: readonly string[];
11
+ /** Enable/disable server-driven OSC 4/104 palette redefinition. */
12
+ export declare function setServerRedefineColorsAllowed(allowed: boolean): void;
13
+ /** Whether the server is currently allowed to redefine palette colors. */
14
+ export declare function isServerRedefineColorsAllowed(): boolean;
15
+ /** Apply an override palette to the global ANSI table (mutates colorCodes.ansi
16
+ * in place so FormatState picks it up without plumbing). Pass `undefined` or
17
+ * a sparse array to restore defaults for unspecified / invalid slots. The
18
+ * palette layout is `[...dark(8), ...bright(8)]`. */
19
+ export declare function applyAnsiPalette(palette?: readonly (string | undefined)[]): void;
20
+ /**
21
+ * OSC 4 palette redefinition: point colour index `index` (0–255) at `hex`
22
+ * (`#rrggbb`). Indices 0–15 also update the 16-colour ANSI table so subsequent
23
+ * SGR 30–37/40–47/90–107 pick up the change, keeping the two tables coherent.
24
+ * Out-of-range indices and malformed colours are ignored.
25
+ */
26
+ export declare function setPaletteColor(index: number, hex: string): void;
27
+ /** OSC 104 single-index reset: restore one palette entry to its base value (the
28
+ * user palette for 0–15, the built-in xterm default otherwise). */
29
+ export declare function resetPaletteColor(index: number): void;
30
+ /** OSC 104 with no index: restore the entire palette to its base state. */
31
+ export declare function resetAllPaletteColors(): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The active profile's `controlCharacterHandling` display mode (Mudlet
3
+ * `setConfig`/`getConfig`: `"asis"` / `"oem"` / `"picture"`). Mirrors Mudlet's
4
+ * `Host::mControlCharacter` — a single per-profile value read at paint time by
5
+ * every console/mini-console/text window. mudix renders exactly one active
6
+ * connection's output at a time, so a module-level value (kept in sync by
7
+ * `MudSession.setControlCharacterMode`) covers the main output, script
8
+ * windows, and logging/copy paths without threading a parameter through all
9
+ * of them.
10
+ */
11
+ export type ControlCharacterMode = 'asis' | 'oem' | 'picture';
12
+ export declare function getControlCharacterMode(): ControlCharacterMode;
13
+ export declare function setControlCharacterMode(mode: ControlCharacterMode): void;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Mudlet's `controlCharacterHandling` glyph substitution, ported from
3
+ * `TTextEdit::replaceControlCharacterWith_Picture` / `_OEMFont`
4
+ * (Mudlet/src/TTextEdit.cpp). Pure display-time substitution — the raw bytes
5
+ * received from the MUD are never altered, only what gets painted.
6
+ */
7
+ import type { ControlCharacterMode } from './controlCharacterMode';
8
+ /** Mudlet's default `mTabStopwidth`. */
9
+ export declare const TAB_STOP_WIDTH = 8;
10
+ /** A control-character cell's rendered replacement. `width` may exceed 2 —
11
+ * only tabs in AsIs/Picture mode expand past that, to the next tab stop,
12
+ * like a real terminal. `box` mirrors cellRender's span-vs-inline-run split. */
13
+ export interface ControlCellOverride {
14
+ text: string;
15
+ width: number;
16
+ box: boolean;
17
+ }
18
+ /**
19
+ * Returns the display substitution for one grapheme at `column` under `mode`,
20
+ * or `null` if `grapheme` isn't a control character (caller should fall back
21
+ * to normal cell rendering).
22
+ *
23
+ * - **asis**: control chars render as Mudlet's default case does — invisible,
24
+ * unchanged (handled by the caller's normal zero-width path) — except tab,
25
+ * which expands to the next tab stop.
26
+ * - **picture**: codes 0-31/127 map onto the Unicode Control Pictures block;
27
+ * tab still expands to a tab stop, with the picture glyph over the first cell.
28
+ * - **oem**: codes 0-31/127 map onto CP437-style glyphs; tab does *not* get
29
+ * tab-stop spacing here (matches Mudlet — it's just a plain glyph, width 1).
30
+ */
31
+ export declare function overrideControlCell(grapheme: string, column: number, mode: ControlCharacterMode): ControlCellOverride | null;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Mudlet OSC 8 hyperlink extension — configuration parsing.
3
+ *
4
+ * Mudlet extends the bare OSC 8 sequence (`ESC ] 8 ; params ; URI ST`) with a
5
+ * rich config carried in the URI's query string:
6
+ *
7
+ * send:attack?config={"style":{"color":"red","bold":true},"tooltip":"…"}
8
+ * send:p1?preset=btn&config={"s":{"c":"yellow"}}
9
+ * preset:btn?config={"s":{"bg":"#07f","c":"white","b":true}} (definition only)
10
+ *
11
+ * The config is a JSON object whose keys may use a compact shorthand (`s`→`style`,
12
+ * `c`→`color`, …). Presets are named, reusable config templates: a `preset:NAME`
13
+ * link registers one (and renders nothing); later links reference it with
14
+ * `?preset=NAME`, optionally layering an override `config=` on top (deep merge,
15
+ * override wins).
16
+ *
17
+ * This module is the pure, side-effect-free parsing layer (plus a small preset
18
+ * registry). It turns a URI into a normalised {@link HyperlinkConfig}; the
19
+ * render/interaction layers consume that. Mirrors Mudlet's
20
+ * `parseHyperlinkConfig` / `parseJsonHyperlinkConfig` / `expandJsonShorthands`
21
+ * (src/TBuffer.cpp) and the shorthand table registered in src/TConsole.cpp.
22
+ */
23
+ import type { FormatColor } from "./FormatState";
24
+ export type UnderlineStyle = "solid" | "wavy" | "dotted" | "dashed";
25
+ /** Visual styling for a link in one state. Mirrors the SGR-style attributes a
26
+ * run can carry, expressed as already-resolved colours. */
27
+ export interface LinkStateStyle {
28
+ foreground?: FormatColor;
29
+ background?: FormatColor;
30
+ bold?: boolean;
31
+ italic?: boolean;
32
+ underline?: boolean;
33
+ underlineStyle?: UnderlineStyle;
34
+ overline?: boolean;
35
+ strikethrough?: boolean;
36
+ /** `text-decoration-color` — the colour of the underline/overline/strike. */
37
+ decorationColor?: FormatColor;
38
+ }
39
+ /** CSS-like pseudo-class states a link style can target. */
40
+ export type LinkState = "hover" | "active" | "focus" | "focus-visible" | "visited" | "link" | "any-link" | "selected" | "disabled";
41
+ export declare const LINK_STATES: readonly LinkState[];
42
+ /** The base style plus any per-state overrides. */
43
+ export interface HyperlinkStyling extends LinkStateStyle {
44
+ states?: Partial<Record<LinkState, LinkStateStyle>>;
45
+ }
46
+ /** One entry in a right-click menu: either a separator or a labelled action. */
47
+ export interface MenuItem {
48
+ separator?: boolean;
49
+ label?: string;
50
+ /** A command URI like `send:strike` / `prompt:cast` / `https://…`. */
51
+ action?: string;
52
+ }
53
+ /** A menu's header line (shown above the items). */
54
+ export interface LinkTitle {
55
+ text?: string;
56
+ style?: LinkStateStyle;
57
+ }
58
+ export type VisibilityAction = "conceal" | "reveal" | "reveal-then-conceal";
59
+ export interface VisibilitySettings {
60
+ action?: VisibilityAction;
61
+ /** Delay before the action fires, in milliseconds. */
62
+ delayMs?: number;
63
+ deletesEntireLine?: boolean;
64
+ expireOnInput?: boolean;
65
+ expireOnPrompt?: boolean;
66
+ expireOnOutput?: boolean;
67
+ outputDelayMs?: number;
68
+ }
69
+ export interface SelectionSettings {
70
+ group?: string;
71
+ value?: string;
72
+ /** Clicking toggles the selected state (default true). */
73
+ toggle?: boolean;
74
+ selected?: boolean;
75
+ /** Radio-button behaviour within the group (default true); false = checkbox. */
76
+ exclusive?: boolean;
77
+ }
78
+ /** The fully-parsed OSC 8 link configuration. Every field is optional — a bare
79
+ * `send:look` link parses to an empty config. */
80
+ export interface HyperlinkConfig {
81
+ style?: HyperlinkStyling;
82
+ tooltip?: string;
83
+ menu?: MenuItem[];
84
+ title?: LinkTitle;
85
+ spoiler?: boolean;
86
+ disabled?: boolean;
87
+ visibility?: VisibilitySettings;
88
+ selection?: SelectionSettings;
89
+ }
90
+ /** Shorthand key → full property name. Mirrors the table registered in
91
+ * Mudlet's TConsole.cpp. Applied recursively to every key in a config object,
92
+ * so `{"s":{"c":"red","h":{"u":true}}}` becomes
93
+ * `{"style":{"color":"red","hover":{"underline":true}}}`. */
94
+ export declare const HYPERLINK_SHORTHANDS: Readonly<Record<string, string>>;
95
+ type JsonObject = Record<string, unknown>;
96
+ /**
97
+ * Recursively expand shorthand keys to their full names. When both a shorthand
98
+ * and its full form are present on the same object (e.g. `s` and `style`), their
99
+ * object values are deep-merged with the shorthand taking precedence — matching
100
+ * Mudlet's `expandJsonShorthands`.
101
+ */
102
+ export declare function expandShorthands(value: unknown): unknown;
103
+ /** Deep-merge two raw JSON objects; `override` wins on scalar/array collisions,
104
+ * objects merge recursively. Mirrors Mudlet's `mergeConfigs`. */
105
+ export declare function deepMerge(base: JsonObject, override: JsonObject): JsonObject;
106
+ /**
107
+ * Normalise an already-shorthand-expanded config object into a
108
+ * {@link HyperlinkConfig}. Unknown keys are ignored; malformed values are
109
+ * skipped rather than throwing (a partially-valid config still applies).
110
+ */
111
+ export declare function normaliseHyperlinkConfig(root: JsonObject): HyperlinkConfig;
112
+ /** Parse a raw config JSON string (shorthand-allowed) into a normalised config,
113
+ * or null if the JSON is invalid / not an object. */
114
+ export declare function parseConfigJson(json: string): HyperlinkConfig | null;
115
+ interface ExtractedQuery {
116
+ /** The URI up to (not including) the first `?`. */
117
+ base: string;
118
+ /** The raw `config={…}` JSON body, if present. */
119
+ configJson?: string;
120
+ /** The `preset=NAME` value, if present. */
121
+ presetName?: string;
122
+ /** Non-reserved query pairs, in original order/encoding (for http links). */
123
+ userPairs: string[];
124
+ }
125
+ /**
126
+ * Split a URI into its base and the reserved/user query parts. `config={…}` is
127
+ * located by brace-matching (its JSON value may contain `&`), mirroring
128
+ * Mudlet's hand-rolled scan; everything else is `&`-delimited `key=value`.
129
+ */
130
+ export declare function extractQuery(uri: string): ExtractedQuery;
131
+ /** Session-scoped store of `preset:NAME` definitions. Holds raw config objects
132
+ * (shorthand un-expanded, as Mudlet does) so a later `?preset=NAME` can deep-
133
+ * merge an override before expansion. */
134
+ export declare class HyperlinkPresetRegistry {
135
+ private presets;
136
+ register(name: string, rawConfig: JsonObject): void;
137
+ get(name: string): JsonObject | undefined;
138
+ clear(): void;
139
+ }
140
+ export type Osc8UriResult =
141
+ /** A `preset:NAME` definition was registered; renders nothing. */
142
+ {
143
+ kind: "preset";
144
+ name: string;
145
+ }
146
+ /** A normal link. `command` is the cleaned URI (reserved params stripped)
147
+ * to hand to scheme classification; `config` is the resolved config. */
148
+ | {
149
+ kind: "link";
150
+ command: string;
151
+ config: HyperlinkConfig;
152
+ };
153
+ /**
154
+ * Parse a full OSC 8 URI (the part after the `8;params;` framing) into either a
155
+ * preset definition or a resolved link. `registry` supplies/receives preset
156
+ * definitions. Returns null for an empty/whitespace URI.
157
+ *
158
+ * - `preset:NAME?config={…}` registers NAME (raw) and returns a `preset` result.
159
+ * - Otherwise the base command is cleaned: send:/prompt: drop all query params;
160
+ * http/https/ftp keep user params but strip `config`/`preset`. The config is
161
+ * resolved as `deepMerge(preset, override)` → expand shorthands → normalise.
162
+ */
163
+ export declare function parseOsc8Uri(uri: string, registry: HyperlinkPresetRegistry): Osc8UriResult | null;
164
+ export {};