@casual-simulation/aux-runtime
Version:
Runtime for AUX projects
2,243 lines (1,901 loc) • 544 kB
Plain Text
// Preact Hooks Types
type Inputs = ReadonlyArray<unknown>;
export type StateUpdater<S> = (value: S | ((prevState: S) => S)) => void;
export type Reducer<S, A> = (prevState: S, action: A) => S;
interface Ref<T> {
readonly current: T | null;
}
interface MutableRef<T> {
current: T;
}
// End Preact Hooks Types
type EffectCallback = () => void | (() => void);
type MaskFunc<Func extends ((...args: any[]) => any)> = {
(...args: Parameters<Func>): ReturnType<Func>;
/**
* Masks this function so that it can return a value when called with the specified parameters.
*/
mask(...args: Parameters<Func>): MaskedFunction;
}
export interface MaskedFunction {
/**
* Specifies the value that should be returned when this function is called with the parameters specified to mask().
* @param value The value that should be returned.
*/
returns(value: any): void;
}
/**
* Contains information about the version of AUX that is running.
*/
export interface AuxVersion {
/**
* The commit of the hash that AUX was built from.
*/
hash: string;
/**
* The full version number.
*/
version: string;
/**
* The major portion of the version.
*/
major: number;
/**
* The minor portion of the version.
*/
minor: number;
/**
* The patch portion of the version.
*/
patch: number;
/**
* Whether this version is an alpha (i.e. test) version.
*/
alpha: boolean | number;
/**
* Gets the player mode of this CasualOS version.
*
* - "player" indicates that the instance has been configured for experiencing AUXes.
* - "builder" indicates that the instance has been configured for building AUXes.
*/
playerMode: 'player' | 'builder';
}
/**
* Contains information about the device that AUX is running on.
*/
export interface AuxDevice {
/**
* Whether the device supports augmented reality features.
*/
supportsAR: boolean;
/**
* Whether the device supports virtual reality features.
*/
supportsVR: boolean;
}
/**
* An interface for an object that contains a set of roles that a user has.
*/
declare interface DeviceInfo {
/**
* The list of roles.
*/
roles: string[];
/**
* The claims that the device contains.
* That is, information about the device which has been verified.
*/
claims: {
username: string;
device_id: string;
session_id: string;
[key: string]: string;
};
}
/**
* Defines an interface that represents an event.
* That is, a time-ordered action in a inst.
* @deprecated
*/
declare interface Action {
/**
* The type of the event.
* This helps determine how the event should be applied to the state.
*/
type: string;
}
/**
* An event that is used to indicate an event that was sent from a remote device.
*/
declare interface DeviceAction extends Action {
type: 'device';
/**
* The device which sent the event.
*/
device: DeviceInfo;
/**
* The event.
*/
event: Action;
}
/**
* An interface that is used to determine which device to send a remote event to.
*/
declare interface DeviceSelector {
/**
* The ID of the session that the event should be sent to.
*/
sessionId?: string;
/**
* The ID of the device that the event should be sent to.
*/
deviceId?: string;
/**
* The username of the user that the event should be sent to.
*/
username?: string;
}
/**
* An event that is used to send events from this device to a remote device.
*/
declare interface RemoteAction extends Action, DeviceSelector {
type: 'remote';
/**
* The event that should be sent to the device.
*/
event: Action;
/**
* Whether this action is allowed to be batched with other remote actions.
* Batching will preserve ordering between remote actions but may
* break ordering with respect to bot actions. Defaults to true.
*/
allowBatching?: boolean;
}
declare type LocalActions = BotActions | ExtraActions | AsyncActions;
/**
* Defines a union type for all the possible events that can be emitted from a bot in an inst.
*/
declare type BotAction =
| BotActions
| TransactionAction
| ExtraActions
| AsyncActions
| RemoteAction
| DeviceAction;
/**
* Defines a union type for all the possible actions that manipulate the bot state.
*/
declare type BotActions =
| AddBotAction
| RemoveBotAction
| UpdateBotAction
| CreateCertificateAction
| SignTagAction
| RevokeCertificateAction
| ApplyStateAction;
``;
/**
* Defines a set of possible local event types.
*/
declare type ExtraActions =
| ShoutAction
| RejectAction
| ShowToastAction
| ShowHtmlAction
| HideHtmlAction
| OpenQRCodeScannerAction
| OpenBarcodeScannerAction
| ShowQRCodeAction
| ShowBarcodeAction
| LoadServerAction
| UnloadServerAction
| SuperShoutAction
| SendWebhookAction
| GoToDimensionAction
| GoToURLAction
| OpenURLAction
| ImportAUXAction
| ShowInputForTagAction
| SetForcedOfflineAction
| ShellAction
| OpenConsoleAction
| DownloadAction
| PasteStateAction
| ReplaceDragBotAction
| SetClipboardAction
| ShowChatBarAction
| RunScriptAction
| ShowUploadAuxFileAction
| LoadSpaceAction
| EnableARAction
| EnableVRAction
| ShowJoinCodeAction
| RequestFullscreenAction
| ExitFullscreenAction
| ClearSpaceAction
| LocalFormAnimationAction
| AddDropSnapTargetsAction
| EnableCustomDraggingAction
| EnablePOVAction
| SetAppOutputAction
| AddDropGridTargetsAction;
/**
* Defines a set of possible async action types.
*/
declare type AsyncActions =
| AsyncResultAction
| AsyncErrorAction
| ShowInputAction
| ShowConfirmAction
| ShareAction
| CreateCertificateAction
| SignTagAction
| RevokeCertificateAction
| BufferSoundAction
| PlaySoundAction
| CancelSoundAction
| RegisterPrefixAction
| FocusOnBotAction
| FocusOnPositionAction
| BeginRecordingAction
| EndRecordingAction
| SpeakTextAction
| GetVoicesAction
| GetGeolocationAction
| ARSupportedAction
| VRSupportedAction
| OpenImageClassifierAction
| MeetCommandAction;
/**
* Defines an interface for actions that represent asynchronous tasks.
*/
declare interface AsyncAction extends Action {
/**
* The ID of the async task.
*/
taskId: number;
}
/**
* Defines an action that supplies a result for an AsyncRequestAction.
*/
declare interface AsyncResultAction extends AsyncAction {
type: 'async_result';
/**
* The result value.
*/
result: any;
}
/**
* Defines an action that supplies an error for an AsyncRequestAction.
*/
declare interface AsyncErrorAction extends AsyncAction {
type: 'async_error';
/**
* The error.
*/
error: any;
}
/**
* Defines a bot event that indicates a bot was added to the state.
*/
declare interface AddBotAction extends Action {
type: 'add_bot';
id: string;
bot: Bot;
}
/**
* Defines a bot event that indicates a bot was removed from the state.
*/
declare interface RemoveBotAction extends Action {
type: 'remove_bot';
id: string;
}
/**
* Defines a bot event that indicates a bot was updated.
*/
declare interface UpdateBotAction extends Action {
type: 'update_bot';
id: string;
update: Partial<Bot>;
}
/**
* Defines the set of options required for creating a certificate.
*/
export interface CreateCertificateOptions {
/**
* The keypair that should be used for the certificate.
*/
keypair: string;
/**
* The ID of the certified bot that is signing the new certificate.
*/
signingBotId?: string;
/**
* The password that should be used to sign the new certificate.
*/
signingPassword: string;
}
/**
* Defines a bot event that creates a new certificate from the given keypair.
*/
export interface CreateCertificateAction
extends AsyncAction,
CreateCertificateOptions {
type: 'create_certificate';
}
/**
* Defines a bot event that creates a signature for the given tag on the given bot using the given certified bot and password.
*/
export interface SignTagAction extends AsyncAction {
type: 'sign_tag';
/**
* The ID of the certified bot that is signing the tag value.
*/
signingBotId: string;
/**
* The password that should be used to sign the value.
*/
signingPassword: string;
/**
* The ID of the bot whose tag is being signed.
*/
botId: string;
/**
* The tag that should be signed.
*/
tag: string;
}
/**
* Defines a bot event that revokes a certificate.
*/
export interface RevokeCertificateAction extends AsyncAction {
type: 'revoke_certificate';
/**
* The ID of the bot that should be used to sign the revocation.
*/
signingBotId: string;
/**
* The password that should be used to sign the revocation.
*/
signingPassword: string;
/**
* The ID of the certificate that should be revoked.
*/
certificateBotId: string;
}
/**
* A set of bot events in one.
*/
declare interface TransactionAction extends Action {
type: 'transaction';
events: BotAction[];
}
/**
* An eventBotsStatesome generic BotsState to the current state.
* This is useful when you have some generic bot state and want to just apply it to the
* current state. An example of doing this is from the automatic merge system.
*/
declare interface ApplyStateAction extends Action {
type: 'apply_state';
state: BotsState;
}
/**
* The options for pasting bots state into a inst.
*/
declare interface PasteStateOptions {
/**
* The dimension that the state should be pasted into.
*/
dimension?: string;
/**
* The X position that the state should be pasted at.
* If a dimension is provided then this is the X position inside the dimension.
* If a dimension is not provided then this is the X position that the new dimension should be created at.
*/
x: number;
/**
* The Y position that the state should be pasted at.
* If a dimension is provided then this is the Y position inside the dimension.
* If a dimension is not provided then this is the Y position that the new dimension should be created at.
*/
y: number;
/**
* The Z position that the state should be pasted at.
* If a dimension is provided then this is the Z position inside the dimension.
* If a dimension is not provided then this is the Z position that the new dimension should be created at.
*/
z: number;
}
/**
* An event to paste the given bots state as a new worksurface at a position.
*/
declare interface PasteStateAction extends Action {
type: 'paste_state';
state: BotsState;
/**
* The options for the event.
*/
options: PasteStateOptions;
}
/**
* An event that is used to override dragging a bot.
*/
declare interface ReplaceDragBotAction extends Action {
type: 'replace_drag_bot';
/**
* The bot that should be used to drag.
*/
bot: Bot | BotTags;
}
/**
* An event that is used to run a shell script.
*/
declare interface ShellAction extends Action {
type: 'shell';
/**
* The script that should be run.
*/
script: string;
}
/**
* An event that is used to show a toast message to the user.
*/
declare interface ShowToastAction extends Action {
type: 'show_toast';
message: string;
duration: number;
}
/**
* An event that is used to show some HTML to the user.
*/
declare interface ShowHtmlAction extends Action {
type: 'show_html';
/**
* Whether the HTML should be visible.
*/
visible: true;
/**
* The HTML that should be shown.
*/
html: string;
}
/**
* An event that is used to hide the HTML from the user.
*/
declare interface HideHtmlAction extends Action {
type: 'show_html';
visible: false;
}
/**
* Options for the os.tweenTo(), os.moveTo(), and os.focusOn() actions.
*/
export interface FocusOnOptions {
/*
* The zoom value to use.
*/
zoom?: number;
/*
* The rotation value to use in radians. These are the polar coordinates that determine where the camera should orbit around the target point.
*/
rotation?: {
x: number;
y: number;
/**
* Whether to normalize the rotation values to between 0 and 2*PI.
* Defaults to true. Setting this to false can be useful for rotating around a bot multiple times.
*/
normalize?: boolean;
};
/**
* The duration in seconds that the animation should take.
* Defaults to 1.
*/
duration?: number;
/**
* The type of easing to use.
* If not specified then "quadratic" "inout" will be used.
*/
easing?: EaseType | Easing;
/**
* The tag that should be focused.
* Only supported by the system portal.
*/
tag?: string;
/**
* The space of the tag that should be focused.
* Only supported by the system portal.
*/
space?: string;
/**
* The line number that should be focued.
* Only supported by the system portal.
*/
lineNumber?: number;
/**
* The column number that should be focused.
* Only supported by the system portal.
*/
columnNumber?: number;
/**
* The portal that the bot should be focused in.
* If not specified, then the bot will be focused in all supported portals. (bot, mini, menu, and system)
*/
portal?: PortalType;
}
/**
* An event that is used to focus on a given bot.
*/
export interface FocusOnBotAction extends AsyncAction, FocusOnOptions {
type: 'focus_on';
/**
* The ID of the bot to tween to.
*/
botId: string;
}
/**
* An event that is used to focus the camera on a specific position.
*/
export interface FocusOnPositionAction extends AsyncAction, FocusOnOptions {
type: 'focus_on_position';
/**
* The position to animate to.
*/
position: {
x: number;
y: number;
z?: number;
};
}
/**
* The possible camera types.
*/
declare type CameraType = 'front' | 'rear';
/**
* An event that is used to show or hide the QR Code Scanner.
*/
declare interface OpenQRCodeScannerAction extends Action {
type: 'show_qr_code_scanner';
/**
* Whether the QR Code scanner should be visible.
*/
open: boolean;
/**
* The camera that should be used.
*/
cameraType: CameraType;
}
/**
* An event that is used to show or hide the barcode scanner.
*/
declare interface OpenBarcodeScannerAction extends Action {
type: 'show_barcode_scanner';
/**
* Whether the barcode scanner should be visible.
*/
open: boolean;
/**
* The camera that should be used.
*/
cameraType: CameraType;
}
/**
* Defines a photo that was taken.
*
* @dochash types/camera
* @docname Photo
*/
export interface Photo {
/**
* The photo data.
*/
data: Blob;
/**
* The width of the photo in pixels.
*/
width: number;
/**
* The height of the photo in pixels.
*/
height: number;
}
/**
* Options for {@link os.openPhotoCamera}.
*
* @dochash types/camera
* @doctitle Camera Types
* @docsidebar Camera
* @docdescription Types that are used in camera actions.
* @docname PhotoCameraOptions
*/
export interface OpenPhotoCameraOptions {
/**
* The camera that should be used.
*/
cameraType?: CameraType;
/**
* The image format that should be used.
*
* Defaults to "png".
*/
imageFormat?: 'png' | 'jpeg';
/**
* A number between 0 and 1 indicating the image quality to be used.
*
* If not specified, then the browser will use its own default.
*/
imageQuality?: number;
/**
* Whether to skip allowing the user to confirm their photo.
*
* Defaults to false.
*/
skipConfirm?: boolean;
/**
* Whether to automatically take a photo after a number of seconds.
*
* If null, then there is no timer and the user is allowed to take the photo manually.
* If positive, then the timer will start counting down from the given number of seconds.
* The user can always cancel the operation manually.
*/
takePhotoAfterSeconds?: number;
/**
* The ideal resolution for the photo to be taken at.
*
* If specified, then the web browser will be told to prefer this resolution, but will use a lower resolution if
* it is not possible to use the ideal resolution.
*/
idealResolution?: {
/**
* The width of the photo in pixels.
*/
width: number;
/**
* The height of the photo in pixels.
*/
height: number;
}
/**
* Whether to mirror the photo after it is taken.
*
* Defaults to false.
*/
mirrorPhoto?: boolean;
}
/**
* An event that is used to toggle whether the console is open.
*/
declare interface OpenConsoleAction extends Action {
type: 'open_console';
/**
* Whether the console should be open.
*/
open: boolean;
}
/**
* An event that is used to show or hide a QR Code on screen.
*/
declare interface ShowQRCodeAction extends Action {
type: 'show_qr_code';
/**
* Whether the QR Code should be visible.
*/
open: boolean;
/**
* The code to display.
*/
code: string;
}
/**
* The list of possible barcode formats.
*/
declare type BarcodeFormat =
| 'code128'
| 'code39'
| 'ean13'
| 'ean8'
| 'upc'
| 'itf14'
| 'msi'
| 'pharmacode'
| 'codabar';
/**
* An event that is used to show or hide a barcode on screen.
*/
declare interface ShowBarcodeAction extends Action {
type: 'show_barcode';
/**
* Whether the barcode should be visible.
*/
open: boolean;
/**
* The code to display.
*/
code: string;
/**
* The format that the code should be displayed in.
*/
format: BarcodeFormat;
}
/**
* An event that is used to show or hide an image classifier on screen.
*/
export interface OpenImageClassifierAction extends AsyncAction {
type: 'show_image_classifier';
/**
* Whether the image classifier should be visible.
*/
open: boolean;
/**
* The URL that the model should be loaded from.
*/
modelUrl?: string;
/**
* The URL that the model JSON should be loaded from.
* Not required. Can be used if you are storing the model JSON in a custom location.
*/
modelJsonUrl?: string;
/**
* The URL that the model metadata should be loaded from.
* Not required. Can be used if you are storing the model metadata in a custom location.
*/
modelMetadataUrl?: string;
/**
* The camera that should be used for the image classifier.
*/
cameraType?: CameraType;
}
export interface ClassifyImagesAction extends AsyncAction {
type: 'classify_images';
/**
* The URL that the model should be loaded from.
*/
modelUrl?: string;
/**
* The URL that the model JSON should be loaded from.
* Not required. Can be used if you are storing the model JSON in a custom location.
*/
modelJsonUrl?: string;
/**
* The URL that the model metadata should be loaded from.
* Not required. Can be used if you are storing the model metadata in a custom location.
*/
modelMetadataUrl?: string;
/**
* The images that should be classified.
*/
images: Image[];
}
export interface Image {
/**
* The URL that the image should be downloaded from for classification.
*/
url?: string;
/**
* The file that should be used for classification.
*/
file?: {
/**
* The name of the file. Includes the file extension.
*/
name: string;
/**
* The size of the file in bytes.
*/
size: number;
/**
* The data of the file.
* If the file is a text file, the data will be a string.
* If the file is not a text file, the data will be an ArrayBuffer.
*
* Text files have one of the following extentions:
* .txt
* .json
* .md
* .aux
* .html
* .js
* .ts
* All the other file extentions map to an ArrayBuffer.
*/
data: string | ArrayBuffer;
/**
* The MIME type of the file.
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types for more information.
*/
mimeType: string;
};
}
export interface ClassifyImagesResult {
/**
* The model that the classifier is currently operating on.
*/
model: {
/**
* The modeUrl that was provided to open the classifier.
*/
modelUrl?: string;
/**
* The modelJsonUrl that was provided to open the classifier.
*/
modelJsonUrl?: string;
/**
* The modelMetadataUrl that was provided to open the classifier.
*/
modelMetadataUrl?: string;
/**
* The names of the categories that the loaded model contains.
*/
classLabels: string[];
};
images: ImageClassification[];
}
export interface ImageClassification {
/**
* The predictions for the image.
*/
predictions: ImagePrediction[];
}
export interface ImagePrediction {
/**
* The name of the class name.
*/
className: string;
/**
* The probability (between 0 and 1) that the image belongs to this category.
* All of the probabilities added together will equal (or be really close to) 1.
*/
probability: number;
}
export type ImageClassifierOptions = Pick<
OpenImageClassifierAction,
'modelUrl' | 'modelJsonUrl' | 'modelMetadataUrl' | 'cameraType'
>;
export type ClassifyImagesOptions = Pick<
ClassifyImagesAction,
'modelUrl' | 'modelJsonUrl' | 'modelMetadataUrl' | 'images'
>
/**
* An event that is used to load a simulation.
*/
declare interface LoadServerAction extends Action {
type: 'load_server';
/**
* The ID of the simulation to load.
*/
id: string;
}
/**
* The configuration for loading an inst.
*
* @dochash types/os/spaces
* @docname InstConfig
*/
export interface InstConfig {
/**
* The owner of the inst.
*
* Possible values are:
* - "public" - The inst is public and temporary.
* - "player" - The inst is owned by the current player.
* - Any record name - the inst will be loaded from the given record.
* - Any user ID - the inst will be loaded from the given user's default record.
* - Any studio ID - the inst will be loaded from the given studio's default record.
*
* Only valid when an inst is also specified.
*/
owner?: string | null;
/**
* The record that the inst should be loaded from.
*
* Only valid when an inst is also specified.
*/
record?: string | null;
/**
* The inst that should be loaded.
*
* When specified, you can also use the owner field to specify where the inst should be loaded from.
*/
inst?: string;
/**
* The static inst that should be loaded.
*
* Only valid when specified on its own.
*/
staticInst?: string;
}
/**
* An event that is used to load an inst.
* @dochash types/os/spaces
* @docname LoadInstConfigAction
*/
export interface LoadServerConfigAction extends Action {
type: 'load_server_config';
/**
* The config that should be used to load the inst.
*/
config: InstConfig;
}
/**
* An event that is used to unload a simulation.
*/
declare interface UnloadServerAction extends Action {
type: 'unload_server';
/**
* The ID of the simulation to unload.
*/
id: string;
}
/**
* An event that is used to unload a simulation.
*/
declare interface UnloadServerConfigAction extends Action {
type: 'unload_server_config';
/**
* The config that should be used to unload the inst.
*/
config: InstConfig;
}
/**
* An event that is used to load an AUX from a remote location.
*/
declare interface ImportAUXAction extends Action {
type: 'import_aux';
/**
* The URL to load.
*/
url: string;
}
/**
* Defines an event for actions that are shouted to every current loaded simulation.
*/
declare interface SuperShoutAction extends Action {
type: 'super_shout';
/**
* The name of the event.
*/
eventName: string;
/**
* The argument to pass as the "that" variable to scripts.
*/
argument?: any;
}
/**
* Defines an event that sends a web request to a website.
*/
declare interface SendWebhookAction extends Action {
type: 'send_webhook';
/**
* The options for the webhook.
*/
options: WebhookOptions;
}
/**
* Defines a set of options for a webhook.
*/
declare interface WebhookOptions {
/**
* The HTTP Method that the request should use.
*/
method?: string;
/**
* The URL that the request should be made to.
*/
url?: string;
/**
* The headers to include in the request.
*/
headers?: {
[key: string]: string;
};
/**
* The data to send with the request.
*/
data?: any;
/**
* The shout that should be made when the request finishes.
*/
responseShout?: string;
/**
* The number of retries that should be attempted for the webhook if it fails.
* Defaults to 0.
*/
retryCount?: number;
/**
* The HTTP response status codes that should allow the web request to be retried.
* Defaults to:
* - 408 - Request Timeout
* - 429 - Too Many Requests
* - 500 - Internal Server Error
* - 502 - Bad Gateway
* - 503 - Service Unavailable
* - 504 - Gateway Timeout
* - 0 - Network Failure / CORS
*/
retryStatusCodes?: number[];
/**
* The number of miliseconds to wait between retry requests.
* Defaults to 3000ms (3 seconds).
*/
retryAfterMs?: number;
}
/**
* Defines a set of options for animateTag().
*/
declare interface AnimateTagFunctionOptions {
/**
* The value that should be animated from.
* If not specified then the current tag value will be used.
*/
fromValue?: any;
/**
* The value that should be animated to.
*/
toValue: any;
/**
* The duration of the animation in seconds.
*/
duration: number;
/**
* The time that the animation should start.
* Should be the number of miliseconds since January 1st 1970 UTC-0. (e.g. os.localTime or os.agreedUponTime).
*/
startTime?: number;
/**
* The type of easing to use.
* If not specified then "linear" "inout" will be used.
*
* Can also be a custom function that takes a single parameter and returns a number.
* The paramater will be a number between 0 and 1 indicating the progress through the tween.
*/
easing?: EaseType | Easing | ((progress: number) => number);
/**
* The space that the tag should be animated in.
* If not specified then "tempLocal" will be used.
* If false, then the bot will be edited instead of using tag masks.
*/
tagMaskSpace?: BotSpace | false;
}
/**
* Defines an event that is used to send the player to a dimension.
*/
declare interface GoToDimensionAction extends Action {
type: 'go_to_dimension';
/**
* The dimension that should be loaded.
*/
dimension: string;
}
/**
* Defines an event that is used to show an input box to edit a tag on a bot.
*/
declare interface ShowInputForTagAction extends Action {
type: 'show_input_for_tag';
/**
* The ID of the bot to edit.
*/
botId: string;
/**
* The tag that should be edited on the bot.
*/
tag: string;
/**
* The options for the input box.
*/
options: Partial<ShowInputOptions>;
}
/**
* Defines an event that is used to show an input box.
*/
declare interface ShowInputAction extends AsyncAction {
type: 'show_input';
/**
* The value that should be in the input box.
*/
currentValue?: any;
/**
* The options for the input box.
*/
options: Partial<ShowInputOptions>;
}
/**
* Defines an event that is used to set whether the connection is forced to be offline.
*/
declare interface SetForcedOfflineAction extends Action {
type: 'set_offline_state';
/**
* Whether the connection should be offline.
*/
offline: boolean;
}
/**
* Defines an event that is used to redirect the user to the given URL.
* This should be equivalent to clicking a link with rel="noreferrer".
*/
declare interface GoToURLAction extends Action {
type: 'go_to_url';
/**
* The URL to open.
*/
url: string;
}
/**
* Defines an event that is used to open the given URL.
* This should be equivalent to clicking a link with rel="noreferrer" and target="_blank".
*/
declare interface OpenURLAction extends Action {
type: 'open_url';
/**
* The URL to open.
*/
url: string;
}
/**
* Defines an event that is used to play a sound from the given url.
*/
declare interface PlaySoundAction extends AsyncAction {
type: 'play_sound';
/**
* The URL to open.
*/
url: string;
/**
* The ID of the sound.
*/
soundID: number | string;
}
/**
* Defines an event that is used to pre-load a sound from the given URL.
*/
export interface BufferSoundAction extends AsyncAction {
type: 'buffer_sound';
/**
* The URL to buffer.
*/
url: string;
}
/**
* Defines an event that is used to cancel a sound that is playing.
*/
export interface CancelSoundAction extends AsyncAction {
type: 'cancel_sound';
/**
* The ID of the sound.
*/
soundID: number;
}
/**
* Defines an event that is used to download a file onto the device.
*/
declare interface DownloadAction extends Action {
type: 'download';
/**
* The data that should be included in the downloaded file.
*/
data: any;
/**
* The name of the downloaded file. (includes the extension)
*/
filename: string;
/**
* The MIME type of the downloaded file.
*/
mimeType: string;
}
export type StoredAux = StoredAuxVersion1 | StoredAuxVersion2;
export interface StoredAuxVersion1 {
version: 1;
state: BotsState;
}
export interface StoredAuxVersion2 {
version: 2;
updates: InstUpdate[];
}
export interface AuxFileOptions {
/**
* The version that should be used for the output file.
*
* Version 1 stores bots as pure JSON and is the original version of the file format.
* Version 2 stores bots as updates and is the new version of the file format.
*
* If not specifed, then version 2 will be used.
*/
version?: 1 | 2;
}
export type InstallAuxFileMode = 'default' | 'copy';
/**
* Defines an interface for options that a show input event can use.
*/
declare interface ShowInputOptions {
/**
* The type of input box to show.
*/
type: ShowInputType;
/**
* The subtype of input box to show.
*/
subtype: ShowInputSubtype;
/**
* The title that should be used for the input.
*/
title: string;
/**
* The placeholder for the value.
*/
placeholder: string;
/**
* The background color to use.
*/
backgroundColor: string;
/**
* The foreground color to use.
*/
foregroundColor: string;
/**
* Whether the text in the input box should be automatically selected.
*/
autoSelect: boolean;
/**
* The items that should be shown in the list.
*/
items?: ShowInputItem[];
}
export interface ShowInputItem {
label: string;
value: any;
}
/**
* Defines the possible input types.
*/
declare type ShowInputType = 'text' | 'color' | 'secret' | 'date' | 'list';
/**
* Defines the possible input types.
*/
declare type ShowInputSubtype = 'basic' | 'swatch' | 'advanced' | 'select' | 'multiSelect' | 'radio' | 'checkbox';
/**
* Defines an event that is used to show a confirmation dialog.
*/
declare interface ShowConfirmAction extends AsyncAction {
type: 'show_confirm';
/**
* The options for the confirmation dialog.
*/
options: ShowConfirmOptions;
}
/**
* Defines an interface that represents the options that can be used for a confirmation dialog.
*/
declare interface ShowConfirmOptions {
/**
* The title that should be shown for the dialog.
*/
title: string;
/**
* The content of the dialog.
*/
content: string;
/**
* The text that should be shown on the "Confirm" button.
*/
confirmText?: string;
/**
* The text that should be shown on the "Cancel" button.
*/
cancelText?: string;
}
/**
* Defines an event for actions.
* Actions are basically user-defined events.
*/
declare interface ShoutAction {
type: 'action';
/**
* The IDs of the bots that the event is being sent to.
* If null, then the action is sent to every bot.
*/
botIds: string[] | null;
/**
* The Bot ID of the user.
*/
userId: string | null;
/**
* The name of the event.
*/
eventName: string;
/**
* The argument to pass as the "that" variable to scripts.
*/
argument?: any;
/**
* Whether the Bot IDs should be sorted before processing.
*/
sortBotIds?: boolean;
}
/**
* Defines an event that prevents the execution of an action.
*/
declare interface RejectAction {
type: 'reject';
/**
* The action to prevent.
*/
action: Action;
}
/**
* Defines an event that sets some text on the user's clipboard.
*/
declare interface SetClipboardAction {
type: 'set_clipboard';
/**
* The text that the clipboard should be set to.
*/
text: string;
}
/**
* Defines an event that shows the chat bar.
*/
declare interface ShowChatBarAction {
type: 'show_chat_bar';
/**
* Whether the chat bar should be visible.
*/
visible: boolean;
/**
* The text that the bar should be filled with by default.
*/
prefill?: string;
/**
* The text that the bar should have as the placeholder.
*/
placeholder?: string;
/**
* The color to use for the placeholder.
*/
placeholderColor?: string;
/**
* The color to use for the background.
*/
backgroundColor?: string;
/**
* The color to use for the foreground (text).
*/
foregroundColor?: string;
}
/**
* Defines the possible options for showing the chat bar.
*/
declare interface ShowChatOptions {
/**
* The text that the bar should be filled with by default.
*/
prefill?: string;
/**
* The text that the bar should have as the placeholder.
*/
placeholder?: string;
/**
* The color to use for the placeholder.
*/
placeholderColor?: string;
/**
* The color to use for the background.
*/
backgroundColor?: string;
/**
* The color to use for the foreground (text).
*/
foregroundColor?: string;
}
/**
* Defines an event that executes a script.
*/
declare interface RunScriptAction extends AsyncAction {
type: 'run_script';
/**
* The script that should be executed.
*/
script: string;
}
/**
* Defines an event that shows the "upload AUX file" dialog.
*/
declare interface ShowUploadAuxFileAction {
type: 'show_upload_aux_file';
}
/**
* Defines an interface that represents a file that was uploaded.
*/
declare interface UploadedFile {
/**
* The name of the file that was uploaded.
*/
name: string;
/**
* The size of the file in bytes.
*/
size: number;
/**
* The MIME type of the file.
*/
mimeType: string;
/**
* The data that the file contains.
*/
data: string | ArrayBuffer;
}
/**
* Defines an event that loads a space into the inst.
*/
declare interface LoadSpaceAction {
type: 'load_space';
/**
* The space that should be loaded.
*/
space: BotSpace;
/**
* The config that should be used to load the space.
*/
config: any;
}
/**
* Defines an interface for objects that specify a tag and value
* that a bot should have to be loaded.
*/
declare interface LoadBotsTagFilter {
/**
* The tag that the bot should have.
*/
tag: string;
/**
* The value that the bot should have.
*/
value?: any;
}
/**
* Defines an event that clears all bots from a space.
*
* Only supported for the following spaces:
* - error
*/
declare interface ClearSpaceAction {
type: 'clear_space';
/**
* The space to clear.
*/
space: BotSpace;
}
/**
* Defines an event that runs an animation locally over
* whatever existing animations are playing.
*/
declare interface LocalFormAnimationAction {
type: 'local_form_animation';
/**
* The bot to run the animation on.
*/
botId: string;
/**
* The animation to run.
*/
animation: number | string;
}
declare type TweenType = 'position' | 'rotation';
declare type EaseType = 'linear' | 'quadratic' | 'cubic' | 'quartic' | 'quintic' | 'sinusoidal' | 'exponential' | 'circular' | 'elastic';
declare type EaseMode = 'in' | 'out' | 'inout';
declare interface Easing {
type: EaseType;
mode: EaseMode;
}
/**
* Defines the set of possible options for tweens.
*/
declare interface TweenOptions {
/**
* The easing type and mode that the tween should use.
*/
easing?: Easing;
/**
* The amount of time that the tween should take in seconds.
*/
duration?: number;
}
/**
* Defines an event that runs a tween locally.
*/
declare interface LocalTweenAction extends Action {
type: 'local_tween';
/**
* The bot to run the tween on.
*/
botId: string;
/**
* The dimension that the bot should be tweened in.
*/
dimension: string;
/**
* The type of the tween.
*/
tweenType: TweenType;
/**
* The easing that should be used.
*/
easing: Easing;
}
/**
* Defines an event that runs a position tween locally.
*/
declare interface LocalPositionTweenAction extends LocalTweenAction {
tweenType: 'position';
/**
* The target position of the tween.
*/
position: { x?: number, y?: number, z?: number };
}
/**
* Defines an event that runs a rotation tween locally.
*/
declare interface LocalRotationTweenAction extends LocalTweenAction {
tweenType: 'rotation';
/**
* The target rotation of the tween.
*/
rotation: { x?: number, y?: number, z?: number };
}
/**
* Defines an interface that represents the options that an EnableARAction or EnableVRAction can have.
*/
export interface EnableXROptions {
/**
* The frame buffer scale factor that should be used for the XR session.
* (see https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/getNativeFramebufferScaleFactor)
* - Null or undefined indicates that the default should be used. (usually 1)
* - A number indicates the ratio of frame buffer pixels to output pixels. (e.g. a value of 2 will cause every 2 frame buffer pixels to be correlated with 1 output pixel, meaning that the render resolution is doubled)
* - "recommended" indicates that CasualOS should try to pick the optimal number.
*/
frameBufferScaleFactor?: number | 'recommended';
}
/**
* Defines an event that enables AR on the device.
*/
declare interface EnableARAction {
type: 'enable_ar';
/**
* Whether AR features should be enabled.
*/
enabled: boolean;
}
/**
* Defines an event that enables VR on the device.
*/
declare interface EnableVRAction {
type: 'enable_vr';
/**
* Whether VR features should be enabled.
*/
enabled: boolean;
}
/**
* Defines an event that checks for AR support on the device.
*/
declare interface ARSupportedAction extends AsyncAction {
type: 'ar_supported';
}
/**
* Defines an event that checks for VR support on the device.
*/
declare interface VRSupportedAction extends AsyncAction {
type: 'vr_supported';
}
/**
* Defines an event that enables POV on the device.
*/
declare interface EnablePOVAction {
type: 'enable_pov';
/**
* Whether POV features should be enabled.
*/
enabled: boolean;
/**
* The point that the camera should be placed at for POV.
*/
center?: { x: number, y: number, z: number };
}
/**
* Defines an interface that represents a wake lock configuration.
*/
declare interface WakeLockConfiguration {
/**
* Whether the wake lock is enabled.
*/
enabled: boolean;
}
/**
* An event that is used to send a command to the Jitsi Meet API.
*/
declare interface MeetCommandAction extends AsyncAction {
type: 'meet_command',
/**
* The name of the command to execute.
*/
command: string;
/**
* The arguments for the command (if any).
*/
args?: any[];
}
/**
* Defines an event that shows a QR code that is a link to a inst & dimension.
*/
declare interface ShowJoinCodeAction {
type: 'show_join_code';
/**
* The inst that should be joined.
*/
inst?: string;
/**
* The dimension that should be joined.
*/
dimension?: string;
}
/**
* Defines an event that requests that AUX enter fullscreen mode.
* This can be denied by the user.
*/
declare interface RequestFullscreenAction {
type: 'request_fullscreen_mode';
}
/**
* Defines an event that exits fullscreen mode.
*/
declare interface ExitFullscreenAction {
type: 'exit_fullscreen_mode';
}
/**
* Defines the options that a share action can have.
*/
declare interface ShareOptions {
/**
* The title of the document being shared.
*/
title?: string;
/**
* The text that should be shared.
*/
text?: string;
/**
* The URL of the document being shared.
*/
url?: string;
}
/**
* Defines an event that shares the given information using the
* device's native social sharing capabilities.
*/
declare interface ShareAction extends AsyncAction, ShareOptions {
type: 'share';
}
/**
* An event that is used to show or hide the circle wipe.
*/
declare interface OpenCircleWipeAction extends AsyncAction {
type: 'show_circle_wipe';
/**
* Whether the circle wipe should be visible.
*/
open: boolean;
/**
* The options for the circle wipe.
*/
options: OpenCircleWipeOptions;
}
/**
* The options for the circle wipe.
*/
declare interface OpenCircleWipeOptions {
/**
* The duration of this half of the circle wipe animation in seconds.
*/
duration: number;
/**
* The color that the circle wipe should be.
*/
color: string;
}
/**
* Defines a base interface for actions that can add drop snap points.
*/
export interface AddDropSnapAction extends Action {
/**
* The ID of the bot that, when it is a drop target, the snap points should be enabled.
* If null, then the targets apply globally during the drag operation.
*/
botId?: string;
}
/**
* An event that is used to add some snap points for a drag operation.
*/
export interface AddDropSnapTargetsAction extends AddDropSnapAction {
type: 'add_drop_snap_targets';
/**
* The list of snap targets that should be used.
*/
targets: SnapTarget[];
}
/**
* Defines an interface that represents a snap point.
* That is, a point in 3D space with an associated snap distance.
*/
declare interface SnapPoint {
/**
* The 3D position for the point.
*/
position: { x: number; y: number; z: number };
/**
* The distance that the snap point should take effect at.
*/
distance: number;
}
/**
* Defines an interface that represents a snap axis.
* That is, a ray in 3D space with an associated snap distance.
*/
export interface SnapAxis {
/**
* The 3D direction that the axis ray travels along.
*/
direction: { x: number; y: number; z: number };
/**
* The 3D position that the ray starts at.
*/
origin: { x: number; y: number; z: number };
/**
* The distance from the ray line that the snap point should take effect at.
*/
distance: number;
}
/**
* The list of possible snap targets.
* - "ground" means that the dragged bot should snap to the ground plane. This option is overriden by "grid".
* - "grid" means that the dragged bot should snap to grid tiles.
* - "face" means that the dragged bot should snap to other bot faces.
* - "bots" means that the dragged bot will snap to other bots.
*/
declare type SnapTarget = 'ground' | 'grid' | 'face' | 'bots' | SnapPoint | SnapAxis;
/**
* An event that is used to add grids as possible drop locations for a drag operation.
*/
export interface AddDropGridTargetsAction extends AddDropSnapAction {
type: 'add_drop_grid_targets';
/**
* The list of grids that bots should be snapped to.
*/
targets: SnapGrid[];
}
/**
* Defines an interface that represents a snap grid.
* That is, a 2D plane that is segmented into discrete sections.
*/
export interface SnapGrid {
/**
* The 3D position of the grid.
* If not specified, then 0,0,0 is used.
*/
position?: { x: number, y: number, z: number };
/**
* The 3D rotation of the grid.
* If not specified, then the identity rotation is used.
*/
rotation?: { x: number, y: number, z: number, w?: number };
/**
* The ID of the bot that defines the portal that this grid should use.
* If not specifed, then the config bot is used.
*/
portalBotId?: string;
/**
* The tag that contains the portal dimension.
* If a portalBotId is specified, then this defaults to formAddress.
* If a portalBotId is not specified, then this defaults to gridPortal.
*/
portalTag?: string;
/**
* The priority that the snap grid has.
* Higher numbers mean higher priority.
*/
priority?: number;
/**
* The bounds that the snap grid has.
* If not specified, then default bounds are used.
*/
bounds?: { x: number, y: number };
/**
* Whether to visualize the grid when dragging bots around.
* Defaults to false.
*/
showGrid?: boolean;
/**
* The type of grid that this snap grid should be.
* Defaults to the type of grid that the portal bot uses.
*
* - "grid" indicates that the snap target should be a flat grid.
* - "sphere" indicates that the snap target should be a sphere.
*/
type?: 'grid' | 'sphere';
}
export interface SnapGridTarget {
/**
* The 3D position that the grid should appear at.
*/
position?: { x: number, y: number, z: number };
/**
* The 3D rotation that the grid should appear at.
*/
rotation?: { x: number, y: number, z: number, w?: number };
/**
* The bot that defines the portal that the grid should exist in.
* If null, then this defaults to the configBot.
*/
portalBot?: Bot | string;
/**
* The tag that the portal uses to determine which dimension to show. Defaults to formAddress.
*/
portalTag?: string;
/**
* The bounds of the grid.
* Defaults to 10 x 10.
*/
bounds?: { x: number, y: number };
/**
* The priority that this grid should be evaluated in over other grids.
* Higher priorities will be evaluated before lower priorities.
*/
priority?: number;
/**
* Whether to visualize the grid while a bot is being dragged.
* Defaults to false.
*/
showGrid?: boolean;
/**
* The type of grid that this snap grid should be.
* Defaults to the type of grid that the portal bot uses.
*
* - "grid" indicates that the snap target should be a flat grid.
* - "sphere" indicates that the snap target should be a sphere.
*/
type?: 'grid' | 'sphere';
}
/**
* An event that is used to disable the default dragging logic (moving the bot) and enable
* "onDragging" shouts and whispers.
*/
export interface EnableCustomDraggingAction extends Action {
type: 'enable_custom_dragging';
}
/**
* Defines an event that registers a custom portal.
*/
export interface RegisterCustomAppAction extends AsyncAction {
type: 'register_custom_app';
/**
* The ID of the portal.
*/
portalId: string;
/**
* The ID of the bot that should be used to configure the portal.
*/
botId: string;
/**
* Options that should be used to configure the custom portal.
*/
options: RegisterCustomAppOptions;
}
/**
* The options for a register custom portal action.
*/
export interface RegisterCustomAppOptions {
/**
* The kind of the custom portal.
* Used to make it easy to register multiple custom portals that rely on the same kind of renderers.
*/
kind?: string;
}
/**
* Defines an event that notifies that the output of a portal shou