@casual-simulation/aux-runtime 4.2.6 → 4.2.7-alpha.28681314276
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/runtime/AuxDevice.d.ts +4 -0
- package/runtime/AuxLibrary.d.ts +34 -1
- package/runtime/AuxLibrary.js +104 -1
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +161 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casual-simulation/aux-runtime",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.7-alpha.28681314276",
|
|
4
4
|
"description": "Runtime for AUX projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@casual-simulation/aux-common": "^4.2.
|
|
29
|
-
"@casual-simulation/aux-records": "^4.2.
|
|
28
|
+
"@casual-simulation/aux-common": "^4.2.7-alpha.28681314276",
|
|
29
|
+
"@casual-simulation/aux-records": "^4.2.7-alpha.28681314276",
|
|
30
30
|
"@casual-simulation/crypto": "^4.0.5",
|
|
31
31
|
"@casual-simulation/engine262": "0.0.1-4de2170374e22761996e46eb1362f4496ee57f8f",
|
|
32
32
|
"@casual-simulation/error-stack-parser": "^2.0.7",
|
package/runtime/AuxDevice.d.ts
CHANGED
package/runtime/AuxLibrary.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import '@casual-simulation/aux-common/BlobPolyfill';
|
|
|
11
11
|
import type { AuxDevice } from './AuxDevice';
|
|
12
12
|
import type { AuxVersion } from './AuxVersion';
|
|
13
13
|
import { Vector3, Vector2, Quaternion, Rotation } from '@casual-simulation/aux-common/math';
|
|
14
|
-
import type { AIChatMessage, CreateRecordResult, GrantResourcePermissionResult, ListStudiosResult, ListRecordsResult, ListSubscriptionsResult, NotificationRecord, PushNotificationPayload, RevokePermissionResult, ListPermissionsResult, SendNotificationResult, SubscribeToNotificationResult, UnsubscribeToNotificationResult, WebhookRecord, CreatePublicRecordKeyResult, GetDataResult, RecordDataResult, RecordFileFailure, EraseDataResult, EraseFileResult, ListDataResult, AddCountResult, GetCountResult, GrantMarkerPermissionResult, GrantRoleResult, RevokeRoleResult, PackageRecord, ListInstalledPackagesResult, ListInstsResult, EraseInstResult, PurchasableItem, PayoutDestination, ContractPricing, JSONAccountBalancesAndSubscriptionInfo, PurchaseCreditsResult } from '@casual-simulation/aux-records';
|
|
14
|
+
import type { AIChatMessage, CreateRecordResult, GrantResourcePermissionResult, ListStudiosResult, ListRecordsResult, ListSubscriptionsResult, NotificationRecord, PushNotificationPayload, RevokePermissionResult, ListPermissionsResult, SendNotificationResult, SubscribeToNotificationResult, UnsubscribeToNotificationResult, WebhookRecord, CreatePublicRecordKeyResult, GetDataResult, RecordDataResult, RecordFileFailure, EraseDataResult, EraseFileResult, ListDataResult, AddCountResult, GetCountResult, GrantMarkerPermissionResult, GrantRoleResult, RevokeRoleResult, PackageRecord, ListInstalledPackagesResult, ListInstsResult, EraseInstResult, PurchasableItem, PayoutDestination, ContractPricing, JSONAccountBalancesAndSubscriptionInfo, PurchaseCreditsResult, SetRecordBudgetResult, GetRecordBudgetResult } from '@casual-simulation/aux-records';
|
|
15
15
|
import { DateTime } from 'luxon';
|
|
16
16
|
import * as hooks from 'preact/hooks';
|
|
17
17
|
import { render, createRef, createContext } from 'preact';
|
|
@@ -74,6 +74,36 @@ export interface APIPurchaseCreditsRequest {
|
|
|
74
74
|
*/
|
|
75
75
|
successUrl: string;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Defines an interface that represents the options for setting a record's budget.
|
|
79
|
+
*
|
|
80
|
+
* @dochash types/records/extra
|
|
81
|
+
* @docname SetRecordBudgetRequest
|
|
82
|
+
* @docid SetRecordBudgetRequest
|
|
83
|
+
*/
|
|
84
|
+
export interface APISetRecordBudgetRequest {
|
|
85
|
+
/**
|
|
86
|
+
* The name of the record that the budget should be set for.
|
|
87
|
+
*/
|
|
88
|
+
recordName: string;
|
|
89
|
+
/**
|
|
90
|
+
* The budget that should be set for the record.
|
|
91
|
+
* Setting this value to null will clear the budget, causing billing for the record to go to the owner's account.
|
|
92
|
+
*/
|
|
93
|
+
budget: {
|
|
94
|
+
/**
|
|
95
|
+
* The type of the budget.
|
|
96
|
+
* - "fixed" means that a set number of credits will be transferred to the record from the owner's account upon a subscription credit grant.
|
|
97
|
+
* - "percent" means that the record will be granted a percentage of the total amount that the owner's account receives upon a subscription credit grant.
|
|
98
|
+
*/
|
|
99
|
+
type: 'fixed' | 'percent';
|
|
100
|
+
/**
|
|
101
|
+
* The budget amount. Can be a string containing a bigint value. Must be an integer.
|
|
102
|
+
* Must be between 0 and 100 if type is "percent".
|
|
103
|
+
*/
|
|
104
|
+
amount: number | string;
|
|
105
|
+
} | null;
|
|
106
|
+
}
|
|
77
107
|
export interface APIInvoiceContractRequest {
|
|
78
108
|
contractId: string;
|
|
79
109
|
amount: number;
|
|
@@ -2601,6 +2631,7 @@ export declare function createDefaultLibrary(context: AuxGlobalContext): {
|
|
|
2601
2631
|
cancelSound: (soundId: number | string | object) => Promise<any>;
|
|
2602
2632
|
hasBotInMiniPortal: (bots: Bot | Bot[]) => boolean;
|
|
2603
2633
|
share: (options: ShareOptions) => Promise<void>;
|
|
2634
|
+
sendEmbedMessage: (message: any, targetOrigin?: string) => Promise<void>;
|
|
2604
2635
|
closeCircleWipe: (options?: Partial<OpenCircleWipeOptions>) => Promise<void>;
|
|
2605
2636
|
openCircleWipe: (options?: Partial<OpenCircleWipeOptions>) => Promise<void>;
|
|
2606
2637
|
addDropSnap: (...targets: SnapTarget[]) => AddDropSnapTargetsAction;
|
|
@@ -2908,6 +2939,8 @@ export declare function createDefaultLibrary(context: AuxGlobalContext): {
|
|
|
2908
2939
|
payout: (request: APIPayoutRequest, options?: RecordActionOptions) => Promise<GenericResult<void, SimpleError>>;
|
|
2909
2940
|
getAccountBalances: (options?: GetAccountBalancesActionOptions) => Promise<GenericResult<JSONAccountBalancesAndSubscriptionInfo, SimpleError>>;
|
|
2910
2941
|
purchaseCredits: (request: APIPurchaseCreditsRequest, options?: RecordActionOptions) => Promise<PurchaseCreditsResult>;
|
|
2942
|
+
setRecordBudget: (request: APISetRecordBudgetRequest, options?: RecordActionOptions) => Promise<SetRecordBudgetResult>;
|
|
2943
|
+
getRecordBudget: (recordName: string, options?: RecordActionOptions) => Promise<GetRecordBudgetResult>;
|
|
2911
2944
|
};
|
|
2912
2945
|
portal: {
|
|
2913
2946
|
registerPrefix: (prefix: string, options?: RegisterPrefixOptions) => Promise<void>;
|
package/runtime/AuxLibrary.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEBUG_STRING, debugStringifyFunction } from './AuxGlobalContext';
|
|
2
|
-
import { hasValue, trimTag, isBot, BOT_SPACE_TAG, toast as toastMessage, getScriptIssues as scriptIssues, configureTypeChecking as calcConfigureTypeChecking, tip as tipMessage, hideTips as hideTipMessages, showJoinCode as calcShowJoinCode, requestFullscreen, exitFullscreen, promptToInstallPWA as calcPromptToInstallPWA, 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, generateQRCode as calcGenerateQRCode, openBarcodeScanner as calcOpenBarcodeScanner, showBarcode as calcShowBarcode, importAUX as calcImportAUX, showInputForTag as calcShowInputForTag, showInput as calcShowInput, showConfirm as calcShowConfirm, showAlert as calcShowAlert, replaceDragBot as calcReplaceDragBot, goToDimension as calcGoToDimension, goToURL as calcGoToURL, openURL as calcOpenURL, playSound as calcPlaySound, bufferSound as calcBufferSound, cancelSound as calcCancelSound, shell as calcShell, reject as calcReject, localFormAnimation as calcLocalFormAnimation, webhook as calcWebhook, superShout as calcSuperShout, share as calcShare, registerPrefix as calcRegisterPrefix, 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, getRemoteCount, getRemotes, listInstUpdates as calcListInstUpdates, getInstStateFromUpdates as calcGetInstStateFromUpdates, action, 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, signOut as calcSignOut, createBot, defineGlobalBot as calcDefineGlobalBot, TEMPORARY_BOT_PARTITION_ID, convertToString, GET_TAG_MASKS_SYMBOL, isBotLink, parseBotLink, createBotLink, convertGeolocationToWhat3Words as calcConvertGeolocationToWhat3Words, meetCommand as calcMeetCommand, meetFunction as calcMeetFunction, openImageClassifier as calcOpenImageClassifier, classifyImages as calcOpenClassifyImages, isBotDate, DATE_TAG_PREFIX, parseBotDate, realNumberOrDefault, 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, KNOWN_TAGS, isStoredVersion2, getCurrentInstUpdate as calcGetCurrentInstUpdate, openPhotoCamera as calcOpenPhotoCamera, getEasing, enableCollaboration as calcEnableCollaboration, showAccountInfo as calcShowAccountInfo, reportInst as calcReportInst, getRecordsEndpoint as calcGetRecordsEndpoint, ldrawCountAddressBuildSteps as calcLdrawCountAddressBuildSteps, ldrawCountTextBuildSteps as calcLdrawCountTextBuildSteps, calculateViewportCoordinatesFromPosition as calcCalculateViewportCoordinatesFromPosition, calculateScreenCoordinatesFromViewportCoordinates as calcCalculateScreenCoordinatesFromViewportCoordinates, calculateViewportCoordinatesFromScreenCoordinates as calcCalculateViewportCoordinatesFromScreenCoordinates, capturePortalScreenshot as calcCapturePortalScreenshot, createStaticHtml as calcCreateStaticHtmlFromBots, recordLoom, watchLoom, getLoomMetadata, loadSharedDocument, installAuxFile as calcInstallAuxFile, calculateStringListTagValue, calculateScreenCoordinatesFromPosition as calcCalculateScreenCoordinatesFromPosition, addMapLayer as calcAddMapLayer, removeMapLayer as calcRemoveMapLayer, GET_DYNAMIC_LISTENERS_SYMBOL, ADD_BOT_LISTENER_SYMBOL, REMOVE_BOT_LISTENER_SYMBOL, trackConfigBotTags as calcTrackConfigBotTags, } from '@casual-simulation/aux-common/bots';
|
|
2
|
+
import { hasValue, trimTag, isBot, BOT_SPACE_TAG, toast as toastMessage, getScriptIssues as scriptIssues, configureTypeChecking as calcConfigureTypeChecking, tip as tipMessage, hideTips as hideTipMessages, showJoinCode as calcShowJoinCode, requestFullscreen, exitFullscreen, promptToInstallPWA as calcPromptToInstallPWA, 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, generateQRCode as calcGenerateQRCode, openBarcodeScanner as calcOpenBarcodeScanner, showBarcode as calcShowBarcode, importAUX as calcImportAUX, showInputForTag as calcShowInputForTag, showInput as calcShowInput, showConfirm as calcShowConfirm, showAlert as calcShowAlert, replaceDragBot as calcReplaceDragBot, goToDimension as calcGoToDimension, goToURL as calcGoToURL, openURL as calcOpenURL, playSound as calcPlaySound, bufferSound as calcBufferSound, cancelSound as calcCancelSound, shell as calcShell, reject as calcReject, localFormAnimation as calcLocalFormAnimation, webhook as calcWebhook, superShout as calcSuperShout, share as calcShare, sendEmbedMessage as calcSendEmbedMessage, registerPrefix as calcRegisterPrefix, 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, getRemoteCount, getRemotes, listInstUpdates as calcListInstUpdates, getInstStateFromUpdates as calcGetInstStateFromUpdates, action, 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, signOut as calcSignOut, createBot, defineGlobalBot as calcDefineGlobalBot, TEMPORARY_BOT_PARTITION_ID, convertToString, GET_TAG_MASKS_SYMBOL, isBotLink, parseBotLink, createBotLink, convertGeolocationToWhat3Words as calcConvertGeolocationToWhat3Words, meetCommand as calcMeetCommand, meetFunction as calcMeetFunction, openImageClassifier as calcOpenImageClassifier, classifyImages as calcOpenClassifyImages, isBotDate, DATE_TAG_PREFIX, parseBotDate, realNumberOrDefault, 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, KNOWN_TAGS, isStoredVersion2, getCurrentInstUpdate as calcGetCurrentInstUpdate, openPhotoCamera as calcOpenPhotoCamera, getEasing, enableCollaboration as calcEnableCollaboration, showAccountInfo as calcShowAccountInfo, reportInst as calcReportInst, getRecordsEndpoint as calcGetRecordsEndpoint, ldrawCountAddressBuildSteps as calcLdrawCountAddressBuildSteps, ldrawCountTextBuildSteps as calcLdrawCountTextBuildSteps, calculateViewportCoordinatesFromPosition as calcCalculateViewportCoordinatesFromPosition, calculateScreenCoordinatesFromViewportCoordinates as calcCalculateScreenCoordinatesFromViewportCoordinates, calculateViewportCoordinatesFromScreenCoordinates as calcCalculateViewportCoordinatesFromScreenCoordinates, capturePortalScreenshot as calcCapturePortalScreenshot, createStaticHtml as calcCreateStaticHtmlFromBots, recordLoom, watchLoom, getLoomMetadata, loadSharedDocument, installAuxFile as calcInstallAuxFile, calculateStringListTagValue, calculateScreenCoordinatesFromPosition as calcCalculateScreenCoordinatesFromPosition, addMapLayer as calcAddMapLayer, removeMapLayer as calcRemoveMapLayer, GET_DYNAMIC_LISTENERS_SYMBOL, ADD_BOT_LISTENER_SYMBOL, REMOVE_BOT_LISTENER_SYMBOL, trackConfigBotTags as calcTrackConfigBotTags, } from '@casual-simulation/aux-common/bots';
|
|
3
3
|
import { aiChat, aiChatStream, aiListChatModels, aiGenerateSkybox, aiGenerateImage, grantRecordPermission as calcGrantRecordPermission, revokeRecordPermission as calcRevokeRecordPermission, listPermissions as calcListPermissions, grantInstAdminPermission as calcGrantInstAdminPermission, grantUserRole as calcGrantUserRole, revokeUserRole as calcRevokeUserRole, grantInstRole as calcGrantInstRole, revokeInstRole as calcRevokeInstRole, listUserStudios as calcListUserStudios, listStudioRecords as calcListStudioRecords, joinRoom as calcJoinRoom, leaveRoom as calcLeaveRoom, setRoomOptions as calcSetRoomOptions, getRoomOptions as calcGetRoomOptions, getRoomTrackOptions as calcGetRoomTrackOptions, setRoomTrackOptions as calcSetRoomTrackOptions, getRoomRemoteOptions as calcGetRoomRemoteOptions, listDataRecord, recordEvent as calcRecordEvent, getEventCount as calcGetEventCount, getFile as calcGetFile, eraseFile as calcEraseFile, getPublicRecordKey as calcGetPublicRecordKey, recordData as calcRecordData, getRecordData, eraseRecordData, recordFile as calcRecordFile, listDataRecordByMarker, aiHumeGetAccessToken, aiSloydGenerateModel, recordWebhook as calcRecordWebhook, getWebhook as calcGetWebhook, listWebhooks as calcListWebhooks, listWebhooksByMarker as calcListWebhooksByMarker, eraseWebhook as calcEraseWebhook, runWebhook as calcRunWebhook, recordNotification as calcRecordNotification, getNotification as calcGetNotification, listNotifications as calcListNotifications, listNotificationsByMarker as calcListNotificationsByMarker, eraseNotification as calcEraseNotification, subscribeToNotification as calcSubscribeToNotification, unsubscribeFromNotification as calcUnsubscribeFromNotification, sendNotification as calcSendNotification, listNotificationSubscriptions as calcListNotificationSubscriptions, listUserNotificationSubscriptions as calcListUserNotificationSubscriptions,
|
|
4
4
|
// getXpUserMeta,
|
|
5
5
|
// createXpContract,
|
|
@@ -651,6 +651,7 @@ export function createDefaultLibrary(context) {
|
|
|
651
651
|
cancelSound,
|
|
652
652
|
hasBotInMiniPortal,
|
|
653
653
|
share,
|
|
654
|
+
sendEmbedMessage,
|
|
654
655
|
closeCircleWipe,
|
|
655
656
|
openCircleWipe,
|
|
656
657
|
addDropSnap,
|
|
@@ -829,6 +830,8 @@ export function createDefaultLibrary(context) {
|
|
|
829
830
|
payout: xpPayout,
|
|
830
831
|
getAccountBalances: xpGetAccountBalances,
|
|
831
832
|
purchaseCredits: xpPurchaseCredits,
|
|
833
|
+
setRecordBudget: xpSetRecordBudget,
|
|
834
|
+
getRecordBudget: xpGetRecordBudget,
|
|
832
835
|
},
|
|
833
836
|
portal: {
|
|
834
837
|
registerPrefix,
|
|
@@ -3005,6 +3008,7 @@ export function createDefaultLibrary(context) {
|
|
|
3005
3008
|
allowCollaborationUpgrade: null,
|
|
3006
3009
|
ab1BootstrapUrl: null,
|
|
3007
3010
|
comID: null,
|
|
3011
|
+
isEmbedded: null,
|
|
3008
3012
|
};
|
|
3009
3013
|
}
|
|
3010
3014
|
/**
|
|
@@ -4748,6 +4752,33 @@ export function createDefaultLibrary(context) {
|
|
|
4748
4752
|
const event = calcShare(options, task.taskId);
|
|
4749
4753
|
return addAsyncAction(task, event);
|
|
4750
4754
|
}
|
|
4755
|
+
/**
|
|
4756
|
+
* Sends a message to the parent window that this CasualOS instance is embedded in.
|
|
4757
|
+
* Returns a Promise that resolves when the message has been sent.
|
|
4758
|
+
* Throws an error if this CasualOS instance is not embedded in an iframe.
|
|
4759
|
+
*
|
|
4760
|
+
* The message must be structure cloneable (transferrables are not supported).
|
|
4761
|
+
*
|
|
4762
|
+
* @param message the message to send to the parent window.
|
|
4763
|
+
* @param targetOrigin the origin that the parent window must have in order to receive the message. If not specified, then the message will be sent to the parent window regardless of its origin.
|
|
4764
|
+
*
|
|
4765
|
+
* @example Send a message to the parent window.
|
|
4766
|
+
* await os.sendEmbedMessage({ hello: 'world' });
|
|
4767
|
+
*
|
|
4768
|
+
* @example Send a message to the parent window with a specific target origin.
|
|
4769
|
+
* await os.sendEmbedMessage({ hello: 'world' }, 'https://example.com');
|
|
4770
|
+
*
|
|
4771
|
+
* @dochash actions/os/system
|
|
4772
|
+
* @docname os.sendEmbedMessage
|
|
4773
|
+
*/
|
|
4774
|
+
function sendEmbedMessage(message, targetOrigin) {
|
|
4775
|
+
if (!context.device?.isEmbedded) {
|
|
4776
|
+
throw new Error('os.sendEmbedMessage() can only be used when CasualOS is embedded in an iframe.');
|
|
4777
|
+
}
|
|
4778
|
+
const task = context.createTask();
|
|
4779
|
+
const event = calcSendEmbedMessage(message, targetOrigin, task.taskId);
|
|
4780
|
+
return addAsyncAction(task, event);
|
|
4781
|
+
}
|
|
4751
4782
|
/**
|
|
4752
4783
|
* Causes a circular wipe animation to close around the screen.
|
|
4753
4784
|
* This can be used to cover the grid portal while transitioning between scenes.
|
|
@@ -5443,6 +5474,78 @@ export function createDefaultLibrary(context) {
|
|
|
5443
5474
|
}, options, task.taskId);
|
|
5444
5475
|
return addAsyncAction(task, event);
|
|
5445
5476
|
}
|
|
5477
|
+
/**
|
|
5478
|
+
* Sets the budget that should be used to automatically transfer credits from a record's owner to the record's own credit account whenever the owner is granted credits from their subscription.
|
|
5479
|
+
* Setting the budget to null clears it, causing billing for the record to go to the owner's account.
|
|
5480
|
+
* Only studio admins and superUsers are authorized to set a record's budget.
|
|
5481
|
+
*
|
|
5482
|
+
* @param request The options for the request.
|
|
5483
|
+
* @returns A promise that resolves with the result of the request.
|
|
5484
|
+
*
|
|
5485
|
+
* @example Set a fixed record budget
|
|
5486
|
+
* const result = await xp.setRecordBudget({
|
|
5487
|
+
* recordName: "myRecord",
|
|
5488
|
+
* budget: {
|
|
5489
|
+
* type: "fixed",
|
|
5490
|
+
* amount: 100
|
|
5491
|
+
* }
|
|
5492
|
+
* });
|
|
5493
|
+
*
|
|
5494
|
+
* @example Set a percent record budget
|
|
5495
|
+
* const result = await xp.setRecordBudget({
|
|
5496
|
+
* recordName: "myRecord",
|
|
5497
|
+
* budget: {
|
|
5498
|
+
* type: "percent",
|
|
5499
|
+
* amount: 10
|
|
5500
|
+
* }
|
|
5501
|
+
* });
|
|
5502
|
+
*
|
|
5503
|
+
* @example Clear a record budget
|
|
5504
|
+
* const result = await xp.setRecordBudget({
|
|
5505
|
+
* recordName: "myRecord",
|
|
5506
|
+
* budget: null
|
|
5507
|
+
* });
|
|
5508
|
+
*
|
|
5509
|
+
* @dochash actions/xp
|
|
5510
|
+
* @docname xp.setRecordBudget
|
|
5511
|
+
*/
|
|
5512
|
+
function xpSetRecordBudget(request, options = {}) {
|
|
5513
|
+
const task = context.createTask();
|
|
5514
|
+
const event = recordsCallProcedure({
|
|
5515
|
+
setRecordBudget: {
|
|
5516
|
+
input: {
|
|
5517
|
+
recordName: request.recordName,
|
|
5518
|
+
budget: request.budget,
|
|
5519
|
+
},
|
|
5520
|
+
},
|
|
5521
|
+
}, options, task.taskId);
|
|
5522
|
+
return addAsyncAction(task, event);
|
|
5523
|
+
}
|
|
5524
|
+
/**
|
|
5525
|
+
* Gets the budget that has been configured for the given record.
|
|
5526
|
+
*
|
|
5527
|
+
* @param recordName The name of the record to get the budget for.
|
|
5528
|
+
* @param options The options for the request.
|
|
5529
|
+
* @returns A promise that resolves with the result of the request.
|
|
5530
|
+
*
|
|
5531
|
+
* @example Get a record's budget
|
|
5532
|
+
* const result = await xp.getRecordBudget("myRecord");
|
|
5533
|
+
* console.log(result);
|
|
5534
|
+
*
|
|
5535
|
+
* @dochash actions/xp
|
|
5536
|
+
* @docname xp.getRecordBudget
|
|
5537
|
+
*/
|
|
5538
|
+
function xpGetRecordBudget(recordName, options = {}) {
|
|
5539
|
+
const task = context.createTask();
|
|
5540
|
+
const event = recordsCallProcedure({
|
|
5541
|
+
getRecordBudget: {
|
|
5542
|
+
input: {
|
|
5543
|
+
recordName,
|
|
5544
|
+
},
|
|
5545
|
+
},
|
|
5546
|
+
}, options, task.taskId);
|
|
5547
|
+
return addAsyncAction(task, event);
|
|
5548
|
+
}
|
|
5446
5549
|
/**
|
|
5447
5550
|
* Specifies that the given prefix should be used to indicate that the tag contains script content.
|
|
5448
5551
|
* Use this function to specify custom prefixes that function similarly to `@` or `🧬`.
|