@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,37 @@
1
+ /**
2
+ * OSC 8 hyperlink `visibility` (Mudlet's THyperlinkVisibilityManager).
3
+ *
4
+ * Timer- and click-driven actions are wired directly onto the rendered link
5
+ * element by {@link applyVisibility}:
6
+ * - **reveal** — start hidden, reveal after `delayMs` (from render).
7
+ * - **conceal** — start visible, conceal on click (now, or after
8
+ * `delayMs`); with expire flags, arm instead.
9
+ * - **reveal-then-conceal** — reveal after `delayMs`, then conceal on click.
10
+ * - **deletesEntireLine** — conceal removes the whole output line.
11
+ *
12
+ * Expire-on-event links (conceal on the next user input / prompt / output after
13
+ * being clicked) can't be driven from the element alone — they're tagged with
14
+ * `data-osc-vis-*` attributes here, and {@link HyperlinkVisibilityController}
15
+ * (owned by the session) conceals them when the matching session event fires.
16
+ * The first occurrence of each trigger is skipped: it's the response to the very
17
+ * command the click sent, not a fresh event.
18
+ */
19
+ import type { VisibilitySettings } from "./hyperlinkConfig";
20
+ /** Wire one link element's visibility behaviour. Call *after* the element's base
21
+ * style has been applied (it may set `visibility: hidden`, which a later
22
+ * `cssText` assignment would wipe). */
23
+ export declare function applyVisibility(el: HTMLElement, vis: VisibilitySettings): void;
24
+ /**
25
+ * Session-scoped driver for expire-on-event visibility links. The session calls
26
+ * `onInput`/`onPrompt`/`onOutput` as those events occur; each conceals every
27
+ * armed link whose trigger set includes that event (after skipping the first
28
+ * occurrence). `getRoot` supplies the DOM subtree to scan (the live output).
29
+ */
30
+ export declare class HyperlinkVisibilityController {
31
+ private readonly getRoot;
32
+ constructor(getRoot: () => ParentNode | null);
33
+ onInput(): void;
34
+ onPrompt(): void;
35
+ onOutput(): void;
36
+ private fire;
37
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Session-scoped state for stateful OSC 8 links — `selection` groups and
3
+ * `:visited` tracking (Mudlet's selection manager + visited links).
4
+ *
5
+ * The styling itself is precomputed by the renderer and stashed on each link
6
+ * element as `data-css-base` / `data-css-selected` / `data-css-visited`; this
7
+ * manager only holds the *state* (which group values are selected, which links
8
+ * have been activated) and re-applies the right stashed style to the live link
9
+ * elements when state changes. Restyling queries the document, so it updates
10
+ * every rendered run of a group across lines — not just the clicked one.
11
+ */
12
+ export declare class OscLinkManager {
13
+ /** group → set of currently-selected values. */
14
+ private readonly selected;
15
+ /** Activated link keys (the command URI), for `:visited` styling. */
16
+ private readonly visited;
17
+ isSelected(group: string, value: string): boolean;
18
+ isVisited(key: string): boolean;
19
+ /**
20
+ * Toggle `(group, value)` and return its new selected state. `exclusive`
21
+ * groups behave like radio buttons (one value at a time); non-exclusive like
22
+ * checkboxes (independent toggles).
23
+ */
24
+ toggleSelection(group: string, value: string, exclusive: boolean): boolean;
25
+ /** Seed an initially-selected value (server sent `selection.selected:true`). */
26
+ select(group: string, value: string, exclusive: boolean): void;
27
+ markVisited(key: string): void;
28
+ /**
29
+ * Re-apply the correct stashed style to every OSC link element under `root`,
30
+ * based on current selection/visited state. Selection wins over visited.
31
+ * No-op when `root` is null (e.g. a headless call with no DOM).
32
+ */
33
+ restyle(root: ParentNode | null | undefined): void;
34
+ clear(): void;
35
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Terminal display-width tables (a wcwidth-style implementation).
3
+ *
4
+ * MUD output is laid out on a monospace grid: every character occupies an
5
+ * integer number of cells (0, 1, or 2). Browsers don't enforce that — a glyph
6
+ * the chosen font lacks falls back to another font with a different advance
7
+ * width, wide CJK/emoji render at their natural width, and combining marks add
8
+ * code-unit length but no visual width. The renderer uses these tables to box
9
+ * each grapheme into a fixed `Nch` cell so columns stay aligned regardless of
10
+ * the font.
11
+ *
12
+ * Ranges follow Markus Kuhn's wcwidth (combining + East Asian Wide/Fullwidth),
13
+ * extended with the Supplementary-plane emoji/symbol blocks. BMP dingbats and
14
+ * miscellaneous symbols (☎ ★ ♠ …) are East Asian *Ambiguous* and kept at width
15
+ * 1, matching the common "narrow" terminal rendering.
16
+ */
17
+ /**
18
+ * Display width of a single Unicode code point, in monospace cells.
19
+ * Returns 0 for combining/zero-width, 2 for wide, 1 otherwise. C0/C1 control
20
+ * characters (which shouldn't reach the renderer) are treated as 0.
21
+ */
22
+ export declare function codePointWidth(cp: number): 0 | 1 | 2;
23
+ /**
24
+ * Display width of a grapheme cluster (base + any combining marks / ZWJ
25
+ * sequence). Width is the widest code point in the cluster, so an emoji ZWJ
26
+ * sequence stays 2 and a base+diacritic stays at the base's width.
27
+ */
28
+ export declare function clusterWidth(cluster: string): 0 | 1 | 2;
29
+ /** Total display width of a string, in monospace cells. */
30
+ export declare function stringWidth(text: string): number;
31
+ export interface DisplayCell {
32
+ /** The grapheme cluster occupying this cell. */
33
+ text: string;
34
+ /** Number of monospace cells the grapheme occupies (0, 1, or 2). */
35
+ width: 0 | 1 | 2;
36
+ }
37
+ /**
38
+ * Split text into display cells, one per grapheme cluster. Uses
39
+ * `Intl.Segmenter` for proper cluster boundaries (so combining marks fold into
40
+ * their base), falling back to per-code-point iteration where it is missing.
41
+ */
42
+ export declare function segmentCells(text: string): DisplayCell[];
43
+ /** Fast check: pure printable ASCII renders at exactly 1 cell with no boxing. */
44
+ export declare function isPlainAscii(text: string): boolean;
@@ -0,0 +1,2 @@
1
+ declare const xterm256: string[];
2
+ export default xterm256;
@@ -0,0 +1,61 @@
1
+ import type { TimerNode } from '../../storage/schema';
2
+ export type { TimerNode };
3
+ type TempFn = () => void;
4
+ type ExecuteFn = (timer: TimerNode) => void;
5
+ export declare class TimerEngine {
6
+ private readonly temp;
7
+ /** Permanent timers keyed by stored TimerNode id (uuid). Two timers can
8
+ * share a name; we keep id as the canonical handle and build a separate
9
+ * name → id index for Mudlet's name-based lookups. */
10
+ private readonly perm;
11
+ /** Name → first matching id, used by remainingTime / kill-by-name. */
12
+ private readonly permNameToId;
13
+ private nextId;
14
+ /** Number of live session-scoped temp timers (Mudlet `getProfileStats` temp count). */
15
+ get tempCount(): number;
16
+ addTemp(seconds: number, fn: TempFn, repeat?: boolean): number;
17
+ /**
18
+ * Fire every one-shot timer that has come due, without waiting for the
19
+ * event loop to deliver its setTimeout.
20
+ *
21
+ * This exists for `waitForEvent`, the busted-only helper Mudlet implements
22
+ * by spinning a nested QEventLoop. A browser can't re-enter its event loop,
23
+ * so a synchronous wait would block the very setTimeout it is waiting on and
24
+ * deadlock; pumping the due timers by hand is the equivalent of Qt draining
25
+ * its timer queue inside that nested loop.
26
+ *
27
+ * Repeating timers are deliberately skipped: their setInterval is still
28
+ * armed, and firing them here would double-fire each tick. A repeat timer
29
+ * therefore misses ticks across a synchronous wait — the same thing that
30
+ * happens whenever the main thread is busy.
31
+ *
32
+ * Returns the number of timers fired.
33
+ */
34
+ pumpDue(now?: number): number;
35
+ killTimer(id: number): boolean;
36
+ /**
37
+ * Cached previous load. `nodes` is the TimerNode keyed by id, `desc` is the
38
+ * shape that determines whether the running setTimeout/setInterval is still
39
+ * correct (seconds, repeat, isGroup, code presence, name) — if `desc` is
40
+ * unchanged AND the timer is still enabled, the live handle is left alone.
41
+ * This makes a name-toggle that disables one timer cost one clearTimeout
42
+ * instead of "clear all + recreate all".
43
+ */
44
+ private readonly prevDesc;
45
+ private descOf;
46
+ loadPerm(timers: TimerNode[], executeFn: ExecuteFn): void;
47
+ private startPerm;
48
+ private killPermHandle;
49
+ /**
50
+ * Mudlet `remainingTime(idOrName)` — seconds until the next fire. For
51
+ * non-repeating timers, returns the time left before the one and only
52
+ * fire. For repeating timers, returns the time until the next tick.
53
+ * Returns -1 if no live timer matches (Mudlet's miss sentinel).
54
+ * - Numeric arg: looks up tempTimer ids only.
55
+ * - String arg: looks up permanent timer names; falls back to the stored
56
+ * TimerNode id when the string is a uuid that no name matched.
57
+ */
58
+ remainingTime(idOrName: number | string): number;
59
+ private stopPerm;
60
+ destroy(): void;
61
+ }
@@ -0,0 +1,11 @@
1
+ import type { MudClient } from '../connection/MudClient';
2
+ export interface ChunkProcessor {
3
+ /** Called with the full sanitized text chunk from each WebSocket frame. */
4
+ processChunk(data: string, timestamp: number, client: MudClient): void;
5
+ }
6
+ /**
7
+ * Passthrough — pushes each chunk to the message buffer so it travels through
8
+ * flushLines → ScriptingEngine, which handles both rendering (via 'message')
9
+ * and trigger processing in one pass.
10
+ */
11
+ export declare function createPassthroughProcessor(): ChunkProcessor;
@@ -0,0 +1,188 @@
1
+ import type { TriggerNode } from '../../storage/schema';
2
+ export type { TriggerNode };
3
+ type Capture = string | undefined;
4
+ type TempFn = (matches: Capture[], spans?: {
5
+ captureSpans: CaptureSpan[];
6
+ namedSpans?: Record<string, CaptureSpan>;
7
+ matchSpan?: CaptureSpan;
8
+ }, namedGroups?: Record<string, string>) => void;
9
+ /**
10
+ * Result of matching a trigger pattern against a line.
11
+ *
12
+ * `captureSpans` and `namedSpans` describe where each capture sits in the
13
+ * source line — needed by `selectCaptureGroup` so it can re-select the
14
+ * actual occurrence rather than picking the first textual match. Spans line
15
+ * up positionally with `captures` (so `captureSpans[0]` is the position of
16
+ * `captures[0]`, i.e. capture group 1). Both are optional because non-PCRE
17
+ * matchers (substring/exactMatch/etc.) don't produce capture-group spans.
18
+ */
19
+ type CaptureSpan = {
20
+ start: number;
21
+ length: number;
22
+ };
23
+ /**
24
+ * What `matchPerm`/`processAndTrigger` hand back to the engine. Adds the
25
+ * trigger node and the AND-trigger-only `multimatches` array on top of the
26
+ * raw `MatchResult`.
27
+ */
28
+ export type TriggerMatch = {
29
+ trigger: TriggerNode;
30
+ captures: Capture[];
31
+ matchedText: string;
32
+ multimatches?: Capture[][];
33
+ namedGroups?: Record<string, string>;
34
+ captureSpans?: CaptureSpan[];
35
+ namedSpans?: Record<string, CaptureSpan>;
36
+ matchStart?: number;
37
+ };
38
+ export declare class TriggerEngine {
39
+ private readonly temp;
40
+ private nextId;
41
+ private inProcessTemp;
42
+ private permCompiled;
43
+ private allById;
44
+ private regCounter;
45
+ private permReg;
46
+ private unified;
47
+ private orderDirty;
48
+ private cache;
49
+ private lineCounter;
50
+ private readonly chainOpenUntil;
51
+ private hasChildren;
52
+ private andStates;
53
+ private filterActiveText;
54
+ private filterActiveOffset;
55
+ /** Resolves once PCRE wasm is initialized and patterns can be compiled. */
56
+ static ready(): Promise<void>;
57
+ /** Number of live session-scoped temp triggers (Mudlet `getProfileStats` temp count). */
58
+ get tempCount(): number;
59
+ /**
60
+ * Register a temp trigger. `kind` selects the match strategy:
61
+ * - `'regex'` — PCRE, same syntax as permanent triggers (Mudlet
62
+ * `tempRegexTrigger`). The callback receives
63
+ * `[fullMatch, capture1, capture2, ...]`; unmatched
64
+ * optional groups surface as empty strings.
65
+ * - `'substring'` — literal `String.prototype.includes` (Mudlet
66
+ * `tempTrigger`). The callback receives `[pattern]`
67
+ * so capture-group access against the substring is a
68
+ * no-op rather than a metacharacter trap.
69
+ * - `'startOfLine'`— literal `String.prototype.startsWith` (Mudlet
70
+ * `tempBeginOfLineTrigger`). Not anchored regex —
71
+ * just a prefix check, which is why it's cheap.
72
+ * Callback receives `[pattern]`.
73
+ * - `'exactMatch'`— full-line equality (Mudlet
74
+ * `tempExactMatchTrigger`). Callback receives `[line]`.
75
+ * - `'prompt'` — fires on every line the server flags as a prompt
76
+ * (Mudlet `tempPromptTrigger`); `pattern` is ignored.
77
+ * Callback receives `[line]`.
78
+ * Invalid regex patterns return a no-op disposer so callers don't need
79
+ * to special-case compile failures.
80
+ */
81
+ addTemp(pattern: string, fn: TempFn, kind?: 'regex' | 'substring' | 'startOfLine' | 'exactMatch' | 'prompt'): () => void;
82
+ /**
83
+ * Mudlet `tempLineTrigger(from, howMany, fn)`. A position-based trigger with
84
+ * no pattern: it fires `fn([lineText])` on `howMany` consecutive lines,
85
+ * starting `from` lines ahead (`from = 1` → the next line). It self-expires
86
+ * after the last fire. When created from within a handler, the line on which
87
+ * it was created is skipped (see `inProcessTemp`/`skipFirst`) so `from`
88
+ * counts from the next line in every creation context. Returns a disposer
89
+ * for early cancellation.
90
+ */
91
+ addTempLine(from: number, howMany: number, fn: TempFn): () => void;
92
+ loadPerm(items: TriggerNode[]): void;
93
+ /** Fresh compile for an item not present in the cache. Returns a CachedEntry
94
+ * with `compiled: null` when no patterns produced a usable matcher — that
95
+ * negative result is cached so we don't retry on every loadPerm. */
96
+ private compileItem;
97
+ processTemp(line: string, isPrompt?: boolean): void;
98
+ /** Match + fire a single temp trigger against `line`. Self-expiring `line`
99
+ * triggers delete themselves (and dirty the unified order) when spent. */
100
+ private fireTempEntry;
101
+ matchPerm(line: string, isPrompt?: boolean): TriggerMatch[];
102
+ /**
103
+ * Match one permanent compiled entry against `line`, appending any matches
104
+ * to `out`. Updates chain/AND/filter state exactly as the old inline loop
105
+ * did. `seen` dedupes a single OR/group item within one line pass; it is
106
+ * shared across all entries processed for that line.
107
+ */
108
+ private matchPermEntry;
109
+ /**
110
+ * Mudlet-faithful single pass: walk the one ordered list of permanent and
111
+ * temporary triggers (see the ordering notes on the fields) and, for each
112
+ * node in turn, match + act on it before moving to the next. Permanent
113
+ * matches are handed to `exec` inline (the caller runs the trigger's
114
+ * command/code); temporary triggers fire their own callback. Because a
115
+ * runtime temp sorts after the permanent triggers that existed when it was
116
+ * created, a permanent trigger on a line runs before a temp that also
117
+ * matches it — which is exactly the order Mudlet produces.
118
+ *
119
+ * The processing list is snapshotted up front (like Mudlet's
120
+ * `copyOfNodeList`), so triggers created mid-pass don't fire on the current
121
+ * line, and `inProcessTemp` is saved/restored to stay correct under the
122
+ * re-entrancy a handler can cause via `feedTriggers`.
123
+ */
124
+ process(line: string, isPrompt: boolean, exec: (match: TriggerMatch) => void): void;
125
+ /** Rebuild the merged, path-sorted processing list from the current
126
+ * permanent entries and temporary triggers. Called lazily from process()
127
+ * when either source changed. */
128
+ private rebuildOrder;
129
+ /** The registration-seq path from the root ancestor down to `item`. */
130
+ private permPath;
131
+ setLuaEval(fn: ((code: string, line: string) => boolean) | null): void;
132
+ /**
133
+ * Wire the buffer-aware colour check used by `colorTrigger` patterns. The
134
+ * matcher receives the parsed `(fg, bg)` indices and asks the registered
135
+ * callback whether the line just appended to the main console carries any
136
+ * segment with those colours. ScriptingEngine sets this to delegate to
137
+ * `ScriptingAPI.currentLineMatchesColor`. Passing `null` disables every
138
+ * colour trigger (e.g. during runtime teardown).
139
+ */
140
+ setColorMatcher(fn: ((fg: number, bg: number) => boolean) | null): void;
141
+ destroy(): void;
142
+ private processAndTrigger;
143
+ /**
144
+ * Record a chain-head match: open the chain for `fireLength` more lines and,
145
+ * if the trigger is also a filter, stash the captured/matched text so
146
+ * descendants see it as their effective input.
147
+ */
148
+ private openChain;
149
+ /**
150
+ * Mudlet `setTriggerStayOpen(name, lines)`: keep the named chain head(s)
151
+ * open for `lines` more lines of input, starting from the line currently
152
+ * being processed. This is transient runtime state — it mutates only the
153
+ * `chainOpenUntil` window, never the persisted `fireLength` on the node, so
154
+ * the trigger's stored definition is untouched and the override expires
155
+ * naturally as input scrolls past.
156
+ *
157
+ * `matchPerm` post-increments `lineCounter`, so during a trigger's script
158
+ * the line just matched is `lineCounter - 1`; the window math then mirrors
159
+ * `openChain` exactly. Negative counts clamp to 0 (open for the current
160
+ * line only). `ids` are resolved by name by the caller.
161
+ */
162
+ setStayOpen(ids: string[], lines: number): void;
163
+ /**
164
+ * Returns the effective line to match against for `item`.
165
+ * If a filter-trigger ancestor has active filter text, that text is used instead.
166
+ * Innermost filter wins.
167
+ */
168
+ private getEffectiveLine;
169
+ /** The offset within the ORIGINAL line at which `item`'s effective (filtered)
170
+ * input begins — 0 unless it sits under a filter ancestor. Mirrors
171
+ * getEffectiveLine: the innermost filter ancestor's recorded offset. */
172
+ private getEffectiveOffset;
173
+ /** Return a copy of `r` with every span (matchStart, captureSpans, namedSpans)
174
+ * shifted by `offset` — used to re-base a filtered descendant's spans onto
175
+ * the original line so selectCaptureGroup/selectString hit the right column.
176
+ * Zero-length (unmatched-group) placeholders keep length 0. */
177
+ private shiftResultSpans;
178
+ /**
179
+ * A trigger is chain-accessible if every patterned ancestor has an open
180
+ * chain (matched within the last fireLength lines, inclusive of the current
181
+ * line). Pattern-less ancestors (pure folders) always grant access. This
182
+ * applies regardless of whether the ancestor is a folder or a leaf with its
183
+ * own script — Mudlet treats any patterned trigger with children as a chain
184
+ * head.
185
+ */
186
+ private isChainAccessible;
187
+ private computeDepth;
188
+ }
@@ -0,0 +1,26 @@
1
+ export type Pcre2MatchGroup = {
2
+ start: number;
3
+ end: number;
4
+ match: string;
5
+ name?: string;
6
+ group?: number;
7
+ };
8
+ export type Pcre2Match = {
9
+ length: number;
10
+ [k: number]: Pcre2MatchGroup;
11
+ [k: string]: Pcre2MatchGroup | number;
12
+ };
13
+ /** Drop the cached line so the next match re-encodes. Used after teardown or
14
+ * when callers want to be sure a stale buffer can't be reused. */
15
+ export declare function resetLineBuffer(): void;
16
+ export default class Pcre2 {
17
+ private codePtr;
18
+ private matchData;
19
+ private readonly nametable;
20
+ static init(): Promise<void>;
21
+ constructor(pattern: string, flags?: string);
22
+ destroy(): void;
23
+ match(subject: string, start?: number): Pcre2Match | null;
24
+ matchAll(subject: string): Pcre2Match[];
25
+ private getLastError;
26
+ }
@@ -0,0 +1,152 @@
1
+ import type { InstallOutcome } from './ScriptingAPI';
2
+ /**
3
+ * Everything {@link ScriptingAPI} needs from {@link ScriptingEngine}.
4
+ *
5
+ * `ScriptingAPI` is constructed before the engine (the engine takes the API in
6
+ * its own constructor), so the API cannot simply hold an engine reference — the
7
+ * dependency is genuinely circular in construction order. That used to be
8
+ * worked around with 57 individual nullable callback fields, each with its own
9
+ * `setXxxCallback` setter and its own `?.() ?? fallback` at the call site:
10
+ * ~400 lines of indirection where a missed wiring failed silently at runtime.
11
+ *
12
+ * This interface replaces all of that with a single late-bound reference. The
13
+ * method names are the engine's own — `ScriptingEngine` satisfies the interface
14
+ * with the methods it already had, so binding is `api.setHost(this)` once.
15
+ *
16
+ * Members are grouped the way the engine groups them, not alphabetically.
17
+ */
18
+ export interface EngineHost {
19
+ /** Run a chunk of Lua on behalf of a clicked hyperlink. Errors are reported
20
+ * through the API's error channel rather than thrown. */
21
+ runLinkCode(code: string): void;
22
+ /** Push text through the full alias pipeline, sending it to the MUD if no
23
+ * alias consumes it. Backs Mudlet's `expandAlias`. */
24
+ expandAlias(text: string, echo: boolean): void;
25
+ /** Raise `sysDataSendRequest` and report whether a handler vetoed the send
26
+ * by calling `denyCurrentSend()`. */
27
+ dispatchSendRequest(text: string): boolean;
28
+ /** Dial a connection through the engine's load gate, so a `connect()` made
29
+ * during initial script load defers until scripts and triggers are ready. */
30
+ requestConnect(url: string): void;
31
+ /** Mudlet `reconnect()` — redial the last URL. Goes through the engine so
32
+ * it observes the same teardown gate as {@link requestConnect}; calling
33
+ * `session.reconnect()` directly would open a socket during disposal. */
34
+ requestReconnect(): boolean;
35
+ /** Run a synthetic batch of lines through the same pipeline as network
36
+ * output, so `feedTriggers` shares ordering semantics with real data. */
37
+ processFlushBatch(groups: {
38
+ text: string;
39
+ type: string;
40
+ }[]): void;
41
+ /** Apply any coalesced trigger/alias reloads immediately instead of on the
42
+ * scheduled microtask. The Mudlet `perm…`, `enableTrigger` and
43
+ * `disableTrigger` families take effect at once, so a script that creates
44
+ * or toggles a trigger and then feeds a line in the same chunk must see the
45
+ * new state — the microtask cannot run until that chunk returns. */
46
+ flushPendingApplies(): void;
47
+ /** Raise a Mudlet event with the given arguments. */
48
+ raiseEvent(event: string, args: unknown[]): void;
49
+ installPackageFromVfsPath(path: string): InstallOutcome;
50
+ uninstallPackageByName(name: string): boolean;
51
+ getPackageNames(): string[];
52
+ getPackageInfo(name: string): Record<string, string>;
53
+ setPackageInfo(name: string, key: string, value: string): boolean;
54
+ installModuleFromPath(path: string): InstallOutcome;
55
+ uninstallModuleByName(name: string): boolean;
56
+ syncModuleToFile(name: string): Promise<void>;
57
+ reloadModuleFromFile(name: string): boolean;
58
+ setModuleSync(name: string, sync: boolean): void;
59
+ getModuleSync(name: string): boolean;
60
+ setModulePriority(name: string, priority: number): boolean;
61
+ getModulePriority(name: string): number;
62
+ getModuleNames(): string[];
63
+ getModulePath(name: string): string | null;
64
+ setModuleInfo(name: string, key: string, value: string): boolean;
65
+ /** Module manifest fields as a flat record, with any Lua-set overrides
66
+ * applied. Null when no module by that name is installed. */
67
+ getModuleInfoRecord(name: string): Record<string, unknown> | null;
68
+ /** Rewrite VFS-relative `url(...)` references in a stylesheet to the paths
69
+ * the service worker serves. Returns the CSS unchanged with no VFS. */
70
+ rewriteCss(css: string): string;
71
+ /** Rewrite profile-local asset refs (`<img src>`, inline `style` url(...))
72
+ * in Lua-supplied HTML to the paths the service worker serves. Returns the
73
+ * HTML unchanged with no VFS. */
74
+ rewriteHtml(html: string): string;
75
+ /** Read raw bytes from the profile VFS, or null if missing/unreadable.
76
+ * Backs synchronous binary consumers such as setMovie's GIF decoder. */
77
+ readFileBytes(path: string): Uint8Array | null;
78
+ toggleScriptByName(name: string, enabled: boolean): boolean;
79
+ toggleTriggerByName(name: string, enabled: boolean): boolean;
80
+ toggleTimerByName(name: string, enabled: boolean): boolean;
81
+ toggleAliasByName(name: string, enabled: boolean): boolean;
82
+ toggleKeyByName(name: string, enabled: boolean): boolean;
83
+ toggleToolBarByName(name: string, show: boolean): boolean;
84
+ setTriggerStayOpenByName(name: string, lines: number): boolean;
85
+ /** The saved keybinding carrying this numeric id, or null — getKeyCode
86
+ * resolves a permanent key by the id permKey returned, not only by name. */
87
+ keyNodeByNumericId(numericId: number): {
88
+ key: string;
89
+ modifiers: string[];
90
+ } | null;
91
+ /** Mudlet's Host::setForceMXPProcessorOn — run the in-band MXP parser with
92
+ * no option-91 handshake. */
93
+ setForceMxpProcessorOn(on: boolean): void;
94
+ /** Mudlet `exists(nameOrId, type)` — count of matching items. */
95
+ existsByName(nameOrId: string | number, type: string): number;
96
+ /** enable/disable a script-created temp trigger or alias by its numeric id.
97
+ * False when no live temp item has that id. */
98
+ setTempItemEnabled(id: number, enabled: boolean): boolean;
99
+ /** Mudlet `isActive(nameOrId, type)` — count of matching *active* items. */
100
+ isActiveByName(nameOrId: string | number, type: string, checkAncestors: boolean): number;
101
+ ancestorsById(id: number, type: string): Array<{
102
+ id: number;
103
+ name: string;
104
+ node: string;
105
+ isActive: boolean;
106
+ }> | null;
107
+ findItemsByName(name: string, type: string, exact: boolean, caseSensitive: boolean): number[];
108
+ isAncestorsActiveById(id: number, type: string): boolean | null;
109
+ getProfileStats(): Record<string, unknown>;
110
+ createPermScript(name: string, parent: string, code: string): number;
111
+ createPermRegexTrigger(name: string, parent: string, regexes: string[], code: string): number;
112
+ createPermSubstringTrigger(name: string, parent: string, patterns: string[], code: string): number;
113
+ createPermBeginOfLineStringTrigger(name: string, parent: string, patterns: string[], code: string): number;
114
+ createPermExactMatchTrigger(name: string, parent: string, patterns: string[], code: string): number;
115
+ createPermPromptTrigger(name: string, parent: string, code: string): number;
116
+ createPermAlias(name: string, parent: string, pattern: string, code: string): number;
117
+ createPermTimer(name: string, parent: string, delay: number, code: string): number;
118
+ /** `modifier` arrives as a Qt::KeyboardModifier int; the engine translates
119
+ * it back into `["ctrl", …]` strings to store on the KeyNode. */
120
+ createPermKey(name: string, parent: string, modifier: number, key: string | number, code: string): number;
121
+ createTempButton(toolbar: string, name: string, code: string, orientation: number): number;
122
+ createTempButtonToolbar(name: string, orientation: number, location: number): number;
123
+ setButtonStateByName(name: string, state: boolean): boolean;
124
+ getButtonStateByName(name: string): boolean | null;
125
+ setButtonStyleSheetByName(name: string, css: string): boolean;
126
+ setScriptByName(name: string, code: string, pos: number): number;
127
+ getScriptByName(name: string, pos: number): {
128
+ code: string;
129
+ count: number;
130
+ } | null;
131
+ /** Mudlet's killTimer/killAlias/killTrigger/killKey by permanent-item name. */
132
+ killByName(kind: 'timer' | 'alias' | 'trigger' | 'key', name: string): boolean;
133
+ /** Mudlet `resetProfile()` — reload the profile with a fresh Lua VM. */
134
+ resetProfile(): void;
135
+ /** Render a map area to a PNG inside the profile VFS. */
136
+ exportAreaImageToVfs(areaId: number, filePath: string, zLevel?: number): {
137
+ path: string;
138
+ } | {
139
+ error: string;
140
+ };
141
+ }
142
+ /**
143
+ * The host used before a real engine is bound.
144
+ *
145
+ * `ScriptingAPI` outlives any single engine (a profile switch destroys the
146
+ * engine and builds a new one), and a handful of API methods can be reached
147
+ * during that window — so rather than making every call site re-check for null,
148
+ * the API always holds *a* host. Each method here returns exactly the fallback
149
+ * the old `?.() ?? …` expressions produced, keeping behaviour identical while
150
+ * collecting the "not wired yet" policy in one readable place.
151
+ */
152
+ export declare const NULL_ENGINE_HOST: EngineHost;
@@ -0,0 +1,36 @@
1
+ /** A value that can cross the global-event channel. Mudlet's raiseGlobalEvent
2
+ * accepts only these (string/number/boolean/nil) — tables and functions can't
3
+ * cross a profile boundary. nil is represented as null. */
4
+ export type GlobalEventArg = string | number | boolean | null;
5
+ /**
6
+ * Cross-tab transport for Mudlet's `raiseGlobalEvent` — delivers an event to
7
+ * every OTHER open profile. Each profile lives in its own browser tab (the
8
+ * per-profile lock guarantees one tab per profile), so "other profiles" means
9
+ * "other tabs". A `BroadcastChannel` carries the event; crucially it does NOT
10
+ * echo a message back to the sender's own channel object, which matches Mudlet's
11
+ * rule that the sending profile never receives its own global event.
12
+ *
13
+ * Degrades to a no-op when BroadcastChannel is unavailable (legacy browser).
14
+ */
15
+ export declare class GlobalEventChannel {
16
+ /** Called when a global event arrives from another tab — dispatch it
17
+ * locally (through the runtime's emitEvent) so handlers fire. */
18
+ private readonly onEvent;
19
+ /** This profile's name, appended to outgoing events (see `raise`). */
20
+ private readonly senderName;
21
+ private channel;
22
+ constructor(
23
+ /** Called when a global event arrives from another tab — dispatch it
24
+ * locally (through the runtime's emitEvent) so handlers fire. */
25
+ onEvent: (name: string, args: GlobalEventArg[]) => void,
26
+ /** This profile's name, appended to outgoing events (see `raise`). */
27
+ senderName: () => string);
28
+ /**
29
+ * Raise a global event in all other tabs' profiles. Mirrors Mudlet: accepts
30
+ * string/number/boolean/nil args only (throws otherwise, surfacing as a Lua
31
+ * error), and appends the sending profile's name as the final argument so
32
+ * handlers can tell which profile it came from. Returns true.
33
+ */
34
+ raise(name: string, args: unknown[]): boolean;
35
+ close(): void;
36
+ }