@casual-simulation/aux-common 2.0.32 → 3.0.0-alpha.1826142686

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.
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { DEBUG_STRING, debugStringifyFunction, } from './AuxGlobalContext';
11
- import { hasValue, trimTag, isBot, BOT_SPACE_TAG, toast as toastMessage, showJoinCode as calcShowJoinCode, requestFullscreen, exitFullscreen, html as htmlMessage, hideHtml as hideHtmlMessage, setClipboard as calcSetClipboard, tweenTo as calcTweenTo, showChat as calcShowChat, hideChat as calcHideChat, runScript, 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, 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, action, getServerStatuses, setSpacePassword, exportGpioPin, unexportGpioPin, setGpioPin, getGpioPin, rpioInitPin, rpioExitPin, rpioOpenPin, rpioModePin, rpioReadPin, rpioReadSequencePin, rpioWritePin, rpioWriteSequencePin, rpioReadpadPin, rpioWritepadPin, rpioPudPin, rpioPollPin, rpioClosePin, rpioI2CBeginPin, rpioI2CSetSlaveAddressPin, rpioI2CSetBaudRatePin, rpioI2CSetClockDividerPin, rpioI2CReadPin, rpioI2CWritePin,
11
+ import { hasValue, trimTag, isBot, BOT_SPACE_TAG, toast as toastMessage, 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, 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, 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, action, getServerStatuses, setSpacePassword, exportGpioPin, unexportGpioPin, setGpioPin, getGpioPin, rpioInitPin, rpioExitPin, rpioOpenPin, rpioModePin, rpioReadPin, rpioReadSequencePin, rpioWritePin, rpioWriteSequencePin, rpioReadpadPin, rpioWritepadPin, rpioPudPin, rpioPollPin, rpioClosePin, rpioI2CBeginPin, rpioI2CSetSlaveAddressPin, rpioI2CSetBaudRatePin, rpioI2CSetClockDividerPin, rpioI2CReadPin, rpioI2CWritePin,
12
12
  // rpioI2CReadRegisterRestartPin,
13
13
  // rpioI2CWriteReadRestartPin,
14
- 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, isRuntimeBot, SET_TAG_MASK_SYMBOL, CLEAR_TAG_MASKS_SYMBOL, getBotScale, EDIT_TAG_SYMBOL, EDIT_TAG_MASK_SYMBOL, circleWipe, addDropSnap as calcAddDropSnap, 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, eraseFile as calcEraseFile, meetCommand as calcMeetCommand, } from '../bots';
14
+ 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, isRuntimeBot, SET_TAG_MASK_SYMBOL, CLEAR_TAG_MASKS_SYMBOL, getBotScale, EDIT_TAG_SYMBOL, EDIT_TAG_MASK_SYMBOL, circleWipe, addDropSnap as calcAddDropSnap, 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, eraseFile as calcEraseFile, meetCommand as calcMeetCommand, listDataRecord, recordEvent as calcRecordEvent, getEventCount as calcGetEventCount, openImageClassifier as calcOpenImageClassifier, } from '../bots';
15
15
  import { sortBy, every, cloneDeep, union, isEqual, flatMap } from 'lodash';
16
16
  import { remote as calcRemote, } from '@casual-simulation/causal-trees';
17
17
  import { RanOutOfEnergyError } from './AuxResults';
@@ -222,6 +222,7 @@ export function createDefaultLibrary(context) {
222
222
  device,
223
223
  isCollaborative,
224
224
  getAB1BootstrapURL,
225
+ getMediaPermission,
225
226
  enableAR,
226
227
  disableAR,
227
228
  enableVR,
@@ -244,6 +245,8 @@ export function createDefaultLibrary(context) {
244
245
  closeBarcodeScanner,
245
246
  showBarcode,
246
247
  hideBarcode,
248
+ openImageClassifier,
249
+ closeImageClassifier,
247
250
  loadServer,
248
251
  unloadServer,
249
252
  loadInst: loadServer,
@@ -298,11 +301,14 @@ export function createDefaultLibrary(context) {
298
301
  recordManualApprovalData,
299
302
  getData,
300
303
  getManualApprovalData,
304
+ listData,
301
305
  eraseData,
302
306
  eraseManualApprovalData,
303
307
  recordFile,
304
308
  getFile,
305
309
  eraseFile,
310
+ recordEvent,
311
+ countEvents,
306
312
  convertGeolocationToWhat3Words,
307
313
  setupInst: setupServer,
308
314
  remotes,
@@ -1502,6 +1508,25 @@ export function createDefaultLibrary(context) {
1502
1508
  const event = calcShowBarcode(false);
1503
1509
  return addAction(event);
1504
1510
  }
1511
+ /**
1512
+ * Shows an image classifier for the given ML Model.
1513
+ * Returns a promise that resolves when the image classifier has been opened.
1514
+ * @param options The options for the classifier.
1515
+ */
1516
+ function openImageClassifier(options) {
1517
+ const task = context.createTask();
1518
+ const action = calcOpenImageClassifier(true, options, task.taskId);
1519
+ return addAsyncAction(task, action);
1520
+ }
1521
+ /**
1522
+ * Hides the image classifier.
1523
+ * Returns a promise that resolves when the image classifier has been hidden.
1524
+ */
1525
+ function closeImageClassifier() {
1526
+ const task = context.createTask();
1527
+ const action = calcOpenImageClassifier(false, {}, task.taskId);
1528
+ return addAsyncAction(task, action);
1529
+ }
1505
1530
  /**
1506
1531
  * Loads the instance with the given ID.
1507
1532
  * @param id The ID of the inst to load.
@@ -2075,6 +2100,19 @@ export function createDefaultLibrary(context) {
2075
2100
  const event = getRecordData(recordName, address, requiresApproval, task.taskId);
2076
2101
  return addAsyncAction(task, event);
2077
2102
  }
2103
+ /**
2104
+ * Lists the data stored in the given record starting with the given address.
2105
+ * @param recordKeyOrName The record that the data should be retrieved from.
2106
+ * @param startingAddress The address that the list should start with.
2107
+ */
2108
+ function listData(recordKeyOrName, startingAddress = null) {
2109
+ let recordName = isRecordKey(recordKeyOrName)
2110
+ ? parseRecordKey(recordKeyOrName)[0]
2111
+ : recordKeyOrName;
2112
+ const task = context.createTask();
2113
+ const event = listDataRecord(recordName, startingAddress, task.taskId);
2114
+ return addAsyncAction(task, event);
2115
+ }
2078
2116
  /**
2079
2117
  * Erases the data stored in the given record at the given address.
2080
2118
  * @param recordKey The key that should be used to access the record.
@@ -2189,6 +2227,53 @@ export function createDefaultLibrary(context) {
2189
2227
  const event = calcEraseFile(recordKey, url, task.taskId);
2190
2228
  return addAsyncAction(task, event);
2191
2229
  }
2230
+ /**
2231
+ * Records that the given event occurred.
2232
+ * @param recordKey The key that should be used to record the event.
2233
+ * @param eventName The name of the event.
2234
+ */
2235
+ function recordEvent(recordKey, eventName) {
2236
+ if (!hasValue(recordKey)) {
2237
+ throw new Error('A recordKey must be provided.');
2238
+ }
2239
+ else if (typeof recordKey !== 'string') {
2240
+ throw new Error('recordKey must be a string.');
2241
+ }
2242
+ if (!hasValue(eventName)) {
2243
+ throw new Error('A eventName must be provided.');
2244
+ }
2245
+ else if (typeof eventName !== 'string') {
2246
+ throw new Error('eventName must be a string.');
2247
+ }
2248
+ const task = context.createTask();
2249
+ const event = calcRecordEvent(recordKey, eventName, 1, task.taskId);
2250
+ return addAsyncAction(task, event);
2251
+ }
2252
+ /**
2253
+ * Gets the number of times that the given event has been recorded.
2254
+ * @param recordNameOrKey The name of the record.
2255
+ * @param eventName The name of the event.
2256
+ */
2257
+ function countEvents(recordNameOrKey, eventName) {
2258
+ if (!hasValue(recordNameOrKey)) {
2259
+ throw new Error('A recordNameOrKey must be provided.');
2260
+ }
2261
+ else if (typeof recordNameOrKey !== 'string') {
2262
+ throw new Error('recordNameOrKey must be a string.');
2263
+ }
2264
+ if (!hasValue(eventName)) {
2265
+ throw new Error('A eventName must be provided.');
2266
+ }
2267
+ else if (typeof eventName !== 'string') {
2268
+ throw new Error('eventName must be a string.');
2269
+ }
2270
+ let recordName = isRecordKey(recordNameOrKey)
2271
+ ? parseRecordKey(recordNameOrKey)[0]
2272
+ : recordNameOrKey;
2273
+ const task = context.createTask();
2274
+ const event = calcGetEventCount(recordName, eventName, task.taskId);
2275
+ return addAsyncAction(task, event);
2276
+ }
2192
2277
  /**
2193
2278
  * Converts the given geolocation to a what3words (https://what3words.com/) address.
2194
2279
  * @param location The latitude and longitude that should be converted to a 3 word address.
@@ -3384,6 +3469,11 @@ export function createDefaultLibrary(context) {
3384
3469
  const action = calcEndRecording(task.taskId);
3385
3470
  return addAsyncAction(task, action);
3386
3471
  }
3472
+ /**
3473
+ * Sends commands to the Jitsi Meet API.
3474
+ * @param command The command to execute.
3475
+ * @param args The args for the command (if any).
3476
+ */
3387
3477
  function meetCommand(command, ...args) {
3388
3478
  return addAction(calcMeetCommand(command, ...args));
3389
3479
  }
@@ -4826,6 +4916,15 @@ export function createDefaultLibrary(context) {
4826
4916
  }
4827
4917
  return user.tags.inputList || [];
4828
4918
  }
4919
+ /**
4920
+ * Gets permission from user to access audio and/or video streams from the device.
4921
+ * @param options The options.
4922
+ */
4923
+ function getMediaPermission(options) {
4924
+ const task = context.createTask();
4925
+ const event = calcGetMediaPermission(options, task.taskId);
4926
+ return addAsyncAction(task, event);
4927
+ }
4829
4928
  /**
4830
4929
  * Runs an event on the given bots.
4831
4930
  * @param name The name of the event to run.