UNPKG

@casual-simulation/aux-common

Version:
1,685 lines 40.9 kB
import { clamp } from '../utils'; import { hasValue } from './BotCalculations'; import { remoteError, remoteResult } from '../common'; /** * Defines a symbol that can be used to signal to the runtime that the action should not be mapped for bots. */ export const UNMAPPABLE = Symbol('UNMAPPABLE'); /** * The maximum allowed duration for tweens. */ export const MAX_TWEEN_DURATION = 60 * 60 * 24; export const APPROVED_SYMBOL = Symbol('approved'); /**z * Creates a new AddBotAction. * @param bot The bot that was added. */ export function botAdded(bot) { return { type: 'add_bot', id: bot.id, bot: bot, }; } /** * Creates a new RemoveBotAction. * @param botId The ID of the bot that was removed. */ export function botRemoved(botId) { return { type: 'remove_bot', id: botId, }; } /** * Creates a new UpdateBotAction. * @param id The ID of the bot that was updated. * @param update The update that was applied to the bot. */ export function botUpdated(id, update) { return { type: 'update_bot', id: id, update: update, }; } /** * Creates a new TransactionAction. * @param events The events to contain in the transaction. */ export function transaction(events) { return { type: 'transaction', events: events, }; } /** * Creates a new ShoutAction. * @param eventName The name of the event. * @param botIds The IDs of the bots that the event should be sent to. If null then the event is sent to every bot. * @param userId The ID of the bot for the current user. * @param arg The optional argument to provide. * @param sortIds Whether the bots should be processed in order of their Bot IDs. */ export function action(eventName, botIds = null, userId = null, arg, sortIds = true) { return { type: 'action', botIds, eventName, userId, argument: arg, sortBotIds: sortIds, }; } /** * Creates a new RejectAction. * @param event The action to reject. */ export function reject(...events) { return { type: 'reject', actions: events, }; } /** * Creates a new ApplyStateAction. * @param state The state to apply. */ export function addState(state) { return { type: 'apply_state', state: state, }; } /** * Creates a new PasteStateAction. * @param state The state to paste. * @param options The options for the event. */ export function pasteState(state, options) { return { type: 'paste_state', state, options, }; } /** * Creates a new ShowToastAction. * @param message The message to show with the event. */ export function toast(message, duration) { if (duration != null) { return { type: 'show_toast', message: message, duration: duration * 1000, }; } return { type: 'show_toast', message: message, duration: 2000, }; } export function getScriptIssues(botId, tag, taskId) { return { type: 'get_script_issues', botId: botId, tag: tag, taskId: taskId, }; } /** * Creates a new ShowTooltipAction. * @param message The message to show with the event. * @param pixelX The X coordinate that the tooltip should be shown at. If null, then the current pointer position will be used. * @param pixelY The Y coordinate that the tooltip should be shown at. If null, then the current pointer position will be used. * @param duration The duration that the tooltip should be shown in miliseconds. * @param taskId The ID of the async task. */ export function tip(message, pixelX, pixelY, duration, taskId) { return { type: 'show_tooltip', message, pixelX, pixelY, duration, taskId, }; } /** * Creates a HideTooltipAction. * @param ids The IDs of the tooltips that should be hidden. If null, then all tooltips will be hidden. * @param taskId The ID of the async task. */ export function hideTips(tooltipIds, taskId) { return { type: 'hide_tooltip', tooltipIds, taskId, }; } /** * Creates a new ShowHtmlAction. * @param template The HTML to show. */ export function html(html) { return { type: 'show_html', visible: true, html: html, }; } /** * Creates a new HideHtmlAction. */ export function hideHtml() { return { type: 'show_html', visible: false, }; } /** * Creates a new FocusOnBotAction. * @param botId The ID of the bot to tween to. * @param zoomValue The zoom value to use. * @param rotX The X rotation value. * @param rotY The Y rotation value. * @param duration The duration. */ export function tweenTo(botId, options = {}, taskId) { return { type: 'focus_on', botId: botId, taskId, ...options, }; } /** * Creates a new FocusOnPositionAction. * @param position The position that the camera should move to. * @param options The options to use. * @param taskId The ID of the task. */ export function animateToPosition(position, options = {}, taskId) { return { type: 'focus_on_position', position, taskId, ...options, }; } /** * Creates a new CancelAnimationAction. * @param taskId The ID of the task. */ export function cancelAnimation(taskId) { return { type: 'cancel_animation', taskId, }; } /** * Creates a new OpenQRCodeScannerAction. * @param open Whether the QR Code scanner should be open or closed. * @param cameraType The camera type that should be used. */ export function openQRCodeScanner(open, cameraType) { return { type: 'show_qr_code_scanner', open: open, cameraType: cameraType, disallowSwitchingCameras: false, }; } /** * Creates a new ShowQRCodeAction. * @param open Whether the QR Code should be visible. * @param code The code that should be shown. */ export function showQRCode(open, code) { return { type: 'show_qr_code', open: open, code: code, }; } /** * Creates a new OpenBarcodeScannerAction. * @param open Whether the barcode scanner should be open or closed. * @param cameraType The camera type that should be used. */ export function openBarcodeScanner(open, cameraType) { return { type: 'show_barcode_scanner', open: open, cameraType: cameraType, disallowSwitchingCameras: false, }; } /** * Creates a new OpenPhotoCameraAction. * @param open Whether the barcode scanner should be open or closed. * @param singlePhoto Whether only a single photo should be taken. * @param cameraType The camera type that should be used. */ export function openPhotoCamera(open, singlePhoto, options, taskId) { return { type: 'open_photo_camera', open: open, singlePhoto, options: options !== null && options !== void 0 ? options : {}, taskId, }; } /** * Creates a new ShowBarcodeAction. * @param open Whether the barcode should be visible. * @param code The code that should be shown. * @param format The format that the code should be shown in. Defaults to 'code128'. */ export function showBarcode(open, code, format = 'code128') { return { type: 'show_barcode', open: open, code: code, format: format, }; } /** * Creates a new OpenImageClassifierAction. * @param open Whether the image classifier should be opened or closed. * @param options The options for the classifier. * @param taskId The ID of the async task. */ export function openImageClassifier(open, options, taskId) { return { type: 'show_image_classifier', open, ...options, taskId, }; } export function classifyImages(options, taskId) { return { type: 'classify_images', ...options, taskId, }; } /** * Creates a new ShowRunBarAction that shows the run bar. * @param options The options that should be used. */ export function showChat(options = {}) { return { type: 'show_chat_bar', visible: true, ...options, }; } /** * Creates a new ShowRunBarAction that hides the run bar. */ export function hideChat() { return { type: 'show_chat_bar', visible: false, }; } export function loadSimulation(id) { if (typeof id === 'object') { return { type: 'load_server_config', config: id, }; } return { type: 'load_server', id: id, }; } export function unloadSimulation(id) { if (typeof id === 'object') { return { type: 'unload_server_config', config: id, }; } return { type: 'unload_server', id: id, }; } /** * Creates a new SuperShoutAction. * @param eventName The name of the event. * @param arg The argument to send as the "that" variable to scripts. */ export function superShout(eventName, arg) { return { type: 'super_shout', eventName, argument: arg, }; } /** * Creates a new GoToContextAction. * @param dimension The simulation ID or dimension to go to. If a simulation ID is being provided, then the dimension parameter must also be provided. */ export function goToDimension(dimension) { return { type: 'go_to_dimension', dimension, }; } /** * Creates a new ImportAUXAction. * @param url The URL that should be loaded. * @param taskId The ID of the async task. */ export function importAUX(url, taskId) { return { type: 'import_aux', url: url, taskId, }; } /** * Creates a new ShowInputForTagAction. * @param botId The ID of the bot to edit. * @param tag The tag to edit. */ export function showInputForTag(botId, tag, options) { return { type: 'show_input_for_tag', botId: botId, tag: tag, options: options || {}, }; } /** * Creates a new ShowInputAction. * @param currentValue The value that the input should be prefilled with. * @param options The options for the input. * @param taskId The ID of the async task. */ export function showInput(currentValue, options, taskId) { return { type: 'show_input', taskId, currentValue, options: options || {}, }; } /** * Creates a new ShowConfirmAction. * @param options The options for the action. * @param taskId The ID of the async task. */ export function showConfirm(options, taskId) { return { type: 'show_confirm', options, taskId, }; } /** * Creates a new SetForcedOfflineAction event. * @param offline Whether the connection should be offline. */ export function setForcedOffline(offline) { return { type: 'set_offline_state', offline: offline, }; } /** * Creates a new GoToURLAction. * @param url The URL to go to. */ export function goToURL(url) { return { type: 'go_to_url', url: url, }; } /** * Creates a new OpenURLAction. * @param url The URL to go to. */ export function openURL(url) { return { type: 'open_url', url: url, }; } /** * Creates a new PlaySoundAction. * @param url The URL of the sound to play. * @param soundID The ID of the sound. * @param taskId The ID of the task. */ export function playSound(url, soundID, taskId) { return { type: 'play_sound', url: url, soundID, taskId, }; } /** * Creates a new BufferSoundAction. * @param url The URL of the sound to play. * @param taskId The ID of the async task. */ export function bufferSound(url, taskId) { return { type: 'buffer_sound', url: url, taskId, }; } /** * Creates a new CancelSoundAction. * @param soundId The ID of the sound to cancel. * @param taskId The ID of the async task. */ export function cancelSound(soundID, taskId) { return { type: 'cancel_sound', soundID, taskId, }; } /** * Creates a new ShellAction. * @param script The script that should be run. */ export function shell(script) { return { type: 'shell', script: script, }; } /** * Creates a new ToggleConsoleEvent. */ export function openConsole() { return { type: 'open_console', open: true, }; } /** * Creates a new DownloadAction. * @param data The data that should be downloaded. * @param filename The name of the file. * @param mimeType The MIME type of the data. */ export function download(data, filename, mimeType) { return { type: 'download', data, filename, mimeType, }; } /** * Creates a new SendWebhookAction. * @param options The options for the webhook. * @param taskId The ID of the task. */ export function webhook(options, taskId) { return { type: 'send_webhook', options: options, taskId, }; } /** * Animates the given tag on the given bot using the given options. * @param botId The ID of the bot. * @param tag The tag to animate. * @param options The options. * @param taskId The ID of the task that this event represents. */ export function animateTag(botId, tag, options, taskId) { return { type: 'animate_tag', botId, tag, options, taskId, }; } /** * Creates a new GetRemoteCountAction. * @param inst The instance that the device count should be retrieved for. */ export function getRemoteCount(recordName, inst, branch) { if (hasValue(inst)) { return { type: 'get_remote_count', recordName, inst, branch, }; } else { return { type: 'get_remote_count', }; } } /** * Creates a new GetRemotesAction. */ export function getRemotes() { return { type: 'get_remotes', }; } /** * Creates a new ListInstUpdatesAction. */ export function listInstUpdates() { return { type: 'list_inst_updates', }; } /** * Creates a new GetInstStateFromUpdatesAction. * @param updates The list of updates to use. */ export function getInstStateFromUpdates(updates) { return { type: 'get_inst_state_from_updates', updates, }; } /** * Creates a new CreateInitializationUpdateAction. * @param bots The bots that should be encoded into the update. * @param taskId The ID of the task. */ export function createInitializationUpdate(bots) { return { type: 'create_initialization_update', bots, }; } /** * Creates a new ApplyUpdatesToInstAction. * @param updates The list of updates that should be applied. * @param taskId The ID of the task. */ export function applyUpdatesToInst(updates) { return { type: 'apply_updates_to_inst', updates, }; } /** * Creates a new GetCurrentInstUpdateAction. */ export function getCurrentInstUpdate() { return { type: 'get_current_inst_update', }; } /** * Creates a new ReplaceDragBotAction. * @param bot The bot/mod that should be dragged instead. */ export function replaceDragBot(bot) { return { type: 'replace_drag_bot', bot, }; } /** * Creates a SetClipboardAction. * @param text The text that should be set to the clipboard. */ export function setClipboard(text) { return { type: 'set_clipboard', text, }; } /** * Creates a RunScriptAction. * @param script The script that should be executed. * @param taskId The ID of the async task that this script represents. */ export function runScript(script, taskId) { return { type: 'run_script', script, taskId, }; } /** * Creates a showUploadAuxFileAction. */ export function showUploadAuxFile() { return { type: 'show_upload_aux_file', }; } /** * Creates a ShowUploadFilesAction. */ export function showUploadFiles(taskId) { return { type: 'show_upload_files', taskId, }; } /** * Loads a space into the instance. * @param space The space to load. * @param config The config which specifies how the space should be loaded. * @param taskId The ID of the async task. */ export function loadSpace(space, config, taskId) { return { type: 'load_space', space, config, taskId, }; } /** * Loads a shared document. * @param recordName The name of the record. * @param inst The instance to load the document into. * @param branch The branch to load the document from. * @param taskId The ID of the async task. */ export function loadSharedDocument(recordName, inst, branch, taskId) { return { type: 'load_shared_document', recordName, inst, branch, taskId, }; } /** * Creates a EnableCollaborationAction. * @param taskId The ID of the async task. */ export function enableCollaboration(taskId) { return { type: 'enable_collaboration', taskId, }; } /** * Creates a ShowAccountInfoAction. * @param taskId The ID of the async task. */ export function showAccountInfo(taskId) { return { type: 'show_account_info', taskId, }; } /** * Creates a EnableARAction. */ export function enableAR(options = {}) { return { type: 'enable_ar', enabled: true, options, }; } /** * Creates a EnableVRAction. */ export function enableVR(options = {}) { return { type: 'enable_vr', enabled: true, options, }; } /** * Creates a EnableARAction that disables AR. */ export function disableAR() { return { type: 'enable_ar', enabled: false, options: {}, }; } /** * Creates a EnableVRAction that disables VR. */ export function disableVR() { return { type: 'enable_vr', enabled: false, options: {}, }; } /** * Creates a new ARSupportedAction. * @param taskId The ID of the async task. */ export function arSupported(taskId) { return { type: 'ar_supported', taskId, }; } /** * Creates a new VRSupportedAction. * @param taskId The ID of the async task. */ export function vrSupported(taskId) { return { type: 'vr_supported', taskId, }; } /** * Creates a EnablePOVAction that enables point-of-view mode. * @param center * @returns */ export function enablePOV(center, imu) { return { type: 'enable_pov', enabled: true, center, imu, }; } /** * Creates a EnablePOVAction that disables point-of-view mode. */ export function disablePOV() { return { type: 'enable_pov', enabled: false, }; } /** * Creates a ShowJoinCodeAction. * @param inst The instance to link to. * @param dimension The dimension to link to. */ export function showJoinCode(inst, dimension) { return { type: 'show_join_code', inst, dimension, }; } /** * Requests that the app go into fullscreen mode. */ export function requestFullscreen() { return { type: 'request_fullscreen_mode', }; } /** * Exists fullscreen mode. */ export function exitFullscreen() { return { type: 'exit_fullscreen_mode', }; } /** * Requests that all the bots in the given space be cleared. * * Only supported for the following spaces: * - error * * @param space The space to clear. * @param taskId The ID of the async task. */ export function clearSpace(space, taskId) { return { type: 'clear_space', space: space, taskId, }; } /** * Requests that the given animation be played for the given bot locally. * @param botId The bot ID. * @param animation The animation. */ export function localFormAnimation(botId, animation) { return { type: 'local_form_animation', botId, animation, }; } /** * Requests that the given bot be tweened to the given position using the given easing. * @param botId The ID of the bot. * @param dimension The dimension that the bot should be tweened in. * @param position The position of the bot. * @param easing The easing to use. * @param duration The duration of the tween in seconds. */ export function localPositionTween(botId, dimension, position, easing = { type: 'linear', mode: 'inout' }, duration = 1, taskId) { return { type: 'local_tween', tweenType: 'position', botId, dimension, easing, position, duration: clamp(duration, 0, MAX_TWEEN_DURATION), taskId, }; } /** * Requests that the given bot be tweened to the given rotation using the given easing. * @param botId The ID of the bot. * @param dimension The dimension that the bot should be tweened in. * @param position The position of the bot. * @param easing The easing to use. * @param duration The duration of the tween in seconds. * */ export function localRotationTween(botId, dimension, rotation, easing = { type: 'linear', mode: 'inout' }, duration = 1, taskId) { return { type: 'local_tween', tweenType: 'rotation', botId, dimension, easing, rotation, duration: clamp(duration, 0, MAX_TWEEN_DURATION), taskId, }; } /** * Enqueues an async result to the given list for the given event. * @param list The list to add the result to. * @param event The event that the result is for. * @param result The result. * @param mapBots Whether the result should have the argument mapped for bots. */ export function enqueueAsyncResult(list, event, result, mapBots) { if (hasValue(event.taskId)) { if (hasValue(event.playerId)) { list.push(remoteResult(result, { sessionId: event.playerId, }, event.taskId)); } else { list.push(asyncResult(event.taskId, result, mapBots)); } } } /** * Enqueues an async error to the given list for the given event. * @param list The list to add the error to. * @param event The event that the error is for. * @param error The error. */ export function enqueueAsyncError(list, event, error) { if (hasValue(event.taskId)) { if (hasValue(event.playerId)) { list.push(remoteError(error, { sessionId: event.playerId, }, event.taskId)); } else { list.push(asyncError(event.taskId, error)); } } } /** * Creates an action that resolves an async task with the given result. * @param taskId The ID of the task. * @param result The result. * @param mapBots Whether to map any bots found in the result to their actual counterparts. * @param uncopiable Whether the result should be uncopiable. */ export function asyncResult(taskId, result, mapBots, uncopiable) { return { type: 'async_result', taskId, result, mapBotsInResult: mapBots, uncopiable, }; } /** * Creates an action that resolves an async task with the given error. * @param taskId The ID of the task. * @param error The error. */ export function asyncError(taskId, error) { return { type: 'async_error', taskId, error, }; } /** * Creates an action that provides a next value to an iterable. * @param taskId The ID of the task for the iterable. * @param value The value. */ export function iterableNext(taskId, value) { return { type: 'iterable_next', taskId, value, }; } /** * Creates an action that completes an iterable. * @param taskId The ID of the task for the iterable. * @returns */ export function iterableComplete(taskId) { return { type: 'iterable_complete', taskId, }; } /** * Creates an action that throws an error for an iterable. * @param taskId The ID of the task for the iterable. * @param error The error to throw from the iterable. */ export function iterableThrow(taskId, error) { return { type: 'iterable_throw', taskId, error, }; } /** * Creates an action that shares some data via the device's social share capabilities. * @param options The options for sharing. * @param taskId The ID of the task. */ export function share(options, taskId) { return { type: 'share', taskId, ...options, }; } /** * Creates an action that opens/closes the circle wipe display element. * @param open Whether the circle wipe should transition to open or closed. * @param options The options that the circle wipe should use. * @param taskId The ID of the task. */ export function circleWipe(open, options, taskId) { return { type: 'show_circle_wipe', open, options, taskId, }; } /** * Creates a AddDropSnapTargetsAction. * @param botId The ID of the bot. * @param targets The list of snap targets to add. */ export function addDropSnap(botId, targets) { return { type: 'add_drop_snap_targets', botId, targets, }; } /** * Creates a AddDropGridTargetsAction. * @param botId The ID of the bot. * @param targets The list of snap targets to add. */ export function addDropGrid(botId, targets) { return { type: 'add_drop_grid_targets', botId, targets, }; } /** * Creates a EnableCustomDraggingAction. */ export function enableCustomDragging() { return { type: 'enable_custom_dragging', }; } /** * Creates an action that registers a portal that is builtin. * This instructs the runtime to create a portal bot if one has not already been created. * @param portalId The ID of the portal. */ export function registerBuiltinPortal(portalId) { return { type: 'register_builtin_portal', portalId, }; } /** * Creates an action that registers the given script prefix for custom portals. * @param prefix The prefix that should be used. * @param taskId The ID of the task. */ export function registerPrefix(prefix, options, taskId) { return { type: 'register_prefix', prefix, options, taskId, }; } /** * Creates a BeginAudioRecordingAction. * @param options The options for the audio recording. * @param taskId The task ID. */ export function beginAudioRecording(options, taskId) { return { type: 'begin_audio_recording', ...options, taskId, }; } /** * Creates a EndAudioRecordingAction. * @param taskId The task ID. */ export function endAudioRecording(taskId) { return { type: 'end_audio_recording', taskId, }; } /** * Creates a BeginRecordingAction. * @param options The options for the recording. * @param taskId The task ID. */ export function beginRecording(options, taskId) { return { type: 'begin_recording', ...options, taskId, }; } /** * Creates a EndRecordingAction. * @param taskId The task ID. */ export function endRecording(taskId) { return { type: 'end_recording', taskId, }; } /** * Creates a MeetCommandAction. * @param command The name of the command to execute. * @param args The arguments for the command. */ export function meetCommand(command, args, taskId) { return { type: 'meet_command', command, args, taskId, }; } /** * Creates a MeetFunctionAction. * @param functionName The name of the function. * @param args The arguments for the function. * @param taskId The ID of the async task. */ export function meetFunction(functionName, args, taskId) { return { type: 'meet_function', functionName, args, taskId, }; } /** * Creates a SpeakTextAction. * @param text The text that should be spoken. * @param options The options that should be used. * @param taskId The ID of the task. */ export function speakText(text, options, taskId) { return { type: 'speak_text', text, ...options, taskId, }; } /** * Creates a GetVoicesAction. * @param taskId The task ID. */ export function getVoices(taskId) { return { type: 'get_voices', taskId, }; } /** * Creates a GetGeolocationAction. * @param taskId The ID of the task. */ export function getGeolocation(taskId) { return { type: 'get_geolocation', taskId, }; } /** * Creates a GoToTagAction. * @param botId The ID of the bot. * @param tag The tag to navigate to. */ export function goToTag(botId, tag, space = null) { return { type: 'go_to_tag', botId, tag, space, }; } export function customAppContainerAvailable() { return { type: 'custom_app_container_available', }; } /** * Creates a RegisterCustomAppAction. * @param appId The Id of the app. * @param botId The ID of the bot. */ export function registerCustomApp(appId, botId, taskId) { return { type: 'register_custom_app', appId, botId, taskId, }; } /** * Creates a UnegisterCustomAppAction. * @param appId The Id of the app. * @param botId The ID of the bot. */ export function unregisterCustomApp(appId, taskId) { return { type: 'unregister_custom_app', appId, taskId, }; } /** * Creates a SetAppOutputAction. * @param appId The ID of the app. * @param output The output that the app should display. */ export function setAppOutput(appId, output) { return { type: 'set_app_output', uncopiable: true, appId, output, }; } /** * Creates a RegisterHtmlAppAction. */ export function registerHtmlApp(appId, instanceId, taskId) { return { type: 'register_html_app', appId, instanceId, taskId, }; } /** * Creates a UnregisterHtmlAppAction. */ export function unregisterHtmlApp(appId, instanceId) { return { type: 'unregister_html_app', appId, instanceId, }; } /** * Creates a UpdateHtmlAppAction. */ export function updateHtmlApp(appId, updates) { return { type: 'update_html_app', appId, updates, [UNMAPPABLE]: true, }; } /** * Creates a HtmlAppEventAction. * @param appId The ID of the portal. * @param event The event that occurred. */ export function htmlAppEvent(appId, event) { return { type: 'html_app_event', appId, event, }; } /** * Creates a HtmlAppMethodCallAction. * @param appId The ID of the app. * @param nodeId The ID of the node. * @param methodName The name of the method that should be called. * @param args The arguments to pass to the method. * @param taskId The ID of the async task. */ export function htmlAppMethod(appId, nodeId, methodName, args, taskId) { return { type: 'html_app_method_call', appId, nodeId, methodName, args, taskId, }; } /** * Creates a ReportInstAction. * @param taskId The ID of the async task. */ export function reportInst(taskId) { return { type: 'report_inst', taskId, }; } /** * Creates a RequestAuthDataAction. * @param requestInBackground Whether the request should be made in the background. */ export function requestAuthData(requestInBackground, taskId) { return { type: 'request_auth_data', requestInBackground, taskId, }; } /** * Creates a DefineGlobalBotAction. */ export function defineGlobalBot(name, botId, taskId) { return { type: 'define_global_bot', name, botId, taskId, }; } /** * Creates a ConvertGeolocationToWhat3WordsAction. * @param options The options. * @param taskId The ID of the async task. */ export function convertGeolocationToWhat3Words(options, taskId) { return { type: 'convert_geolocation_to_w3w', ...options, taskId, }; } /** * Approves the given data record action and returns a new action that has been approved. * @param action The action to approve. */ export function approveAction(action) { return { ...action, [APPROVED_SYMBOL]: true, }; } /** * Creates a new MediaPermissionAction * @param options The options. * @param taskId The ID of the async task. */ export function getMediaPermission(options, taskId) { return { type: 'media_permission', ...options, taskId, }; } /** * Creates a new GetAverageFrameRateAction. * @param taskId The ID of the async task. */ export function getAverageFrameRate(taskId) { return { type: 'get_average_frame_rate', taskId, }; } /** * Creates a new RaycastFromCameraAction. * @param portal The portal that the raycast should occur in. * @param viewportCoordinates The point on the viewport that the raycast should be sent from. * @param taskId The ID of the task. */ export function raycastFromCamera(portal, viewportCoordinates, taskId) { return { type: 'raycast_from_camera', portal, viewportCoordinates, taskId, }; } /** * Creates a new RaycastInPortalAction. * @param portal The portal that the raycast should occur in. * @param origin The 3D point that the ray should start at. * @param direction The 3D direction that the ray should move in. * @param taskId The ID of the task. */ export function raycastInPortal(portal, origin, direction, taskId) { return { type: 'raycast_in_portal', portal, origin, direction, taskId, }; } /** * Creates a new CalculateRayFromCameraAction. * @param portal The portal that the ray should be calcualted for. * @param viewportCoordinates The point on the viewport that the calculated ray should be sent from. * @param taskId The ID of the task. */ export function calculateRayFromCamera(portal, viewportCoordinates, taskId) { return { type: 'calculate_camera_ray', portal, viewportCoordinates, taskId, }; } /** * Creates a new CalculateViewportCoordinatesFromPositionAction. * @param portal The portal that the ray should be calcualted for. * @param position The 3D position that the ray should be calculated for. * @param taskId The ID of the task. */ export function calculateViewportCoordinatesFromPosition(portal, position, taskId) { return { type: 'calculate_viewport_coordinates_from_position', portal, position, taskId, }; } /** * Creates a new CalculateScreenCoordinatesFromViewportCoordinatesAction. * @param portal The portal that the ray should be calcualted for. * @param coordinates The 2D position that the coordinates should be calculated for. * @param taskId The ID of the task. */ export function calculateScreenCoordinatesFromViewportCoordinates(portal, coordinates, taskId) { return { type: 'calculate_screen_coordinates_from_viewport_coordinates', portal, coordinates, taskId, }; } /** * Creates a new CalculateViewportCoordinatesFromScreenCoordinatesAction. * @param portal The portal that the ray should be calcualted for. * @param coordinates The 2D position that the coordinates should be calculated for. * @param taskId The ID of the task. */ export function calculateViewportCoordinatesFromScreenCoordinates(portal, coordinates, taskId) { return { type: 'calculate_viewport_coordinates_from_screen_coordinates', portal, coordinates, taskId, }; } export function calculateScreenCoordinatesFromPosition(portal, coordinates, taskId) { return { type: 'calculate_screen_coordinates_from_position', portal, coordinates, taskId, }; } /** * Creates a new BufferFormAddressGLTFAction. * @param address The address that should be cached. * @param taskId The ID of the async task. */ export function bufferFormAddressGltf(address, taskId) { return { type: 'buffer_form_address_gltf', address, taskId, }; } /** * Creates a new StartFormAnimationAction. * @param botIds The IDs of the bots that the animation should be started for. * @param nameOrIndex The name of the animation. * @param options The options that should be used for the animation. * @param taskId The ID of the async task. */ export function startFormAnimation(botIds, nameOrIndex, options, taskId) { return { type: 'start_form_animation', botIds, nameOrIndex, ...options, taskId, }; } /** * Creates a new StopFormAnimationAction. * @param botIds The IDs of the bots that the animation should be stopped on. * @param options The options that should be used. * @param taskId The ID of the async task. */ export function stopFormAnimation(botIds, options, taskId) { return { type: 'stop_form_animation', botIds, ...options, taskId, }; } export function listFormAnimations(address, taskId) { return { type: 'list_form_animations', address, taskId, }; } /** * Creates a new LDrawCountBuildStepsAction. * @param address The address of the LDraw file that should be used. * @param taskId The ID of the async task. */ export function ldrawCountAddressBuildSteps(address, taskId) { return { type: 'ldraw_count_build_steps', address, taskId, }; } /** * Creates a new LDrawCountBuildStepsAction. * @param text The text content of the LDraw file that should be used. * @param taskId The ID of the async task. */ export function ldrawCountTextBuildSteps(text, taskId) { return { type: 'ldraw_count_build_steps', text, taskId, }; } /** * Creates a new ConfigureWakeLockAction. * @param enabled Whether the wake lock should be enabled. * @param taskId The ID of the async task. */ export function configureWakeLock(enabled, taskId) { return { type: 'configure_wake_lock', enabled, taskId, }; } /** * Creates a GetWakeLockConfigurationAction. * @param taskId The ID of the async task. */ export function getWakeLockConfiguration(taskId) { return { type: 'get_wake_lock_configuration', taskId, }; } /** * Creates a AnalyticsRecordEventAction. * @param name The name of the event that should be recorded. * @param metadata The metadata that should be recorded with the event. * @param taskId The ID of the async task. */ export function analyticsRecordEvent(name, metadata, taskId) { return { type: 'analytics_record_event', name, metadata, taskId, }; } /** * Creates a GetRecordsEndpointAction. * @param taskId The ID of the async task. */ export function getRecordsEndpoint(taskId) { return { type: 'get_records_endpoint', taskId, }; } /** * Creates a CapturePortalScreenshotAction. * @param portal The portal that the screenshot should be captured from. * @param taskId The ID of the task. */ export function capturePortalScreenshot(portal, taskId) { return { type: 'capture_portal_screenshot', portal, taskId, }; } /** * Creates a CreateStaticHtmlAction. * @param bots The bots that should be used to render the template. * @param templateUrl The URL of the template. * @param taskId The ID of the task. */ export function createStaticHtml(bots, templateUrl, taskId) { return { type: 'create_static_html', bots, templateUrl, taskId, }; } export function recordLoom(options, taskId) { return { type: 'record_loom', options, taskId, }; } export function watchLoom(sharedUrl, taskId) { return { type: 'watch_loom', sharedUrl, taskId, }; } export function getLoomMetadata(sharedUrl, taskId) { return { type: 'get_loom_metadata', sharedUrl, taskId, }; } export function installAuxFile(aux, mode) { return { type: 'install_aux_file', aux, mode, }; } /** * Creates a new AddMapLayerAction. * @param portal The portal that the layer should be added to. * @param layer The layer that should be added. * @param index The index that the layer should be added at. * @param taskId The ID of the async task. */ export function addMapLayer(portal, layer, taskId) { return { type: 'add_map_layer', portal, layer, taskId, }; } /** * Creates a RemoveMapLayerAction. * @param layerId The ID of the layer that should be removed. * @param taskId The ID of the async task. * @returns The RemoveMapLayerAction. */ export function removeMapLayer(layerId, taskId) { return { type: 'remove_map_layer', layerId, taskId, }; } //# sourceMappingURL=BotEvents.js.map