@mudlet/mudlet-web 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +338 -0
- package/README.md +150 -0
- package/dist-lib/App.d.ts +1 -0
- package/dist-lib/MudletWebApp.d.ts +11 -0
- package/dist-lib/ProfileSession.d.ts +15 -0
- package/dist-lib/assets/mapParser.worker-t-3rd1zR.js +9 -0
- package/dist-lib/branding.d.ts +213 -0
- package/dist-lib/core/EventBus.d.ts +29 -0
- package/dist-lib/db/sqliteClient.d.ts +25 -0
- package/dist-lib/hooks/useEngines.d.ts +12 -0
- package/dist-lib/hooks/useMudSession.d.ts +10 -0
- package/dist-lib/hooks/useOutput.d.ts +17 -0
- package/dist-lib/hooks/useViewportMode.d.ts +14 -0
- package/dist-lib/import/applyMudletProfile.d.ts +57 -0
- package/dist-lib/import/collectProfileExport.d.ts +16 -0
- package/dist-lib/import/defaultPackages.d.ts +81 -0
- package/dist-lib/import/defaults/mudlet-mapper.xml +13023 -0
- package/dist-lib/import/defaults/run-lua-code.mpackage +0 -0
- package/dist-lib/import/mudletHost.d.ts +67 -0
- package/dist-lib/import/mudletLink.d.ts +34 -0
- package/dist-lib/import/mudletProfileExport.d.ts +49 -0
- package/dist-lib/import/mudletProfileImport.d.ts +71 -0
- package/dist-lib/import/mudletVariables.d.ts +49 -0
- package/dist-lib/import/mudletWriteback.d.ts +12 -0
- package/dist-lib/import/mudletXmlExport.d.ts +16 -0
- package/dist-lib/import/mudletXmlImport.d.ts +21 -0
- package/dist-lib/import/packageInstaller.d.ts +72 -0
- package/dist-lib/import/packageRepository.d.ts +54 -0
- package/dist-lib/import/remotePackageInstall.d.ts +52 -0
- package/dist-lib/index.d.ts +30 -0
- package/dist-lib/index.js +42307 -0
- package/dist-lib/logging/SessionLogger.d.ts +41 -0
- package/dist-lib/main.d.ts +2 -0
- package/dist-lib/map/MapSelectionOverlay.d.ts +15 -0
- package/dist-lib/map/MapStore.d.ts +1067 -0
- package/dist-lib/map/MudixMapReader.d.ts +90 -0
- package/dist-lib/map/MudletHighlightOverlay.d.ts +18 -0
- package/dist-lib/map/mapImageExport.d.ts +26 -0
- package/dist-lib/map/mapParser.worker.d.ts +1 -0
- package/dist-lib/map/mapParserClient.d.ts +35 -0
- package/dist-lib/map/pathfinding.d.ts +52 -0
- package/dist-lib/map/xmlMapImport.d.ts +28 -0
- package/dist-lib/mud/MudSession.d.ts +236 -0
- package/dist-lib/mud/PatternEngine.d.ts +28 -0
- package/dist-lib/mud/aliases/AliasEngine.d.ts +15 -0
- package/dist-lib/mud/connection/LineAssembler.d.ts +84 -0
- package/dist-lib/mud/connection/MudClient.d.ts +268 -0
- package/dist-lib/mud/connection/PingTracker.d.ts +28 -0
- package/dist-lib/mud/connection/TelnetNegotiator.d.ts +188 -0
- package/dist-lib/mud/connection/telnetDebug.d.ts +54 -0
- package/dist-lib/mud/events.d.ts +160 -0
- package/dist-lib/mud/keybindings/KeyEngine.d.ts +36 -0
- package/dist-lib/mud/keybindings/browserReservedKeys.d.ts +45 -0
- package/dist-lib/mud/keybindings/qtKeys.d.ts +33 -0
- package/dist-lib/mud/protocol/charset.d.ts +105 -0
- package/dist-lib/mud/protocol/constants.d.ts +116 -0
- package/dist-lib/mud/protocol/echo.d.ts +63 -0
- package/dist-lib/mud/protocol/gmcp.d.ts +28 -0
- package/dist-lib/mud/protocol/index.d.ts +11 -0
- package/dist-lib/mud/protocol/mccp.d.ts +18 -0
- package/dist-lib/mud/protocol/mnes.d.ts +83 -0
- package/dist-lib/mud/protocol/msdp.d.ts +19 -0
- package/dist-lib/mud/protocol/msp.d.ts +47 -0
- package/dist-lib/mud/protocol/mssp.d.ts +25 -0
- package/dist-lib/mud/protocol/mxp.d.ts +188 -0
- package/dist-lib/mud/protocol/naws.d.ts +7 -0
- package/dist-lib/mud/replay/ReplayPlayer.d.ts +31 -0
- package/dist-lib/mud/replay/ReplayRecorder.d.ts +18 -0
- package/dist-lib/mud/replay/replayFormat.d.ts +49 -0
- package/dist-lib/mud/text/Console.d.ts +183 -0
- package/dist-lib/mud/text/FormatState.d.ts +256 -0
- package/dist-lib/mud/text/ansiEscapes.d.ts +88 -0
- package/dist-lib/mud/text/cellRender.d.ts +21 -0
- package/dist-lib/mud/text/colorParsers.d.ts +54 -0
- package/dist-lib/mud/text/colors.d.ts +31 -0
- package/dist-lib/mud/text/controlCharacterMode.d.ts +13 -0
- package/dist-lib/mud/text/controlChars.d.ts +31 -0
- package/dist-lib/mud/text/hyperlinkConfig.d.ts +164 -0
- package/dist-lib/mud/text/hyperlinkVisibility.d.ts +37 -0
- package/dist-lib/mud/text/oscLinkManager.d.ts +35 -0
- package/dist-lib/mud/text/wcwidth.d.ts +44 -0
- package/dist-lib/mud/text/xterm256.d.ts +2 -0
- package/dist-lib/mud/timers/TimerEngine.d.ts +61 -0
- package/dist-lib/mud/triggers/ChunkProcessor.d.ts +11 -0
- package/dist-lib/mud/triggers/TriggerEngine.d.ts +188 -0
- package/dist-lib/mud/triggers/pcre/Pcre2.d.ts +26 -0
- package/dist-lib/scripting/EngineHost.d.ts +152 -0
- package/dist-lib/scripting/GlobalEventChannel.d.ts +36 -0
- package/dist-lib/scripting/IScriptingRuntime.d.ts +95 -0
- package/dist-lib/scripting/MapOpenNotifier.d.ts +19 -0
- package/dist-lib/scripting/ScriptingAPI.d.ts +1691 -0
- package/dist-lib/scripting/ScriptingEngine.d.ts +806 -0
- package/dist-lib/scripting/StopwatchManager.d.ts +94 -0
- package/dist-lib/scripting/heldModifiers.d.ts +3 -0
- package/dist-lib/scripting/http/HttpService.d.ts +23 -0
- package/dist-lib/scripting/lua/LuaRuntime.d.ts +190 -0
- package/dist-lib/scripting/lua/bindings/automation.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/commandLine.d.ts +11 -0
- package/dist-lib/scripting/lua/bindings/context.d.ts +87 -0
- package/dist-lib/scripting/lua/bindings/cursor.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/diagnostics.d.ts +9 -0
- package/dist-lib/scripting/lua/bindings/map.d.ts +14 -0
- package/dist-lib/scripting/lua/bindings/media.d.ts +24 -0
- package/dist-lib/scripting/lua/bindings/output.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/packages.d.ts +10 -0
- package/dist-lib/scripting/lua/bindings/session.d.ts +16 -0
- package/dist-lib/scripting/lua/bindings/textEdit.d.ts +9 -0
- package/dist-lib/scripting/lua/bindings/userWindows.d.ts +11 -0
- package/dist-lib/scripting/lua/bindings/window.d.ts +10 -0
- package/dist-lib/scripting/lua/imageSize.d.ts +4 -0
- package/dist-lib/scripting/lua/luaCompletions.d.ts +9 -0
- package/dist-lib/scripting/lua/mudlet-lua/generic-mapper/generic_mapper.mpackage +0 -0
- package/dist-lib/scripting/lua/rex.d.ts +3 -0
- package/dist-lib/scripting/lua/sqlRowEncoder.d.ts +1 -0
- package/dist-lib/scripting/lua/yajl.d.ts +11 -0
- package/dist-lib/scripting/profilesPresence.d.ts +50 -0
- package/dist-lib/scripting/vfs/ProfileVFS.d.ts +62 -0
- package/dist-lib/scripting/vfs/cssRewrite.d.ts +21 -0
- package/dist-lib/scripting/vfs/folderHandleStore.d.ts +16 -0
- package/dist-lib/scripting/vfs/folderSync.d.ts +59 -0
- package/dist-lib/scripting/vfs/htmlRewrite.d.ts +26 -0
- package/dist-lib/scripting/vfs/vfsBridge.d.ts +16 -0
- package/dist-lib/services/cloudflare.d.ts +54 -0
- package/dist-lib/storage/appStore.d.ts +132 -0
- package/dist-lib/storage/crossTabSync.d.ts +3 -0
- package/dist-lib/storage/debouncedStorage.d.ts +18 -0
- package/dist-lib/storage/hooks.d.ts +17 -0
- package/dist-lib/storage/index.d.ts +4 -0
- package/dist-lib/storage/logExport.d.ts +32 -0
- package/dist-lib/storage/logStorage.d.ts +45 -0
- package/dist-lib/storage/mapStorage.d.ts +2 -0
- package/dist-lib/storage/profileVfsData.d.ts +47 -0
- package/dist-lib/storage/schema.d.ts +638 -0
- package/dist-lib/styles.css +2 -0
- package/dist-lib/ui/AboutModal.d.ts +8 -0
- package/dist-lib/ui/BrandLoginFields.d.ts +25 -0
- package/dist-lib/ui/BrandLoginScreen.d.ts +11 -0
- package/dist-lib/ui/CharLoginModal.d.ts +32 -0
- package/dist-lib/ui/CmdLineMenuRegistry.d.ts +27 -0
- package/dist-lib/ui/CodeEditorPreview.d.ts +19 -0
- package/dist-lib/ui/CommandBar.d.ts +17 -0
- package/dist-lib/ui/ConnectionFormModal.d.ts +13 -0
- package/dist-lib/ui/ConnectionGrid.d.ts +18 -0
- package/dist-lib/ui/ConnectionScreen.d.ts +14 -0
- package/dist-lib/ui/FileBrowserModal.d.ts +20 -0
- package/dist-lib/ui/FilePickerModal.d.ts +21 -0
- package/dist-lib/ui/FolderPermissionScreen.d.ts +16 -0
- package/dist-lib/ui/JsonPreview.d.ts +15 -0
- package/dist-lib/ui/LogBrowserModal.d.ts +7 -0
- package/dist-lib/ui/MapEditorModal.d.ts +9 -0
- package/dist-lib/ui/MarkdownPreview.d.ts +15 -0
- package/dist-lib/ui/MergeConflictModal.d.ts +17 -0
- package/dist-lib/ui/ModuleResolveModal.d.ts +22 -0
- package/dist-lib/ui/MouseEventRegistry.d.ts +31 -0
- package/dist-lib/ui/ProfileBusyScreen.d.ts +12 -0
- package/dist-lib/ui/ProfileExportModal.d.ts +7 -0
- package/dist-lib/ui/ProxyInfoModal.d.ts +6 -0
- package/dist-lib/ui/ProxyWhyModal.d.ts +6 -0
- package/dist-lib/ui/ProxyWizardModal.d.ts +6 -0
- package/dist-lib/ui/QuickOpenPalette.d.ts +8 -0
- package/dist-lib/ui/ResizableModal.d.ts +17 -0
- package/dist-lib/ui/ScriptingDocsModal.d.ts +12 -0
- package/dist-lib/ui/SettingsModal.d.ts +9 -0
- package/dist-lib/ui/Toolbar.d.ts +29 -0
- package/dist-lib/ui/bufferWords.d.ts +38 -0
- package/dist-lib/ui/buttons/ButtonsBar.d.ts +21 -0
- package/dist-lib/ui/cmdline/CommandLineManager.d.ts +97 -0
- package/dist-lib/ui/cmdline/CommandLineOverlay.d.ts +8 -0
- package/dist-lib/ui/codemirror/theme.d.ts +5 -0
- package/dist-lib/ui/commandHistory.d.ts +31 -0
- package/dist-lib/ui/components/Button.d.ts +9 -0
- package/dist-lib/ui/components/ConfirmDialog.d.ts +29 -0
- package/dist-lib/ui/components/ContextMenu.d.ts +9 -0
- package/dist-lib/ui/components/FontPicker.d.ts +9 -0
- package/dist-lib/ui/components/FormField.d.ts +16 -0
- package/dist-lib/ui/components/HelpTip.d.ts +7 -0
- package/dist-lib/ui/components/Input.d.ts +6 -0
- package/dist-lib/ui/components/Toggle.d.ts +10 -0
- package/dist-lib/ui/components/index.d.ts +9 -0
- package/dist-lib/ui/components/useModalFocus.d.ts +18 -0
- package/dist-lib/ui/labels/LabelManager.d.ts +220 -0
- package/dist-lib/ui/labels/LabelOverlay.d.ts +9 -0
- package/dist-lib/ui/labels/backgroundImageSize.d.ts +10 -0
- package/dist-lib/ui/labels/cursorShapes.d.ts +6 -0
- package/dist-lib/ui/labels/gifMovie.d.ts +100 -0
- package/dist-lib/ui/labels/qtCss.d.ts +57 -0
- package/dist-lib/ui/layout/ContentLayout.d.ts +19 -0
- package/dist-lib/ui/layout/DockArea.d.ts +14 -0
- package/dist-lib/ui/layout/DockedPanel.d.ts +13 -0
- package/dist-lib/ui/layout/FloatingWindowLayer.d.ts +10 -0
- package/dist-lib/ui/layout/MobileLayout.d.ts +22 -0
- package/dist-lib/ui/layout/PopoutWindow.d.ts +35 -0
- package/dist-lib/ui/layout/ScriptWindow.d.ts +29 -0
- package/dist-lib/ui/layout/SplitGroupPanel.d.ts +17 -0
- package/dist-lib/ui/layout/TabGroupPanel.d.ts +12 -0
- package/dist-lib/ui/layout/WindowContextMenu.d.ts +11 -0
- package/dist-lib/ui/layout/dockDetect.d.ts +26 -0
- package/dist-lib/ui/layout/overlayLayerOrder.d.ts +71 -0
- package/dist-lib/ui/markdown.d.ts +1 -0
- package/dist-lib/ui/output/CaretReviewPanel.d.ts +22 -0
- package/dist-lib/ui/output/OutputArea.d.ts +9 -0
- package/dist-lib/ui/output/OutputContextMenu.d.ts +23 -0
- package/dist-lib/ui/output/OutputRenderer.d.ts +64 -0
- package/dist-lib/ui/output/ScreenReaderLog.d.ts +23 -0
- package/dist-lib/ui/output/StickyOutputPanel.d.ts +28 -0
- package/dist-lib/ui/output/backgroundImageStyle.d.ts +17 -0
- package/dist-lib/ui/output/caretMode.d.ts +40 -0
- package/dist-lib/ui/output/linkNavigation.d.ts +29 -0
- package/dist-lib/ui/output/osc8Menu.d.ts +16 -0
- package/dist-lib/ui/output/outputCopy.d.ts +15 -0
- package/dist-lib/ui/preventPinchZoom.d.ts +1 -0
- package/dist-lib/ui/scrollbox/ScrollBoxManager.d.ts +62 -0
- package/dist-lib/ui/scrollbox/ScrollBoxOverlay.d.ts +25 -0
- package/dist-lib/ui/sound/SoundManager.d.ts +149 -0
- package/dist-lib/ui/sound/closedCaption.d.ts +37 -0
- package/dist-lib/ui/textedit/TextEditManager.d.ts +56 -0
- package/dist-lib/ui/tts/TtsManager.d.ts +68 -0
- package/dist-lib/ui/useBrandLogin.d.ts +19 -0
- package/dist-lib/ui/useCommandHistory.d.ts +7 -0
- package/dist-lib/ui/video/VideoManager.d.ts +56 -0
- package/dist-lib/ui/windows/ScriptEditorModal.d.ts +13 -0
- package/dist-lib/ui/windows/WindowManager.d.ts +694 -0
- package/dist-lib/ui/windows/panels/HtmlPanel.d.ts +27 -0
- package/dist-lib/ui/windows/panels/LuaEditor.d.ts +14 -0
- package/dist-lib/ui/windows/panels/MapPanel.d.ts +8 -0
- package/dist-lib/ui/windows/panels/PackageRepositoryModal.d.ts +18 -0
- package/dist-lib/ui/windows/panels/ScriptEditorPanel.d.ts +24 -0
- package/dist-lib/ui/windows/panels/ScriptSearch.d.ts +12 -0
- package/dist-lib/ui/windows/panels/TextPanel.d.ts +35 -0
- package/dist-lib/ui/windows/panels/VariablesView.d.ts +21 -0
- package/dist-lib/ui/windows/panels/VfsModulePickerModal.d.ts +8 -0
- package/dist-lib/ui/windows/panels/WindowCmdLine.d.ts +23 -0
- package/dist-lib/ui/windows/types.d.ts +145 -0
- package/dist-lib/utils/documentTitle.d.ts +33 -0
- package/dist-lib/utils/fontLoader.d.ts +52 -0
- package/dist-lib/utils/profileLock.d.ts +26 -0
- package/dist-lib/utils/sessionCredentials.d.ts +16 -0
- package/dist-lib/version.d.ts +39 -0
- package/dist-lib/vfs-sw.js +131 -0
- package/dist-lib/vite.d.ts +2 -0
- package/dist-lib/vite.js +154 -0
- package/package.json +93 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { AnsiAwareBuffer } from './text/FormatState';
|
|
2
|
+
import type { MspCommand } from './protocol';
|
|
3
|
+
import type { ScriptLogSource } from './MudSession';
|
|
4
|
+
export type SessionStatus = 'disconnected' | 'connecting' | 'connected';
|
|
5
|
+
/** A pending Mudlet `invokeFileDialog(...)` request. The Lua handler that
|
|
6
|
+
* called it is suspended (parked coroutine) until `onPick` fires, so the UI
|
|
7
|
+
* must always resolve it eventually — pass the picked VFS path, or '' for
|
|
8
|
+
* cancel (Mudlet returns '' when the native dialog is dismissed too). */
|
|
9
|
+
export interface FileDialogRequest {
|
|
10
|
+
/** What the script asked to pick: a file or a directory. */
|
|
11
|
+
mode: 'file' | 'folder';
|
|
12
|
+
/** Dialog title supplied by the script (may be ''). */
|
|
13
|
+
title: string;
|
|
14
|
+
/** VFS path to start browsing at; '' means the profile root. */
|
|
15
|
+
location: string;
|
|
16
|
+
/** Resolve the dialog. Must be called exactly once. */
|
|
17
|
+
onPick: (path: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export type MudClientEvents = {
|
|
20
|
+
'open': [event: Event];
|
|
21
|
+
'close': [event: CloseEvent];
|
|
22
|
+
'error': [error: unknown];
|
|
23
|
+
'client.connect': void;
|
|
24
|
+
'client.disconnect': void;
|
|
25
|
+
'client.error': [message: string];
|
|
26
|
+
/** The WebSocket subprotocol the server selected from our advertised list
|
|
27
|
+
* (RFC 6455), or '' if none — only emitted when we advertised any. */
|
|
28
|
+
'client.subprotocol': [protocol: string];
|
|
29
|
+
'gmcp.negotiated': void;
|
|
30
|
+
'msdp.negotiated': void;
|
|
31
|
+
'mssp.negotiated': void;
|
|
32
|
+
'msp.negotiated': void;
|
|
33
|
+
/** Fires when MNES / NEW-ENVIRON (telnet option 39) negotiation starts — the
|
|
34
|
+
* server sent IAC DO NEW-ENVIRON and the client agreed (IAC WILL). The
|
|
35
|
+
* client then answers the server's SEND request with its environment
|
|
36
|
+
* variables. The payload names the active mode — `'MNES'` (restricted core
|
|
37
|
+
* set) or `'NEW-ENVIRON'` (extended capability set) — so scripts can hook
|
|
38
|
+
* the right `sysProtocolEnabled` name. */
|
|
39
|
+
'mnes.negotiated': string;
|
|
40
|
+
/** Fires when NAWS (telnet option 31) negotiation completes — the client
|
|
41
|
+
* offered IAC WILL NAWS and the server replied IAC DO NAWS. From then on
|
|
42
|
+
* the client reports the main output area's character grid (columns × rows)
|
|
43
|
+
* and re-sends it whenever the window resizes. */
|
|
44
|
+
'naws.negotiated': void;
|
|
45
|
+
/** Fires when MXP (telnet option 91) starts for the session. The scripting
|
|
46
|
+
* engine flips its `mxpActive` flag on this so in-band MXP markup starts
|
|
47
|
+
* being parsed, and mirrors Mudlet's `sysProtocolEnabled('MXP')`.
|
|
48
|
+
* `viaTelnet` is true when started by a real option-91 handshake (server
|
|
49
|
+
* WILL/DO MXP) and false when inferred from in-band `ESC[<n>z` line modes
|
|
50
|
+
* on a server that skipped negotiation. Only telnet-negotiated MXP gets the
|
|
51
|
+
* `<SUPPORTS>`/`<VERSION>` handshake replies — an in-band-only server's
|
|
52
|
+
* inbound MXP channel isn't confirmed, so replying would spam it with
|
|
53
|
+
* invalid commands. */
|
|
54
|
+
'mxp.negotiated': [viaTelnet: boolean];
|
|
55
|
+
/** Fired for every `!!SOUND` / `!!MUSIC` tag parsed from the in-band text
|
|
56
|
+
* stream (or an `IAC SB MSP ... IAC SE` subnegotiation body). The
|
|
57
|
+
* scripting engine wires this to the SoundManager. */
|
|
58
|
+
'msp': [command: MspCommand];
|
|
59
|
+
/** Fires when a CHARSET (RFC 2066) negotiation completes — either the
|
|
60
|
+
* server's REQUEST was ACCEPTED or our advertised REQUEST was ACCEPTED.
|
|
61
|
+
* Argument is the IANA charset name as agreed (the wire spelling, e.g.
|
|
62
|
+
* "UTF-8"). */
|
|
63
|
+
'charset.negotiated': [encoding: string];
|
|
64
|
+
'socket.incoming': [data: string];
|
|
65
|
+
'socket.outgoing': [data: string];
|
|
66
|
+
'message': [text?: string | AnsiAwareBuffer, type?: string, timestamp?: number, isPrompt?: boolean];
|
|
67
|
+
'flushLines': [groups: {
|
|
68
|
+
text: string;
|
|
69
|
+
type: string;
|
|
70
|
+
}[]];
|
|
71
|
+
'gmcp': [payload: {
|
|
72
|
+
path: string;
|
|
73
|
+
value: unknown;
|
|
74
|
+
}];
|
|
75
|
+
/** A `Client.GUI` server package-install request, in either wire format:
|
|
76
|
+
* the parsed `{url, version}` object, or the legacy raw `<version>\n<url>`
|
|
77
|
+
* string. Carried separately from `gmcp` because the legacy form never
|
|
78
|
+
* becomes a GMCP table entry — decoding both shapes is the install
|
|
79
|
+
* handler's job (parseClientGuiPayload), not this bus's. */
|
|
80
|
+
'clientGui': [payload: unknown];
|
|
81
|
+
'msdp': [payload: {
|
|
82
|
+
path: string;
|
|
83
|
+
value: unknown;
|
|
84
|
+
}];
|
|
85
|
+
'mssp': [payload: {
|
|
86
|
+
name: string;
|
|
87
|
+
value: string;
|
|
88
|
+
}];
|
|
89
|
+
'gmcp.core.ping': [value: unknown];
|
|
90
|
+
/** Fires when the server requests GMCP login (Char.Login.Default). The
|
|
91
|
+
* argument is the list of supported authentication methods it advertised
|
|
92
|
+
* (e.g. `["password-credentials"]`). The UI shows a credentials popup and
|
|
93
|
+
* replies via `sendCharLoginCredentials` — or an empty reply (cancel) to
|
|
94
|
+
* fall back to the server's text login prompt. */
|
|
95
|
+
'charLogin.request': [methods: string[]];
|
|
96
|
+
/** Fires when the server reports a GMCP login outcome (Char.Login.Result).
|
|
97
|
+
* `success` is true on a successful authentication; on failure `message`
|
|
98
|
+
* carries the server's human-readable reason (e.g. "Invalid credentials"). */
|
|
99
|
+
'charLogin.result': [result: {
|
|
100
|
+
success: boolean;
|
|
101
|
+
message?: string;
|
|
102
|
+
}];
|
|
103
|
+
/** Fires when the command input should switch in/out of password masking.
|
|
104
|
+
* True only for a genuine password prompt (server enabled ECHO *after* it
|
|
105
|
+
* began sending output); a connect-time server-wide ECHO suppresses local
|
|
106
|
+
* echo without masking, so it does not raise this with `true`. */
|
|
107
|
+
'telnet.echo': [maskInput: boolean];
|
|
108
|
+
/** Mirror of Mudlet's `sysEchoAnomalyDetected`. Fires once per session when
|
|
109
|
+
* the server toggles `IAC WILL/WONT ECHO` ≥5 times within 5 s; at that
|
|
110
|
+
* point the client sends `IAC DONT ECHO` and refuses any further ECHO
|
|
111
|
+
* negotiation for the rest of the connection. */
|
|
112
|
+
'telnet.echo.anomaly': void;
|
|
113
|
+
/** Mudlet `sysTelnetEvent(type, option, message)` — fired for telnet
|
|
114
|
+
* IAC commands the client doesn't natively recognise (everything other
|
|
115
|
+
* than the hardcoded GMCP/MSDP/TTYPE/MCCP/ECHO negotiations). */
|
|
116
|
+
'telnet.event': [type: number, option: number, message: string];
|
|
117
|
+
/** Mudlet `raiseProtocolEvent("sysProtocolRejected", name)` — a telnet
|
|
118
|
+
* option mudix deliberately refuses. mudix, like Mudlet, operates in line
|
|
119
|
+
* mode only, so it rejects SUPPRESS_GO_AHEAD (option 3) and LINEMODE
|
|
120
|
+
* (option 34) rather than let the server switch it into character-at-a-
|
|
121
|
+
* time / server-driven line editing. The payload is the protocol name
|
|
122
|
+
* (`'SUPPRESS_GO_AHEAD'` or `'LINEMODE'`). */
|
|
123
|
+
'protocol.rejected': [protocol: string];
|
|
124
|
+
/** Mudlet `sysCharacterModeDetected`. Fires once per connection when the
|
|
125
|
+
* server has both asked to suppress go-ahead (IAC WILL SGA) *and* enabled
|
|
126
|
+
* server-side echo — the classic character-at-a-time signature that mudix,
|
|
127
|
+
* a line-based client, can't drive well. Lets scripts / the UI warn the
|
|
128
|
+
* user that input may not behave as expected. */
|
|
129
|
+
'charmode.detected': void;
|
|
130
|
+
} & Record<string, any>;
|
|
131
|
+
export type MudEvents = MudClientEvents & {
|
|
132
|
+
'status': [status: SessionStatus];
|
|
133
|
+
'ping': [duration: number | null];
|
|
134
|
+
'script.log': [text: string, level: 'error' | 'info', source?: ScriptLogSource];
|
|
135
|
+
'output.ready': void;
|
|
136
|
+
'script.deleteline': void;
|
|
137
|
+
'script.clearwindow': void;
|
|
138
|
+
'script.appendcmd': [text: string];
|
|
139
|
+
'script.setcmd': [text: string];
|
|
140
|
+
'script.clearcmd': void;
|
|
141
|
+
'script.selectcmd': void;
|
|
142
|
+
'script.cmdlinesuggestions': [items: string[]];
|
|
143
|
+
'script.openvfs': [path: string];
|
|
144
|
+
/** Fired by ScriptingAPI when Lua calls `invokeFileDialog(...)`. The UI
|
|
145
|
+
* (ProfileSession) shows the in-app VFS picker and resolves the request
|
|
146
|
+
* via `request.onPick`. See {@link FileDialogRequest}. */
|
|
147
|
+
'script.filedialog': [request: FileDialogRequest];
|
|
148
|
+
'prompt': void;
|
|
149
|
+
'script.movecursorup': void;
|
|
150
|
+
'script.movecursordown': void;
|
|
151
|
+
/** A Mudlet-format replay started playing. Payload is the recording's
|
|
152
|
+
* total duration in milliseconds (sum of chunk offsets, at 1× speed). */
|
|
153
|
+
'replay.start': [durationMs: number];
|
|
154
|
+
/** The active replay finished or was aborted. */
|
|
155
|
+
'replay.over': void;
|
|
156
|
+
/** Replay recording was toggled on/off (the toolbar Record button state). */
|
|
157
|
+
'replay.recording': [recording: boolean];
|
|
158
|
+
/** The replay playback speed divisor changed (1..1024). */
|
|
159
|
+
'replay.speed': [speed: number];
|
|
160
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { KeyNode } from '../../storage/schema';
|
|
2
|
+
export type { KeyNode };
|
|
3
|
+
type TempFn = () => void;
|
|
4
|
+
/** Mudlet getKeyCode() result — a Qt::Key integer + Qt::KeyboardModifier mask. */
|
|
5
|
+
export interface KeyCodeInfo {
|
|
6
|
+
keyCode: number;
|
|
7
|
+
modifiers: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class KeyEngine {
|
|
10
|
+
private readonly temp;
|
|
11
|
+
private perm;
|
|
12
|
+
private nextId;
|
|
13
|
+
/** Number of live session-scoped temp keys (Mudlet `getProfileStats` temp count). */
|
|
14
|
+
get tempCount(): number;
|
|
15
|
+
addTemp(key: string, modifiers: string[], fn: TempFn, qt?: {
|
|
16
|
+
keyCode: number;
|
|
17
|
+
modifier: number;
|
|
18
|
+
}): number;
|
|
19
|
+
/** Whether a temp key with this id is live — backs exists(id, "key"). */
|
|
20
|
+
hasTemp(id: number): boolean;
|
|
21
|
+
/** Whether a live temp key is enabled — backs isActive(id, "key"). */
|
|
22
|
+
isTempEnabled(id: number): boolean;
|
|
23
|
+
/** enableKey/disableKey with a numeric id. False when no temp key matches. */
|
|
24
|
+
setTempEnabled(id: number, enabled: boolean): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Mudlet getKeyCode(idOrName) lookup. A numeric id resolves a temp key; a
|
|
27
|
+
* string resolves a permanent key by name. Returns the Qt key code + modifier
|
|
28
|
+
* mask, or null when nothing matches (caller turns that into nil + errMsg).
|
|
29
|
+
*/
|
|
30
|
+
getKeyCode(idOrName: number | string): KeyCodeInfo | null;
|
|
31
|
+
killKey(id: number): boolean;
|
|
32
|
+
processTemp(event: KeyboardEvent): boolean;
|
|
33
|
+
loadPerm(keybindings: KeyNode[]): void;
|
|
34
|
+
matchPerm(event: KeyboardEvent): KeyNode | null;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some keyboard shortcuts are owned by the browser (or the OS) and are handled
|
|
3
|
+
* *above* the web page — Ctrl+T opens a new tab, Ctrl+W closes it, F12 opens
|
|
4
|
+
* devtools. The page never receives the keydown (or can't suppress it), so a MUD
|
|
5
|
+
* keybinding on one of these can never fire in mudix.
|
|
6
|
+
*
|
|
7
|
+
* Real Mudlet runs natively and binds these freely; opened in a browser they
|
|
8
|
+
* silently do nothing, which is baffling. We scan the loaded keybindings on
|
|
9
|
+
* profile open (and temp keys as scripts register them) and warn about the ones
|
|
10
|
+
* the browser intercepts.
|
|
11
|
+
*
|
|
12
|
+
* We deliberately do NOT warn about page-level shortcuts the browser owns but a
|
|
13
|
+
* page can still capture with preventDefault — Ctrl+R (reload), Ctrl+S (save),
|
|
14
|
+
* Ctrl+P (print), Ctrl+F (find), F5, Ctrl+L, etc. mudix intercepts those, so they
|
|
15
|
+
* work exactly like they do in Mudlet: while the client has keyboard focus.
|
|
16
|
+
*
|
|
17
|
+
* Keys are stored as DOM `KeyboardEvent.code` strings (see {@link KeyNode}), so we
|
|
18
|
+
* match against codes like `KeyT`, `Digit1`, `F12`.
|
|
19
|
+
*/
|
|
20
|
+
import type { KeyNode } from '../../storage/schema';
|
|
21
|
+
export interface ReservedKeyWarning {
|
|
22
|
+
node: KeyNode;
|
|
23
|
+
combo: string;
|
|
24
|
+
action: string;
|
|
25
|
+
}
|
|
26
|
+
/** Platform accelerator — browser shortcuts use Cmd (meta) on macOS, Ctrl elsewhere. */
|
|
27
|
+
export type Accel = 'ctrl' | 'meta';
|
|
28
|
+
/** Detect the platform accelerator modifier. Falls back to Ctrl off-browser (tests). */
|
|
29
|
+
export declare function detectAccel(): Accel;
|
|
30
|
+
/** Render a keybinding as a display combo like "Ctrl+Shift+I". */
|
|
31
|
+
export declare function formatKeyCombo(node: Pick<KeyNode, 'key' | 'modifiers'>): string;
|
|
32
|
+
/** Explanation appended to each warning line. */
|
|
33
|
+
export declare function reservedKeyNote(action: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Classify a single keybinding against the browser-reserved set. Returns the
|
|
36
|
+
* browser action it collides with, or null when the combo is safe to bind.
|
|
37
|
+
*/
|
|
38
|
+
export declare function classifyReservedKey(node: Pick<KeyNode, 'key' | 'modifiers'>, accel?: Accel): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Scan a list of keybindings and return a warning for each one the browser
|
|
41
|
+
* intercepts. Group nodes and keyless nodes are skipped; the caller is expected
|
|
42
|
+
* to pass the effectively-enabled bindings (disabled binds never fire, so
|
|
43
|
+
* warning about them would be noise).
|
|
44
|
+
*/
|
|
45
|
+
export declare function findReservedKeybindings(keys: KeyNode[], accel?: Accel): ReservedKeyWarning[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Qt::KeypadModifier — set by Mudlet when a binding came from the numpad. */
|
|
2
|
+
export declare const QT_KEYPAD_MODIFIER = 536870912;
|
|
3
|
+
/**
|
|
4
|
+
* Translate a Qt::Key integer (or already-translated DOM `KeyboardEvent.code`
|
|
5
|
+
* string) into a DOM `KeyboardEvent.code`. Mudlet `tempKey` accepts both;
|
|
6
|
+
* passing a string straight through lets users pre-resolve when they prefer.
|
|
7
|
+
*
|
|
8
|
+
* When `modifier` includes Qt::KeypadModifier, digit and symbol codes resolve
|
|
9
|
+
* to their Numpad* DOM variants — DOM `KeyboardEvent.code` distinguishes
|
|
10
|
+
* numpad keys from the main keyboard while Qt::Key alone does not.
|
|
11
|
+
*/
|
|
12
|
+
export declare function qtKeyToDomCode(key: string | number, modifier?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Translate a Qt::KeyboardModifier bitmask into an array of modifier names
|
|
15
|
+
* that match the {ctrl,shift,alt,meta} strings KeyEngine compares against.
|
|
16
|
+
*
|
|
17
|
+
* Qt::ShiftModifier = 0x02000000
|
|
18
|
+
* Qt::ControlModifier = 0x04000000
|
|
19
|
+
* Qt::AltModifier = 0x08000000
|
|
20
|
+
* Qt::MetaModifier = 0x10000000
|
|
21
|
+
* Qt::KeypadModifier = 0x20000000 (ignored — DOM `code` already encodes "Numpad*")
|
|
22
|
+
* Qt::GroupSwitchMod. = 0x40000000 (ignored — X11-only)
|
|
23
|
+
*/
|
|
24
|
+
export declare function qtModifiersToList(modifier: number): string[];
|
|
25
|
+
/** Inverse of qtModifiersToList — {ctrl,shift,alt,meta} names → Qt bitmask. */
|
|
26
|
+
export declare function listToQtModifiers(modifiers: string[]): number;
|
|
27
|
+
/**
|
|
28
|
+
* Inverse of qtKeyToDomCode for the common case — a DOM `KeyboardEvent.code`
|
|
29
|
+
* back to a Qt::Key integer. Used by getKeyCode() to report a permanent key
|
|
30
|
+
* binding (stored as a DOM code) in Mudlet's Qt terms. Returns undefined for a
|
|
31
|
+
* code with no Qt mapping.
|
|
32
|
+
*/
|
|
33
|
+
export declare function domCodeToQtKey(code: string): number | undefined;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CHARSET (RFC 2066, telnet option 42) negotiation and the session's byte→char
|
|
3
|
+
* codec. The `SessionCodec` owns the streaming inbound decoder and the outgoing
|
|
4
|
+
* encoding; the `CharsetHandler` drives the REQUEST/ACCEPTED/REJECTED exchange
|
|
5
|
+
* against it. Extracted from MudClient so the wire protocol lives alongside the
|
|
6
|
+
* other per-option modules in `src/mud/protocol/`.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Map a wire-format charset name (case-insensitive, with various dash/underscore
|
|
10
|
+
* spellings) onto an IANA label that `TextDecoder` accepts. Returns null for
|
|
11
|
+
* encodings we don't support — most legacy MUD codepages aren't reachable from
|
|
12
|
+
* the browser TextDecoder API and would need a polyfill not worth shipping.
|
|
13
|
+
*
|
|
14
|
+
* Coverage is deliberately narrow: UTF-8 (the universal modern answer), the
|
|
15
|
+
* Latin-N family, the Cyrillic KOI8 variants, and the Windows-125x codepages.
|
|
16
|
+
* That covers every Polish, Russian, and Western European MUD seen in practice.
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeCharsetName(raw: string): string | null;
|
|
19
|
+
/** Wire-format names of every charset mudix can decode, surfaced to Lua scripts
|
|
20
|
+
* via `getServerEncodingsList()`. Every entry round-trips through
|
|
21
|
+
* {@link normalizeCharsetName}, so any name here is a valid `setServerEncoding`
|
|
22
|
+
* argument. ("ASCII" maps to the UTF-8 decoder, which handles it byte-for-byte.) */
|
|
23
|
+
export declare const SUPPORTED_SERVER_ENCODINGS: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* Parse an `IAC SB CHARSET REQUEST ...` subnegotiation body (leading byte is
|
|
26
|
+
* the option code 42, then subcommand byte 1, then optional `[TTABLE]<ver>`
|
|
27
|
+
* prefix, then a separator byte, then separator-delimited IANA names). Returns
|
|
28
|
+
* the best match against {@link CHARSET_PRIORITY} with both the original wire
|
|
29
|
+
* spelling (echoed back in the ACCEPTED reply per RFC 2066) and the normalized
|
|
30
|
+
* IANA label suitable for `new TextDecoder(...)`. Returns null if no offered
|
|
31
|
+
* name is supported.
|
|
32
|
+
*/
|
|
33
|
+
export declare function pickCharsetFromRequest(subneg: string): {
|
|
34
|
+
original: string;
|
|
35
|
+
normalized: string;
|
|
36
|
+
} | null;
|
|
37
|
+
/**
|
|
38
|
+
* The session's byte→char codec. Owns the streaming inbound `TextDecoder`
|
|
39
|
+
* (holding trailing partial multi-byte chars across WebSocket frames) and the
|
|
40
|
+
* matching outgoing encoding. Starts at UTF-8 — correct for ASCII and modern
|
|
41
|
+
* MUDs — and switches when a CHARSET exchange (or an explicit
|
|
42
|
+
* `setServerEncoding`) agrees on something else.
|
|
43
|
+
*/
|
|
44
|
+
export declare class SessionCodec {
|
|
45
|
+
private decoder;
|
|
46
|
+
private currentEncoding;
|
|
47
|
+
/** The IANA name of the decoder currently applied to the inbound stream. */
|
|
48
|
+
get encoding(): string;
|
|
49
|
+
/** Back to the UTF-8 baseline with a fresh decoder (call on connect). */
|
|
50
|
+
reset(): void;
|
|
51
|
+
/** Swap the streaming decoder to a new encoding label (an IANA name the
|
|
52
|
+
* TextDecoder constructor accepts: 'utf-8', 'iso-8859-2', ...). Any partial
|
|
53
|
+
* multi-byte sequence buffered in the previous decoder is discarded —
|
|
54
|
+
* fine because CHARSET typically negotiates before any real content
|
|
55
|
+
* arrives. Returns false (leaving the current decoder untouched) when the
|
|
56
|
+
* browser refuses the label. */
|
|
57
|
+
trySetEncoding(encoding: string): boolean;
|
|
58
|
+
/** Converts a Latin-1 byte-string into decoded text under the current
|
|
59
|
+
* encoding, buffering any trailing partial multi-byte sequence for the
|
|
60
|
+
* next frame. */
|
|
61
|
+
decode(byteString: string): string;
|
|
62
|
+
/** Convert a user-typed JS string (UTF-16) into the Latin-1 byte-string the
|
|
63
|
+
* socket layer expects, using the currently negotiated outgoing encoding.
|
|
64
|
+
* For UTF-8 we run it through TextEncoder so multi-byte chars survive;
|
|
65
|
+
* for other encodings we fall back to a per-char `& 0xff` truncation,
|
|
66
|
+
* which is lossless for ASCII and acceptable for Latin-1-family inputs.
|
|
67
|
+
* TextEncoder has no API for non-UTF-8 outputs, so a full per-encoding
|
|
68
|
+
* outbound table isn't worth the bytes given how rare non-UTF-8 MUDs are. */
|
|
69
|
+
encodeOutgoing(text: string): string;
|
|
70
|
+
}
|
|
71
|
+
export interface CharsetHandlerHooks {
|
|
72
|
+
sendRaw(data: string): void;
|
|
73
|
+
/** Fired when an encoding switch takes effect. The argument is the
|
|
74
|
+
* wire-spelling name (e.g. "UTF-8") so listeners can surface it. */
|
|
75
|
+
onNegotiated(displayName: string): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Drives the CHARSET REQUEST/ACCEPTED/REJECTED exchange against a
|
|
79
|
+
* {@link SessionCodec}. Negotiation methods are gated on `enabled` (the
|
|
80
|
+
* per-profile CHARSET toggle); `setServerEncoding` is not — it's the explicit
|
|
81
|
+
* Mudlet API call, honored regardless.
|
|
82
|
+
*/
|
|
83
|
+
export declare class CharsetHandler {
|
|
84
|
+
private readonly codec;
|
|
85
|
+
private readonly enabled;
|
|
86
|
+
private readonly hooks;
|
|
87
|
+
constructor(codec: SessionCodec, enabled: boolean, hooks: CharsetHandlerHooks);
|
|
88
|
+
/** Send `IAC SB CHARSET REQUEST ;UTF-8;ISO-8859-2;ISO-8859-1 IAC SE` —
|
|
89
|
+
* advertising the encodings we can decode, in preference order. Each name
|
|
90
|
+
* is prefixed by the separator (`;`) per RFC 2066 (the separator comes
|
|
91
|
+
* before each charset, not between them). The server replies ACCEPTED
|
|
92
|
+
* <name> or REJECTED; handleSubneg() processes either. */
|
|
93
|
+
sendRequest(): void;
|
|
94
|
+
/** Route an `IAC SB CHARSET ... IAC SE` subnegotiation body (leading byte
|
|
95
|
+
* is the option code, 42). Handles REQUEST (server lists charsets, we
|
|
96
|
+
* ACCEPT one or REJECT), ACCEPTED (server picked one of ours — switch
|
|
97
|
+
* codec), and REJECTED (server didn't like any of ours — stay put).
|
|
98
|
+
* TTABLE-* subcommands are silently ignored; almost no MUD uses them. */
|
|
99
|
+
handleSubneg(subneg: string): void;
|
|
100
|
+
/** Mudlet `setServerEncoding(name)`. Switch the inbound decoder to `name`
|
|
101
|
+
* (any value from getServerEncodingsList()). Returns false — leaving the
|
|
102
|
+
* current encoding untouched — when the name isn't one we can decode. */
|
|
103
|
+
setServerEncoding(name: string): boolean;
|
|
104
|
+
private setEncoding;
|
|
105
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export declare const TELNET_OPTION_REGEX: RegExp;
|
|
2
|
+
export declare const TELNET_GA = "\u00FF\u00F9";
|
|
3
|
+
export declare const TELNET_EOR = "\u00FF\u00EF";
|
|
4
|
+
export declare const TELOPT_EOR = "\u0019";
|
|
5
|
+
export declare const EOR_WILL = "\u00FF\u00FB\u0019";
|
|
6
|
+
export declare const EOR_DO = "\u00FF\u00FD\u0019";
|
|
7
|
+
export declare const TELOPT_SGA = "\u0003";
|
|
8
|
+
export declare const SGA_WILL = "\u00FF\u00FB\u0003";
|
|
9
|
+
export declare const SGA_DO = "\u00FF\u00FD\u0003";
|
|
10
|
+
export declare const SGA_DONT = "\u00FF\u00FE\u0003";
|
|
11
|
+
export declare const TELOPT_LINEMODE = "\"";
|
|
12
|
+
export declare const LINEMODE_WILL = "\u00FF\u00FB\"";
|
|
13
|
+
export declare const LINEMODE_DO = "\u00FF\u00FD\"";
|
|
14
|
+
export declare const LINEMODE_DONT = "\u00FF\u00FE\"";
|
|
15
|
+
export declare const LINEMODE_WONT = "\u00FF\u00FC\"";
|
|
16
|
+
export declare const GMCP_COMMAND_CODE = 201;
|
|
17
|
+
export declare const GMCP_IAC = "\u00FF";
|
|
18
|
+
export declare const GMCP_SB = "\u00FA";
|
|
19
|
+
export declare const GMCP_SE = "\u00F0";
|
|
20
|
+
export declare const MCCP2_OPTION = 86;
|
|
21
|
+
export declare const MSDP_COMMAND_CODE = 69;
|
|
22
|
+
export declare const OPT_MSDP = "E";
|
|
23
|
+
export declare const MSDP_VAR = "\u0001";
|
|
24
|
+
export declare const MSDP_VAL = "\u0002";
|
|
25
|
+
export declare const MSDP_TABLE_OPEN = "\u0003";
|
|
26
|
+
export declare const MSDP_TABLE_CLOSE = "\u0004";
|
|
27
|
+
export declare const MSDP_ARRAY_OPEN = "\u0005";
|
|
28
|
+
export declare const MSDP_ARRAY_CLOSE = "\u0006";
|
|
29
|
+
export declare const MSDP_WILL = "\u00FF\u00FBE";
|
|
30
|
+
export declare const MSDP_DO = "\u00FF\u00FDE";
|
|
31
|
+
export declare const MSSP_COMMAND_CODE = 70;
|
|
32
|
+
export declare const OPT_MSSP = "F";
|
|
33
|
+
export declare const MSSP_VAR = "\u0001";
|
|
34
|
+
export declare const MSSP_VAL = "\u0002";
|
|
35
|
+
export declare const MSSP_WILL = "\u00FF\u00FBF";
|
|
36
|
+
export declare const MSSP_DO = "\u00FF\u00FDF";
|
|
37
|
+
export declare const GMCP_WILL = "\u00FF\u00FB\u00C9";
|
|
38
|
+
export declare const GMCP_DO = "\u00FF\u00FD\u00C9";
|
|
39
|
+
export declare const ATCP_COMMAND_CODE = 200;
|
|
40
|
+
export declare const OPT_ATCP = "\u00C8";
|
|
41
|
+
export declare const TELNET_102_COMMAND_CODE = 102;
|
|
42
|
+
export declare const OPT_TELNET_102 = "f";
|
|
43
|
+
export declare const TTYPE_COMMAND_CODE = 24;
|
|
44
|
+
export declare const OPT_TTYPE = "\u0018";
|
|
45
|
+
export declare const TTYPE_IS = "\0";
|
|
46
|
+
export declare const TTYPE_SEND = "\u0001";
|
|
47
|
+
export declare const TTYPE_DO = "\u00FF\u00FD\u0018";
|
|
48
|
+
export declare const TTYPE_WILL = "\u00FF\u00FB\u0018";
|
|
49
|
+
export declare const ECHO_WILL = "\u00FF\u00FB\u0001";
|
|
50
|
+
export declare const ECHO_WONT = "\u00FF\u00FC\u0001";
|
|
51
|
+
export declare const ECHO_DO = "\u00FF\u00FD\u0001";
|
|
52
|
+
export declare const ECHO_DONT = "\u00FF\u00FE\u0001";
|
|
53
|
+
export declare const MSP_COMMAND_CODE = 90;
|
|
54
|
+
export declare const OPT_MSP = "Z";
|
|
55
|
+
export declare const MSP_WILL = "\u00FF\u00FBZ";
|
|
56
|
+
export declare const MSP_DO = "\u00FF\u00FDZ";
|
|
57
|
+
export declare const MXP_COMMAND_CODE = 91;
|
|
58
|
+
export declare const OPT_MXP = "[";
|
|
59
|
+
export declare const MXP_WILL = "\u00FF\u00FB[";
|
|
60
|
+
export declare const MXP_DO = "\u00FF\u00FD[";
|
|
61
|
+
export declare const NEW_ENVIRON_COMMAND_CODE = 39;
|
|
62
|
+
export declare const OPT_NEW_ENVIRON = "'";
|
|
63
|
+
export declare const NEW_ENVIRON_IS = "\0";
|
|
64
|
+
export declare const NEW_ENVIRON_SEND = "\u0001";
|
|
65
|
+
export declare const NEW_ENVIRON_INFO = "\u0002";
|
|
66
|
+
export declare const NEW_ENVIRON_VAR = "\0";
|
|
67
|
+
export declare const NEW_ENVIRON_VALUE = "\u0001";
|
|
68
|
+
export declare const NEW_ENVIRON_ESC = "\u0002";
|
|
69
|
+
export declare const NEW_ENVIRON_USERVAR = "\u0003";
|
|
70
|
+
export declare const NEW_ENVIRON_DO = "\u00FF\u00FD'";
|
|
71
|
+
export declare const NEW_ENVIRON_WILL = "\u00FF\u00FB'";
|
|
72
|
+
export declare const NEW_ENVIRON_WONT = "\u00FF\u00FC'";
|
|
73
|
+
export declare const MTTS_ANSI = 1;
|
|
74
|
+
export declare const MTTS_VT100 = 2;
|
|
75
|
+
export declare const MTTS_UTF8 = 4;
|
|
76
|
+
export declare const MTTS_256_COLORS = 8;
|
|
77
|
+
export declare const MTTS_MOUSE_TRACKING = 16;
|
|
78
|
+
export declare const MTTS_OSC_COLOR_PALETTE = 32;
|
|
79
|
+
export declare const MTTS_SCREEN_READER = 64;
|
|
80
|
+
export declare const MTTS_PROXY = 128;
|
|
81
|
+
export declare const MTTS_TRUECOLOR = 256;
|
|
82
|
+
export declare const MTTS_MNES = 512;
|
|
83
|
+
export declare const MTTS_MSLP = 1024;
|
|
84
|
+
export declare const MTTS_SSL = 2048;
|
|
85
|
+
/** Live capabilities that toggle the dynamic MTTS bits. The static bits (ANSI,
|
|
86
|
+
* 256 colours, OSC colour palette, truecolour) are always on. */
|
|
87
|
+
export interface MttsCapabilities {
|
|
88
|
+
/** UTF-8 is the active encoding (sets the UTF-8 bit). */
|
|
89
|
+
utf8?: boolean;
|
|
90
|
+
/** The game-facing transport is TLS-encrypted (sets the SSL bit). */
|
|
91
|
+
tls?: boolean;
|
|
92
|
+
/** MNES is negotiated (sets the MNES bit). */
|
|
93
|
+
mnes?: boolean;
|
|
94
|
+
/** A screen reader is being advertised (sets the SCREEN READER bit). */
|
|
95
|
+
screenReader?: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Compose the MTTS bitvector mudix advertises. Mirrors Mudlet's
|
|
99
|
+
* `getNewEnvironMTTS`: ANSI + 256 COLORS + OSC COLOR PALETTE + TRUECOLOR are
|
|
100
|
+
* always present (mudix's static terminal capabilities); UTF-8, SSL/TLS, MNES
|
|
101
|
+
* and SCREEN READER are added from live state. With UTF-8 + TLS this yields
|
|
102
|
+
* 2349, matching a default Mudlet connection.
|
|
103
|
+
*/
|
|
104
|
+
export declare function computeMtts(caps?: MttsCapabilities): number;
|
|
105
|
+
export declare const NAWS_COMMAND_CODE = 31;
|
|
106
|
+
export declare const OPT_NAWS = "\u001F";
|
|
107
|
+
export declare const NAWS_WILL = "\u00FF\u00FB\u001F";
|
|
108
|
+
export declare const NAWS_DO = "\u00FF\u00FD\u001F";
|
|
109
|
+
export declare const NAWS_DONT = "\u00FF\u00FE\u001F";
|
|
110
|
+
export declare const CHARSET_COMMAND_CODE = 42;
|
|
111
|
+
export declare const OPT_CHARSET = "*";
|
|
112
|
+
export declare const CHARSET_REQUEST = "\u0001";
|
|
113
|
+
export declare const CHARSET_ACCEPTED = "\u0002";
|
|
114
|
+
export declare const CHARSET_REJECTED = "\u0003";
|
|
115
|
+
export declare const CHARSET_WILL = "\u00FF\u00FB*";
|
|
116
|
+
export declare const CHARSET_DO = "\u00FF\u00FD*";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export declare class EchoHandler {
|
|
2
|
+
/** Committed (debounced) state exposed to UI / send-echo logic. True
|
|
3
|
+
* whenever the server is echoing for us, which means we must suppress our
|
|
4
|
+
* own local command echo to avoid showing every line twice. This is *not*
|
|
5
|
+
* the same as password masking — see `_passwordStyle` / `passwordMode`. */
|
|
6
|
+
private _serverEchoing;
|
|
7
|
+
/** Latest raw on-the-wire state. Used to gate ack dedup and decide whether
|
|
8
|
+
* to schedule a commit. */
|
|
9
|
+
private _rawEchoing;
|
|
10
|
+
/** Whether the *current* ECHO engagement should mask the input line. A
|
|
11
|
+
* server that enables ECHO during the opening negotiation burst — before
|
|
12
|
+
* it has printed any output — is doing session-wide remote echo (it will
|
|
13
|
+
* echo your name, commands, everything), not requesting a password. The
|
|
14
|
+
* classic Diku/ROM password pattern instead toggles `IAC WILL ECHO` on
|
|
15
|
+
* *after* the name prompt, right before "Password:". So we only treat an
|
|
16
|
+
* ECHO that engages after the server has already sent output as a password
|
|
17
|
+
* prompt. Captured at each OFF→ON transition. Mudlet masks on every ECHO;
|
|
18
|
+
* doing so here would hide the name on full-server-echo MUDs, which is the
|
|
19
|
+
* bug this distinction fixes. */
|
|
20
|
+
private _passwordStyle;
|
|
21
|
+
/** Set once the server has emitted any non-telnet output. Distinguishes a
|
|
22
|
+
* connect-time (server-wide) ECHO from a later (password) ECHO. */
|
|
23
|
+
private sawAppData;
|
|
24
|
+
private stabilityTimer;
|
|
25
|
+
private passwordSafetyTimer;
|
|
26
|
+
private connectionStartAt;
|
|
27
|
+
private toggleCount;
|
|
28
|
+
private lastToggleAt;
|
|
29
|
+
private _anomalyDetected;
|
|
30
|
+
private readonly sendRaw;
|
|
31
|
+
private readonly onEchoChange;
|
|
32
|
+
private readonly onAnomalyDetected;
|
|
33
|
+
constructor(sendRaw: (data: string) => void, onEchoChange: (maskInput: boolean) => void, onAnomalyDetected?: () => void);
|
|
34
|
+
get serverEchoing(): boolean;
|
|
35
|
+
/** Whether the command input should be masked (password mode). Only true
|
|
36
|
+
* for an ECHO engagement that began after the server started sending
|
|
37
|
+
* output — a genuine password prompt — never for connect-time server-wide
|
|
38
|
+
* echo. */
|
|
39
|
+
get passwordMode(): boolean;
|
|
40
|
+
get anomalyDetected(): boolean;
|
|
41
|
+
/** Scan the post-MCCP byte stream for true `IAC WILL/WONT ECHO`. Substring
|
|
42
|
+
* matching on the raw buffer is unsafe — GMCP/MSDP subnegotiation payloads
|
|
43
|
+
* can contain the same byte sequence (e.g. an unescaped IAC followed by
|
|
44
|
+
* MSDP_VAR=\x01), which would spuriously flip password mode every prompt
|
|
45
|
+
* on data-heavy servers like Legend of Kallisti. Walk the stream as
|
|
46
|
+
* telnet: skip SB…SE blocks entirely, honor IAC IAC escapes, and only act
|
|
47
|
+
* on top-level IAC WILL/WONT ECHO. */
|
|
48
|
+
processData(data: string): void;
|
|
49
|
+
private setEchoing;
|
|
50
|
+
/** Arm / disarm the Mudlet-style "password mode never ended" safety
|
|
51
|
+
* timeout. Called right after a committed state change. */
|
|
52
|
+
private updatePasswordSafetyTimer;
|
|
53
|
+
/** Mirror cTelnet::checkEchoAnomalyPattern. Increments a sliding-window
|
|
54
|
+
* toggle counter on every raw flip and, when the threshold is crossed,
|
|
55
|
+
* trips sticky anomaly state. Returns true when anomaly was tripped on
|
|
56
|
+
* this call (the caller should bail out). */
|
|
57
|
+
private trackToggleAndDetectAnomaly;
|
|
58
|
+
/** Refuse ECHO for the rest of the session: send `IAC DONT ECHO`, drop any
|
|
59
|
+
* pending commit / safety timers, force the UI back to normal, and notify
|
|
60
|
+
* the engine so a `sysEchoAnomalyDetected` Lua event can fire. */
|
|
61
|
+
private tripAnomaly;
|
|
62
|
+
reset(): void;
|
|
63
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface GmcpEnvelope {
|
|
2
|
+
path: string;
|
|
3
|
+
value: unknown;
|
|
4
|
+
}
|
|
5
|
+
export type TelnetOptionHandler = (data: string) => string;
|
|
6
|
+
export declare const createTelnetOptionParser: (onSubnegotiation: (data: string) => void) => TelnetOptionHandler;
|
|
7
|
+
export declare const stripTelnetSequences: (data: string, handler: TelnetOptionHandler) => string;
|
|
8
|
+
export declare const encodeGmcp: (path: string, payload: unknown) => string;
|
|
9
|
+
/** Encode a GMCP frame from a single pre-formatted body (e.g. `"Module.Sub args"`).
|
|
10
|
+
* Matches Mudlet's `sendGMCP` semantics — the caller controls the exact bytes
|
|
11
|
+
* between IAC SB GMCP and IAC SE. */
|
|
12
|
+
export declare const encodeGmcpRaw: (message: string) => string;
|
|
13
|
+
export interface GmcpStreamOptions {
|
|
14
|
+
onEnvelope: (payload: GmcpEnvelope) => void;
|
|
15
|
+
/** Called for gmcp_msgs subnegotiations (base64-encoded text with a type field). */
|
|
16
|
+
onMessage?: (text: string, type: string) => void;
|
|
17
|
+
/** Called for every `Client.GUI` request, in whichever wire format it
|
|
18
|
+
* arrived: the parsed `{url, version}` object, or the legacy raw
|
|
19
|
+
* `<version>\n<url>` string. Split out from `onEnvelope` so the install has
|
|
20
|
+
* one entry point for both formats, and so the legacy one — which Mudlet
|
|
21
|
+
* keeps out of the Lua `gmcp` table — has somewhere to go that isn't the
|
|
22
|
+
* table-populating path. The JSON form still emits its envelope as well,
|
|
23
|
+
* and does so first, so scripts observe it before the install runs. */
|
|
24
|
+
onClientGui?: (payload: unknown) => void;
|
|
25
|
+
/** Text decoder used for gmcp_msgs payloads. Defaults to UTF-8. */
|
|
26
|
+
textEncoding?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const createGmcpStream: ({ onEnvelope, onMessage, onClientGui, textEncoding, }: GmcpStreamOptions) => (data: string) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./constants";
|
|
2
|
+
export * from "./gmcp";
|
|
3
|
+
export * from "./msdp";
|
|
4
|
+
export * from "./mssp";
|
|
5
|
+
export { MccpHandler } from "./mccp";
|
|
6
|
+
export { EchoHandler } from "./echo";
|
|
7
|
+
export { MspParser, type MspCommand, type MspKind } from "./msp";
|
|
8
|
+
export { MxpParser, splitMxpResultLines, type MxpLink, type MxpLineResult } from "./mxp";
|
|
9
|
+
export { parseMnesRequest, encodeMnesIs, selectMnesVars, buildNewEnvironVars, CLIENT_NAME, CLIENT_VERSION, TERMINAL_TYPE, type MnesVar, type MnesRequest, type NewEnvironState } from "./mnes";
|
|
10
|
+
export { encodeNaws } from "./naws";
|
|
11
|
+
export { SessionCodec, CharsetHandler, normalizeCharsetName, pickCharsetFromRequest, SUPPORTED_SERVER_ENCODINGS, type CharsetHandlerHooks } from "./charset";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class MccpHandler {
|
|
2
|
+
private compressing;
|
|
3
|
+
private inflator;
|
|
4
|
+
private readonly sendRaw;
|
|
5
|
+
private _enabled;
|
|
6
|
+
constructor(sendRaw: (data: string) => void);
|
|
7
|
+
isActive(): boolean;
|
|
8
|
+
get enabled(): boolean;
|
|
9
|
+
set enabled(value: boolean);
|
|
10
|
+
/**
|
|
11
|
+
* Process incoming data, handling MCCP negotiation and decompression.
|
|
12
|
+
* Must be called BEFORE stripTelnetSequences.
|
|
13
|
+
*/
|
|
14
|
+
processData(data: string): string;
|
|
15
|
+
reset(): void;
|
|
16
|
+
private startCompression;
|
|
17
|
+
private decompress;
|
|
18
|
+
}
|