@mudlet/mudlet-web 0.5.0 → 1.0.1

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 (301) hide show
  1. package/README.md +1 -1
  2. package/dist-lib/analytics.d.ts +27 -0
  3. package/dist-lib/assets/fonts/Vera.woff2 +0 -0
  4. package/dist-lib/assets/fonts/VeraBI.woff2 +0 -0
  5. package/dist-lib/assets/fonts/VeraBd.woff2 +0 -0
  6. package/dist-lib/assets/fonts/VeraIt.woff2 +0 -0
  7. package/dist-lib/assets/mapParser.worker-DrVZ3wg_.js +9 -0
  8. package/dist-lib/backupImport-wt8r7JXI.js +233 -0
  9. package/dist-lib/branding.d.ts +111 -13
  10. package/dist-lib/db/sqliteClient.d.ts +195 -7
  11. package/dist-lib/hooks/useAutoReconnect.d.ts +61 -0
  12. package/dist-lib/hooks/useDocumentFullscreen.d.ts +23 -0
  13. package/dist-lib/hooks/useKeyboardShortcuts.d.ts +37 -0
  14. package/dist-lib/hooks/useRecordLastPlayed.d.ts +10 -0
  15. package/dist-lib/import/applyMudletProfile.d.ts +35 -9
  16. package/dist-lib/import/backupImport.d.ts +118 -0
  17. package/dist-lib/import/collectProfileExport.d.ts +33 -2
  18. package/dist-lib/import/defaultPackages.d.ts +57 -14
  19. package/dist-lib/import/defaults/CF-loader/CF-loader.mpackage +0 -0
  20. package/dist-lib/import/defaults/MedBootstrap/MedBootstrap.mpackage +0 -0
  21. package/dist-lib/import/defaults/deleteOldProfiles/deleteOldProfiles.mpackage +0 -0
  22. package/dist-lib/import/defaults/echo/echo.mpackage +0 -0
  23. package/dist-lib/import/defaults/enable-accessibility/enable-accessibility.mpackage +0 -0
  24. package/dist-lib/import/defaults/generic_mapper/generic_mapper.mpackage +0 -0
  25. package/dist-lib/import/defaults/gui-drop/gui-drop.mpackage +0 -0
  26. package/dist-lib/import/defaults/icesus-loader/icesus-loader.mpackage +0 -0
  27. package/dist-lib/import/defaults/mg-loader/mg-loader.mpackage +0 -0
  28. package/dist-lib/import/defaults/mudlet-base-ui/mudlet-base-ui.mpackage +0 -0
  29. package/dist-lib/import/defaults/mudlet-mapper.xml +1215 -389
  30. package/dist-lib/import/mudletControlChars.d.ts +14 -0
  31. package/dist-lib/import/mudletHost.d.ts +73 -10
  32. package/dist-lib/import/mudletLink.d.ts +53 -2
  33. package/dist-lib/import/mudletProfileExport.d.ts +38 -5
  34. package/dist-lib/import/mudletProfileImport.d.ts +110 -12
  35. package/dist-lib/import/mudletVariables.d.ts +4 -3
  36. package/dist-lib/import/mudletWriteback.d.ts +15 -1
  37. package/dist-lib/import/mudletXmlImport.d.ts +46 -0
  38. package/dist-lib/import/packageFonts.d.ts +33 -0
  39. package/dist-lib/import/packageInstaller.d.ts +111 -7
  40. package/dist-lib/import/qtProfileData.d.ts +10 -0
  41. package/dist-lib/import/remotePackageInstall.d.ts +23 -7
  42. package/dist-lib/import/zipEntries.d.ts +45 -0
  43. package/dist-lib/index.d.ts +7 -3
  44. package/dist-lib/index.js +50508 -29836
  45. package/dist-lib/logging/SessionLogger.d.ts +75 -15
  46. package/dist-lib/map/MapSelectionOverlay.d.ts +2 -2
  47. package/dist-lib/map/MapStore.d.ts +387 -60
  48. package/dist-lib/map/MudletHighlightOverlay.d.ts +2 -2
  49. package/dist-lib/map/{MudixMapReader.d.ts → MudletMapReader.d.ts} +2 -2
  50. package/dist-lib/map/areaGraph.d.ts +120 -0
  51. package/dist-lib/map/environmentKit.d.ts +36 -0
  52. package/dist-lib/map/labelPixmap.d.ts +90 -0
  53. package/dist-lib/map/mapImageExport.d.ts +36 -2
  54. package/dist-lib/map/mapStyle.d.ts +11 -0
  55. package/dist-lib/map/mapVersion.d.ts +66 -0
  56. package/dist-lib/map/pathfinding.d.ts +2 -2
  57. package/dist-lib/mud/CharLoginController.d.ts +230 -0
  58. package/dist-lib/mud/ItemIdSequence.d.ts +1 -1
  59. package/dist-lib/mud/MudSession.d.ts +279 -22
  60. package/dist-lib/mud/PatternEngine.d.ts +153 -14
  61. package/dist-lib/mud/aliases/AliasEngine.d.ts +55 -9
  62. package/dist-lib/mud/autoLogin.d.ts +59 -0
  63. package/dist-lib/mud/commandSplit.d.ts +9 -0
  64. package/dist-lib/mud/connection/LineAssembler.d.ts +38 -11
  65. package/dist-lib/mud/connection/MudClient.d.ts +291 -53
  66. package/dist-lib/mud/connection/SubnegotiationRepair.d.ts +24 -0
  67. package/dist-lib/mud/connection/TelnetNegotiator.d.ts +208 -68
  68. package/dist-lib/mud/connection/telnetDebug.d.ts +8 -8
  69. package/dist-lib/mud/events.d.ts +102 -23
  70. package/dist-lib/mud/games/bundledGames.d.ts +12 -7
  71. package/dist-lib/mud/games/gameLinks.d.ts +40 -0
  72. package/dist-lib/mud/games/icons/3Kingdoms.png +0 -0
  73. package/dist-lib/mud/games/icons/3Scapes.png +0 -0
  74. package/dist-lib/mud/games/icons/achaea.png +0 -0
  75. package/dist-lib/mud/games/icons/aetolia.png +0 -0
  76. package/dist-lib/mud/games/icons/banner_astaria.png +0 -0
  77. package/dist-lib/mud/games/icons/banner_darkmists.png +0 -0
  78. package/dist-lib/mud/games/icons/banner_dreamland.png +0 -0
  79. package/dist-lib/mud/games/icons/banner_petria.jpg +0 -0
  80. package/dist-lib/mud/games/icons/banner_ropmud.png +0 -0
  81. package/dist-lib/mud/games/icons/blackmud.png +0 -0
  82. package/dist-lib/mud/games/icons/carrionfields.png +0 -0
  83. package/dist-lib/mud/games/icons/dragonfire_icon.png +0 -0
  84. package/dist-lib/mud/games/icons/fed2-logo.png +0 -0
  85. package/dist-lib/mud/games/icons/icesus_480x120.png +0 -0
  86. package/dist-lib/mud/games/icons/imperian.png +0 -0
  87. package/dist-lib/mud/games/icons/infinity_480x120.png +0 -0
  88. package/dist-lib/mud/games/icons/lusternia.png +0 -0
  89. package/dist-lib/mud/games/icons/morgengrauen_480x120.png +0 -0
  90. package/dist-lib/mud/games/icons/mudlet-tutorial.png +0 -0
  91. package/dist-lib/mud/games/icons/phoenixmud_480x120.png +0 -0
  92. package/dist-lib/mud/games/icons/starmourn.png +0 -0
  93. package/dist-lib/mud/games/icons/voidmud_icon.png +0 -0
  94. package/dist-lib/mud/games/icons/wotmudicon.png +0 -0
  95. package/dist-lib/mud/games/websiteLinks.d.ts +21 -0
  96. package/dist-lib/mud/keybindings/KeyEngine.d.ts +110 -4
  97. package/dist-lib/mud/keybindings/browserReservedKeys.d.ts +2 -2
  98. package/dist-lib/mud/keybindings/keyEventTarget.d.ts +61 -0
  99. package/dist-lib/mud/keybindings/qtKeys.d.ts +91 -12
  100. package/dist-lib/mud/protocol/atcp.d.ts +19 -0
  101. package/dist-lib/mud/protocol/byteString.d.ts +24 -0
  102. package/dist-lib/mud/protocol/charLoginFlow.d.ts +243 -16
  103. package/dist-lib/mud/protocol/charset.d.ts +111 -46
  104. package/dist-lib/mud/protocol/codePages.d.ts +10 -0
  105. package/dist-lib/mud/protocol/constants.d.ts +17 -10
  106. package/dist-lib/mud/protocol/echo.d.ts +23 -27
  107. package/dist-lib/mud/protocol/gmcp.d.ts +36 -6
  108. package/dist-lib/mud/protocol/index.d.ts +3 -2
  109. package/dist-lib/mud/protocol/luaLiteral.d.ts +12 -0
  110. package/dist-lib/mud/protocol/mccp.d.ts +83 -1
  111. package/dist-lib/mud/protocol/mnes.d.ts +41 -58
  112. package/dist-lib/mud/protocol/msdp.d.ts +11 -4
  113. package/dist-lib/mud/protocol/msp.d.ts +3 -2
  114. package/dist-lib/mud/protocol/mssp.d.ts +9 -4
  115. package/dist-lib/mud/protocol/multiByte.d.ts +51 -0
  116. package/dist-lib/mud/protocol/multiByteEncode.d.ts +42 -0
  117. package/dist-lib/mud/protocol/mxp.d.ts +193 -14
  118. package/dist-lib/mud/protocol/oauthClientFlow.d.ts +128 -0
  119. package/dist-lib/mud/protocol/qtCodePages.generated.d.ts +1 -0
  120. package/dist-lib/mud/protocol/tlsCodes.d.ts +40 -3
  121. package/dist-lib/mud/replay/ReplayPlayer.d.ts +16 -1
  122. package/dist-lib/mud/replay/replayFormat.d.ts +29 -2
  123. package/dist-lib/mud/text/Console.d.ts +255 -49
  124. package/dist-lib/mud/text/FormatState.d.ts +137 -14
  125. package/dist-lib/mud/text/ansiEscapes.d.ts +32 -16
  126. package/dist-lib/mud/text/colorParsers.d.ts +14 -2
  127. package/dist-lib/mud/text/colorSpaceId.d.ts +2 -0
  128. package/dist-lib/mud/text/colors.d.ts +17 -10
  129. package/dist-lib/mud/text/controlCharacterMode.d.ts +1 -1
  130. package/dist-lib/mud/text/hyperlinkVisibility.d.ts +1 -1
  131. package/dist-lib/mud/text/lineBreak.d.ts +5 -0
  132. package/dist-lib/mud/text/serverWrap.d.ts +2 -2
  133. package/dist-lib/mud/text/textAnalyzer.d.ts +79 -0
  134. package/dist-lib/mud/text/unicodeRuns.d.ts +11 -0
  135. package/dist-lib/mud/text/unicodeTables.generated.d.ts +3 -0
  136. package/dist-lib/mud/text/wcwidth.d.ts +27 -22
  137. package/dist-lib/mud/timers/TimerEngine.d.ts +163 -11
  138. package/dist-lib/mud/timers/workerClock.d.ts +67 -0
  139. package/dist-lib/mud/triggers/TriggerEngine.d.ts +449 -47
  140. package/dist-lib/mud/triggers/legacyColorPatterns.d.ts +58 -0
  141. package/dist-lib/mud/triggers/pcre/Pcre2.d.ts +83 -1
  142. package/dist-lib/oauth-callback.html +94 -0
  143. package/dist-lib/pcre2Wasm.d.ts +54 -0
  144. package/dist-lib/pcre2Wasm.js +241 -0
  145. package/dist-lib/scripting/EngineHost.d.ts +45 -21
  146. package/dist-lib/scripting/IScriptingRuntime.d.ts +103 -27
  147. package/dist-lib/scripting/MxpFrameManager.d.ts +10 -1
  148. package/dist-lib/scripting/ScriptingAPI.d.ts +1030 -213
  149. package/dist-lib/scripting/ScriptingEngine.d.ts +727 -106
  150. package/dist-lib/scripting/StopwatchManager.d.ts +97 -36
  151. package/dist-lib/scripting/http/HttpService.d.ts +9 -1
  152. package/dist-lib/scripting/http/userUrl.d.ts +41 -0
  153. package/dist-lib/scripting/lua/LuaRuntime.d.ts +352 -77
  154. package/dist-lib/scripting/lua/argContracts.d.ts +71 -0
  155. package/dist-lib/scripting/lua/bindings/automation.d.ts +1 -1
  156. package/dist-lib/scripting/lua/bindings/commands.d.ts +13 -0
  157. package/dist-lib/scripting/lua/bindings/context.d.ts +20 -2
  158. package/dist-lib/scripting/lua/bindings/diagnostics.d.ts +1 -1
  159. package/dist-lib/scripting/lua/bindings/map.d.ts +1 -1
  160. package/dist-lib/scripting/lua/bindings/media.d.ts +2 -2
  161. package/dist-lib/scripting/lua/bindings/output.d.ts +1 -1
  162. package/dist-lib/scripting/lua/bindings/session.d.ts +2 -2
  163. package/dist-lib/scripting/lua/bindings/textEdit.d.ts +1 -1
  164. package/dist-lib/scripting/lua/bindings/userWindows.d.ts +1 -1
  165. package/dist-lib/scripting/lua/byteArmor.d.ts +36 -0
  166. package/dist-lib/scripting/lua/imageSize.d.ts +7 -0
  167. package/dist-lib/scripting/lua/rex.d.ts +4 -2
  168. package/dist-lib/scripting/lua/sqlRowEncoder.d.ts +6 -1
  169. package/dist-lib/scripting/lua/utf8CaseMap.d.ts +1 -0
  170. package/dist-lib/scripting/lua/utf8Patterns.d.ts +21 -1
  171. package/dist-lib/scripting/lua/wellFormedStrings.d.ts +40 -0
  172. package/dist-lib/scripting/lua/yajl.d.ts +43 -5
  173. package/dist-lib/scripting/profilesPresence.d.ts +20 -2
  174. package/dist-lib/scripting/vfs/ProfileVFS.d.ts +164 -10
  175. package/dist-lib/scripting/vfs/fsErrors.d.ts +28 -0
  176. package/dist-lib/scripting/vfs/idbCommit.d.ts +20 -0
  177. package/dist-lib/storage/appStore.d.ts +24 -9
  178. package/dist-lib/storage/hooks.d.ts +5 -1
  179. package/dist-lib/storage/index.d.ts +2 -2
  180. package/dist-lib/storage/mapStorage.d.ts +2 -0
  181. package/dist-lib/storage/persistentStorage.d.ts +3 -1
  182. package/dist-lib/storage/profileStorage.d.ts +15 -0
  183. package/dist-lib/storage/profileVfsData.d.ts +3 -3
  184. package/dist-lib/storage/schema.d.ts +512 -40
  185. package/dist-lib/storage/storageMigration.d.ts +82 -0
  186. package/dist-lib/storage-g5V1b-c1.js +2039 -0
  187. package/dist-lib/styles.css +1 -1
  188. package/dist-lib/ui/AboutModal.d.ts +1 -1
  189. package/dist-lib/ui/BrandLoginFields.d.ts +1 -1
  190. package/dist-lib/ui/BrowserSignInModal.d.ts +23 -0
  191. package/dist-lib/ui/CmdLineMenuRegistry.d.ts +14 -5
  192. package/dist-lib/ui/CommandBar.d.ts +8 -8
  193. package/dist-lib/ui/ConnectionFormModal.d.ts +20 -1
  194. package/dist-lib/ui/ConnectionScreen.d.ts +9 -1
  195. package/dist-lib/ui/GameLinkPrompt.d.ts +28 -0
  196. package/dist-lib/ui/HelpModal.d.ts +5 -1
  197. package/dist-lib/ui/MapSymbolUsageModal.d.ts +32 -0
  198. package/dist-lib/ui/MouseEventRegistry.d.ts +31 -4
  199. package/dist-lib/ui/NotepadModal.d.ts +22 -0
  200. package/dist-lib/ui/ResizableModal.d.ts +16 -1
  201. package/dist-lib/ui/SettingsModal.d.ts +10 -1
  202. package/dist-lib/ui/TlsAlertBanner.d.ts +3 -1
  203. package/dist-lib/ui/Toolbar.d.ts +22 -1
  204. package/dist-lib/ui/VaultManageButton.d.ts +10 -5
  205. package/dist-lib/ui/VaultModal.d.ts +3 -0
  206. package/dist-lib/ui/buttons/ButtonsBar.d.ts +3 -1
  207. package/dist-lib/ui/buttons/inactiveButtons.d.ts +25 -0
  208. package/dist-lib/ui/cmdline/CommandLineManager.d.ts +19 -0
  209. package/dist-lib/ui/cmdline/plainText.d.ts +16 -0
  210. package/dist-lib/ui/cmdline/subCommandLine.d.ts +78 -0
  211. package/dist-lib/ui/cmdline/useCmdLineSelection.d.ts +26 -0
  212. package/dist-lib/ui/cmdline/useSubCommandLineKeys.d.ts +33 -0
  213. package/dist-lib/ui/codemirror/lineParagraphMarks.d.ts +19 -0
  214. package/dist-lib/ui/codemirror/luaHover.d.ts +7 -0
  215. package/dist-lib/ui/codemirror/options.d.ts +33 -0
  216. package/dist-lib/ui/codemirror/theme.d.ts +29 -5
  217. package/dist-lib/ui/commands/addonCommands.d.ts +134 -0
  218. package/dist-lib/ui/commands/appShortcuts.d.ts +86 -0
  219. package/dist-lib/ui/commands/hostCommands.d.ts +88 -0
  220. package/dist-lib/ui/commands/keyMatch.d.ts +20 -0
  221. package/dist-lib/ui/commands/keySequence.d.ts +57 -0
  222. package/dist-lib/ui/components/ContextMenu.d.ts +21 -1
  223. package/dist-lib/ui/components/FontPicker.d.ts +5 -1
  224. package/dist-lib/ui/components/useModalFocus.d.ts +13 -1
  225. package/dist-lib/ui/helpTopics.d.ts +15 -0
  226. package/dist-lib/ui/labels/LabelManager.d.ts +172 -9
  227. package/dist-lib/ui/labels/LabelOverlay.d.ts +19 -0
  228. package/dist-lib/ui/labels/backgroundImageSize.d.ts +19 -0
  229. package/dist-lib/ui/labels/labelModel.d.ts +64 -0
  230. package/dist-lib/ui/labels/qColor.d.ts +13 -0
  231. package/dist-lib/ui/labels/qtCss.d.ts +12 -4
  232. package/dist-lib/ui/landmarks.d.ts +9 -0
  233. package/dist-lib/ui/launcher/ActionMenu.d.ts +19 -0
  234. package/dist-lib/ui/launcher/GameDetails.d.ts +21 -0
  235. package/dist-lib/ui/launcher/GameSection.d.ts +18 -0
  236. package/dist-lib/ui/launcher/LauncherSearch.d.ts +23 -0
  237. package/dist-lib/ui/launcher/ProfileArt.d.ts +20 -0
  238. package/dist-lib/ui/launcher/ProfileSection.d.ts +43 -0
  239. package/dist-lib/ui/launcher/launcherModel.d.ts +72 -0
  240. package/dist-lib/ui/layout/overlayLayerOrder.d.ts +2 -2
  241. package/dist-lib/ui/menu/MenuBar.d.ts +31 -0
  242. package/dist-lib/ui/menu/SplitButton.d.ts +39 -0
  243. package/dist-lib/ui/menu/anchoredPopup.d.ts +74 -0
  244. package/dist-lib/ui/menu/appMenus.d.ts +65 -0
  245. package/dist-lib/ui/menu/menuModel.d.ts +88 -0
  246. package/dist-lib/ui/menu/toolbarModel.d.ts +56 -0
  247. package/dist-lib/ui/notepad.d.ts +76 -0
  248. package/dist-lib/ui/openSignInPage.d.ts +14 -0
  249. package/dist-lib/ui/output/OutputContextMenu.d.ts +14 -1
  250. package/dist-lib/ui/output/OutputRenderer.d.ts +5 -0
  251. package/dist-lib/ui/output/OutputSearchBar.d.ts +5 -1
  252. package/dist-lib/ui/output/StickyOutputPanel.d.ts +17 -3
  253. package/dist-lib/ui/output/TextAnalyzerModal.d.ts +25 -0
  254. package/dist-lib/ui/output/caretMode.d.ts +3 -2
  255. package/dist-lib/ui/output/clearSplit.d.ts +11 -0
  256. package/dist-lib/ui/output/outputCopy.d.ts +41 -2
  257. package/dist-lib/ui/output/outputRows.d.ts +43 -0
  258. package/dist-lib/ui/output/selectionGesture.d.ts +35 -0
  259. package/dist-lib/ui/output/wordSelection.d.ts +33 -0
  260. package/dist-lib/ui/search/matcher.d.ts +14 -4
  261. package/dist-lib/ui/settings/SettingsShell.d.ts +91 -0
  262. package/dist-lib/ui/settings/ShortcutEditor.d.ts +13 -0
  263. package/dist-lib/ui/sound/SoundManager.d.ts +210 -44
  264. package/dist-lib/ui/sound/closedCaption.d.ts +4 -1
  265. package/dist-lib/ui/sound/mediaDirection.d.ts +35 -0
  266. package/dist-lib/ui/tabCompletion.d.ts +53 -0
  267. package/dist-lib/ui/textedit/TextEditManager.d.ts +11 -2
  268. package/dist-lib/ui/useOpenProfiles.d.ts +1 -1
  269. package/dist-lib/ui/video/VideoManager.d.ts +7 -0
  270. package/dist-lib/ui/windows/WindowManager.d.ts +452 -37
  271. package/dist-lib/ui/windows/panels/ScriptEditorPanel.d.ts +14 -0
  272. package/dist-lib/ui/windows/panels/ScriptSearch.d.ts +6 -1
  273. package/dist-lib/ui/windows/panels/TextPanel.d.ts +4 -1
  274. package/dist-lib/ui/windows/panels/VariablesView.d.ts +37 -7
  275. package/dist-lib/ui/windows/panels/WindowCmdLine.d.ts +4 -2
  276. package/dist-lib/ui/windows/panels/aliasLoop.d.ts +24 -0
  277. package/dist-lib/ui/windows/panels/editorClipboard.d.ts +45 -0
  278. package/dist-lib/ui/windows/panels/editorUndo.d.ts +79 -0
  279. package/dist-lib/ui/windows/panels/mapAreaChange.d.ts +10 -0
  280. package/dist-lib/utils/appShellCache.d.ts +25 -0
  281. package/dist-lib/utils/fontFamilyName.d.ts +13 -0
  282. package/dist-lib/utils/fontLoader.d.ts +31 -0
  283. package/dist-lib/utils/formatBytes.d.ts +4 -0
  284. package/dist-lib/utils/mustBeOneOf.d.ts +9 -0
  285. package/dist-lib/utils/profileLock.d.ts +1 -1
  286. package/dist-lib/utils/systemTheme.d.ts +24 -0
  287. package/dist-lib/utils/timeZone.d.ts +10 -0
  288. package/dist-lib/vault/CredentialVault.d.ts +51 -5
  289. package/dist-lib/vault/deviceUnlock.d.ts +47 -0
  290. package/dist-lib/vault/vaultAccess.d.ts +24 -2
  291. package/dist-lib/vault/vaultHelpTopic.d.ts +9 -0
  292. package/dist-lib/vault/vaultRecord.d.ts +33 -1
  293. package/dist-lib/vfs-sw.js +220 -11
  294. package/dist-lib/vite.d.ts +1 -1
  295. package/dist-lib/vite.js +66 -43
  296. package/package.json +23 -15
  297. package/dist-lib/assets/mapParser.worker-t-3rd1zR.js +0 -9
  298. package/dist-lib/mud/connection/PingTracker.d.ts +0 -41
  299. package/dist-lib/ui/BundledGameGrid.d.ts +0 -21
  300. package/dist-lib/ui/ConnectionGrid.d.ts +0 -21
  301. package/dist-lib/ui/bufferWords.d.ts +0 -38
@@ -1,4 +1,4 @@
1
- import type { IScriptingRuntime, CaptureSpan, LuaGlobalEntry } from '../IScriptingRuntime';
1
+ import type { IScriptingRuntime, CaptureSpan, LuaGlobalEntry, ScriptHandlerEntry, VariableEdit } from '../IScriptingRuntime';
2
2
  import type { ScriptingAPI } from '../ScriptingAPI';
3
3
  import type { ProfileVFS } from '../vfs/ProfileVFS';
4
4
  import { type MudletVariable } from '../../import/mudletVariables';
@@ -7,13 +7,6 @@ export declare class LuaRuntime implements IScriptingRuntime {
7
7
  private readonly api;
8
8
  private vfs;
9
9
  private readonly proxyUrlGetter;
10
- /** Script-created temp aliases/triggers by id. `dead` marks one killed but
11
- * not yet reaped: Mudlet frees a killed unit in the deferred cleanup it
12
- * runs at the end of a line, not at the kill, so until then it is still
13
- * findable while no longer firing — `exists` says 1, `isActive` says 0, and
14
- * a second kill finds a corpse and answers false. {@link reapKilledTempItems}
15
- * does the freeing. */
16
- private readonly tempIds;
17
10
  private readonly labelCbIds;
18
11
  private cmdLineActionCbId;
19
12
  private windowCmdLineActionCbIds;
@@ -21,6 +14,7 @@ export declare class LuaRuntime implements IScriptingRuntime {
21
14
  private currentMatches;
22
15
  private currentCaptureSpans;
23
16
  private currentNamedSpans;
17
+ private nestedDispatchStates;
24
18
  private currentFullMatchSpan;
25
19
  /**
26
20
  * Move the capture positions recorded for the line being processed to
@@ -30,9 +24,18 @@ export declare class LuaRuntime implements IScriptingRuntime {
30
24
  * `selectCaptureGroup` would otherwise select the text that has slid into
31
25
  * where the capture used to be. A capture that starts at or after the
32
26
  * insert moves whole; one the insert lands inside grows by it.
27
+ *
28
+ * For a `replace` of `replaced` characters at `at`
29
+ * (TLuaInterpreter::adjustCaptureGroupsForReplace) the capture that was
30
+ * exactly the replaced text keeps its start and takes the replacement's
31
+ * length, one starting after `at` moves, and the rest — an enclosing group
32
+ * that shares the start among them — stay as they were.
33
33
  */
34
- shiftCaptureSpans(at: number, delta: number): void;
35
- private _denyCurrentSend;
34
+ shiftCaptureSpans(at: number, delta: number, replaced?: number): void;
35
+ /** One entry per sysDataSendRequest dispatch on the stack, innermost
36
+ * last: whether a handler denied THAT command. A send a handler makes
37
+ * dispatches its own, so a deny is never spent by the wrong command. */
38
+ private _sendRequestDenies;
36
39
  /** The read-only `/lua/` namespace: bundled Mudlet Lua, and in busted builds
37
40
  * the spec corpus and its fixtures. Values are Latin-1 byte-strings. */
38
41
  private builtinFiles;
@@ -75,7 +78,9 @@ export declare class LuaRuntime implements IScriptingRuntime {
75
78
  private tts;
76
79
  private globalEvents;
77
80
  private flushPendingSqlSnapshots;
78
- private toLuaValue;
81
+ private stopAnsiPaletteSync;
82
+ private closeSqlConnections;
83
+ private yajl;
79
84
  private constructor();
80
85
  static create(api: ScriptingAPI, vfs?: ProfileVFS | null, proxyUrlGetter?: () => string | undefined): Promise<LuaRuntime>;
81
86
  private setup;
@@ -102,6 +107,12 @@ export declare class LuaRuntime implements IScriptingRuntime {
102
107
  * wasmoon's habit of stringifying a bound global into its entire JS source.
103
108
  * Lua 5.1's `print` reads the global at call time, so it follows along.
104
109
  *
110
+ * It counts its arguments rather than naming one: a named parameter turns
111
+ * `tostring()` into `tostring(nil)` and answers "nil", where stock Lua
112
+ * raises "bad argument #1 to 'tostring' (value expected)" — with no
113
+ * position, as luaL_argerror gives a C function — and a buggy
114
+ * `tostring(select(2, ...))` has to fail here as it does on desktop.
115
+ *
105
116
  * Installed after every `global.set` above and before Bridge.lua, so no
106
117
  * bundled or user chunk can capture the unsafe version as an upvalue.
107
118
  */
@@ -109,57 +120,46 @@ export declare class LuaRuntime implements IScriptingRuntime {
109
120
  private installMudletLuaOverrides;
110
121
  private installFastColorEcho;
111
122
  private setupAnsiColorTable;
123
+ private static readonly ANSI16_NAMES;
112
124
  /**
113
- * True when a script-created (temp) alias/trigger with this id is live and of
114
- * the given type. Backs exists(id, "alias"/"trigger") for temp items, which
115
- * don't live in the persisted store the way permanent items do.
116
- */
117
- tempItemExists(id: number, type: string): boolean;
118
- /** A live temp item of `type` carrying this Mudlet-supplied name — how
119
- * exists()/killTrigger() reach a tempComplexRegexTrigger. */
120
- tempItemIdByName(name: string, type: string): number | null;
121
- /**
122
- * killAlias/killTrigger with a numeric id, for a script-created item.
125
+ * TLuaInterpreter::updateAnsi16ColorsInTable: write the sixteen ANSI colours
126
+ * in force into `color_table` under all three of their names (`ansi_001`,
127
+ * `ansi_red`, `ansiRed`), each a fresh `{r, g, b}`. Unconditional — the
128
+ * entries describe the palette, so they replace whatever was there.
123
129
  *
124
- * The item is unsubscribed and its callback released straight away — it must
125
- * not fire again, including later in the very line pass that killed it — but
126
- * the entry stays in the map, marked dead, until {@link reapKilledTempItems}.
127
- * That is Mudlet's deferred cleanup: until the line ends, the corpse is still
128
- * findable, which is what lets a second kill report `false` rather than
129
- * mistaking the id for one that never existed.
130
- */
131
- /** Resolve a killTrigger/killAlias argument to a live temp item's id: the
132
- * number itself, or the name a tempComplexRegexTrigger was given. */
133
- tempItemId(idOrName: number | string, type: 'alias' | 'trigger'): number | null;
134
- private killTempItem;
135
- /**
136
- * Free every temp alias/trigger killed since the last call, or only those of
137
- * `type` when given.
138
- *
139
- * Mudlet cleans up per unit, at the end of whatever pass that unit runs:
140
- * aliases when nested expandAlias processing unwinds, triggers when the line
141
- * finishes. Passing the type keeps those independent, so an alias pass can't
142
- * reap a trigger the current line is still walking past.
143
- */
144
- reapKilledTempItems(type?: 'alias' | 'trigger'): void;
145
- /** enableTrigger/disableTrigger/enableAlias/disableAlias with a numeric id.
146
- * False when no temp item of that id is live — a killed one is still
147
- * findable until the reap, but re-enabling it would resurrect it. */
148
- setTempItemEnabled(id: number, enabled: boolean): boolean;
149
- /** Whether a live temp item is enabled — backs isActive(id, type). */
150
- tempItemEnabled(id: number): boolean;
130
+ * Raw table writes on the main state rather than a Lua chunk: this runs
131
+ * whenever the palette moves, which can be in the middle of a script (a
132
+ * `feedTriggers` carrying `ESC]P`), and it must neither dispatch anything
133
+ * nor be able to fail half-way.
134
+ */
135
+ private updateAnsi16ColorsInTable;
151
136
  private setupBustedBridge;
152
137
  private setupSqlBridge;
153
138
  /**
154
- * Fire sysPathChanged for any addFileWatch subscription whose path equals
155
- * `changedPath` or is an ancestor directory of it. Mudlet's QFileSystemWatcher
156
- * reports the *watched* path (not the inner file) for directory watches, so
157
- * we do the same — handlers comparing `path == watchedPath` round-trip.
139
+ * Fire sysPathChanged for the addFileWatch subscriptions a set of VFS
140
+ * changes touches, by the rules desktop's QFileSystemWatcher (inotify)
141
+ * follows:
142
+ *
143
+ * - A watched *file* reports any change to it ('modify', 'attrib'), and
144
+ * its removal — after which the watch is gone, as the watcher drops a
145
+ * path whose inode was deleted or moved away: a file recreated under
146
+ * the same name reports nothing, and removeFileWatch answers false.
147
+ * - A watched *directory* reports its direct children being created,
148
+ * removed or renamed, or their attributes changing (lfs.touch) — not a
149
+ * write into a child that already exists, and nothing from further
150
+ * down the tree. Removing the directory itself reports and drops it.
151
+ *
152
+ * The *watched* path is what is reported, not the child, so handlers
153
+ * comparing `path == watchedPath` round-trip. Each watch reports at most
154
+ * once per batch.
158
155
  */
159
156
  private notifyVfsPathChange;
160
157
  private setupVFS;
161
158
  load(code: string, name: string): void;
162
- run(code: string, name: string): void;
159
+ syntaxError(code: string, chunkName: string): string | null;
160
+ /** `chunkName`, when given, is what Lua reports the code under — Mudlet's
161
+ * "Timer: <name>" / "Key: <name>" — rather than "@name". */
162
+ run(code: string, name: string, chunkName?: string): void;
163
163
  /**
164
164
  * Restore saved Lua globals (a parsed Mudlet `<VariablePackage>` tree) into
165
165
  * `_G`. Call on profile load, after the bundle is up but before user scripts
@@ -177,14 +177,194 @@ export declare class LuaRuntime implements IScriptingRuntime {
177
177
  /** Enumerate `_G` (user globals as a nested tree, built-ins flagged) for the
178
178
  * Variables view. See {@link LuaGlobalEntry}. */
179
179
  listGlobals(): LuaGlobalEntry[];
180
- runWithMatches(code: string, name: string, matches: (string | undefined)[], multimatches?: (string | undefined)[][], namedGroups?: Record<string, string>, captureSpans?: CaptureSpan[], namedSpans?: Record<string, CaptureSpan>, fullMatchSpan?: CaptureSpan): void;
180
+ /**
181
+ * Apply one Variables-view edit to the live `_G`, returning `null` on
182
+ * success or the reason it was refused.
183
+ *
184
+ * Desktop edits variables through `LuaInterface`/`VarUnit` and re-runs the
185
+ * assignment as Lua (`dlgTriggerEditor::addVar`, :5211, and the
186
+ * `saveVar`/`deleteVar` paths); the same job here is one small chunk over
187
+ * the request, so the change is visible to running scripts immediately
188
+ * rather than only after the next profile save.
189
+ */
190
+ editVariable(request: VariableEdit): string | null;
191
+ withCaptures(matches: (string | undefined)[], captureSpans: CaptureSpan[] | undefined, namedSpans: Record<string, CaptureSpan> | undefined, fullMatchSpan: CaptureSpan | undefined, fn: () => void): void;
192
+ runWithMatches(code: string, name: string, matches: (string | undefined)[], multimatches?: (string | undefined)[][], namedGroups?: Record<string, string>, captureSpans?: CaptureSpan[], namedSpans?: Record<string, CaptureSpan>, fullMatchSpan?: CaptureSpan,
193
+ /** Named captures per multimatches row, aligned with it. */
194
+ multiNamedGroups?: (Record<string, string> | undefined)[],
195
+ /** See IScriptingRuntime.runWithMatches. */
196
+ chunkName?: string): void;
181
197
  private setMatches;
198
+ /** Nesting of {@link setMatches}' table builds — see the note there. */
199
+ private captureBuildDepth;
200
+ /** Mudlet's TLuaInterpreter::buildingCaptureTables: true while
201
+ * `matches`/`multimatches` are being built, when only a __gc finaliser can
202
+ * be running Lua — and an alias or trigger pass it starts is turned away. */
203
+ buildingCaptureTables(): boolean;
204
+ /** Whether {@link setMatches} handed the scripts anything for these
205
+ * captures, which is when {@link clearCaptureGlobals} is owed after them. */
206
+ private static captured;
207
+ /** Registry key of the empty table `matches` holds between fires, reused
208
+ * for as long as nothing has been put in it. See {@link clearCaptureGlobals}.
209
+ * A named key rather than a luaL_ref: the table is replaced in place, and
210
+ * writing to a numbered slot is only safe while nothing else has freed it. */
211
+ private static readonly EMPTY_MATCHES_KEY;
212
+ /**
213
+ * Put the between-fires globals back once a fire with captures is over,
214
+ * as TLuaInterpreter::clearCaptureGroups does after every trigger and alias
215
+ * that had any — even when its script raised. `matches` becomes an empty
216
+ * table and `multimatches` a new one, so a script that kept a reference to
217
+ * the tables its fire was handed keeps them to itself, and a later fire
218
+ * never finds another fire's captures in place.
219
+ *
220
+ * The empty `matches` is one table reused while it is still empty and has
221
+ * no metatable (Mudlet's pushUnusedTable): a table a script has filled or
222
+ * given a metatable is that script's, and a new one takes its place.
223
+ */
224
+ private clearCaptureGlobals;
225
+ private pushUnusedEmptyMatches;
226
+ /**
227
+ * Store the value on top of the stack as the global `name`, raw.
228
+ *
229
+ * This is how a dispatch hands the scripts it runs their own `command` and
230
+ * `line` (`matches` and `multimatches` go through {@link assignGlobal},
231
+ * as desktop's do), and it runs with the whole dispatch
232
+ * on the JS stack below it. `lua_setglobal` honours a metatable on the
233
+ * globals table, so a `__newindex` a package installed there runs from
234
+ * inside this call on the first write of a name that is absent — and a Lua
235
+ * error raised by one does not longjmp to the nearest pcall the way it does
236
+ * on desktop, it unwinds through wasmoon's C closure and takes the whole
237
+ * lua_State with it. Mudlet writes these raw for the milder version of the
238
+ * same reason (`set_lua_string`, upstream #10799), and intercepting them
239
+ * was never something a package could usefully do: the name is absent only
240
+ * until the first dispatch writes it.
241
+ */
242
+ private rawSetGlobal;
243
+ /**
244
+ * Store the value on top of the stack as the global `name` by assignment,
245
+ * popping it — how desktop's setMatches and clearCaptureGroups hand out
246
+ * `matches` and `multimatches` (lua_setglobal), so a `__newindex` on the
247
+ * globals table sees each write of a name it does not hold.
248
+ *
249
+ * The assignment runs in Bridge.lua's `mudlet.assignGlobal` under
250
+ * lua_pcall, never as a lua_setglobal from here: see {@link rawSetGlobal}
251
+ * for what a raising metamethod does to a write made from JS. A handler
252
+ * that raises is reported, and the value is then stored raw, so the
253
+ * scripts of the fire still get their captures.
254
+ */
255
+ private assignGlobal;
256
+ private static readonly ASSIGN_GLOBAL_KEY;
257
+ /**
258
+ * Park the dispatch state the calling script is holding, and answer the
259
+ * depth the matching {@link popNestedDispatchState} has to unwind to.
260
+ *
261
+ * `expandAlias()` runs a whole alias pass inside whatever script called it,
262
+ * and that pass claims the per-dispatch globals for the scripts IT runs:
263
+ * `command` before any pattern is tried, `matches`/`multimatches` on every
264
+ * fire. Nothing used to put the caller's back, so a script resumed holding
265
+ * the nested command and an emptied matches table — even `matches[1]`, the
266
+ * full match, was gone (Mudlet's TLuaInterpreter::pushNestedDispatchState,
267
+ * upstream #10799).
268
+ *
269
+ * The tables are parked by reference rather than rebuilt from the capture
270
+ * list: a script is free to write into the `matches` it was handed, and it
271
+ * has to get that same table back. Every read is raw, so a package's
272
+ * `__index` on the globals table can neither be run by the parking nor
273
+ * raise from inside it — `multimatches` really is absent from a fresh
274
+ * profile's globals, which is exactly when an `__index` would answer.
275
+ *
276
+ * The JS mirror of the same state (`currentMatches` and the capture spans
277
+ * `selectCaptureGroup` reads) needs nothing here: every dispatch entry
278
+ * point already saves and restores it around the script it runs.
279
+ *
280
+ * `command` is parked only for an alias script by default; feedTriggers
281
+ * never parks it (see the binding).
282
+ */
283
+ pushNestedDispatchState(parkCommand?: boolean): number;
284
+ /** Hand the caller at `depth` back the state {@link
285
+ * pushNestedDispatchState} parked for it. Anything parked above that depth
286
+ * belongs to a dispatch that never reached its own restore; it is stale,
287
+ * and handing one back here would give this caller some other script's
288
+ * captures and command, so it is discarded. */
289
+ popNestedDispatchState(depth: number): void;
290
+ private releaseNestedDispatchState;
291
+ /**
292
+ * While an alias pass runs, what `command` ends it holding unless a script
293
+ * changes it (the last command expanded), and the value the last restore of
294
+ * an alias script's own command put back. TLuaInterpreter::mPassCommand.
295
+ */
296
+ private passCommandRef;
297
+ private restoredCommandRef;
298
+ /** Whether the script running now is an alias's: expandAlias() hands
299
+ * `command` back to that one only. TLuaInterpreter::mRunningAliasScript. */
300
+ private runningAliasScript;
301
+ /** Claimed by the next entry into Lua — see {@link asAliasScript}. */
302
+ private nextEntryIsAliasScript;
303
+ /** Run `fn`, whose entry into Lua is an alias's script — the role of
304
+ * desktop's `ScriptCallerScope(*this, true)` around TAlias::execute.
305
+ * Every other entry runs as a non-alias caller. */
306
+ asAliasScript<T>(fn: () => T): T;
307
+ /**
308
+ * Start an alias pass for `command` (AliasUnit::processDataStream →
309
+ * TLuaInterpreter::setExpandedCommand): `command` holds it, and whatever an
310
+ * enclosing pass kept for {@link settleCommandAfterAliasPass} is out of date.
311
+ */
312
+ setExpandedCommand(command: string): void;
313
+ /**
314
+ * End of an alias pass, at every depth. An alias script had its own
315
+ * `command` back while it ran, but what is read once the pass is over is the
316
+ * last command expanded — or whatever a script set it to, which survives.
317
+ * TLuaInterpreter::settleCommandAfterAliasPass.
318
+ */
319
+ settleCommandAfterAliasPass(): void;
182
320
  /** Push a 1-indexed Lua table of capture strings (`matches[1]` = whole match),
183
321
  * optionally merging named captures as string keys (`matches.hp`). Same shape
184
322
  * the old `oneIndexed()` + `global.set` produced, via raw stack ops. An
185
323
  * unmatched optional group (`undefined`) is left unset → nil, as before. */
186
324
  private pushMatchesTable;
187
325
  private exec;
326
+ /**
327
+ * The chunk name every piece of Mudlet Web's own Lua is compiled under —
328
+ * Bridge.lua, the io/lfs/utf8/yajl/luasql/rex/lpeg shims, and the one-line
329
+ * entry chunks JS runs. Desktop implements all of that in C, so Lua reports
330
+ * it as `[C]` there; Bridge.lua's error/debug.getinfo/debug.traceback use
331
+ * this name to show it the same way (see the top of Bridge.lua).
332
+ */
333
+ static readonly INTERNAL_CHUNK = "=[C]";
334
+ /**
335
+ * The standard library as it stood when an internal chunk loaded, bound as
336
+ * locals of that chunk, so Mudlet Web's own Lua never looks these up in the
337
+ * globals table at call time. Desktop's API is C and reaches none of them
338
+ * through Lua globals, so a script's own global `select` (a "select target"
339
+ * helper), `type` or `unpack = nil` must leave `send`, `echo`,
340
+ * `tempTrigger` and the rest working (mudlet-web#374). The tables are bound
341
+ * too, which still follows a script that changes a function inside one, as
342
+ * desktop's Lua-side code does. Part of {@link INTERNAL_PROLOGUE}, so it
343
+ * stays on the chunk's first line.
344
+ */
345
+ private static readonly BUILTIN_LOCALS;
346
+ private static readonly TOSTRING_LOCAL;
347
+ /**
348
+ * Put in front of an internal chunk, on its first line so the chunk's line
349
+ * numbers don't move: `error` there is one of {@link C_ERROR_LUA}'s, so an
350
+ * error raised from that code is positioned the way the C it stands in for
351
+ * positions it.
352
+ * - `mudlet`: Mudlet's own API raises with lua_error — no position at
353
+ * all (`tempTimer: bad argument #1 ...`).
354
+ * - `lual`: the C libraries (io, lfs, luautf8, lrexlib, lua-yajl,
355
+ * LuaSQL, LPeg) raise with luaL_error / luaL_argerror — the position
356
+ * of the script line that called them, none when C called them.
357
+ * A chunk-local rather than a replaced global `error`, because a script's
358
+ * `return error(msg)` tail-calls it: the stock C function keeps the
359
+ * caller's frame for its position, a Lua replacement would not.
360
+ */
361
+ private static readonly INTERNAL_PROLOGUE;
362
+ /** Run one of Mudlet Web's own bootstrap chunks on the main state, under
363
+ * {@link INTERNAL_CHUNK}. */
364
+ private runInternalChunk;
365
+ /** {@link exec} for Mudlet Web's own Lua: compiled under
366
+ * {@link INTERNAL_CHUNK}, so what it defines reads as C to a script. */
367
+ private execInternal;
188
368
  private static readonly LUA_GCCOUNT;
189
369
  private static readonly MEMORY_WARN_MB;
190
370
  private static readonly MEMORY_SAMPLE_EVERY;
@@ -206,6 +386,44 @@ export declare class LuaRuntime implements IScriptingRuntime {
206
386
  */
207
387
  private markFatal;
208
388
  private execInner;
389
+ private readonly runningThreads;
390
+ /** Make the globals table `from` runs with the main state's, and so the one
391
+ * every thread made from now on starts with. */
392
+ private adoptGlobalsOf;
393
+ /** Hand `to` the main state's globals table. */
394
+ private giveGlobalsTo;
395
+ /** Before anything reads or writes the globals table from JS, or makes a
396
+ * thread: whatever the running script switched to is the one. */
397
+ private syncGlobalsFromRunning;
398
+ /** Run `resume` with `t` as the running thread, then leave its globals
399
+ * table in place — in the main state and in the thread it returns to. */
400
+ private resumeAsRunning;
401
+ /** Desktop runs every entry point on the main state, so a script must not
402
+ * see the thread at `threadIndex` as a coroutine — Bridge.lua's
403
+ * coroutine.running/yield consult this registry table. Absent until
404
+ * Bridge.lua has run. */
405
+ private markEntryThread;
406
+ private static readonly ENTRY_THREADS_KEY;
407
+ /** Give the new entry thread at `threadIndex` the debug hook a script set
408
+ * on the main state, if any. Desktop runs every entry on that one state,
409
+ * so its hook carries over from callback to callback; Lua 5.1 keeps hooks
410
+ * per thread, so each thread made here has to be handed it (Bridge.lua's
411
+ * debug.sethook keeps the record). */
412
+ private inheritDebugHook;
413
+ /**
414
+ * Before wasmoon reads a failed thread's error, make it a string.
415
+ *
416
+ * `assertOk` renders a non-string error with its own `luaL_tolstring`,
417
+ * which calls `__tostring` unprotected: an error object whose `__tostring`
418
+ * raises is then a Lua panic, and the panic is C `exit()` — the module is
419
+ * gone for the session (mudlet-web#330). Desktop reports such an error and
420
+ * carries on, so the object is described here first, under a pcall, by
421
+ * Bridge.lua's `__mudlet_describe_error`. Strings, numbers and userdata
422
+ * (wasmoon's wrapped JS errors, whose message `assertOk` keeps) are left
423
+ * alone.
424
+ */
425
+ private stringifyThreadError;
426
+ private static readonly DESCRIBE_ERROR_KEY;
209
427
  private execOnThread;
210
428
  private runChunk;
211
429
  private runChunkOnThread;
@@ -216,10 +434,10 @@ export declare class LuaRuntime implements IScriptingRuntime {
216
434
  /**
217
435
  * A thread resume returned LUA_YIELD. If it is invokeFileDialog's yield
218
436
  * (sentinel first), read the request off the thread stack, anchor the
219
- * thread, and open the picker — returns true. Any other yield reaching
220
- * the handler boundary is a script bug (stock Lua 5.1 errors with
221
- * "attempt to yield from outside a coroutine" there): report and abandon
222
- * the thread — returns false.
437
+ * thread, and open the picker — returns true. No other yield should get
438
+ * here: Bridge.lua's coroutine.yield refuses to leave an entry thread, as
439
+ * desktop's main state does. Should one anyway, report and abandon the
440
+ * thread — returns false.
223
441
  *
224
442
  * First park: the thread still sits at `threadIndex` on the global stack
225
443
  * (the caller's finally pops it), so take a registry ref now. Re-park
@@ -229,13 +447,27 @@ export declare class LuaRuntime implements IScriptingRuntime {
229
447
  /** Continue a parked handler with the picked VFS path ('' = cancelled). */
230
448
  private resumeDialogThread;
231
449
  private dispatchCb;
450
+ /** Set by {@link runCallback}: whether the callback's first result was
451
+ * `true` — the way an expiring temp trigger asks for another life. */
452
+ private cbReturnedTrue;
453
+ /** Whether the callback {@link dispatchCb} last ran returned true. */
454
+ private lastCbReturnedTrue;
232
455
  private dispatchCbWithArg;
456
+ /**
457
+ * Call the Lua function registered under `cbId` (Bridge.lua's
458
+ * `mudlet.cb` registry table) as the base function of a fresh entry
459
+ * thread. Desktop calls such a callback straight from C with lua_pcall, so
460
+ * nothing sits under it: its traceback ends at the callback, which shows as
461
+ * `in function <chunk:line>` — called from C, it has no name. Running it
462
+ * through a Lua dispatcher chunk instead left two frames of ours under it.
463
+ */
464
+ private runCallback;
233
465
  private unregisterCb;
234
466
  /**
235
467
  * Mudlet `T2DMap::initiateSpeedWalk` / `Host::startSpeedWalk` — the map's
236
468
  * double-click-to-walk gesture. Pathfinds `from` → `to` (unless the mapper
237
469
  * opted into `mudlet.custom_speedwalk`) and calls the mapper package's
238
- * `doSpeedWalk`; see `__mudix_start_speedwalk` in Bridge.lua. Errors inside
470
+ * `doSpeedWalk`; see `__mudlet_start_speedwalk` in Bridge.lua. Errors inside
239
471
  * the mapper are reported, never thrown at the UI caller.
240
472
  */
241
473
  startSpeedWalk(from: number, to: number): void;
@@ -253,25 +485,55 @@ export declare class LuaRuntime implements IScriptingRuntime {
253
485
  * distinct from nil's "not my pattern, use yours".
254
486
  */
255
487
  private installNativeUtf8Find;
256
- private dispatchingEvent;
257
- private readonly pendingEvents;
488
+ /**
489
+ * The Unicode tables behind luautf8's normalize_nfc / isnfc /
490
+ * grapheme_indices, read off the JS engine (String.prototype.normalize,
491
+ * Intl.Segmenter) rather than vendored. Both take and give the text armored
492
+ * (see byteArmor.ts) — valid UTF-8 may still hold a NUL, which the wasmoon
493
+ * string bridge would cut at. utf8.lua validates before calling, so the
494
+ * bytes always decode.
495
+ */
496
+ private installUtf8Natives;
258
497
  emitEvent(event: string, args: unknown[]): void;
259
498
  private dispatchEventNow;
260
499
  setGmcpValue(path: string, value: unknown): void;
261
500
  setMsdpValue(path: string, value: unknown): void;
501
+ /**
502
+ * Push a JSON-decoded protocol payload as yajl.to_value would decode it.
503
+ * False, with nothing pushed, when it nests deeper than lua_yajl accepts —
504
+ * Mudlet's json_to_value raises on such a payload and the table is left as
505
+ * it was, so the caller skips the update too.
506
+ */
507
+ private pushDecodedJson;
508
+ /** Records one channel-102 report in the Lua `channel102` global. Both
509
+ * halves are bytes, so there is nothing to marshal — Mudlet's
510
+ * setChannel102Table does the same rawset. */
511
+ setChannel102Value(variable: number, value: number): void;
512
+ /** Records one ATCP message in the Lua `atcp` global — Mudlet's
513
+ * setAtcpTable rawset. The event is raised separately by the engine. */
514
+ setAtcpValue(name: string, value: string): void;
262
515
  setMsspValue(name: string, value: string): void;
263
516
  /**
264
517
  * Bridges one use of a server-defined MXP element into the Lua `mxp` global
265
518
  * as `mxp.<element>` — a fresh table each time, with every attribute key
266
519
  * lowercased and a `text` field, exactly as Mudlet's signalMXPEvent builds
267
- * it. Values keep their case.
520
+ * it. Values keep their case. `body` carries what a tag that wraps text
521
+ * reports about it: the text itself, and the Lua its click would run.
268
522
  */
269
- setMxpElement(name: string, attrs: Record<string, string>): void;
523
+ setMxpElement(name: string, attrs: Record<string, string>, body?: {
524
+ text: string;
525
+ actions: string[];
526
+ }): void;
270
527
  /**
271
- * Mudlet-style async unzip. Reads the zip from the profile VFS, decodes
272
- * it on a worker (fflate falls back to a chunked main-thread decode where
273
- * workers aren't available), writes every entry under destDir, then
274
- * raises sysUnzipDone / sysUnzipError. Always fire-and-forget.
528
+ * Mudlet-style async unzip, after TLuaInterpreter::unzipAsync: the extract
529
+ * directory is created (mkpath) before the call returns, whether or not the
530
+ * zip turns out to be usable, and everything after that — reading the zip,
531
+ * decoding it, writing every entry under destDir — runs on the timer queue
532
+ * and ends in sysUnzipDone or sysUnzipError. A missing or broken zip is
533
+ * therefore reported after unzipAsync() has returned, never inside it.
534
+ *
535
+ * Returns null once started, or the message desktop's warnArgumentValue
536
+ * gives when the directory could not be made (and nothing is queued).
275
537
  */
276
538
  private runUnzipAsync;
277
539
  /** Run `fn` off the current call stack, on the queue a blocked script still
@@ -285,7 +547,21 @@ export declare class LuaRuntime implements IScriptingRuntime {
285
547
  setCurrentLine(line: string, _isPrompt: boolean): void;
286
548
  setCommand(command: string): void;
287
549
  dispatchSendRequest(text: string): boolean;
288
- killScriptHandlers(scriptId: string): void;
550
+ syncScriptHandlers(entries: ScriptHandlerEntry[]): void;
551
+ /**
552
+ * A package's `config.lua`, read the way Mudlet reads one: by RUNNING it in
553
+ * an environment with nothing in it. Returns the string and number globals
554
+ * the chunk set, or the reason it never finished — a manifest that raises
555
+ * partway leaves nothing behind, which is the contract packages are written
556
+ * against and the reason a pattern match is not good enough here.
557
+ */
558
+ readPackageConfig(source: string): {
559
+ ok: true;
560
+ info: Record<string, string>;
561
+ } | {
562
+ ok: false;
563
+ reason: string;
564
+ };
289
565
  /**
290
566
  * Mudlet REGEX_LUA_CODE: the pattern body runs as a Lua function on every
291
567
  * incoming line. Side effects (raiseEvent, etc.) always run; the trigger
@@ -295,7 +571,7 @@ export declare class LuaRuntime implements IScriptingRuntime {
295
571
  /**
296
572
  * Invoke a `registerMapInfo` contributor. The Lua dispatcher pcalls the
297
573
  * stashed callback and writes its multi-return into scalar globals
298
- * (`__mudix_mapinfo_text` / _bold / _italic / _r / _g / _b). Returning
574
+ * (`__mudlet_mapinfo_text` / _bold / _italic / _r / _g / _b). Returning
299
575
  * `null` covers three cases: runtime is being torn down, callback id is
300
576
  * stale, or the callback returned a nil/empty text — the panel treats
301
577
  * all three the same (skip the entry).
@@ -321,16 +597,15 @@ export declare class LuaRuntime implements IScriptingRuntime {
321
597
  * pushTable does (see issue #2) is gone:
322
598
  * - integer-valued numbers → lua_pushinteger, others → lua_pushnumber
323
599
  * - arrays keyed by Object.keys + lua_rawseti, so dense 0-based arrays
324
- * (map getters) stay 0-indexed and the sparse 1-based arrays toLuaValue
325
- * builds stay 1-indexed — identical to wasmoon's arrIndexs handling
600
+ * (map getters) stay 0-indexed and sparse 1-based arrays stay
601
+ * 1-indexed — identical to wasmoon's arrIndexs handling
326
602
  * - plain objects → string keys via lua_setfield
327
603
  * Anything that isn't a primitive / plain array / plain object (wasmoon
328
- * LuaTable proxies such as the yajl.null sentinel, functions, Maps, class
329
- * instances) is delegated to wasmoon's own pushValue, which is O(1) for
330
- * these leaves and preserves their reference identity. Such values only
331
- * appear as leaves of GMCP/MSDP payloads (toLuaValue rebuilds every
332
- * container as a fresh plain array/object) and always push on the main
333
- * thread; on a coroutine stack we can't safely delegate, so degrade to nil.
604
+ * LuaTable proxies, functions, Maps, class instances) is delegated to
605
+ * wasmoon's own pushValue, which is O(1) for these leaves and preserves
606
+ * their reference identity. That is only safe on the main thread; on a
607
+ * coroutine stack we can't delegate, so degrade to nil. (GMCP/MSDP
608
+ * payloads don't come through here — see pushDecodedJson.)
334
609
  */
335
610
  private pushJsValue;
336
611
  /**
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Mudlet's argument-type contracts for the C API, as data.
3
+ *
4
+ * Desktop Mudlet validates the arguments of its C functions up front
5
+ * (`getVerifiedString/Int/Bool/Double`, `checkStringArg`, the `WINDOW_NAME` and
6
+ * `CMDLINE_NAME` macros in `TLuaInterpreter*.cpp`) and RAISES
7
+ * `"<fn>: bad argument #N type (<name> as <type> expected, got <type>!)"` on a
8
+ * mismatch. Mudlet Web's bindings mostly coerced or answered false/nil instead,
9
+ * so a script bug that fails loudly on desktop went unnoticed here and a
10
+ * `pcall` guard never fired (issue #277).
11
+ *
12
+ * Rather than hand-edit a check into every binding, each contract below is
13
+ * compiled once — by {@link buildArgContractLua} — into a small Lua wrapper that
14
+ * is installed over the global right after Bridge.lua, before the bundled
15
+ * mudlet-lua tree runs (so Geyser & co. capture the checked versions, as they
16
+ * do on desktop). The wrapper only VALIDATES: arguments are forwarded to the
17
+ * original binding untouched, so its existing coercion and its soft
18
+ * `(nil, msg)` answers for missing windows/rooms stay as they were.
19
+ *
20
+ * Validation follows Lua 5.1's `lua_is*`, exactly like desktop:
21
+ * - `s` (lua_isstring) — a string OR a number passes;
22
+ * - `n` / `i` (lua_isnumber) — a number OR a numeric string passes; `i`
23
+ * adds getVerifiedInt's 32-bit range check;
24
+ * - `b` (lua_isboolean) — strictly true/false.
25
+ * Where desktop picks an optional leading window name by ARGUMENT COUNT
26
+ * (`if (lua_gettop(L) > K)`), `win: K` does the same; desktop functions that
27
+ * dispatch on the TYPE of an argument are written out as `custom` checkers.
28
+ *
29
+ * Messages are desktop's, character for character, including the C++ function
30
+ * name where it differs from the Lua one (`clearWindow` reports as
31
+ * `clearUserWindow`). The error is raised at the caller's line (level 2 from
32
+ * the wrapper), as Bridge.lua's own checks are.
33
+ *
34
+ * Only functions where desktop really raises belong here; see the PR for #277
35
+ * for what was left out and why.
36
+ */
37
+ type Kind = 's' | 'n' | 'i' | 'b' | 'w' | 'c' | 'si' | 'sf' | 'x';
38
+ interface Arg {
39
+ k: Kind;
40
+ name?: string;
41
+ /** Desktop passes isOptional=true: the message reads "is optional". */
42
+ opt?: boolean;
43
+ /** Checked only when the argument is present (desktop gates on lua_gettop). */
44
+ present?: boolean;
45
+ /** Checked only when present and not nil (desktop gates on lua_isnoneornil). */
46
+ nonnil?: boolean;
47
+ /** A hand-written desktop message: `%d` is the position, `%s` the type name. */
48
+ msg?: string;
49
+ }
50
+ interface Contract {
51
+ args?: Arg[];
52
+ /** When more than this many arguments are passed, #1 is a window name. */
53
+ win?: number;
54
+ /** How that leading name is checked; WINDOW_NAME semantics when omitted. */
55
+ winArg?: Arg;
56
+ /** The C++ function name desktop's messages carry, when it differs. */
57
+ cname?: string;
58
+ /**
59
+ * A Lua function `(n, ...) -> errMsg|nil` for desktop functions whose
60
+ * argument layout depends on the type of an argument. It may use the
61
+ * helpers defined in PRELUDE (M, MW, MF, MO, isS, isN).
62
+ */
63
+ custom?: string;
64
+ }
65
+ export declare const ARG_CONTRACTS: Record<string, Contract>;
66
+ /**
67
+ * One Lua chunk that wraps every global named in {@link ARG_CONTRACTS} that
68
+ * exists when it runs. A missing global is skipped, not created.
69
+ */
70
+ export declare function buildArgContractLua(): string;
71
+ export {};
@@ -7,4 +7,4 @@ import type { BindingContext } from './context';
7
7
  * Every one of these is a thin forward into ScriptingAPI, which in turn routes
8
8
  * through the engine callbacks so mutations land in the appStore tree.
9
9
  */
10
- export declare function installAutomationBindings({ lua, api }: BindingContext): void;
10
+ export declare function installAutomationBindings({ lua, api, releaseCb }: BindingContext): void;
@@ -0,0 +1,13 @@
1
+ import type { BindingContext } from './context';
2
+ /**
3
+ * Mudlet's addon command API: the commands a package places on the client's own
4
+ * surfaces, and the handful of things it can change about one afterwards.
5
+ *
6
+ * The argument CONTRACT is in Bridge.lua rather than here, because every
7
+ * refusal names the Lua type of what it was handed ("surfaces has to be a list
8
+ * of surface names and this one holds a boolean") and a value's Lua type is
9
+ * precisely what does not survive the trip across wasmoon. What is left for
10
+ * this side is everything that needs state or real parsing: the ids, the key
11
+ * sequence, who already holds a key, and what the pulse will accept.
12
+ */
13
+ export declare function installCommandBindings({ lua, api, registerRawGlobal }: BindingContext): void;