@jsprismarine/script-host 0.0.0 → 0.23.0-unstable-20261120210452
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/CHANGELOG.md +99 -0
- package/LICENSE +21 -0
- package/README.md +667 -28
- package/dist/ScriptEngine.d.ts +250 -0
- package/dist/ScriptEngine.d.ts.map +1 -0
- package/dist/ScriptEngine.js +427 -0
- package/dist/ScriptEngine.js.map +1 -0
- package/dist/absentGlobals.d.ts +29 -0
- package/dist/absentGlobals.d.ts.map +1 -0
- package/dist/absentGlobals.js +94 -0
- package/dist/absentGlobals.js.map +1 -0
- package/dist/debugger/DebugSession.d.ts +189 -0
- package/dist/debugger/DebugSession.d.ts.map +1 -0
- package/dist/debugger/DebugSession.js +588 -0
- package/dist/debugger/DebugSession.js.map +1 -0
- package/dist/debugger/EngineDebugger.d.ts +158 -0
- package/dist/debugger/EngineDebugger.d.ts.map +1 -0
- package/dist/debugger/EngineDebugger.js +174 -0
- package/dist/debugger/EngineDebugger.js.map +1 -0
- package/dist/debugger/channel.d.ts +67 -0
- package/dist/debugger/channel.d.ts.map +1 -0
- package/dist/debugger/channel.js +120 -0
- package/dist/debugger/channel.js.map +1 -0
- package/dist/debugger/connectionWorker.d.ts +2 -0
- package/dist/debugger/connectionWorker.d.ts.map +1 -0
- package/dist/debugger/connectionWorker.js +98 -0
- package/dist/debugger/connectionWorker.js.map +1 -0
- package/dist/debugger/framing.d.ts +46 -0
- package/dist/debugger/framing.d.ts.map +1 -0
- package/dist/debugger/framing.js +106 -0
- package/dist/debugger/framing.js.map +1 -0
- package/dist/debugger/profiler.d.ts +72 -0
- package/dist/debugger/profiler.d.ts.map +1 -0
- package/dist/debugger/profiler.js +92 -0
- package/dist/debugger/profiler.js.map +1 -0
- package/dist/debugger/protocol.d.ts +170 -0
- package/dist/debugger/protocol.d.ts.map +1 -0
- package/dist/debugger/protocol.js +141 -0
- package/dist/debugger/protocol.js.map +1 -0
- package/dist/debugger/thread.d.ts +85 -0
- package/dist/debugger/thread.d.ts.map +1 -0
- package/dist/debugger/thread.js +134 -0
- package/dist/debugger/thread.js.map +1 -0
- package/dist/debugger/transport.d.ts +80 -0
- package/dist/debugger/transport.d.ts.map +1 -0
- package/dist/debugger/transport.js +150 -0
- package/dist/debugger/transport.js.map +1 -0
- package/dist/engineSource.d.ts +14 -0
- package/dist/engineSource.d.ts.map +1 -0
- package/dist/engineSource.js +17 -0
- package/dist/engineSource.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +62 -0
- package/dist/errors.js.map +1 -0
- package/dist/ffi.d.ts +63 -0
- package/dist/ffi.d.ts.map +1 -0
- package/dist/ffi.js +156 -0
- package/dist/ffi.js.map +1 -0
- package/dist/generated/script-modules/common.d.ts +2 -0
- package/dist/generated/script-modules/common.js +262 -0
- package/dist/generated/script-modules/common.js.map +1 -0
- package/dist/generated/script-modules/common.json.d.ts +2 -0
- package/dist/generated/script-modules/debug-utilities.d.ts +2 -0
- package/dist/generated/script-modules/debug-utilities.js +23 -0
- package/dist/generated/script-modules/debug-utilities.js.map +1 -0
- package/dist/generated/script-modules/debug-utilities.json.d.ts +2 -0
- package/dist/generated/script-modules/diagnostics.d.ts +2 -0
- package/dist/generated/script-modules/diagnostics.js +281 -0
- package/dist/generated/script-modules/diagnostics.js.map +1 -0
- package/dist/generated/script-modules/diagnostics.json.d.ts +2 -0
- package/dist/generated/script-modules/server-admin.d.ts +2 -0
- package/dist/generated/script-modules/server-admin.js +23 -0
- package/dist/generated/script-modules/server-admin.js.map +1 -0
- package/dist/generated/script-modules/server-admin.json.d.ts +2 -0
- package/dist/generated/script-modules/server-gametest.d.ts +2 -0
- package/dist/generated/script-modules/server-gametest.js +23 -0
- package/dist/generated/script-modules/server-gametest.js.map +1 -0
- package/dist/generated/script-modules/server-gametest.json.d.ts +2 -0
- package/dist/generated/script-modules/server-graphics.d.ts +2 -0
- package/dist/generated/script-modules/server-graphics.js +30 -0
- package/dist/generated/script-modules/server-graphics.js.map +1 -0
- package/dist/generated/script-modules/server-graphics.json.d.ts +2 -0
- package/dist/generated/script-modules/server-net.d.ts +2 -0
- package/dist/generated/script-modules/server-net.js +24 -0
- package/dist/generated/script-modules/server-net.js.map +1 -0
- package/dist/generated/script-modules/server-net.json.d.ts +2 -0
- package/dist/generated/script-modules/server-ui.d.ts +2 -0
- package/dist/generated/script-modules/server-ui.js +110 -0
- package/dist/generated/script-modules/server-ui.js.map +1 -0
- package/dist/generated/script-modules/server-ui.json.d.ts +2 -0
- package/dist/generated/script-modules/server.d.ts +2 -0
- package/dist/generated/script-modules/server.js +251 -0
- package/dist/generated/script-modules/server.js.map +1 -0
- package/dist/generated/script-modules/server.json.d.ts +2 -0
- package/dist/generated/scriptApi.d.ts +3233 -0
- package/dist/generated/scriptApi.d.ts.map +1 -0
- package/dist/generated/scriptApi.js +0 -0
- package/dist/generated/scriptModules.d.ts +13 -0
- package/dist/generated/scriptModules.d.ts.map +1 -0
- package/dist/generated/scriptModules.js +34 -0
- package/dist/generated/scriptModules.js.map +1 -0
- package/dist/host/PackForms.d.ts +71 -0
- package/dist/host/PackForms.d.ts.map +1 -0
- package/dist/host/PackForms.js +164 -0
- package/dist/host/PackForms.js.map +1 -0
- package/dist/host/ScriptForms.d.ts +51 -0
- package/dist/host/ScriptForms.d.ts.map +1 -0
- package/dist/host/ScriptForms.js +103 -0
- package/dist/host/ScriptForms.js.map +1 -0
- package/dist/host/ScriptHttp.d.ts +54 -0
- package/dist/host/ScriptHttp.d.ts.map +1 -0
- package/dist/host/ScriptHttp.js +82 -0
- package/dist/host/ScriptHttp.js.map +1 -0
- package/dist/host/WorldScripts.d.ts +350 -0
- package/dist/host/WorldScripts.d.ts.map +1 -0
- package/dist/host/WorldScripts.js +1421 -0
- package/dist/host/WorldScripts.js.map +1 -0
- package/dist/host/blocksItems/blockComponents.d.ts +27 -0
- package/dist/host/blocksItems/blockComponents.d.ts.map +1 -0
- package/dist/host/blocksItems/blockComponents.js +73 -0
- package/dist/host/blocksItems/blockComponents.js.map +1 -0
- package/dist/host/blocksItems/blocks.d.ts +12 -0
- package/dist/host/blocksItems/blocks.d.ts.map +1 -0
- package/dist/host/blocksItems/blocks.js +247 -0
- package/dist/host/blocksItems/blocks.js.map +1 -0
- package/dist/host/blocksItems/componentFacts.d.ts +14 -0
- package/dist/host/blocksItems/componentFacts.d.ts.map +1 -0
- package/dist/host/blocksItems/componentFacts.js +34 -0
- package/dist/host/blocksItems/componentFacts.js.map +1 -0
- package/dist/host/blocksItems/containers.d.ts +18 -0
- package/dist/host/blocksItems/containers.d.ts.map +1 -0
- package/dist/host/blocksItems/containers.js +128 -0
- package/dist/host/blocksItems/containers.js.map +1 -0
- package/dist/host/blocksItems/handles.d.ts +10 -0
- package/dist/host/blocksItems/handles.d.ts.map +1 -0
- package/dist/host/blocksItems/handles.js +30 -0
- package/dist/host/blocksItems/handles.js.map +1 -0
- package/dist/host/blocksItems/implement.d.ts +22 -0
- package/dist/host/blocksItems/implement.d.ts.map +1 -0
- package/dist/host/blocksItems/implement.js +23 -0
- package/dist/host/blocksItems/implement.js.map +1 -0
- package/dist/host/blocksItems/itemExtras.d.ts +8 -0
- package/dist/host/blocksItems/itemExtras.d.ts.map +1 -0
- package/dist/host/blocksItems/itemExtras.js +106 -0
- package/dist/host/blocksItems/itemExtras.js.map +1 -0
- package/dist/host/blocksItems/itemLink.d.ts +12 -0
- package/dist/host/blocksItems/itemLink.d.ts.map +1 -0
- package/dist/host/blocksItems/itemLink.js +38 -0
- package/dist/host/blocksItems/itemLink.js.map +1 -0
- package/dist/host/blocksItems/items.d.ts +25 -0
- package/dist/host/blocksItems/items.d.ts.map +1 -0
- package/dist/host/blocksItems/items.js +427 -0
- package/dist/host/blocksItems/items.js.map +1 -0
- package/dist/host/blocksItems/tags.d.ts +24 -0
- package/dist/host/blocksItems/tags.d.ts.map +1 -0
- package/dist/host/blocksItems/tags.js +27 -0
- package/dist/host/blocksItems/tags.js.map +1 -0
- package/dist/host/blocksItems/types.d.ts +13 -0
- package/dist/host/blocksItems/types.d.ts.map +1 -0
- package/dist/host/blocksItems/types.js +83 -0
- package/dist/host/blocksItems/types.js.map +1 -0
- package/dist/host/blocksItems/volumes.d.ts +37 -0
- package/dist/host/blocksItems/volumes.d.ts.map +1 -0
- package/dist/host/blocksItems/volumes.js +361 -0
- package/dist/host/blocksItems/volumes.js.map +1 -0
- package/dist/host/coverage.d.ts +28 -0
- package/dist/host/coverage.d.ts.map +1 -0
- package/dist/host/coverage.js +45 -0
- package/dist/host/coverage.js.map +1 -0
- package/dist/host/customContent.d.ts +81 -0
- package/dist/host/customContent.d.ts.map +1 -0
- package/dist/host/customContent.js +213 -0
- package/dist/host/customContent.js.map +1 -0
- package/dist/host/debugUtilities.d.ts +192 -0
- package/dist/host/debugUtilities.d.ts.map +1 -0
- package/dist/host/debugUtilities.js +503 -0
- package/dist/host/debugUtilities.js.map +1 -0
- package/dist/host/entities/aimAssist.d.ts +11 -0
- package/dist/host/entities/aimAssist.d.ts.map +1 -0
- package/dist/host/entities/aimAssist.js +195 -0
- package/dist/host/entities/aimAssist.js.map +1 -0
- package/dist/host/entities/area.d.ts +14 -0
- package/dist/host/entities/area.d.ts.map +1 -0
- package/dist/host/entities/area.js +19 -0
- package/dist/host/entities/area.js.map +1 -0
- package/dist/host/entities/components.d.ts +61 -0
- package/dist/host/entities/components.d.ts.map +1 -0
- package/dist/host/entities/components.js +642 -0
- package/dist/host/entities/components.js.map +1 -0
- package/dist/host/entities/entityMembers.d.ts +35 -0
- package/dist/host/entities/entityMembers.d.ts.map +1 -0
- package/dist/host/entities/entityMembers.js +494 -0
- package/dist/host/entities/entityMembers.js.map +1 -0
- package/dist/host/entities/playerMembers.d.ts +23 -0
- package/dist/host/entities/playerMembers.d.ts.map +1 -0
- package/dist/host/entities/playerMembers.js +576 -0
- package/dist/host/entities/playerMembers.js.map +1 -0
- package/dist/host/entities/world.d.ts +315 -0
- package/dist/host/entities/world.d.ts.map +1 -0
- package/dist/host/entities/world.js +0 -0
- package/dist/host/events/componentEvents.d.ts +11 -0
- package/dist/host/events/componentEvents.d.ts.map +1 -0
- package/dist/host/events/componentEvents.js +23 -0
- package/dist/host/events/componentEvents.js.map +1 -0
- package/dist/host/events/eventOptions.d.ts +14 -0
- package/dist/host/events/eventOptions.d.ts.map +1 -0
- package/dist/host/events/eventOptions.js +224 -0
- package/dist/host/events/eventOptions.js.map +1 -0
- package/dist/host/events/eventValues.d.ts +41 -0
- package/dist/host/events/eventValues.d.ts.map +1 -0
- package/dist/host/events/eventValues.js +89 -0
- package/dist/host/events/eventValues.js.map +1 -0
- package/dist/host/events/worldEvents.d.ts +30 -0
- package/dist/host/events/worldEvents.d.ts.map +1 -0
- package/dist/host/events/worldEvents.js +207 -0
- package/dist/host/events/worldEvents.js.map +1 -0
- package/dist/host/formJson.d.ts +35 -0
- package/dist/host/formJson.d.ts.map +1 -0
- package/dist/host/formJson.js +84 -0
- package/dist/host/formJson.js.map +1 -0
- package/dist/host/formKit.d.ts +40 -0
- package/dist/host/formKit.d.ts.map +1 -0
- package/dist/host/formKit.js +124 -0
- package/dist/host/formKit.js.map +1 -0
- package/dist/host/forms.d.ts +92 -0
- package/dist/host/forms.d.ts.map +1 -0
- package/dist/host/forms.js +361 -0
- package/dist/host/forms.js.map +1 -0
- package/dist/host/gametest.d.ts +202 -0
- package/dist/host/gametest.d.ts.map +1 -0
- package/dist/host/gametest.js +316 -0
- package/dist/host/gametest.js.map +1 -0
- package/dist/host/inputs.d.ts +29 -0
- package/dist/host/inputs.d.ts.map +1 -0
- package/dist/host/inputs.js +110 -0
- package/dist/host/inputs.js.map +1 -0
- package/dist/host/jobs.d.ts +48 -0
- package/dist/host/jobs.d.ts.map +1 -0
- package/dist/host/jobs.js +62 -0
- package/dist/host/jobs.js.map +1 -0
- package/dist/host/jsprismarineServer.d.ts +65 -0
- package/dist/host/jsprismarineServer.d.ts.map +1 -0
- package/dist/host/jsprismarineServer.js +83 -0
- package/dist/host/jsprismarineServer.js.map +1 -0
- package/dist/host/minecraftServer.d.ts +229 -0
- package/dist/host/minecraftServer.d.ts.map +1 -0
- package/dist/host/minecraftServer.js +304 -0
- package/dist/host/minecraftServer.js.map +1 -0
- package/dist/host/minecraftServerUi.d.ts +30 -0
- package/dist/host/minecraftServerUi.d.ts.map +1 -0
- package/dist/host/minecraftServerUi.js +89 -0
- package/dist/host/minecraftServerUi.js.map +1 -0
- package/dist/host/netKit.d.ts +44 -0
- package/dist/host/netKit.d.ts.map +1 -0
- package/dist/host/netKit.js +87 -0
- package/dist/host/netKit.js.map +1 -0
- package/dist/host/pack.d.ts +71 -0
- package/dist/host/pack.d.ts.map +1 -0
- package/dist/host/pack.js +157 -0
- package/dist/host/pack.js.map +1 -0
- package/dist/host/serverAdmin.d.ts +44 -0
- package/dist/host/serverAdmin.d.ts.map +1 -0
- package/dist/host/serverAdmin.js +96 -0
- package/dist/host/serverAdmin.js.map +1 -0
- package/dist/host/serverBlocks.d.ts +32 -0
- package/dist/host/serverBlocks.d.ts.map +1 -0
- package/dist/host/serverBlocks.js +93 -0
- package/dist/host/serverBlocks.js.map +1 -0
- package/dist/host/serverComponents.d.ts +46 -0
- package/dist/host/serverComponents.d.ts.map +1 -0
- package/dist/host/serverComponents.js +297 -0
- package/dist/host/serverComponents.js.map +1 -0
- package/dist/host/serverCustom.d.ts +16 -0
- package/dist/host/serverCustom.d.ts.map +1 -0
- package/dist/host/serverCustom.js +161 -0
- package/dist/host/serverCustom.js.map +1 -0
- package/dist/host/serverEntities.d.ts +49 -0
- package/dist/host/serverEntities.d.ts.map +1 -0
- package/dist/host/serverEntities.js +358 -0
- package/dist/host/serverEntities.js.map +1 -0
- package/dist/host/serverFeedback.d.ts +15 -0
- package/dist/host/serverFeedback.d.ts.map +1 -0
- package/dist/host/serverFeedback.js +413 -0
- package/dist/host/serverFeedback.js.map +1 -0
- package/dist/host/serverGametest.d.ts +43 -0
- package/dist/host/serverGametest.d.ts.map +1 -0
- package/dist/host/serverGametest.js +246 -0
- package/dist/host/serverGametest.js.map +1 -0
- package/dist/host/serverItems.d.ts +17 -0
- package/dist/host/serverItems.d.ts.map +1 -0
- package/dist/host/serverItems.js +71 -0
- package/dist/host/serverItems.js.map +1 -0
- package/dist/host/serverNet.d.ts +41 -0
- package/dist/host/serverNet.d.ts.map +1 -0
- package/dist/host/serverNet.js +289 -0
- package/dist/host/serverNet.js.map +1 -0
- package/dist/host/serverObjects.d.ts +142 -0
- package/dist/host/serverObjects.d.ts.map +1 -0
- package/dist/host/serverObjects.js +326 -0
- package/dist/host/serverObjects.js.map +1 -0
- package/dist/host/serverProperties.d.ts +48 -0
- package/dist/host/serverProperties.d.ts.map +1 -0
- package/dist/host/serverProperties.js +193 -0
- package/dist/host/serverProperties.js.map +1 -0
- package/dist/host/serverScoreboard.d.ts +9 -0
- package/dist/host/serverScoreboard.d.ts.map +1 -0
- package/dist/host/serverScoreboard.js +198 -0
- package/dist/host/serverScoreboard.js.map +1 -0
- package/dist/host/serverStructures.d.ts +9 -0
- package/dist/host/serverStructures.d.ts.map +1 -0
- package/dist/host/serverStructures.js +243 -0
- package/dist/host/serverStructures.js.map +1 -0
- package/dist/host/tasks.d.ts +66 -0
- package/dist/host/tasks.d.ts.map +1 -0
- package/dist/host/tasks.js +107 -0
- package/dist/host/tasks.js.map +1 -0
- package/dist/host/world.d.ts +1359 -0
- package/dist/host/world.d.ts.map +1 -0
- package/dist/host/world.js +10 -0
- package/dist/host/world.js.map +1 -0
- package/dist/host/worldsystem/gameRules.d.ts +189 -0
- package/dist/host/worldsystem/gameRules.d.ts.map +1 -0
- package/dist/host/worldsystem/gameRules.js +86 -0
- package/dist/host/worldsystem/gameRules.js.map +1 -0
- package/dist/host/worldsystem/memoryWorldSystem.d.ts +18 -0
- package/dist/host/worldsystem/memoryWorldSystem.d.ts.map +1 -0
- package/dist/host/worldsystem/memoryWorldSystem.js +223 -0
- package/dist/host/worldsystem/memoryWorldSystem.js.map +1 -0
- package/dist/host/worldsystem/seam.d.ts +163 -0
- package/dist/host/worldsystem/seam.d.ts.map +1 -0
- package/dist/host/worldsystem/seam.js +0 -0
- package/dist/host/worldsystem/serverClocks.d.ts +18 -0
- package/dist/host/worldsystem/serverClocks.d.ts.map +1 -0
- package/dist/host/worldsystem/serverClocks.js +166 -0
- package/dist/host/worldsystem/serverClocks.js.map +1 -0
- package/dist/host/worldsystem/serverDimension.d.ts +10 -0
- package/dist/host/worldsystem/serverDimension.d.ts.map +1 -0
- package/dist/host/worldsystem/serverDimension.js +388 -0
- package/dist/host/worldsystem/serverDimension.js.map +1 -0
- package/dist/host/worldsystem/serverFog.d.ts +15 -0
- package/dist/host/worldsystem/serverFog.d.ts.map +1 -0
- package/dist/host/worldsystem/serverFog.js +66 -0
- package/dist/host/worldsystem/serverFog.js.map +1 -0
- package/dist/host/worldsystem/serverLoot.d.ts +9 -0
- package/dist/host/worldsystem/serverLoot.d.ts.map +1 -0
- package/dist/host/worldsystem/serverLoot.js +255 -0
- package/dist/host/worldsystem/serverLoot.js.map +1 -0
- package/dist/host/worldsystem/serverPrimitiveShapes.d.ts +9 -0
- package/dist/host/worldsystem/serverPrimitiveShapes.d.ts.map +1 -0
- package/dist/host/worldsystem/serverPrimitiveShapes.js +149 -0
- package/dist/host/worldsystem/serverPrimitiveShapes.js.map +1 -0
- package/dist/host/worldsystem/serverTickingAreas.d.ts +11 -0
- package/dist/host/worldsystem/serverTickingAreas.d.ts.map +1 -0
- package/dist/host/worldsystem/serverTickingAreas.js +176 -0
- package/dist/host/worldsystem/serverTickingAreas.js.map +1 -0
- package/dist/host/worldsystem/serverVolumes.d.ts +9 -0
- package/dist/host/worldsystem/serverVolumes.d.ts.map +1 -0
- package/dist/host/worldsystem/serverVolumes.js +248 -0
- package/dist/host/worldsystem/serverVolumes.js.map +1 -0
- package/dist/host/worldsystem/serverWorld.d.ts +18 -0
- package/dist/host/worldsystem/serverWorld.d.ts.map +1 -0
- package/dist/host/worldsystem/serverWorld.js +199 -0
- package/dist/host/worldsystem/serverWorld.js.map +1 -0
- package/dist/host/worldsystem/tags.d.ts +40 -0
- package/dist/host/worldsystem/tags.d.ts.map +1 -0
- package/dist/host/worldsystem/tags.js +43 -0
- package/dist/host/worldsystem/tags.js.map +1 -0
- package/dist/install.d.ts +39 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +83 -0
- package/dist/install.js.map +1 -0
- package/dist/isRecord.d.ts +3 -0
- package/dist/isRecord.d.ts.map +1 -0
- package/dist/isRecord.js +6 -0
- package/dist/isRecord.js.map +1 -0
- package/dist/library.d.ts +40 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +101 -0
- package/dist/library.js.map +1 -0
- package/dist/manifest.d.ts +37 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +40 -0
- package/dist/manifest.js.map +1 -0
- package/dist/native/manifest.json.js +45 -0
- package/dist/native/manifest.json.js.map +1 -0
- package/dist/nativeHash.d.ts +16 -0
- package/dist/nativeHash.d.ts.map +1 -0
- package/dist/nativeHash.js +52 -0
- package/dist/nativeHash.js.map +1 -0
- package/dist/platform.d.ts +50 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +77 -0
- package/dist/platform.js.map +1 -0
- package/dist/shape/binding.d.ts +112 -0
- package/dist/shape/binding.d.ts.map +1 -0
- package/dist/shape/binding.js +558 -0
- package/dist/shape/binding.js.map +1 -0
- package/dist/shape/engineRuntime.d.ts +55 -0
- package/dist/shape/engineRuntime.d.ts.map +1 -0
- package/dist/shape/engineRuntime.js +451 -0
- package/dist/shape/engineRuntime.js.map +1 -0
- package/dist/shape/format.d.ts +249 -0
- package/dist/shape/format.d.ts.map +1 -0
- package/dist/shape/format.js +43 -0
- package/dist/shape/format.js.map +1 -0
- package/dist/shape/history.d.ts +24 -0
- package/dist/shape/history.d.ts.map +1 -0
- package/dist/shape/history.js +65 -0
- package/dist/shape/history.js.map +1 -0
- package/dist/shape/implementations.d.ts +105 -0
- package/dist/shape/implementations.d.ts.map +1 -0
- package/dist/shape/implementations.js +62 -0
- package/dist/shape/implementations.js.map +1 -0
- package/dist/shape/plan.d.ts +138 -0
- package/dist/shape/plan.d.ts.map +1 -0
- package/dist/shape/plan.js +0 -0
- package/dist/shape/resolve.d.ts +56 -0
- package/dist/shape/resolve.d.ts.map +1 -0
- package/dist/shape/resolve.js +78 -0
- package/dist/shape/resolve.js.map +1 -0
- package/dist/shape/version.d.ts +15 -0
- package/dist/shape/version.d.ts.map +1 -0
- package/dist/shape/version.js +35 -0
- package/dist/shape/version.js.map +1 -0
- package/dist/testing/debuggerWorker.d.ts +15 -0
- package/dist/testing/debuggerWorker.d.ts.map +1 -0
- package/dist/testing/debuggerWorker.js +29 -0
- package/dist/testing/debuggerWorker.js.map +1 -0
- package/dist/testing/engineWorker.d.ts +7 -0
- package/dist/testing/engineWorker.d.ts.map +1 -0
- package/dist/testing/engineWorker.js +31 -0
- package/dist/testing/engineWorker.js.map +1 -0
- package/dist/values.d.ts +94 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +204 -0
- package/dist/values.js.map +1 -0
- package/native/manifest.json +49 -0
- package/package.json +177 -6
- package/scripts/postinstall.mjs +54 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { engineFunctionSource } from "../engineSource.js";
|
|
2
|
+
// src/host/formKit.ts
|
|
3
|
+
/**
|
|
4
|
+
* Makes the kit of one context. It runs inside a script engine, so it must not refer to anything
|
|
5
|
+
* outside its own body, and it takes the built-ins it uses before any of the pack's code runs.
|
|
6
|
+
*/
|
|
7
|
+
function formKit() {
|
|
8
|
+
"use strict";
|
|
9
|
+
const { stringify, parse } = JSON;
|
|
10
|
+
const { isArray } = Array;
|
|
11
|
+
const { apply } = Reflect;
|
|
12
|
+
const { defineProperty } = Object;
|
|
13
|
+
/** Makes an own property, which no setter a script put on `Object.prototype` can intercept. */
|
|
14
|
+
const put = (target, key, value) => {
|
|
15
|
+
defineProperty(target, key, {
|
|
16
|
+
value,
|
|
17
|
+
writable: true,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const PromiseConstructor = Promise;
|
|
23
|
+
const WeakMapConstructor = WeakMap;
|
|
24
|
+
const uncurry = (fn) => (self, ...args) => apply(fn, self, args);
|
|
25
|
+
const weakGet = uncurry(WeakMap.prototype.get);
|
|
26
|
+
const weakSet = uncurry(WeakMap.prototype.set);
|
|
27
|
+
const push = uncurry(Array.prototype.push);
|
|
28
|
+
/** The properties of `RawMessage`, `RawMessageScore` and the form options interfaces. */
|
|
29
|
+
const KEYS = [
|
|
30
|
+
"rawtext",
|
|
31
|
+
"score",
|
|
32
|
+
"name",
|
|
33
|
+
"objective",
|
|
34
|
+
"text",
|
|
35
|
+
"translate",
|
|
36
|
+
"with",
|
|
37
|
+
"defaultValue",
|
|
38
|
+
"defaultValueIndex",
|
|
39
|
+
"tooltip",
|
|
40
|
+
"valueStep"
|
|
41
|
+
];
|
|
42
|
+
/** How deep a raw message nests before the kit stops following it. */
|
|
43
|
+
const DEPTH = 32;
|
|
44
|
+
const copy = (value, depth) => {
|
|
45
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
46
|
+
if (typeof value !== "object" || value === null || depth > DEPTH) return null;
|
|
47
|
+
if (isArray(value)) {
|
|
48
|
+
const list = [];
|
|
49
|
+
const { length } = value;
|
|
50
|
+
for (let index = 0; index < length; index++) push(list, copy(value[index], depth + 1));
|
|
51
|
+
return list;
|
|
52
|
+
}
|
|
53
|
+
const object = value;
|
|
54
|
+
const copied = {};
|
|
55
|
+
for (let index = 0; index < KEYS.length; index++) {
|
|
56
|
+
const key = KEYS[index];
|
|
57
|
+
if (key === void 0) continue;
|
|
58
|
+
const field = object[key];
|
|
59
|
+
if (field !== void 0) put(copied, key, copy(field, depth + 1));
|
|
60
|
+
}
|
|
61
|
+
return copied;
|
|
62
|
+
};
|
|
63
|
+
const forms = new WeakMapConstructor();
|
|
64
|
+
const stateOf = (form) => {
|
|
65
|
+
const known = weakGet(forms, form);
|
|
66
|
+
if (known !== void 0) return known;
|
|
67
|
+
const made = {
|
|
68
|
+
fields: {},
|
|
69
|
+
elements: []
|
|
70
|
+
};
|
|
71
|
+
weakSet(forms, form, made);
|
|
72
|
+
return made;
|
|
73
|
+
};
|
|
74
|
+
const responses = new WeakMapConstructor();
|
|
75
|
+
return {
|
|
76
|
+
plain: (value) => stringify(copy(value, 0)),
|
|
77
|
+
set(form, field, fragment) {
|
|
78
|
+
put(stateOf(form).fields, field, fragment);
|
|
79
|
+
return form;
|
|
80
|
+
},
|
|
81
|
+
add(form, kind, fragment) {
|
|
82
|
+
push(stateOf(form).elements, [kind, fragment]);
|
|
83
|
+
return form;
|
|
84
|
+
},
|
|
85
|
+
read: (form) => stringify(weakGet(forms, form) ?? {
|
|
86
|
+
fields: {},
|
|
87
|
+
elements: []
|
|
88
|
+
}),
|
|
89
|
+
deferred() {
|
|
90
|
+
let resolve = () => {};
|
|
91
|
+
let reject = () => {};
|
|
92
|
+
return [
|
|
93
|
+
new PromiseConstructor((onResolve, onReject) => {
|
|
94
|
+
resolve = onResolve;
|
|
95
|
+
reject = onReject;
|
|
96
|
+
}),
|
|
97
|
+
resolve,
|
|
98
|
+
reject
|
|
99
|
+
];
|
|
100
|
+
},
|
|
101
|
+
attach(response, data) {
|
|
102
|
+
weakSet(responses, response, parse(data));
|
|
103
|
+
},
|
|
104
|
+
field(response, key) {
|
|
105
|
+
const data = weakGet(responses, response);
|
|
106
|
+
if (data === void 0) return void 0;
|
|
107
|
+
if (key === "canceled") return data.canceled;
|
|
108
|
+
if (key === "cancelationReason") return data.cancelationReason;
|
|
109
|
+
if (key === "selection") return data.selection;
|
|
110
|
+
if (key !== "formValues" || data.formValues === void 0) return void 0;
|
|
111
|
+
const values = [];
|
|
112
|
+
for (let index = 0; index < data.formValues.length; index++) {
|
|
113
|
+
const value = data.formValues[index];
|
|
114
|
+
push(values, value === null && data.nullIsUndefined === true ? void 0 : value);
|
|
115
|
+
}
|
|
116
|
+
return values;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** The source text that evaluates, inside an engine, to {@link formKit}. */
|
|
121
|
+
var formKitSource = () => engineFunctionSource(formKit.toString());
|
|
122
|
+
export { formKit, formKitSource };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=formKit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formKit.js","names":[],"sources":["../../src/host/formKit.ts"],"sourcesContent":["import { engineFunctionSource } from '../engineSource';\n\n/**\n * The part of `@minecraft/server-ui` that runs inside a pack's engine context, never in Node.js.\n *\n * A form builder and a form response are objects a script holds and may drop at any time, so\n * what the host knows of each lives beside it, in a `WeakMap` of the pack's realm, and goes when\n * the script lets the object go. The host writes and reads it through the functions this returns.\n * Reading a script's argument into plain data runs here too, so the watchdog counts every getter\n * and element it visits, as it counts the script's own work.\n */\nexport interface FormKit {\n /**\n * Copies a `RawMessage`, an options object or a list of either into plain data and returns it\n * as JSON text, reading only the properties the Script API defines. A value nested deeper than\n * the kit follows is copied as `null`.\n */\n plain(value: unknown): string;\n /** Sets one of a form's fields, such as its title, to a fragment of form JSON, and returns the form. */\n set(form: object, field: string, fragment: string): object;\n /** Adds an element to a form, a fragment of form JSON and its kind, and returns the form. */\n add(form: object, kind: string, fragment: string): object;\n /** A form's fields and elements as JSON text: `{ fields, elements: [kind, fragment][] }`. */\n read(form: object): string;\n /** A new promise and the two functions that settle it. */\n deferred(): [Promise<unknown>, (value: unknown) => void, (reason: unknown) => void];\n /** Attaches what a response holds, as JSON text, to the response object a script gets. */\n attach(response: object, data: string): void;\n /**\n * Reads one field of a response. `formValues` is a new array each time, with each `null` of a\n * response that writes an absent value as `undefined`.\n */\n field(response: object, key: string): unknown;\n}\n\n/**\n * Makes the kit of one context. It runs inside a script engine, so it must not refer to anything\n * outside its own body, and it takes the built-ins it uses before any of the pack's code runs.\n */\nexport function formKit(): FormKit {\n // biome-ignore lint/suspicious/noRedundantUseStrict: the engine runs this source as a script, which is sloppy unless it says otherwise.\n 'use strict';\n const { stringify, parse } = JSON;\n const { isArray } = Array;\n const { apply } = Reflect;\n const { defineProperty } = Object;\n /** Makes an own property, which no setter a script put on `Object.prototype` can intercept. */\n const put = (target: object, key: string, value: unknown): void => {\n defineProperty(target, key, { value, writable: true, enumerable: true, configurable: true });\n };\n const PromiseConstructor = Promise;\n const WeakMapConstructor = WeakMap;\n const uncurry =\n <This, Args extends unknown[], Result>(fn: (this: This, ...args: Args) => Result) =>\n (self: This, ...args: Args): Result =>\n apply(fn, self, args);\n // The uncurried accessors lose the collections' type parameters, which these restore.\n const weakGet = uncurry(WeakMap.prototype.get) as <V>(map: WeakMap<object, V>, key: object) => V | undefined;\n const weakSet = uncurry(WeakMap.prototype.set);\n const push = uncurry(Array.prototype.push) as <T>(list: T[], value: T) => number;\n /** The properties of `RawMessage`, `RawMessageScore` and the form options interfaces. */\n const KEYS = [\n 'rawtext',\n 'score',\n 'name',\n 'objective',\n 'text',\n 'translate',\n 'with',\n 'defaultValue',\n 'defaultValueIndex',\n 'tooltip',\n 'valueStep'\n ];\n /** How deep a raw message nests before the kit stops following it. */\n const DEPTH = 32;\n\n type Plain = string | number | boolean | null | Plain[] | { [key: string]: Plain };\n const copy = (value: unknown, depth: number): Plain => {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return value;\n if (typeof value !== 'object' || value === null || depth > DEPTH) return null;\n if (isArray(value)) {\n const list: Plain[] = [];\n const { length } = value;\n for (let index = 0; index < length; index++) push(list, copy(value[index], depth + 1));\n return list;\n }\n // Any object a script passed; only the Script API's own properties are read from it.\n const object = value as Readonly<Record<string, unknown>>;\n const copied: { [key: string]: Plain } = {};\n for (let index = 0; index < KEYS.length; index++) {\n const key = KEYS[index];\n if (key === undefined) continue;\n const field = object[key];\n if (field !== undefined) put(copied, key, copy(field, depth + 1));\n }\n return copied;\n };\n\n interface FormState {\n readonly fields: { [field: string]: string };\n readonly elements: [string, string][];\n }\n const forms = new WeakMapConstructor<object, FormState>();\n const stateOf = (form: object): FormState => {\n const known = weakGet(forms, form);\n if (known !== undefined) return known;\n const made: FormState = { fields: {}, elements: [] };\n weakSet(forms, form, made);\n return made;\n };\n\n interface ResponseData {\n readonly canceled: boolean;\n readonly cancelationReason?: string;\n readonly selection?: number;\n /** The JSON array the client sent, for a submitted modal form. */\n readonly formValues?: Plain[];\n /** Whether a `null` among the form values reads as `undefined`. */\n readonly nullIsUndefined?: boolean;\n }\n const responses = new WeakMapConstructor<object, ResponseData>();\n\n return {\n plain: (value) => stringify(copy(value, 0)),\n set(form, field, fragment) {\n put(stateOf(form).fields, field, fragment);\n return form;\n },\n add(form, kind, fragment) {\n push(stateOf(form).elements, [kind, fragment]);\n return form;\n },\n read: (form) => stringify(weakGet(forms, form) ?? { fields: {}, elements: [] }),\n deferred() {\n let resolve: (value: unknown) => void = () => {};\n let reject: (reason: unknown) => void = () => {};\n const promise = new PromiseConstructor((onResolve, onReject) => {\n resolve = onResolve;\n reject = onReject;\n });\n return [promise, resolve, reject];\n },\n attach(response, data) {\n weakSet(responses, response, parse(data));\n },\n field(response, key) {\n const data = weakGet(responses, response);\n if (data === undefined) return undefined;\n if (key === 'canceled') return data.canceled;\n if (key === 'cancelationReason') return data.cancelationReason;\n if (key === 'selection') return data.selection;\n if (key !== 'formValues' || data.formValues === undefined) return undefined;\n const values: unknown[] = [];\n for (let index = 0; index < data.formValues.length; index++) {\n const value = data.formValues[index];\n push(values, value === null && data.nullIsUndefined === true ? undefined : value);\n }\n return values;\n }\n };\n}\n\n/** The source text that evaluates, inside an engine, to {@link formKit}. */\nexport const formKitSource = (): string => engineFunctionSource(formKit.toString());\n"],"mappings":";;;;;;AAuCA,SAAgB,UAAmB;CAE/B;CACA,MAAM,EAAE,WAAW,UAAU;CAC7B,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE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;IAC9B,KAAK,QAAQ,UAAU,QAAQ,KAAK,oBAAoB,OAAO,KAAA,IAAY,KAAK;GACpF;GACA,OAAO;EACX;CACJ;AACJ;;AAGA,IAAa,sBAA8B,qBAAqB,QAAQ,SAAS,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { BdsJson, BdsJsonObject } from './formJson.js';
|
|
2
|
+
/** The three form builders, by the `type` their JSON has. */
|
|
3
|
+
export type FormKind = 'action' | 'modal' | 'message';
|
|
4
|
+
/** An argument as the engine copied it out: a primitive, or a plain copy of an object or list. */
|
|
5
|
+
export type PlainValue = string | number | boolean | null | readonly PlainValue[] | PlainObject;
|
|
6
|
+
/** A plain copy of an object a script passed. */
|
|
7
|
+
export interface PlainObject {
|
|
8
|
+
readonly [key: string]: PlainValue;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A string or `RawMessage` argument as form JSON: a string as it is, and a `RawMessage` as a
|
|
12
|
+
* `rawtext` list, unless it is one already.
|
|
13
|
+
* @param argument - The argument's index, which the errors name.
|
|
14
|
+
* @throws {ScriptApiError} BDS's `RawMessageError` for a message that holds nothing.
|
|
15
|
+
* @throws {TypeError} When the value is neither.
|
|
16
|
+
*/
|
|
17
|
+
export declare const formText: (value: PlainValue, argument: number) => BdsJson;
|
|
18
|
+
/** A form element's kind, as its JSON `type` names it. */
|
|
19
|
+
export type FormElementKind = 'button' | 'header' | 'label' | 'divider' | 'input' | 'dropdown' | 'slider' | 'toggle';
|
|
20
|
+
/** What one builder call does to a form: set one of its fields, or add an element. */
|
|
21
|
+
export type FormChange = {
|
|
22
|
+
readonly field: string;
|
|
23
|
+
readonly json: BdsJson;
|
|
24
|
+
} | {
|
|
25
|
+
readonly element: FormElementKind;
|
|
26
|
+
readonly json: BdsJsonObject;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* What one builder call does to a form.
|
|
30
|
+
* @param kind - The builder.
|
|
31
|
+
* @param member - The member the script called, such as `button`.
|
|
32
|
+
* @param args - Its arguments, after the binding's checks, copied out of the engine.
|
|
33
|
+
* @param major - The major version of `@minecraft/server-ui` the pack is served.
|
|
34
|
+
* @throws {ScriptApiError} BDS's `RawMessageError` for a `RawMessage` that holds nothing.
|
|
35
|
+
* @throws {TypeError} For a `RawMessage` with a part of the wrong type.
|
|
36
|
+
* @throws {RangeError} For a member that is not a builder call.
|
|
37
|
+
*/
|
|
38
|
+
export declare const formChange: (kind: FormKind, member: string, args: readonly PlainValue[], major: number) => FormChange;
|
|
39
|
+
/** A form as the host keeps it: each field and each element as a written fragment of form JSON. */
|
|
40
|
+
export interface FormParts {
|
|
41
|
+
readonly fields: Readonly<Record<string, string>>;
|
|
42
|
+
readonly elements: readonly (readonly [string, string])[];
|
|
43
|
+
}
|
|
44
|
+
/** A form ready to send: its JSON, and what a response to it is read against. */
|
|
45
|
+
export interface BuiltForm {
|
|
46
|
+
readonly kind: FormKind;
|
|
47
|
+
readonly major: number;
|
|
48
|
+
/** The document a `ModalFormRequestPacket` carries, byte for byte as BDS writes it. */
|
|
49
|
+
readonly json: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Writes a whole form from its parts, with the defaults BDS writes for what the script left out:
|
|
53
|
+
* an empty title, body and buttons, and `null` for a form with no elements.
|
|
54
|
+
*/
|
|
55
|
+
export declare const buildForm: (kind: FormKind, major: number, parts: FormParts) => BuiltForm;
|
|
56
|
+
/** Why a form closed without an answer, as `FormCancelationReason` names it. */
|
|
57
|
+
export type FormCancelationReason = 'UserBusy' | 'UserClosed';
|
|
58
|
+
/** What a `show()` promise settles with, by what the client sent. */
|
|
59
|
+
export type FormOutcome = {
|
|
60
|
+
readonly settle: 'canceled';
|
|
61
|
+
readonly reason: FormCancelationReason;
|
|
62
|
+
} | {
|
|
63
|
+
readonly settle: 'selection';
|
|
64
|
+
readonly selection: number;
|
|
65
|
+
} | {
|
|
66
|
+
readonly settle: 'values';
|
|
67
|
+
readonly formValues: readonly PlainValue[];
|
|
68
|
+
readonly nullIsUndefined: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
readonly settle: 'malformed';
|
|
71
|
+
}
|
|
72
|
+
/** A response with neither JSON nor a reason: BDS drops it and the form stays open. */
|
|
73
|
+
| {
|
|
74
|
+
readonly settle: 'none';
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Reads a client's answer to a form as BDS does. A cancel reason, when the response has one, wins
|
|
78
|
+
* over its JSON: 1 is `UserBusy` and any other byte `UserClosed`. Otherwise the JSON must fit the
|
|
79
|
+
* form, or the promise rejects as malformed:
|
|
80
|
+
*
|
|
81
|
+
* - an action form takes an integer or a boolean, as {@link unsignedOf} reads it, whatever its
|
|
82
|
+
* number of buttons;
|
|
83
|
+
* - a message form takes the same, except that a boolean picks the first button with `true` in
|
|
84
|
+
* version 2, and with `false` in version 1, whose buttons are written the other way round;
|
|
85
|
+
* - a modal form takes a list of strings, numbers and booleans, of any length, and version 2
|
|
86
|
+
* also takes `null`, which reads as `undefined`.
|
|
87
|
+
*
|
|
88
|
+
* A response whose text is not JSON reads as malformed here; the server disconnects the client
|
|
89
|
+
* that sent it before it gets this far, as BDS does.
|
|
90
|
+
*/
|
|
91
|
+
export declare const readFormResponse: (form: BuiltForm, json: string | null, cancelReason: number | null) => FormOutcome;
|
|
92
|
+
//# sourceMappingURL=forms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forms.d.ts","sources":["../../src/host/forms.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGzD,6DAA6D;AAC7D,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAKtD,kGAAkG;AAClG,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,UAAU,EAAE,GAAG,WAAW,CAAC;AAEhG,iDAAiD;AAC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M,MAAM,qBAAqB,GAAG,UAAU,GAAG,YAAY,CAAC;AAE9D,qEAAqE;AACrE,MAAM,MAAM,WAAW,GACjB;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE,GACvE;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,UAAU,EAAE,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAAE,GAC5G;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE;AAClC,uFAAuF;GACrF;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAuBlC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,SAAU,SAAS,QAAQ,MAAM,GAAG,IAAI,gBAAgB,MAAM,GAAG,IAAI,KAAG,WA6BpG,CAAC"}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { ScriptApiError } from "../errors.js";
|
|
2
|
+
import { isRecord } from "../isRecord.js";
|
|
3
|
+
import { BdsFloat, writeBdsJson, writeBdsJsonValue } from "./formJson.js";
|
|
4
|
+
import { ScriptHostErrors } from "@jsprismarine/errors/script-host";
|
|
5
|
+
// src/host/forms.ts
|
|
6
|
+
/**
|
|
7
|
+
* The forms of `@minecraft/server-ui`, as Bedrock Dedicated Server (BDS) builds them and reads
|
|
8
|
+
* their answers. Everything here is plain data in and out: a builder call's arguments, copied out
|
|
9
|
+
* of the engine, become a fragment of form JSON; a form's fragments become the document a
|
|
10
|
+
* `ModalFormRequestPacket` carries; and the client's `ModalFormResponsePacket` becomes what
|
|
11
|
+
* `show()` settles with.
|
|
12
|
+
*
|
|
13
|
+
* The `forms`, `form-json`, `form-responses` and `forms-v1` scenarios of the parity suite's
|
|
14
|
+
* `scripting.ui` family record each rule on the pinned BDS.
|
|
15
|
+
*/
|
|
16
|
+
/** The JSON `type` of each form kind. */
|
|
17
|
+
var FORM_TYPE = {
|
|
18
|
+
action: "form",
|
|
19
|
+
modal: "custom_form",
|
|
20
|
+
message: "modal"
|
|
21
|
+
};
|
|
22
|
+
/** Whether a copied value is an object, not a list or a primitive. */
|
|
23
|
+
var isPlainObject = (value) => isRecord(value) && !Array.isArray(value);
|
|
24
|
+
/** The TypeError the binding throws for an argument that is neither a string nor a `RawMessage`. */
|
|
25
|
+
var notTextError = (argument) => new ScriptHostErrors.TextConversionFailed({ argument });
|
|
26
|
+
/**
|
|
27
|
+
* One `RawMessage` as BDS turns it into JSON, or null when it holds nothing. A non-empty
|
|
28
|
+
* `rawtext` wins over `translate`, which wins over `text`, which wins over `score`. A child that
|
|
29
|
+
* holds nothing is left out of its `rawtext`, which is null when no child is left. A `with` list
|
|
30
|
+
* of strings becomes a `rawtext` of texts, and an empty one is left out.
|
|
31
|
+
* @throws {TypeError} When a part is not of a `RawMessage` property's type.
|
|
32
|
+
*/
|
|
33
|
+
var rawMessagePart = (message, argument) => {
|
|
34
|
+
if (!isPlainObject(message)) throw notTextError(argument);
|
|
35
|
+
const { rawtext, translate, text, score } = message;
|
|
36
|
+
if (rawtext !== void 0 && rawtext !== null) {
|
|
37
|
+
if (!Array.isArray(rawtext)) throw notTextError(argument);
|
|
38
|
+
if (rawtext.length > 0) {
|
|
39
|
+
const parts = rawtext.map((part) => rawMessagePart(part, argument)).filter((part) => part !== null);
|
|
40
|
+
return { rawtext: parts.length === 0 ? null : parts };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (typeof translate === "string") {
|
|
44
|
+
const with_ = message.with;
|
|
45
|
+
if (Array.isArray(with_)) {
|
|
46
|
+
if (with_.length === 0) return { translate };
|
|
47
|
+
return {
|
|
48
|
+
translate,
|
|
49
|
+
with: { rawtext: with_.map((each) => {
|
|
50
|
+
if (typeof each !== "string") throw notTextError(argument);
|
|
51
|
+
return { text: each };
|
|
52
|
+
}) }
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (isPlainObject(with_)) return {
|
|
56
|
+
translate,
|
|
57
|
+
with: rawMessagePart(with_, argument)
|
|
58
|
+
};
|
|
59
|
+
return { translate };
|
|
60
|
+
}
|
|
61
|
+
if (typeof text === "string") return { text };
|
|
62
|
+
if (isPlainObject(score)) {
|
|
63
|
+
const { name, objective } = score;
|
|
64
|
+
return { score: {
|
|
65
|
+
...typeof name === "string" ? { name } : {},
|
|
66
|
+
...typeof objective === "string" ? { objective } : {}
|
|
67
|
+
} };
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* A string or `RawMessage` argument as form JSON: a string as it is, and a `RawMessage` as a
|
|
73
|
+
* `rawtext` list, unless it is one already.
|
|
74
|
+
* @param argument - The argument's index, which the errors name.
|
|
75
|
+
* @throws {ScriptApiError} BDS's `RawMessageError` for a message that holds nothing.
|
|
76
|
+
* @throws {TypeError} When the value is neither.
|
|
77
|
+
*/
|
|
78
|
+
var formText = (value, argument) => {
|
|
79
|
+
if (typeof value === "string") return value;
|
|
80
|
+
const part = rawMessagePart(value, argument);
|
|
81
|
+
if (part !== null && "rawtext" in part) return part;
|
|
82
|
+
const wrapped = { rawtext: [part] };
|
|
83
|
+
if (part === null) throw new ScriptApiError("@minecraft/server", "RawMessageError", `Failed to resolve raw message from json: \n${writeBdsJson(wrapped)}.`);
|
|
84
|
+
return wrapped;
|
|
85
|
+
};
|
|
86
|
+
/** A 32-bit integer, as BDS converts a number argument or option of an integer type. */
|
|
87
|
+
var int32 = (value) => Math.trunc(value) | 0;
|
|
88
|
+
/** An option's value, when the options object has it with the type it must have. */
|
|
89
|
+
var option = (options, key, is) => {
|
|
90
|
+
if (!isPlainObject(options)) return void 0;
|
|
91
|
+
const value = options[key];
|
|
92
|
+
return value !== void 0 && is(value) ? value : void 0;
|
|
93
|
+
};
|
|
94
|
+
var isNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
95
|
+
var isBoolean = (value) => typeof value === "boolean";
|
|
96
|
+
var isText = (value) => typeof value === "string" || isPlainObject(value);
|
|
97
|
+
/** The `tooltip` of a version 2 options object, when it has one. */
|
|
98
|
+
var tooltipOf = (options, argument) => {
|
|
99
|
+
const tooltip = option(options, "tooltip", isText);
|
|
100
|
+
return tooltip === void 0 ? {} : { tooltip: formText(tooltip, argument) };
|
|
101
|
+
};
|
|
102
|
+
/** A number argument the binding has checked. */
|
|
103
|
+
var numberAt = (args, index) => {
|
|
104
|
+
const value = args[index];
|
|
105
|
+
return typeof value === "number" ? value : 0;
|
|
106
|
+
};
|
|
107
|
+
/** The elements every builder of a version that has them shares: a header, a label and a divider. */
|
|
108
|
+
var textElement = (member, args) => {
|
|
109
|
+
if (member === "header" || member === "label") return {
|
|
110
|
+
element: member,
|
|
111
|
+
json: {
|
|
112
|
+
text: formText(args[0] ?? null, 0),
|
|
113
|
+
type: member
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
if (member === "divider") return {
|
|
117
|
+
element: "divider",
|
|
118
|
+
json: {
|
|
119
|
+
text: "",
|
|
120
|
+
type: "divider"
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/** One modal form element, under the version 1 signatures or the version 2 options objects. */
|
|
125
|
+
var modalElement = (member, args, major) => {
|
|
126
|
+
const label = () => formText(args[0] ?? null, 0);
|
|
127
|
+
switch (member) {
|
|
128
|
+
case "textField": {
|
|
129
|
+
const third = args[2];
|
|
130
|
+
const fallback = major === 1 ? third ?? void 0 : option(third, "defaultValue", isText);
|
|
131
|
+
return {
|
|
132
|
+
element: "input",
|
|
133
|
+
json: {
|
|
134
|
+
...fallback === void 0 || fallback === null ? {} : { default: formText(fallback, 2) },
|
|
135
|
+
placeholder: formText(args[1] ?? null, 1),
|
|
136
|
+
text: label(),
|
|
137
|
+
...major === 1 ? {} : tooltipOf(third, 2),
|
|
138
|
+
type: "input"
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
case "dropdown": {
|
|
143
|
+
const items = args[1];
|
|
144
|
+
const options = Array.isArray(items) && items.length > 0 ? items.map((item) => formText(item, 1)) : null;
|
|
145
|
+
const third = args[2];
|
|
146
|
+
const index = major === 1 ? typeof third === "number" ? third : void 0 : option(third, "defaultValueIndex", isNumber);
|
|
147
|
+
return {
|
|
148
|
+
element: "dropdown",
|
|
149
|
+
json: {
|
|
150
|
+
...index === void 0 ? {} : { default: int32(index) },
|
|
151
|
+
options,
|
|
152
|
+
text: label(),
|
|
153
|
+
...major === 1 ? {} : tooltipOf(third, 2),
|
|
154
|
+
type: "dropdown"
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
case "slider": {
|
|
159
|
+
const fourth = args[3];
|
|
160
|
+
const step = major === 1 ? numberAt(args, 3) : option(fourth, "valueStep", isNumber);
|
|
161
|
+
const fifth = args[4];
|
|
162
|
+
const fallback = major === 1 ? typeof fifth === "number" ? fifth : void 0 : option(fourth, "defaultValue", isNumber);
|
|
163
|
+
return {
|
|
164
|
+
element: "slider",
|
|
165
|
+
json: {
|
|
166
|
+
...fallback === void 0 ? {} : { default: int32(fallback) },
|
|
167
|
+
max: new BdsFloat(numberAt(args, 2)),
|
|
168
|
+
min: new BdsFloat(numberAt(args, 1)),
|
|
169
|
+
step: new BdsFloat(step === void 0 ? 1 : major === 1 ? step : int32(step)),
|
|
170
|
+
text: label(),
|
|
171
|
+
timeout: new BdsFloat(100),
|
|
172
|
+
...major === 1 ? {} : tooltipOf(fourth, 3),
|
|
173
|
+
type: "slider"
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
case "toggle": {
|
|
178
|
+
const second = args[1];
|
|
179
|
+
const fallback = major === 1 ? typeof second === "boolean" ? second : void 0 : option(second, "defaultValue", isBoolean);
|
|
180
|
+
return {
|
|
181
|
+
element: "toggle",
|
|
182
|
+
json: {
|
|
183
|
+
...fallback === void 0 ? {} : { default: fallback },
|
|
184
|
+
text: label(),
|
|
185
|
+
...major === 1 ? {} : tooltipOf(second, 1),
|
|
186
|
+
type: "toggle"
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
default: return textElement(member, args);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* What one builder call does to a form.
|
|
195
|
+
* @param kind - The builder.
|
|
196
|
+
* @param member - The member the script called, such as `button`.
|
|
197
|
+
* @param args - Its arguments, after the binding's checks, copied out of the engine.
|
|
198
|
+
* @param major - The major version of `@minecraft/server-ui` the pack is served.
|
|
199
|
+
* @throws {ScriptApiError} BDS's `RawMessageError` for a `RawMessage` that holds nothing.
|
|
200
|
+
* @throws {TypeError} For a `RawMessage` with a part of the wrong type.
|
|
201
|
+
* @throws {RangeError} For a member that is not a builder call.
|
|
202
|
+
*/
|
|
203
|
+
var formChange = (kind, member, args, major) => {
|
|
204
|
+
const text = (index) => formText(args[index] ?? null, index);
|
|
205
|
+
if (member === "title") return {
|
|
206
|
+
field: "title",
|
|
207
|
+
json: text(0)
|
|
208
|
+
};
|
|
209
|
+
if (kind === "action") {
|
|
210
|
+
if (member === "body") return {
|
|
211
|
+
field: "content",
|
|
212
|
+
json: text(0)
|
|
213
|
+
};
|
|
214
|
+
if (member === "button") {
|
|
215
|
+
const icon = args[1];
|
|
216
|
+
return {
|
|
217
|
+
element: "button",
|
|
218
|
+
json: {
|
|
219
|
+
image: typeof icon === "string" ? {
|
|
220
|
+
data: icon,
|
|
221
|
+
type: "path"
|
|
222
|
+
} : null,
|
|
223
|
+
text: text(0),
|
|
224
|
+
type: "button"
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const element = textElement(member, args);
|
|
229
|
+
if (element !== void 0) return element;
|
|
230
|
+
} else if (kind === "modal") {
|
|
231
|
+
if (member === "submitButton") return {
|
|
232
|
+
field: "submit",
|
|
233
|
+
json: text(0)
|
|
234
|
+
};
|
|
235
|
+
const element = modalElement(member, args, major);
|
|
236
|
+
if (element !== void 0) return element;
|
|
237
|
+
} else {
|
|
238
|
+
if (member === "body") return {
|
|
239
|
+
field: "content",
|
|
240
|
+
json: text(0)
|
|
241
|
+
};
|
|
242
|
+
if (member === "button1") return {
|
|
243
|
+
field: major === 1 ? "button2" : "button1",
|
|
244
|
+
json: text(0)
|
|
245
|
+
};
|
|
246
|
+
if (member === "button2") return {
|
|
247
|
+
field: major === 1 ? "button1" : "button2",
|
|
248
|
+
json: text(0)
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
throw new ScriptHostErrors.NotAFormBuilderMember({
|
|
252
|
+
member,
|
|
253
|
+
kind
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
/** A written fragment, kept as it is when the document around it is written. */
|
|
257
|
+
var Fragment = class {
|
|
258
|
+
text;
|
|
259
|
+
constructor(text) {
|
|
260
|
+
this.text = text;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Writes a whole form from its parts, with the defaults BDS writes for what the script left out:
|
|
265
|
+
* an empty title, body and buttons, and `null` for a form with no elements.
|
|
266
|
+
*/
|
|
267
|
+
var buildForm = (kind, major, parts) => {
|
|
268
|
+
const field = (name, fallback) => new Fragment(parts.fields[name] ?? writeBdsJsonValue(fallback));
|
|
269
|
+
const elements = parts.elements.length === 0 ? null : new Fragment(`[${parts.elements.map(([, json]) => json).join(",")}]`);
|
|
270
|
+
const top = {
|
|
271
|
+
title: field("title", ""),
|
|
272
|
+
type: FORM_TYPE[kind]
|
|
273
|
+
};
|
|
274
|
+
if (kind === "action") {
|
|
275
|
+
top.content = field("content", "");
|
|
276
|
+
top.elements = elements;
|
|
277
|
+
} else if (kind === "modal") {
|
|
278
|
+
top.content = elements;
|
|
279
|
+
top.icon = null;
|
|
280
|
+
if (parts.fields.submit !== void 0) top.submit = new Fragment(parts.fields.submit);
|
|
281
|
+
} else {
|
|
282
|
+
top.content = field("content", "");
|
|
283
|
+
top.button1 = field("button1", "");
|
|
284
|
+
top.button2 = field("button2", "");
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
kind,
|
|
288
|
+
major,
|
|
289
|
+
json: `{${Object.keys(top).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((key) => {
|
|
290
|
+
const value = top[key] ?? null;
|
|
291
|
+
return `${writeBdsJsonValue(key)}:${value instanceof Fragment ? value.text : writeBdsJsonValue(value)}`;
|
|
292
|
+
}).join(",")}}\n`
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
/** JSON's whitespace, which the response may have around its value. */
|
|
296
|
+
var JSON_WHITESPACE = /^[ \t\n\r]*|[ \t\n\r]*$/g;
|
|
297
|
+
/** The range a JSON integer must be in to be read as one rather than as a double. */
|
|
298
|
+
var INT64_MIN = -(2n ** 63n);
|
|
299
|
+
var UINT64_MAX = 2n ** 64n - 1n;
|
|
300
|
+
/**
|
|
301
|
+
* Reads a response that is an integer or a boolean as BDS does: an integer as a 32-bit unsigned
|
|
302
|
+
* number, so -1 is 4294967295, and a boolean as 1 or 0. A number with a fraction or an exponent,
|
|
303
|
+
* even `1.0`, is not an integer.
|
|
304
|
+
*/
|
|
305
|
+
var unsignedOf = (text, value) => {
|
|
306
|
+
if (typeof value === "boolean") return value ? 1 : 0;
|
|
307
|
+
const trimmed = text.replace(JSON_WHITESPACE, "");
|
|
308
|
+
if (!/^-?(0|[1-9][0-9]*)$/.test(trimmed)) return void 0;
|
|
309
|
+
const integer = BigInt(trimmed);
|
|
310
|
+
if (integer < INT64_MIN || integer > UINT64_MAX) return void 0;
|
|
311
|
+
return Number(BigInt.asUintN(32, integer));
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Reads a client's answer to a form as BDS does. A cancel reason, when the response has one, wins
|
|
315
|
+
* over its JSON: 1 is `UserBusy` and any other byte `UserClosed`. Otherwise the JSON must fit the
|
|
316
|
+
* form, or the promise rejects as malformed:
|
|
317
|
+
*
|
|
318
|
+
* - an action form takes an integer or a boolean, as {@link unsignedOf} reads it, whatever its
|
|
319
|
+
* number of buttons;
|
|
320
|
+
* - a message form takes the same, except that a boolean picks the first button with `true` in
|
|
321
|
+
* version 2, and with `false` in version 1, whose buttons are written the other way round;
|
|
322
|
+
* - a modal form takes a list of strings, numbers and booleans, of any length, and version 2
|
|
323
|
+
* also takes `null`, which reads as `undefined`.
|
|
324
|
+
*
|
|
325
|
+
* A response whose text is not JSON reads as malformed here; the server disconnects the client
|
|
326
|
+
* that sent it before it gets this far, as BDS does.
|
|
327
|
+
*/
|
|
328
|
+
var readFormResponse = (form, json, cancelReason) => {
|
|
329
|
+
if (cancelReason !== null) return {
|
|
330
|
+
settle: "canceled",
|
|
331
|
+
reason: cancelReason === 1 ? "UserBusy" : "UserClosed"
|
|
332
|
+
};
|
|
333
|
+
if (json === null) return { settle: "none" };
|
|
334
|
+
let value;
|
|
335
|
+
try {
|
|
336
|
+
value = JSON.parse(json);
|
|
337
|
+
} catch {
|
|
338
|
+
return { settle: "malformed" };
|
|
339
|
+
}
|
|
340
|
+
if (form.kind === "modal") {
|
|
341
|
+
if (!Array.isArray(value)) return { settle: "malformed" };
|
|
342
|
+
const nullIsUndefined = form.major !== 1;
|
|
343
|
+
return value.every((each) => typeof each === "string" || typeof each === "number" || typeof each === "boolean" || each === null && nullIsUndefined) ? {
|
|
344
|
+
settle: "values",
|
|
345
|
+
formValues: value,
|
|
346
|
+
nullIsUndefined
|
|
347
|
+
} : { settle: "malformed" };
|
|
348
|
+
}
|
|
349
|
+
if (form.kind === "message" && typeof value === "boolean") return {
|
|
350
|
+
settle: "selection",
|
|
351
|
+
selection: value === (form.major === 1) ? 1 : 0
|
|
352
|
+
};
|
|
353
|
+
const selection = unsignedOf(json, value);
|
|
354
|
+
return selection === void 0 ? { settle: "malformed" } : {
|
|
355
|
+
settle: "selection",
|
|
356
|
+
selection
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
export { buildForm, formChange, formText, readFormResponse };
|
|
360
|
+
|
|
361
|
+
//# sourceMappingURL=forms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forms.js","names":[],"sources":["../../src/host/forms.ts"],"sourcesContent":["/**\n * The forms of `@minecraft/server-ui`, as Bedrock Dedicated Server (BDS) builds them and reads\n * their answers. Everything here is plain data in and out: a builder call's arguments, copied out\n * of the engine, become a fragment of form JSON; a form's fragments become the document a\n * `ModalFormRequestPacket` carries; and the client's `ModalFormResponsePacket` becomes what\n * `show()` settles with.\n *\n * The `forms`, `form-json`, `form-responses` and `forms-v1` scenarios of the parity suite's\n * `scripting.ui` family record each rule on the pinned BDS.\n */\nimport { ScriptHostErrors } from '@jsprismarine/errors/script-host';\n\nimport { ScriptApiError } from '../errors';\nimport { isRecord } from '../isRecord';\nimport type { BdsJson, BdsJsonObject } from './formJson';\nimport { BdsFloat, writeBdsJson, writeBdsJsonValue } from './formJson';\n\n/** The three form builders, by the `type` their JSON has. */\nexport type FormKind = 'action' | 'modal' | 'message';\n\n/** The JSON `type` of each form kind. */\nconst FORM_TYPE: Readonly<Record<FormKind, string>> = { action: 'form', modal: 'custom_form', message: 'modal' };\n\n/** An argument as the engine copied it out: a primitive, or a plain copy of an object or list. */\nexport type PlainValue = string | number | boolean | null | readonly PlainValue[] | PlainObject;\n\n/** A plain copy of an object a script passed. */\nexport interface PlainObject {\n readonly [key: string]: PlainValue;\n}\n\n/** Whether a copied value is an object, not a list or a primitive. */\nconst isPlainObject = (value: PlainValue | undefined): value is PlainObject => isRecord(value) && !Array.isArray(value);\n\n/** The TypeError the binding throws for an argument that is neither a string nor a `RawMessage`. */\nconst notTextError = (argument: number): TypeError => new ScriptHostErrors.TextConversionFailed({ argument });\n\n/**\n * One `RawMessage` as BDS turns it into JSON, or null when it holds nothing. A non-empty\n * `rawtext` wins over `translate`, which wins over `text`, which wins over `score`. A child that\n * holds nothing is left out of its `rawtext`, which is null when no child is left. A `with` list\n * of strings becomes a `rawtext` of texts, and an empty one is left out.\n * @throws {TypeError} When a part is not of a `RawMessage` property's type.\n */\nconst rawMessagePart = (message: PlainValue, argument: number): BdsJsonObject | null => {\n if (!isPlainObject(message)) throw notTextError(argument);\n const { rawtext, translate, text, score } = message;\n if (rawtext !== undefined && rawtext !== null) {\n if (!Array.isArray(rawtext)) throw notTextError(argument);\n if (rawtext.length > 0) {\n const parts = rawtext\n .map((part: PlainValue) => rawMessagePart(part, argument))\n .filter((part): part is BdsJsonObject => part !== null);\n return { rawtext: parts.length === 0 ? null : parts };\n }\n }\n if (typeof translate === 'string') {\n const with_ = message.with;\n if (Array.isArray(with_)) {\n if (with_.length === 0) return { translate };\n const texts = with_.map((each: PlainValue) => {\n if (typeof each !== 'string') throw notTextError(argument);\n return { text: each };\n });\n return { translate, with: { rawtext: texts } };\n }\n if (isPlainObject(with_)) return { translate, with: rawMessagePart(with_, argument) };\n return { translate };\n }\n if (typeof text === 'string') return { text };\n if (isPlainObject(score)) {\n const { name, objective } = score;\n return {\n score: {\n ...(typeof name === 'string' ? { name } : {}),\n ...(typeof objective === 'string' ? { objective } : {})\n }\n };\n }\n return null;\n};\n\n/**\n * A string or `RawMessage` argument as form JSON: a string as it is, and a `RawMessage` as a\n * `rawtext` list, unless it is one already.\n * @param argument - The argument's index, which the errors name.\n * @throws {ScriptApiError} BDS's `RawMessageError` for a message that holds nothing.\n * @throws {TypeError} When the value is neither.\n */\nexport const formText = (value: PlainValue, argument: number): BdsJson => {\n if (typeof value === 'string') return value;\n const part = rawMessagePart(value, argument);\n if (part !== null && 'rawtext' in part) return part;\n const wrapped: BdsJsonObject = { rawtext: [part] };\n if (part === null) {\n throw new ScriptApiError(\n '@minecraft/server',\n 'RawMessageError',\n `Failed to resolve raw message from json: \\n${writeBdsJson(wrapped)}.`\n );\n }\n return wrapped;\n};\n\n/** A form element's kind, as its JSON `type` names it. */\nexport type FormElementKind = 'button' | 'header' | 'label' | 'divider' | 'input' | 'dropdown' | 'slider' | 'toggle';\n\n/** What one builder call does to a form: set one of its fields, or add an element. */\nexport type FormChange =\n | { readonly field: string; readonly json: BdsJson }\n | { readonly element: FormElementKind; readonly json: BdsJsonObject };\n\n/** A 32-bit integer, as BDS converts a number argument or option of an integer type. */\nconst int32 = (value: number): number => Math.trunc(value) | 0;\n\n/** An option's value, when the options object has it with the type it must have. */\nconst option = <Value extends PlainValue>(\n options: PlainValue | undefined,\n key: string,\n is: (value: PlainValue) => value is Value\n): Value | undefined => {\n if (!isPlainObject(options)) return undefined;\n const value = options[key];\n return value !== undefined && is(value) ? value : undefined;\n};\nconst isNumber = (value: PlainValue): value is number => typeof value === 'number' && Number.isFinite(value);\nconst isBoolean = (value: PlainValue): value is boolean => typeof value === 'boolean';\nconst isText = (value: PlainValue): value is PlainValue => typeof value === 'string' || isPlainObject(value);\n\n/** The `tooltip` of a version 2 options object, when it has one. */\nconst tooltipOf = (options: PlainValue | undefined, argument: number): BdsJsonObject => {\n const tooltip = option(options, 'tooltip', isText);\n return tooltip === undefined ? {} : { tooltip: formText(tooltip, argument) };\n};\n\n/** A number argument the binding has checked. */\nconst numberAt = (args: readonly PlainValue[], index: number): number => {\n const value = args[index];\n return typeof value === 'number' ? value : 0;\n};\n\n/** The elements every builder of a version that has them shares: a header, a label and a divider. */\nconst textElement = (member: string, args: readonly PlainValue[]): FormChange | undefined => {\n if (member === 'header' || member === 'label') {\n return { element: member, json: { text: formText(args[0] ?? null, 0), type: member } };\n }\n if (member === 'divider') return { element: 'divider', json: { text: '', type: 'divider' } };\n return undefined;\n};\n\n/** One modal form element, under the version 1 signatures or the version 2 options objects. */\nconst modalElement = (member: string, args: readonly PlainValue[], major: number): FormChange | undefined => {\n const label = (): BdsJson => formText(args[0] ?? null, 0);\n switch (member) {\n case 'textField': {\n const third = args[2];\n const fallback = major === 1 ? (third ?? undefined) : option(third, 'defaultValue', isText);\n return {\n element: 'input',\n json: {\n ...(fallback === undefined || fallback === null ? {} : { default: formText(fallback, 2) }),\n placeholder: formText(args[1] ?? null, 1),\n text: label(),\n ...(major === 1 ? {} : tooltipOf(third, 2)),\n type: 'input'\n }\n };\n }\n case 'dropdown': {\n const items = args[1];\n const options = Array.isArray(items) && items.length > 0 ? items.map((item) => formText(item, 1)) : null;\n const third = args[2];\n const index =\n major === 1\n ? typeof third === 'number'\n ? third\n : undefined\n : option(third, 'defaultValueIndex', isNumber);\n return {\n element: 'dropdown',\n json: {\n ...(index === undefined ? {} : { default: int32(index) }),\n options,\n text: label(),\n ...(major === 1 ? {} : tooltipOf(third, 2)),\n type: 'dropdown'\n }\n };\n }\n case 'slider': {\n const fourth = args[3];\n const step = major === 1 ? numberAt(args, 3) : option(fourth, 'valueStep', isNumber);\n const fifth = args[4];\n const fallback =\n major === 1\n ? typeof fifth === 'number'\n ? fifth\n : undefined\n : option(fourth, 'defaultValue', isNumber);\n return {\n element: 'slider',\n json: {\n ...(fallback === undefined ? {} : { default: int32(fallback) }),\n max: new BdsFloat(numberAt(args, 2)),\n min: new BdsFloat(numberAt(args, 1)),\n step: new BdsFloat(step === undefined ? 1 : major === 1 ? step : int32(step)),\n text: label(),\n timeout: new BdsFloat(100),\n ...(major === 1 ? {} : tooltipOf(fourth, 3)),\n type: 'slider'\n }\n };\n }\n case 'toggle': {\n const second = args[1];\n const fallback =\n major === 1\n ? typeof second === 'boolean'\n ? second\n : undefined\n : option(second, 'defaultValue', isBoolean);\n return {\n element: 'toggle',\n json: {\n ...(fallback === undefined ? {} : { default: fallback }),\n text: label(),\n ...(major === 1 ? {} : tooltipOf(second, 1)),\n type: 'toggle'\n }\n };\n }\n default:\n return textElement(member, args);\n }\n};\n\n/**\n * What one builder call does to a form.\n * @param kind - The builder.\n * @param member - The member the script called, such as `button`.\n * @param args - Its arguments, after the binding's checks, copied out of the engine.\n * @param major - The major version of `@minecraft/server-ui` the pack is served.\n * @throws {ScriptApiError} BDS's `RawMessageError` for a `RawMessage` that holds nothing.\n * @throws {TypeError} For a `RawMessage` with a part of the wrong type.\n * @throws {RangeError} For a member that is not a builder call.\n */\nexport const formChange = (kind: FormKind, member: string, args: readonly PlainValue[], major: number): FormChange => {\n const text = (index: number): BdsJson => formText(args[index] ?? null, index);\n if (member === 'title') return { field: 'title', json: text(0) };\n if (kind === 'action') {\n if (member === 'body') return { field: 'content', json: text(0) };\n if (member === 'button') {\n const icon = args[1];\n return {\n element: 'button',\n json: {\n image: typeof icon === 'string' ? { data: icon, type: 'path' } : null,\n text: text(0),\n type: 'button'\n }\n };\n }\n const element = textElement(member, args);\n if (element !== undefined) return element;\n } else if (kind === 'modal') {\n if (member === 'submitButton') return { field: 'submit', json: text(0) };\n const element = modalElement(member, args, major);\n if (element !== undefined) return element;\n } else {\n if (member === 'body') return { field: 'content', json: text(0) };\n // Version 1 writes the two buttons the other way round, and reads the answer the other way round.\n if (member === 'button1') return { field: major === 1 ? 'button2' : 'button1', json: text(0) };\n if (member === 'button2') return { field: major === 1 ? 'button1' : 'button2', json: text(0) };\n }\n throw new ScriptHostErrors.NotAFormBuilderMember({ member, kind });\n};\n\n/** A form as the host keeps it: each field and each element as a written fragment of form JSON. */\nexport interface FormParts {\n readonly fields: Readonly<Record<string, string>>;\n readonly elements: readonly (readonly [string, string])[];\n}\n\n/** A form ready to send: its JSON, and what a response to it is read against. */\nexport interface BuiltForm {\n readonly kind: FormKind;\n readonly major: number;\n /** The document a `ModalFormRequestPacket` carries, byte for byte as BDS writes it. */\n readonly json: string;\n}\n\n/** A written fragment, kept as it is when the document around it is written. */\nclass Fragment {\n public readonly text: string;\n public constructor(text: string) {\n this.text = text;\n }\n}\n\n/**\n * Writes a whole form from its parts, with the defaults BDS writes for what the script left out:\n * an empty title, body and buttons, and `null` for a form with no elements.\n */\nexport const buildForm = (kind: FormKind, major: number, parts: FormParts): BuiltForm => {\n const field = (name: string, fallback: string): Fragment =>\n new Fragment(parts.fields[name] ?? writeBdsJsonValue(fallback));\n const elements =\n parts.elements.length === 0 ? null : new Fragment(`[${parts.elements.map(([, json]) => json).join(',')}]`);\n const top: Record<string, Fragment | string | null> = { title: field('title', ''), type: FORM_TYPE[kind] };\n if (kind === 'action') {\n top.content = field('content', '');\n top.elements = elements;\n } else if (kind === 'modal') {\n top.content = elements;\n top.icon = null;\n if (parts.fields.submit !== undefined) top.submit = new Fragment(parts.fields.submit);\n } else {\n top.content = field('content', '');\n top.button1 = field('button1', '');\n top.button2 = field('button2', '');\n }\n const keys = Object.keys(top).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n const body = keys.map((key) => {\n const value = top[key] ?? null;\n return `${writeBdsJsonValue(key)}:${value instanceof Fragment ? value.text : writeBdsJsonValue(value)}`;\n });\n return { kind, major, json: `{${body.join(',')}}\\n` };\n};\n\n/** Why a form closed without an answer, as `FormCancelationReason` names it. */\nexport type FormCancelationReason = 'UserBusy' | 'UserClosed';\n\n/** What a `show()` promise settles with, by what the client sent. */\nexport type FormOutcome =\n | { readonly settle: 'canceled'; readonly reason: FormCancelationReason }\n | { readonly settle: 'selection'; readonly selection: number }\n | { readonly settle: 'values'; readonly formValues: readonly PlainValue[]; readonly nullIsUndefined: boolean }\n | { readonly settle: 'malformed' }\n /** A response with neither JSON nor a reason: BDS drops it and the form stays open. */\n | { readonly settle: 'none' };\n\n/** JSON's whitespace, which the response may have around its value. */\nconst JSON_WHITESPACE = /^[ \\t\\n\\r]*|[ \\t\\n\\r]*$/g;\n\n/** The range a JSON integer must be in to be read as one rather than as a double. */\nconst INT64_MIN = -(2n ** 63n);\nconst UINT64_MAX = 2n ** 64n - 1n;\n\n/**\n * Reads a response that is an integer or a boolean as BDS does: an integer as a 32-bit unsigned\n * number, so -1 is 4294967295, and a boolean as 1 or 0. A number with a fraction or an exponent,\n * even `1.0`, is not an integer.\n */\nconst unsignedOf = (text: string, value: unknown): number | undefined => {\n if (typeof value === 'boolean') return value ? 1 : 0;\n const trimmed = text.replace(JSON_WHITESPACE, '');\n if (!/^-?(0|[1-9][0-9]*)$/.test(trimmed)) return undefined;\n const integer = BigInt(trimmed);\n if (integer < INT64_MIN || integer > UINT64_MAX) return undefined;\n return Number(BigInt.asUintN(32, integer));\n};\n\n/**\n * Reads a client's answer to a form as BDS does. A cancel reason, when the response has one, wins\n * over its JSON: 1 is `UserBusy` and any other byte `UserClosed`. Otherwise the JSON must fit the\n * form, or the promise rejects as malformed:\n *\n * - an action form takes an integer or a boolean, as {@link unsignedOf} reads it, whatever its\n * number of buttons;\n * - a message form takes the same, except that a boolean picks the first button with `true` in\n * version 2, and with `false` in version 1, whose buttons are written the other way round;\n * - a modal form takes a list of strings, numbers and booleans, of any length, and version 2\n * also takes `null`, which reads as `undefined`.\n *\n * A response whose text is not JSON reads as malformed here; the server disconnects the client\n * that sent it before it gets this far, as BDS does.\n */\nexport const readFormResponse = (form: BuiltForm, json: string | null, cancelReason: number | null): FormOutcome => {\n if (cancelReason !== null) return { settle: 'canceled', reason: cancelReason === 1 ? 'UserBusy' : 'UserClosed' };\n if (json === null) return { settle: 'none' };\n let value: unknown;\n try {\n value = JSON.parse(json);\n } catch {\n return { settle: 'malformed' };\n }\n if (form.kind === 'modal') {\n if (!Array.isArray(value)) return { settle: 'malformed' };\n const nullIsUndefined = form.major !== 1;\n const fits = value.every(\n (each: unknown) =>\n typeof each === 'string' ||\n typeof each === 'number' ||\n typeof each === 'boolean' ||\n (each === null && nullIsUndefined)\n );\n // Checked above: every element is a string, a number, a boolean or null.\n return fits\n ? { settle: 'values', formValues: value as PlainValue[], nullIsUndefined }\n : { settle: 'malformed' };\n }\n if (form.kind === 'message' && typeof value === 'boolean') {\n return { settle: 'selection', selection: value === (form.major === 1) ? 1 : 0 };\n }\n const selection = unsignedOf(json, value);\n return selection === undefined ? { settle: 'malformed' } : { settle: 'selection', selection };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,IAAM,YAAgD;CAAE,QAAQ;CAAQ,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