@casual-simulation/aux-common 3.2.0 → 3.2.1-alpha.5646793078

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.
@@ -22,7 +22,7 @@ import { DEBUG_STRING, debugStringifyFunction, } from './AuxGlobalContext';
22
22
  import { hasValue, trimTag, isBot, BOT_SPACE_TAG, toast as toastMessage, tip as tipMessage, hideTips as hideTipMessages, showJoinCode as calcShowJoinCode, requestFullscreen, exitFullscreen, html as htmlMessage, hideHtml as hideHtmlMessage, setClipboard as calcSetClipboard, tweenTo as calcTweenTo, showChat as calcShowChat, hideChat as calcHideChat, runScript, getMediaPermission as calcGetMediaPermission, getAverageFrameRate as calcGetAverageFrameRate, enableAR as calcEnableAR, disableAR as calcDisableAR, enableVR as calcEnableVR, disableVR as calcDisableVR, arSupported as calcARSupported, vrSupported as calcVRSupported, showUploadAuxFile as calcShowUploadAuxFile, openQRCodeScanner as calcOpenQRCodeScanner, showQRCode as calcShowQRCode, openBarcodeScanner as calcOpenBarcodeScanner, showBarcode as calcShowBarcode, importAUX as calcImportAUX, showInputForTag as calcShowInputForTag, showInput as calcShowInput, showConfirm as calcShowConfirm, replaceDragBot as calcReplaceDragBot, goToDimension as calcGoToDimension, goToURL as calcGoToURL, openURL as calcOpenURL, checkout as calcCheckout, playSound as calcPlaySound, bufferSound as calcBufferSound, cancelSound as calcCancelSound, setupServer as calcSetupServer, shell as calcShell, backupToGithub as calcBackupToGithub, backupAsDownload as calcBackupAsDownload, finishCheckout as calcFinishCheckout, markHistory as calcMarkHistory, browseHistory as calcBrowseHistory, restoreHistoryMark as calcRestoreHistoryMark, loadFile as calcLoadFile, saveFile as calcSaveFile, reject as calcReject, localFormAnimation as calcLocalFormAnimation, webhook as calcWebhook, superShout as calcSuperShout, share as calcShare, registerPrefix as calcRegisterPrefix, createCertificate as calcCreateCertificate, signTag as calcSignTag, revokeCertificate as calcRevokeCertificate, localPositionTween as calcLocalPositionTween, localRotationTween as calcLocalRotationTween, showUploadFiles as calcShowUploadFiles, download, loadSimulation, unloadSimulation, getUploadState, addState, getPortalTag, KNOWN_PORTALS, openConsole, tagsOnBot, getOriginalObject, getBotSpace, trimEvent, CREATE_ACTION_NAME, CREATE_ANY_ACTION_NAME, DESTROY_ACTION_NAME, ORIGINAL_OBJECT, unlockSpace, getRemoteCount, getServers, getRemotes, listInstUpdates as calcListInstUpdates, getInstStateFromUpdates as calcGetInstStateFromUpdates, action, getServerStatuses, setSpacePassword, rpioInitPin, rpioExitPin, rpioOpenPin, rpioModePin, rpioReadPin, rpioReadSequencePin, rpioWritePin, rpioWriteSequencePin, rpioReadpadPin, rpioWritepadPin, rpioPudPin, rpioPollPin, rpioClosePin, rpioI2CBeginPin, rpioI2CSetSlaveAddressPin, rpioI2CSetBaudRatePin, rpioI2CSetClockDividerPin, rpioI2CReadPin, rpioI2CWritePin,
23
23
  // rpioI2CReadRegisterRestartPin,
24
24
  // rpioI2CWriteReadRestartPin,
25
- rpioI2CEndPin, rpioPWMSetClockDividerPin, rpioPWMSetRangePin, rpioPWMSetDataPin, rpioSPIBeginPin, rpioSPIChipSelectPin, rpioSPISetCSPolarityPin, rpioSPISetClockDividerPin, rpioSPISetDataModePin, rpioSPITransferPin, rpioSPIWritePin, rpioSPIEndPin, serialConnectPin, serialOpenPin, serialStreamPin, serialUpdatePin, serialWritePin, serialReadPin, serialClosePin, serialFlushPin, serialDrainPin, serialPausePin, serialResumePin, calculateAnchorPoint, calculateAnchorPointOffset, getBotPosition as calcGetBotPosition, getBotRotation as calcGetBotRotation, isRuntimeBot, SET_TAG_MASK_SYMBOL, CLEAR_TAG_MASKS_SYMBOL, getBotScale, EDIT_TAG_SYMBOL, EDIT_TAG_MASK_SYMBOL, circleWipe, addDropSnap as calcAddDropSnap, addDropGrid as calcAddDropGrid, animateToPosition, beginAudioRecording as calcBeginAudioRecording, endAudioRecording as calcEndAudioRecording, beginRecording as calcBeginRecording, endRecording as calcEndRecording, speakText as calcSpeakText, getVoices as calcGetVoices, getGeolocation as calcGetGeolocation, cancelAnimation, disablePOV, enablePOV, enableCustomDragging as calcEnableCustomDragging, MINI_PORTAL, registerCustomApp, setAppOutput, unregisterCustomApp, requestAuthData as calcRequestAuthData, createBot, defineGlobalBot as calcDefineGlobalBot, TEMPORARY_BOT_PARTITION_ID, convertToString, GET_TAG_MASKS_SYMBOL, isBotLink, parseBotLink, createBotLink, convertGeolocationToWhat3Words as calcConvertGeolocationToWhat3Words, getPublicRecordKey as calcGetPublicRecordKey, recordData as calcRecordData, getRecordData, eraseRecordData, recordFile as calcRecordFile, getFile as calcGetFile, eraseFile as calcEraseFile, meetCommand as calcMeetCommand, meetFunction as calcMeetFunction, listDataRecord, recordEvent as calcRecordEvent, getEventCount as calcGetEventCount, openImageClassifier as calcOpenImageClassifier, isBotDate, DATE_TAG_PREFIX, parseBotDate, realNumberOrDefault, joinRoom as calcJoinRoom, leaveRoom as calcLeaveRoom, setRoomOptions as calcSetRoomOptions, getRoomOptions as calcGetRoomOptions, getRoomTrackOptions as calcGetRoomTrackOptions, setRoomTrackOptions as calcSetRoomTrackOptions, getRoomRemoteOptions as calcGetRoomRemoteOptions, raycastFromCamera as calcRaycastFromCamera, raycastInPortal as calcRaycastInPortal, calculateRayFromCamera as calcCalculateRayFromCamera, bufferFormAddressGltf, startFormAnimation as calcStartFormAnimation, stopFormAnimation as calcStopFormAnimation, listFormAnimations as calcListFormAnimations, calculateStringTagValue, createInitializationUpdate as calcCreateInitalizationUpdate, applyUpdatesToInst as calcApplyUpdatesToInst, configureWakeLock, getWakeLockConfiguration as calcGetWakeLockConfiguration, analyticsRecordEvent as calcAnalyticsRecordEvent, attachRuntime, detachRuntime, KNOWN_TAGS, isStoredVersion2, grantRecordMarkerPermission as calcGrantRecordMarkerPermission, revokeRecordMarkerPermission as calcRevokeRecordMarkerPermission, grantInstAdminPermission as calcGrantInstAdminPermission, grantUserRole as calcGrantUserRole, revokeUserRole as calcRevokeUserRole, grantInstRole as calcGrantInstRole, revokeInstRole as calcRevokeInstRole, getCurrentInstUpdate as calcGetCurrentInstUpdate, } from '../bots';
25
+ rpioI2CEndPin, rpioPWMSetClockDividerPin, rpioPWMSetRangePin, rpioPWMSetDataPin, rpioSPIBeginPin, rpioSPIChipSelectPin, rpioSPISetCSPolarityPin, rpioSPISetClockDividerPin, rpioSPISetDataModePin, rpioSPITransferPin, rpioSPIWritePin, rpioSPIEndPin, serialConnectPin, serialOpenPin, serialStreamPin, serialUpdatePin, serialWritePin, serialReadPin, serialClosePin, serialFlushPin, serialDrainPin, serialPausePin, serialResumePin, calculateAnchorPoint, calculateAnchorPointOffset, getBotPosition as calcGetBotPosition, getBotRotation as calcGetBotRotation, isRuntimeBot, SET_TAG_MASK_SYMBOL, CLEAR_TAG_MASKS_SYMBOL, getBotScale, EDIT_TAG_SYMBOL, EDIT_TAG_MASK_SYMBOL, circleWipe, addDropSnap as calcAddDropSnap, addDropGrid as calcAddDropGrid, animateToPosition, beginAudioRecording as calcBeginAudioRecording, endAudioRecording as calcEndAudioRecording, beginRecording as calcBeginRecording, endRecording as calcEndRecording, speakText as calcSpeakText, getVoices as calcGetVoices, getGeolocation as calcGetGeolocation, cancelAnimation, disablePOV, enablePOV, enableCustomDragging as calcEnableCustomDragging, MINI_PORTAL, registerCustomApp, setAppOutput, unregisterCustomApp, requestAuthData as calcRequestAuthData, createBot, defineGlobalBot as calcDefineGlobalBot, TEMPORARY_BOT_PARTITION_ID, convertToString, GET_TAG_MASKS_SYMBOL, isBotLink, parseBotLink, createBotLink, convertGeolocationToWhat3Words as calcConvertGeolocationToWhat3Words, getPublicRecordKey as calcGetPublicRecordKey, recordData as calcRecordData, getRecordData, eraseRecordData, recordFile as calcRecordFile, getFile as calcGetFile, eraseFile as calcEraseFile, meetCommand as calcMeetCommand, meetFunction as calcMeetFunction, listDataRecord, recordEvent as calcRecordEvent, getEventCount as calcGetEventCount, openImageClassifier as calcOpenImageClassifier, isBotDate, DATE_TAG_PREFIX, parseBotDate, realNumberOrDefault, joinRoom as calcJoinRoom, leaveRoom as calcLeaveRoom, setRoomOptions as calcSetRoomOptions, getRoomOptions as calcGetRoomOptions, getRoomTrackOptions as calcGetRoomTrackOptions, setRoomTrackOptions as calcSetRoomTrackOptions, getRoomRemoteOptions as calcGetRoomRemoteOptions, raycastFromCamera as calcRaycastFromCamera, raycastInPortal as calcRaycastInPortal, calculateRayFromCamera as calcCalculateRayFromCamera, bufferFormAddressGltf, startFormAnimation as calcStartFormAnimation, stopFormAnimation as calcStopFormAnimation, listFormAnimations as calcListFormAnimations, calculateStringTagValue, createInitializationUpdate as calcCreateInitalizationUpdate, applyUpdatesToInst as calcApplyUpdatesToInst, configureWakeLock, getWakeLockConfiguration as calcGetWakeLockConfiguration, analyticsRecordEvent as calcAnalyticsRecordEvent, attachRuntime, detachRuntime, KNOWN_TAGS, isStoredVersion2, grantRecordMarkerPermission as calcGrantRecordMarkerPermission, revokeRecordMarkerPermission as calcRevokeRecordMarkerPermission, grantInstAdminPermission as calcGrantInstAdminPermission, grantUserRole as calcGrantUserRole, revokeUserRole as calcRevokeUserRole, grantInstRole as calcGrantInstRole, revokeInstRole as calcRevokeInstRole, getCurrentInstUpdate as calcGetCurrentInstUpdate, openPhotoCamera as calcOpenPhotoCamera, } from '../bots';
26
26
  import { sortBy, every, cloneDeep, union, isEqual, flatMap } from 'lodash';
27
27
  import { remote as calcRemote, } from '@casual-simulation/causal-trees';
28
28
  import { RanOutOfEnergyError } from './AuxResults';
@@ -374,6 +374,9 @@ export function createDefaultLibrary(context) {
374
374
  hideBarcode,
375
375
  openImageClassifier,
376
376
  closeImageClassifier,
377
+ openPhotoCamera,
378
+ capturePhoto,
379
+ closePhotoCamera,
377
380
  /**
378
381
  * Gets the device-local time as the number of miliseconds since midnight January 1st, 1970 UTC-0 (i.e. the Unix Epoch). This is what your device's clock thinks the current time is.
379
382
  *
@@ -2920,6 +2923,82 @@ export function createDefaultLibrary(context) {
2920
2923
  const action = calcOpenImageClassifier(false, {}, task.taskId);
2921
2924
  return addAsyncAction(task, action);
2922
2925
  }
2926
+ /**
2927
+ * Opens the photo camera. Returns a promise that resolves once the camera has been opened. Triggers the {@tag @onPhotoCameraOpened} shout once opened.
2928
+ *
2929
+ * While open, each time the user takes a photo the system will send a {@tag @onPhotoCaptured} shout. Optionally accepts which camera to use for scanning. (front/back)
2930
+ *
2931
+ * @param options the options that should be used for the photo camera.
2932
+ *
2933
+ * @example Open the photo camera.
2934
+ * await os.openPhotoCamera();
2935
+ *
2936
+ * @example Open the photo camera, defaulting to the front-facing camera.
2937
+ * await os.openPhotoCamera({
2938
+ * cameraType: "front"
2939
+ * });
2940
+ *
2941
+ * @dochash actions/camera
2942
+ * @doctitle Camera Actions
2943
+ * @docsidebar Camera
2944
+ * @docdescription Actions for taking photos.
2945
+ * @docname os.openPhotoCamera
2946
+ */
2947
+ function openPhotoCamera(options) {
2948
+ const task = context.createTask();
2949
+ const action = calcOpenPhotoCamera(true, false, options, task.taskId);
2950
+ return addAsyncAction(task, action);
2951
+ }
2952
+ /**
2953
+ * Opens the photo camera for the user to take a single photo. Returns a promise that resolves with the taken photo. Triggers the {@tag @onPhotoCameraOpened} shout once opened.
2954
+ *
2955
+ * While open, each time the user takes a photo the system will send a {@tag @onPhotoCaptured} shout. Optionally accepts which camera to use for scanning. (front/back)
2956
+ *
2957
+ * @param options the options that should be used for the photo camera.
2958
+ *
2959
+ * @example Prompt the user to take a single photo.
2960
+ * const photo = await os.capturePhoto();
2961
+ *
2962
+ * @example Take a single photo, defaulting to the front-facing camera.
2963
+ * await os.capturePhoto({
2964
+ * cameraType: "front"
2965
+ * });
2966
+ *
2967
+ * @example Take a single photo, skipping the confirmation user step.
2968
+ * await os.capturePhoto({
2969
+ * skipConfirm: true
2970
+ * });
2971
+ *
2972
+ * @example Take a single photo after a 3 second delay.
2973
+ * await os.capturePhoto({
2974
+ * takePhotoAfterSeconds: 3
2975
+ * });
2976
+ *
2977
+ * @dochash actions/camera
2978
+ * @doctitle Camera Actions
2979
+ * @docsidebar Camera
2980
+ * @docdescription Actions for taking photos.
2981
+ * @docname os.capturePhoto
2982
+ */
2983
+ function capturePhoto(options) {
2984
+ const task = context.createTask();
2985
+ const action = calcOpenPhotoCamera(true, true, options, task.taskId);
2986
+ return addAsyncAction(task, action);
2987
+ }
2988
+ /**
2989
+ * Closes the photo camera. Returns a promise that resolves once the camera has been closed. Triggers the {@tag @onPhotoCameraClosed} shout once closed.
2990
+ *
2991
+ * @example Close the photo camera
2992
+ * await os.closePhotoCamera();
2993
+ *
2994
+ * @dochash actions/camera
2995
+ * @docname os.closePhotoCamera
2996
+ */
2997
+ function closePhotoCamera() {
2998
+ const task = context.createTask();
2999
+ const action = calcOpenPhotoCamera(false, false, undefined, task.taskId);
3000
+ return addAsyncAction(task, action);
3001
+ }
2923
3002
  /**
2924
3003
  * Loads the given inst into the current browser tab. When the inst is loaded, the {@tag @onInstJoined} shout will be triggered.
2925
3004
  *
@@ -5289,8 +5368,16 @@ export function createDefaultLibrary(context) {
5289
5368
  return addAsyncAction(task, event);
5290
5369
  }
5291
5370
  /**
5292
- * Requests that the given address be pre-cached so that it is available for use on a bot.
5371
+ * Pre-caches the given GLTF mesh address so that it will load instantly when used on a bot later.
5372
+ * Returns a promise that resolves once the address has been cached.
5293
5373
  * @param address The address that should be cached.
5374
+ *
5375
+ * @example Buffer a specific GLTF
5376
+ * await os.bufferFormAddressGLTF('https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Fox/glTF/Fox.gltf');
5377
+ * os.toast("Buffered!");
5378
+ *
5379
+ * @dochash actions/animations
5380
+ * @docname os.bufferFormAddressGLTF
5294
5381
  */
5295
5382
  function bufferFormAddressGLTF(address) {
5296
5383
  const task = context.createTask();
@@ -7125,25 +7212,76 @@ export function createDefaultLibrary(context) {
7125
7212
  return addAsyncAction(task, event);
7126
7213
  }
7127
7214
  /**
7128
- * Plays the given animation on the given bot locally.
7129
- * Reverts back to the original animation when done playing.
7130
- * @param bot The bot.
7131
- * @param animation The animation to play.
7215
+ * Locally plays the given animation on the given bot.
7216
+ *
7217
+ * If an animation is already playing, it will be interrupted.
7218
+ * When the given animation is finished playing, the interrupted animation will be restored.
7219
+ *
7220
+ * @param bot the Bot or Bot ID that the animation should be played on.
7221
+ * @param animation the name or index of the animation that should be played.
7222
+ *
7223
+ * @example Play the "jump" animation on this bot.
7224
+ * experiment.localFormAnimation(this, "jump");
7132
7225
  *
7133
- * @docgroup 20-experimental
7134
- * @docgrouptitle Experimental Actions
7226
+ * @dochash actions/experimental
7227
+ * @docname experiment.localFormAnimation
7135
7228
  */
7136
7229
  function localFormAnimation(bot, animation) {
7137
7230
  return addAction(calcLocalFormAnimation(getID(bot), animation));
7138
7231
  }
7139
7232
  /**
7140
- * Tweens the position of the given bot.
7141
- * @param bot The bot or bot ID to tween.
7142
- * @param dimension The dimension that the bot should be tweened in.
7143
- * @param position The position that the bot should be tweened to.
7144
- * @param options The options that should be used for the tween.
7233
+ * Locally plays a tween that moves the given bot in the given dimension to the given position.
7234
+ * Optionally allows customizing the easing of the tween.
7235
+ *
7236
+ * Returns a promise that resolves when the tween is finished.
7237
+ *
7238
+ * While the tween is playing, any updates to the bot's position and rotation are ignored.
7239
+ * Once the tween is done playing, any change to the bot will reset the position/rotation.
7240
+ *
7241
+ *
7242
+ *
7243
+ * @param bot the bot or ID of the bot that should be tweened.
7244
+ * @param dimension the dimension that the bot should be tweened in.
7245
+ * Note that the tween will only work if the given dimension is currently in the grid portal or miniGridPortal.
7246
+ *
7247
+ * @param position the position that the bot should be tweened to. If you exclude a dimension (like `x`, `y`, or `z`), then it will remain unchanged.
7248
+ * @param options the options that should be used.
7145
7249
  *
7146
- * @docgroup 20-experimental
7250
+ * @example Tween the bot to X = 10 in the `home` dimension.
7251
+ * experiment.localPositionTween(
7252
+ * this,
7253
+ * 'home',
7254
+ * {
7255
+ * x: 10,
7256
+ * });
7257
+ *
7258
+ * @example Tween the bot over 5 seconds.
7259
+ * experiment.localPositionTween(
7260
+ * this,
7261
+ * 'home',
7262
+ * {
7263
+ * x: 10,
7264
+ * },
7265
+ * {
7266
+ * duration: 5
7267
+ * });
7268
+ *
7269
+ * @example Tween the bot with quadratic easing.
7270
+ * experiment.localPositionTween(
7271
+ * this,
7272
+ * 'home',
7273
+ * {
7274
+ * x: 10,
7275
+ * },
7276
+ * {
7277
+ * easing: {
7278
+ * type: 'quadratic',
7279
+ * mode: 'inout'
7280
+ * }
7281
+ * });
7282
+ *
7283
+ * @dochash actions/experimental
7284
+ * @docname experiment.localPositionTween
7147
7285
  */
7148
7286
  function localPositionTween(bot, dimension, position, options) {
7149
7287
  const task = context.createTask();
@@ -7151,13 +7289,56 @@ export function createDefaultLibrary(context) {
7151
7289
  return addAsyncAction(task, action);
7152
7290
  }
7153
7291
  /**
7154
- * Tweens the rotation of the given bot.
7155
- * @param bot The bot or bot ID to tween.
7156
- * @param dimension The dimension that the bot should be tweened in.
7157
- * @param rotation The rotation that the bot should be tweened to.
7158
- * @param options The options that should be used for the tween.\
7292
+ * Locally plays a tween that rotates the given bot in the given dimension to the given rotation.
7293
+ * Optionally allows customizing the easing of the tween.
7294
+ *
7295
+ * Returns a promise that resolves when the tween is finished.
7296
+ *
7297
+ * While the tween is playing, any updates to the bot's position and rotation are ignored.
7298
+ * Once the tween is done playing, any change to the bot will reset the position/rotation.
7299
+ *
7300
+ * @param bot the bot or ID of the bot that should be tweened.
7301
+ * @param dimension the dimension that the bot should be tweened in.
7302
+ * Note that the tween will only work if the given dimension is currently in the grid portal or miniGridPortal.
7303
+ *
7304
+ * @param rotation the rotation that the bot should be tweened to in radians. If you exclude a dimension (like `x`, `y`, or `z`), then it will remain unchanged.
7305
+ * @param options The options that should be used for the tween.
7306
+ *
7307
+ * @example Tween the bot 90 degrees around the Z axis in the `home` dimension.
7308
+ * experiment.localRotationTween(
7309
+ * this,
7310
+ * 'home',
7311
+ * {
7312
+ * z: Math.PI / 2,
7313
+ * });
7314
+ *
7315
+ * @example Tween the bot for 5 seconds.
7316
+ * experiment.localRotationTween(
7317
+ * this,
7318
+ * 'home',
7319
+ * {
7320
+ * z: Math.PI / 2,
7321
+ * },
7322
+ * {
7323
+ * duration: 5
7324
+ * });
7325
+ *
7326
+ * @example Tween the bot with quadratic easing.
7327
+ * experiment.localRotationTween(
7328
+ * this,
7329
+ * 'home',
7330
+ * {
7331
+ * z: Math.PI / 2,
7332
+ * },
7333
+ * {
7334
+ * easing: {
7335
+ * type: 'quadratic',
7336
+ * mode: 'inout'
7337
+ * }
7338
+ * });
7159
7339
  *
7160
- * @docgroup 20-experimental
7340
+ * @dochash actions/experimental
7341
+ * @docname experiment.localRotationTween
7161
7342
  */
7162
7343
  function localRotationTween(bot, dimension, rotation, options) {
7163
7344
  const task = context.createTask();
@@ -7165,12 +7346,48 @@ export function createDefaultLibrary(context) {
7165
7346
  return addAsyncAction(task, action);
7166
7347
  }
7167
7348
  /**
7168
- * Gets the position that the center of the given bot would placed at if it had the given anchor point.
7169
- * @param bot The bot.
7170
- * @param dimension The dimension to get the position of.
7171
- * @param anchorPoint The anchor point.
7349
+ * Gets the absolute position in the given dimension that the center of the given bot would be placed at if the bot was using the given anchor point.
7350
+ *
7351
+ * @param bot the bot that the anchor point position should be calculated for.
7352
+ * @param dimension the dimension that the anchor point position should be calculated in.
7353
+ * @param anchorPoint the anchor point that should be calculated. Can be any valid {@tag anchorPoint} value.
7354
+ *
7355
+ * @example Get the top anchor point of the current bot in the "home" dimension.
7356
+ * const point = experiment.getAnchorPointPosition(bot, "home", "top");
7357
+ * os.toast(point);
7358
+ *
7359
+ * @example Get the back right anchor point of the current bot in the "home" dimension.
7360
+ * const point = experiment.getAnchorPointPosition(bot, "home", [ 0.5, -0.5, 0 ]);
7361
+ * os.toast(point);
7362
+ *
7363
+ * @example Place bots at each of the anchor points.
7364
+ * let points = [
7365
+ * 'top',
7366
+ * 'bottom',
7367
+ * 'front',
7368
+ * 'back',
7369
+ * 'left',
7370
+ * 'right',
7371
+ * 'center',
7372
+ * ];
7373
+ *
7374
+ * for(let point of points) {
7375
+ * let pos = experiment.getAnchorPointPosition(bot, os.getCurrentDimension(), point);
7376
+ * create({
7377
+ * space: 'tempShared',
7378
+ * color: 'green',
7379
+ * [os.getCurrentDimension()]: true,
7380
+ * [os.getCurrentDimension() + "X"]: pos.x,
7381
+ * [os.getCurrentDimension() + "Y"]: pos.y,
7382
+ * [os.getCurrentDimension() + "Z"]: pos.z,
7383
+ * anchorPoint: 'center',
7384
+ * targetAnchorPoint: point,
7385
+ * scale: 0.1,
7386
+ * });
7387
+ * }
7172
7388
  *
7173
- * @docgroup 20-experimental
7389
+ * @dochash actions/experimental
7390
+ * @docname experiment.getAnchorPointPosition
7174
7391
  */
7175
7392
  function getAnchorPointPosition(bot, dimension, anchorPoint) {
7176
7393
  const offset = getAnchorPointOffset(anchorPoint);
@@ -7240,22 +7457,72 @@ export function createDefaultLibrary(context) {
7240
7457
  return addAsyncAction(task, action);
7241
7458
  }
7242
7459
  /**
7243
- * Starts a new recording.
7244
- * @param options The options for the recording.
7245
- * @returns A promise that resolves when the recording has started.
7460
+ * Starts a new recording. Returns a promise that resolves when recording has started.
7461
+ * The returned promise will throw an error if recording could not be started. Reasons for this include insufficient permissions and not having a microphone.
7462
+ * @param options the options that should be used for the recording.
7463
+ * Defaults to: `{ audio: true, video: true, screen: false }`
7464
+ *
7465
+ * @example Record for 10 seconds and download the files.
7466
+ * await experiment.beginRecording({
7467
+ * audio: true,
7468
+ * video: true,
7469
+ * screen: false
7470
+ * });
7471
+ * await os.sleep(10000);
7472
+ * const data = await experiment.endRecording();
7473
+ * let index = 0;
7474
+ * for(let file of data.files) {
7475
+ * os.download(file.data, `file-${index}`);
7476
+ * index += 1;
7477
+ * }
7478
+ *
7479
+ * @example Record the screen with microphone audio.
7480
+ * await experiment.beginRecording({
7481
+ * audio: ['microphone'],
7482
+ * video: false,
7483
+ * screen: true
7484
+ * });
7485
+ * await os.sleep(10000);
7486
+ * const data = await experiment.endRecording();
7487
+ * let index = 0;
7488
+ * for(let file of data.files) {
7489
+ * os.download(file.data, `file-${index}`);
7490
+ * index += 1;
7491
+ * }
7246
7492
  *
7247
- * @docgroup 20-experimental
7493
+ * @dochash actions/experimental
7494
+ * @doctitle Experimental Actions
7495
+ * @docsidebar Experimental
7496
+ * @docdescription Experimental actions are actions that are not yet fully supported and may change in the future.
7497
+ * @docname experiment.beginRecording
7248
7498
  */
7249
- function beginRecording(options = { audio: true, video: true, screen: false }) {
7499
+ function beginRecording(options) {
7500
+ if (!options) {
7501
+ options = { audio: true, video: true, screen: false };
7502
+ }
7250
7503
  const task = context.createTask();
7251
7504
  const action = calcBeginRecording(options, task.taskId);
7252
7505
  return addAsyncAction(task, action);
7253
7506
  }
7254
7507
  /**
7255
- * Finishes a recording.
7256
- * Returns a promise that resolves with the recorded data.
7508
+ * Stops the recording that is in progress. Returns a promise that resolves with the recorded data.
7257
7509
  *
7258
- * @docgroup 20-experimental
7510
+ * @example Record for 10 seconds and download the files.
7511
+ * await experiment.beginRecording({
7512
+ * audio: true,
7513
+ * video: true,
7514
+ * screen: false
7515
+ * });
7516
+ * await os.sleep(10000);
7517
+ * const data = await experiment.endRecording();
7518
+ * let index = 0;
7519
+ * for(let file of data.files) {
7520
+ * os.download(file.data, `file-${index}`);
7521
+ * index += 1;
7522
+ * }
7523
+ *
7524
+ * @dochash actions/experimental
7525
+ * @docname experiment.endRecording
7259
7526
  */
7260
7527
  function endRecording() {
7261
7528
  const task = context.createTask();
@@ -7547,15 +7814,19 @@ export function createDefaultLibrary(context) {
7547
7814
  return null;
7548
7815
  }
7549
7816
  /**
7550
- * Speaks the given text.
7817
+ * Speaks the given text using a synthetic voice and options.
7818
+ * Note that this is a local effect. The gererated sounds are only played in the current session.
7819
+ *
7551
7820
  * Returns a promise that resolves when the text has been spoken.
7552
- * @param text The text that should be spoken.
7553
- * @param options The options that should be used.
7821
+ * @param text the text that should be spoken.
7822
+ * @param options the options that should be used to speak the text.
7554
7823
  *
7555
- * @docgroup 20-experimental
7824
+ * @dochash actions/experimental
7825
+ * @docname experiment.speakText
7556
7826
  */
7557
- function speakText(text, options = {}) {
7827
+ function speakText(text, options) {
7558
7828
  var _a;
7829
+ options = options !== null && options !== void 0 ? options : {};
7559
7830
  const task = context.createTask();
7560
7831
  const voice = typeof options.voice === 'object'
7561
7832
  ? (_a = options.voice) === null || _a === void 0 ? void 0 : _a.name
@@ -7567,7 +7838,17 @@ export function createDefaultLibrary(context) {
7567
7838
  * Gets the list of synthetic voices that are supported by the system.
7568
7839
  * Returns a promise that resolves with the voices.
7569
7840
  *
7570
- * @docgroup 20-experimental
7841
+ * @example Toast the list of voices that are supported.
7842
+ * const voices = await experiment.getVoices();
7843
+ * os.toast(voices);
7844
+ *
7845
+ * @example Get the first US English voice.
7846
+ * const voices = await experiment.getVoices();
7847
+ * const usEnglish = voices.find(v => v.language === "en-US");
7848
+ * os.toast(usEnglish);
7849
+ *
7850
+ * @dochash actions/experimental
7851
+ * @docname experiment.getVoices
7571
7852
  */
7572
7853
  function getVoices() {
7573
7854
  const task = context.createTask();