@casual-simulation/aux-common 2.0.16 → 2.0.21
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/aux-format-2/AuxStateHelpers.d.ts +11 -1
- package/aux-format-2/AuxStateHelpers.js +20 -5
- package/aux-format-2/AuxStateHelpers.js.map +1 -1
- package/aux-format-2/AuxWeaveHelpers.d.ts +0 -1
- package/aux-format-2/AuxWeaveHelpers.js +1 -15
- package/aux-format-2/AuxWeaveHelpers.js.map +1 -1
- package/aux-format-2/AuxWeaveReducer.js +6 -6
- package/aux-format-2/AuxWeaveReducer.js.map +1 -1
- package/bots/Bot.d.ts +46 -0
- package/bots/Bot.js +6 -0
- package/bots/Bot.js.map +1 -1
- package/bots/BotCalculations.d.ts +29 -1
- package/bots/BotCalculations.js +94 -14
- package/bots/BotCalculations.js.map +1 -1
- package/bots/BotEvents.d.ts +30 -1
- package/bots/BotEvents.js +8 -0
- package/bots/BotEvents.js.map +1 -1
- package/bots/test/BotCalculationContextTests.js +11 -4
- package/bots/test/BotCalculationContextTests.js.map +1 -1
- package/package.json +5 -3
- package/partitions/MemoryPartition.js +23 -6
- package/partitions/MemoryPartition.js.map +1 -1
- package/partitions/RemoteYjsPartition.js +2 -2
- package/partitions/RemoteYjsPartition.js.map +1 -1
- package/partitions/YjsPartition.js +2 -2
- package/partitions/YjsPartition.js.map +1 -1
- package/partitions/test/PartitionTests.js +93 -19
- package/partitions/test/PartitionTests.js.map +1 -1
- package/runtime/AuxGlobalContext.d.ts +2 -2
- package/runtime/AuxGlobalContext.js.map +1 -1
- package/runtime/AuxLibrary.d.ts +29 -2
- package/runtime/AuxLibrary.js +391 -17
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +243 -8
- package/runtime/AuxRuntime.d.ts +3 -0
- package/runtime/AuxRuntime.js +31 -10
- package/runtime/AuxRuntime.js.map +1 -1
- package/runtime/RuntimeBot.d.ts +6 -0
- package/runtime/RuntimeBot.js +123 -6
- package/runtime/RuntimeBot.js.map +1 -1
- package/runtime/Transpiler.js +3 -3
- package/runtime/Transpiler.js.map +1 -1
- package/runtime/Utils.d.ts +6 -0
- package/runtime/Utils.js +30 -0
- package/runtime/Utils.js.map +1 -1
- package/runtime/test/TestScriptBotFactory.js +6 -3
- package/runtime/test/TestScriptBotFactory.js.map +1 -1
- package/test/YjsTestHelpers.js.map +1 -1
- package/yjs/YjsHelpers.d.ts +1 -1
|
@@ -965,6 +965,31 @@ declare interface WebhookOptions {
|
|
|
965
965
|
* The shout that should be made when the request finishes.
|
|
966
966
|
*/
|
|
967
967
|
responseShout?: string;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* The number of retries that should be attempted for the webhook if it fails.
|
|
971
|
+
* Defaults to 0.
|
|
972
|
+
*/
|
|
973
|
+
retryCount?: number;
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* The HTTP response status codes that should allow the web request to be retried.
|
|
977
|
+
* Defaults to:
|
|
978
|
+
* - 408 - Request Timeout
|
|
979
|
+
* - 429 - Too Many Requests
|
|
980
|
+
* - 500 - Internal Server Error
|
|
981
|
+
* - 502 - Bad Gateway
|
|
982
|
+
* - 503 - Service Unavailable
|
|
983
|
+
* - 504 - Gateway Timeout
|
|
984
|
+
* - 0 - Network Failure / CORS
|
|
985
|
+
*/
|
|
986
|
+
retryStatusCodes?: number[];
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* The number of miliseconds to wait between retry requests.
|
|
990
|
+
* Defaults to 3000ms (3 seconds).
|
|
991
|
+
*/
|
|
992
|
+
retryAfterMs?: number;
|
|
968
993
|
}
|
|
969
994
|
|
|
970
995
|
/**
|
|
@@ -2303,6 +2328,26 @@ export interface DeletableRecord {
|
|
|
2303
2328
|
address: string;
|
|
2304
2329
|
};
|
|
2305
2330
|
|
|
2331
|
+
/**
|
|
2332
|
+
* Defines an interface that represents options for converting a geolocation to a what3words address.
|
|
2333
|
+
*/
|
|
2334
|
+
export interface ConvertGeolocationToWhat3WordsOptions {
|
|
2335
|
+
/**
|
|
2336
|
+
* The latitude to convert.
|
|
2337
|
+
*/
|
|
2338
|
+
latitude: number;
|
|
2339
|
+
|
|
2340
|
+
/**
|
|
2341
|
+
* The longitude to convert.
|
|
2342
|
+
*/
|
|
2343
|
+
longitude: number;
|
|
2344
|
+
|
|
2345
|
+
/**
|
|
2346
|
+
* The identifier of the language that should be used for the resulting what3words address.
|
|
2347
|
+
*/
|
|
2348
|
+
language?: string;
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2306
2351
|
/**
|
|
2307
2352
|
* Defines an interface for options that show a payment box.
|
|
2308
2353
|
*/
|
|
@@ -2432,6 +2477,32 @@ declare interface BotTags {
|
|
|
2432
2477
|
[key: string]: any;
|
|
2433
2478
|
}
|
|
2434
2479
|
|
|
2480
|
+
/**
|
|
2481
|
+
* Defines an interface that represents a bot link that was parsed from a tag.
|
|
2482
|
+
*/
|
|
2483
|
+
declare interface ParsedBotLink {
|
|
2484
|
+
/**
|
|
2485
|
+
* The tag that the link was parsed from.
|
|
2486
|
+
*/
|
|
2487
|
+
tag: string;
|
|
2488
|
+
|
|
2489
|
+
/**
|
|
2490
|
+
* The bot IDs that the link references.
|
|
2491
|
+
*/
|
|
2492
|
+
botIDs: string[];
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
declare interface BotVars {
|
|
2496
|
+
[variable: string]: any;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
/**
|
|
2500
|
+
* Defines an interface that represents the bot links a bot can have.
|
|
2501
|
+
*/
|
|
2502
|
+
declare interface BotLinks {
|
|
2503
|
+
[tag: string]: Bot | Bot[];
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2435
2506
|
/**
|
|
2436
2507
|
* Defines the basic structure of a bot.
|
|
2437
2508
|
*/
|
|
@@ -2441,6 +2512,11 @@ export interface Bot {
|
|
|
2441
2512
|
*/
|
|
2442
2513
|
id: string;
|
|
2443
2514
|
|
|
2515
|
+
/**
|
|
2516
|
+
* The link to this bot.
|
|
2517
|
+
*/
|
|
2518
|
+
link: string;
|
|
2519
|
+
|
|
2444
2520
|
/**
|
|
2445
2521
|
* The space the bot lives in.
|
|
2446
2522
|
*/
|
|
@@ -2456,6 +2532,16 @@ export interface Bot {
|
|
|
2456
2532
|
*/
|
|
2457
2533
|
masks: BotTags;
|
|
2458
2534
|
|
|
2535
|
+
/**
|
|
2536
|
+
* The links that this bot has to other bots.
|
|
2537
|
+
*/
|
|
2538
|
+
links: BotLinks;
|
|
2539
|
+
|
|
2540
|
+
/**
|
|
2541
|
+
* THe variables that are stored in this bot.
|
|
2542
|
+
*/
|
|
2543
|
+
vars: BotVars;
|
|
2544
|
+
|
|
2459
2545
|
/**
|
|
2460
2546
|
* The raw tag values that the bot contains.
|
|
2461
2547
|
* If you want to access the script code for a formula, use this.
|
|
@@ -2575,6 +2661,11 @@ declare interface BotsState {
|
|
|
2575
2661
|
[id: string]: Bot;
|
|
2576
2662
|
}
|
|
2577
2663
|
|
|
2664
|
+
declare type PartialBot = Partial<Bot>;
|
|
2665
|
+
|
|
2666
|
+
declare interface PartialBotsState {
|
|
2667
|
+
[id: string]: PartialBot;
|
|
2668
|
+
}
|
|
2578
2669
|
|
|
2579
2670
|
/**
|
|
2580
2671
|
* The possible bot spaces.
|
|
@@ -2934,6 +3025,34 @@ declare global {
|
|
|
2934
3025
|
*/
|
|
2935
3026
|
function getJSON(data: any): string;
|
|
2936
3027
|
|
|
3028
|
+
/**
|
|
3029
|
+
* Gets nicely formatted JSON for the given data.
|
|
3030
|
+
* @param data The data.
|
|
3031
|
+
*/
|
|
3032
|
+
function getFormattedJSON(data: any): string;
|
|
3033
|
+
|
|
3034
|
+
/**
|
|
3035
|
+
* Makes a snapshot of the given bot(s).
|
|
3036
|
+
* Snapshots are like mods except they contain multiple bots and include the ID, space, tags, and tag masks of the bots.
|
|
3037
|
+
* @param bots The bots to make a snapshot of.
|
|
3038
|
+
*/
|
|
3039
|
+
function getSnapshot(bots: Bot | Bot[]): BotsState;
|
|
3040
|
+
|
|
3041
|
+
/**
|
|
3042
|
+
* Calculates the difference between the two given snapshots.
|
|
3043
|
+
* @param first The first snapshot.
|
|
3044
|
+
* @param second The second snapshot.
|
|
3045
|
+
*/
|
|
3046
|
+
function diffSnapshots(first: BotsState, second: BotsState): PartialBotsState;
|
|
3047
|
+
|
|
3048
|
+
/**
|
|
3049
|
+
* Applies the given delta to the given snapshot and returns the result.
|
|
3050
|
+
* This is essentially the opposite of diffSnapshots().
|
|
3051
|
+
* @param snapshot The snapshot that the diff should be applied to.
|
|
3052
|
+
* @param diff The delta that should be applied to the snapshot.
|
|
3053
|
+
*/
|
|
3054
|
+
function applyDiffToSnapshot(snapshot: BotsState, diff: PartialBotsState): BotsState;
|
|
3055
|
+
|
|
2937
3056
|
/**
|
|
2938
3057
|
* Shouts the given events in order until a bot returns a result.
|
|
2939
3058
|
* Returns the result that was produced or undefined if no result was produced.
|
|
@@ -2942,6 +3061,26 @@ declare global {
|
|
|
2942
3061
|
*/
|
|
2943
3062
|
function priorityShout(eventNames: string[], arg?: any): any;
|
|
2944
3063
|
|
|
3064
|
+
/**
|
|
3065
|
+
* Creates a tag value that can be used to link to the given bots.
|
|
3066
|
+
* @param bots The bots that the link should point to.
|
|
3067
|
+
*/
|
|
3068
|
+
function createBotLink(...bots: (Bot | string | (Bot | string)[])[]): string;
|
|
3069
|
+
|
|
3070
|
+
/**
|
|
3071
|
+
* Gets the list of bot links that are stored in this bot's tags.
|
|
3072
|
+
* @param bot The bot to get the links for.
|
|
3073
|
+
*/
|
|
3074
|
+
function getBotLinks(bot: Bot): ParsedBotLink[];
|
|
3075
|
+
|
|
3076
|
+
/**
|
|
3077
|
+
* Updates all the links in the given bot using the given ID map.
|
|
3078
|
+
* Useful if you know that the links in the given bot are outdated and you know which IDs map to the new IDs.
|
|
3079
|
+
* @param bot The bot to update.
|
|
3080
|
+
* @param idMap The map of old IDs to new IDs that should be used.
|
|
3081
|
+
*/
|
|
3082
|
+
function updateBotLinks(bot: Bot, idMap: Map<string, string | Bot> | { [id: string]: string | Bot }): void;
|
|
3083
|
+
|
|
2945
3084
|
/**
|
|
2946
3085
|
* Asks every bot in the inst to run the given action.
|
|
2947
3086
|
* In effect, this is like shouting to a bunch of people in a room.
|
|
@@ -2962,7 +3101,39 @@ declare global {
|
|
|
2962
3101
|
* // Tell every bot say "Hi" to you.
|
|
2963
3102
|
* shout("sayHi()", "My Name");
|
|
2964
3103
|
*/
|
|
2965
|
-
|
|
3104
|
+
const shout: {
|
|
3105
|
+
/**
|
|
3106
|
+
* Asks every bot in the inst to run the given action.
|
|
3107
|
+
* In effect, this is like shouting to a bunch of people in a room.
|
|
3108
|
+
*
|
|
3109
|
+
* @param name The event name.
|
|
3110
|
+
* @param arg The optional argument to include in the shout.
|
|
3111
|
+
* @returns Returns a list which contains the values returned from each script that was run for the shout.
|
|
3112
|
+
*
|
|
3113
|
+
* @example
|
|
3114
|
+
* // Tell every bot to reset themselves.
|
|
3115
|
+
* shout("reset()");
|
|
3116
|
+
*
|
|
3117
|
+
* @example
|
|
3118
|
+
* // Ask every bot for its name.
|
|
3119
|
+
* const names = shout("getName()");
|
|
3120
|
+
*
|
|
3121
|
+
* @example
|
|
3122
|
+
* // Tell every bot say "Hi" to you.
|
|
3123
|
+
* shout("sayHi()", "My Name");
|
|
3124
|
+
*/
|
|
3125
|
+
(name: string, arg?: any): any[],
|
|
3126
|
+
[name: string]: {
|
|
3127
|
+
/**
|
|
3128
|
+
* Asks every bot in the inst to run the given action.
|
|
3129
|
+
* In effect, this is like shouting to a bunch of people in a room.
|
|
3130
|
+
*
|
|
3131
|
+
* @param arg The optional argument to include in the shout.
|
|
3132
|
+
* @returns Returns a list which contains the values returned from each script that was run for the shout.
|
|
3133
|
+
*/
|
|
3134
|
+
(arg?: any): any[]
|
|
3135
|
+
}
|
|
3136
|
+
};
|
|
2966
3137
|
|
|
2967
3138
|
/**
|
|
2968
3139
|
* Asks the given bots to run the given action.
|
|
@@ -3658,14 +3829,62 @@ interface Debugger {
|
|
|
3658
3829
|
* @param data The data.
|
|
3659
3830
|
*/
|
|
3660
3831
|
getJSON(data: any): string;
|
|
3661
|
-
|
|
3832
|
+
|
|
3833
|
+
/**
|
|
3834
|
+
* Gets nicely formatted JSON for the given data.
|
|
3835
|
+
* @param data The data.
|
|
3836
|
+
*/
|
|
3837
|
+
getFormattedJSON(data: any): string;
|
|
3838
|
+
|
|
3839
|
+
/**
|
|
3840
|
+
* Makes a snapshot of the given bot(s).
|
|
3841
|
+
* Snapshots are like mods except they contain multiple bots and include the ID, space, tags, and tag masks of the bots.
|
|
3842
|
+
* @param bots The bots to make a snapshot of.
|
|
3843
|
+
*/
|
|
3844
|
+
getSnapshot(bots: Bot | Bot[]): BotsState;
|
|
3845
|
+
|
|
3846
|
+
/**
|
|
3847
|
+
* Calculates the difference between the two given snapshots.
|
|
3848
|
+
* @param first The first snapshot.
|
|
3849
|
+
* @param second The second snapshot.
|
|
3850
|
+
*/
|
|
3851
|
+
diffSnapshots(first: BotsState, second: BotsState): PartialBotsState;
|
|
3852
|
+
|
|
3853
|
+
/**
|
|
3854
|
+
* Applies the given delta to the given snapshot and returns the result.
|
|
3855
|
+
* This is essentially the opposite of diffSnapshots().
|
|
3856
|
+
* @param snapshot The snapshot that the diff should be applied to.
|
|
3857
|
+
* @param diff The delta that should be applied to the snapshot.
|
|
3858
|
+
*/
|
|
3859
|
+
applyDiffToSnapshot(snapshot: BotsState, diff: PartialBotsState): BotsState;
|
|
3860
|
+
|
|
3861
|
+
/**
|
|
3862
|
+
* Creates a tag value that can be used to link to the given bots.
|
|
3863
|
+
* @param bots The bots that the link should point to.
|
|
3864
|
+
*/
|
|
3865
|
+
createBotLink(...bots: (Bot | string | (Bot | string)[])[]): string;
|
|
3866
|
+
|
|
3867
|
+
/**
|
|
3868
|
+
* Gets the list of bot links that are stored in this bot's tags.
|
|
3869
|
+
* @param bot The bot to get the links for.
|
|
3870
|
+
*/
|
|
3871
|
+
getBotLinks(bot: Bot): ParsedBotLink[];
|
|
3872
|
+
|
|
3873
|
+
/**
|
|
3874
|
+
* Updates all the links in the given bot using the given ID map.
|
|
3875
|
+
* Useful if you know that the links in the given bot are outdated and you know which IDs map to the new IDs.
|
|
3876
|
+
* @param bot The bot to update.
|
|
3877
|
+
* @param idMap The map of old IDs to new IDs that should be used.
|
|
3878
|
+
*/
|
|
3879
|
+
updateBotLinks(bot: Bot, idMap: Map<string, string | Bot> | { [id: string]: string | Bot }): void
|
|
3880
|
+
|
|
3662
3881
|
/**
|
|
3663
3882
|
* Shouts the given events in order until a bot returns a result.
|
|
3664
3883
|
* Returns the result that was produced or undefined if no result was produced.
|
|
3665
3884
|
* @param eventNames The names of the events to shout.
|
|
3666
3885
|
* @param arg The argument to shout.
|
|
3667
3886
|
*/
|
|
3668
|
-
|
|
3887
|
+
priorityShout(eventNames: string[], arg?: any): any;
|
|
3669
3888
|
|
|
3670
3889
|
/**
|
|
3671
3890
|
* Asks every bot in the inst to run the given action.
|
|
@@ -4933,11 +5152,17 @@ interface Os {
|
|
|
4933
5152
|
*/
|
|
4934
5153
|
getRecords: MaskFunc<(...filters: RecordFilters[]) => Promise<GetRecordsResult>>;
|
|
4935
5154
|
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
5155
|
+
/**
|
|
5156
|
+
* Requests that the given record be destroyed.
|
|
5157
|
+
* @param record The record that should be deleted.
|
|
5158
|
+
*/
|
|
5159
|
+
destroyRecord: MaskFunc<(record: DeletableRecord) => Promise<void>>;
|
|
5160
|
+
|
|
5161
|
+
/**
|
|
5162
|
+
* Converts the given geolocation to a what3words (https://what3words.com/) address.
|
|
5163
|
+
* @param location The latitude and longitude that should be converted to a 3 word address.
|
|
5164
|
+
*/
|
|
5165
|
+
convertGeolocationToWhat3Words(location: ConvertGeolocationToWhat3WordsOptions): Promise<string>;
|
|
4941
5166
|
|
|
4942
5167
|
/**
|
|
4943
5168
|
* Specifies that the given prefix should be interpreted as code.
|
|
@@ -4987,6 +5212,16 @@ interface Os {
|
|
|
4987
5212
|
* @param options The options that should be used for the debugger.
|
|
4988
5213
|
*/
|
|
4989
5214
|
createDebugger(options?: DebuggerOptions): Debugger;
|
|
5215
|
+
|
|
5216
|
+
/**
|
|
5217
|
+
* Gets the debugger that this script is currently running in.
|
|
5218
|
+
*/
|
|
5219
|
+
getExecutingDebugger(): Debugger;
|
|
5220
|
+
|
|
5221
|
+
/**
|
|
5222
|
+
* The global variables that are stored in the OS.
|
|
5223
|
+
*/
|
|
5224
|
+
vars: typeof globalThis;
|
|
4990
5225
|
}
|
|
4991
5226
|
|
|
4992
5227
|
interface Server {
|
package/runtime/AuxRuntime.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare class AuxRuntime implements RuntimeBotInterface, RuntimeBotFactor
|
|
|
57
57
|
*/
|
|
58
58
|
private _autoBatch;
|
|
59
59
|
private _forceSyncScripts;
|
|
60
|
+
private _currentDebugger;
|
|
60
61
|
private _libraryFactory;
|
|
61
62
|
get forceSignedScripts(): boolean;
|
|
62
63
|
get context(): AuxGlobalContext;
|
|
@@ -94,6 +95,7 @@ export declare class AuxRuntime implements RuntimeBotInterface, RuntimeBotFactor
|
|
|
94
95
|
* @param actions The actions to process.
|
|
95
96
|
*/
|
|
96
97
|
process(actions: BotAction[]): void;
|
|
98
|
+
private _getExecutingDebugger;
|
|
97
99
|
private _createDebugger;
|
|
98
100
|
private _processCore;
|
|
99
101
|
private _processAction;
|
|
@@ -153,6 +155,7 @@ export declare class AuxRuntime implements RuntimeBotInterface, RuntimeBotFactor
|
|
|
153
155
|
updateTagMask(bot: CompiledBot, tag: string, spaces: string[], value: any): RealtimeEditMode;
|
|
154
156
|
getTagMask(bot: CompiledBot, tag: string): RealtimeEditMode;
|
|
155
157
|
getListener(bot: CompiledBot, tag: string): CompiledBotListener;
|
|
158
|
+
getTagLink(bot: CompiledBot, tag: string): RuntimeBot | RuntimeBot[];
|
|
156
159
|
getSignature(bot: CompiledBot, signature: string): string;
|
|
157
160
|
private _compileTagOrMask;
|
|
158
161
|
private _compileTag;
|
package/runtime/AuxRuntime.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 3. Channel - These are manager objects which handle the persistence and runtime aspects of an AUX.
|
|
6
6
|
// 4. Partitions - These are services which manage the persistence and realtime sync of the AUX data model.
|
|
7
7
|
// 5. Runtimes - These are services which manage script execution and formula precalculation.
|
|
8
|
-
import { hasValue, tagsOnBot, isFormula, isScript, isNumber, BOT_SPACE_TAG, botUpdated, isBot, ORIGINAL_OBJECT, DEFAULT_ENERGY, getBotSpace, ON_ACTION_ACTION_NAME, breakIntoIndividualEvents, ON_BOT_ADDED_ACTION_NAME, ON_ANY_BOTS_ADDED_ACTION_NAME, ON_ANY_BOTS_REMOVED_ACTION_NAME, ON_BOT_CHANGED_ACTION_NAME, ON_ANY_BOTS_CHANGED_ACTION_NAME, updatedBot, TAG_MASK_SPACE_PRIORITIES, CLEAR_CHANGES_SYMBOL, DNA_TAG_PREFIX, isRuntimeBot, createBot, ON_ERROR, action, isBotInDimension, asyncResult, registerBuiltinPortal, defineGlobalBot, } from '../bots';
|
|
8
|
+
import { hasValue, tagsOnBot, isFormula, isScript, isNumber, BOT_SPACE_TAG, botUpdated, isBot, ORIGINAL_OBJECT, DEFAULT_ENERGY, getBotSpace, ON_ACTION_ACTION_NAME, breakIntoIndividualEvents, ON_BOT_ADDED_ACTION_NAME, ON_ANY_BOTS_ADDED_ACTION_NAME, ON_ANY_BOTS_REMOVED_ACTION_NAME, ON_BOT_CHANGED_ACTION_NAME, ON_ANY_BOTS_CHANGED_ACTION_NAME, updatedBot, TAG_MASK_SPACE_PRIORITIES, CLEAR_CHANGES_SYMBOL, DNA_TAG_PREFIX, isRuntimeBot, createBot, ON_ERROR, action, isBotInDimension, asyncResult, registerBuiltinPortal, defineGlobalBot, isBotLink, parseBotLink, } from '../bots';
|
|
9
9
|
import { Subject, Subscription } from 'rxjs';
|
|
10
10
|
import { AuxCompiler } from './AuxCompiler';
|
|
11
11
|
import { addToContext, MemoryGlobalContext, removeFromContext, isInContext, } from './AuxGlobalContext';
|
|
@@ -16,7 +16,7 @@ import { convertToCopiableValue, DeepObjectError, formatAuthToken, } from './Uti
|
|
|
16
16
|
import { DefaultRealtimeEditModeProvider, } from './AuxRealtimeEditModeProvider';
|
|
17
17
|
import { sortBy, forOwn, merge, union } from 'lodash';
|
|
18
18
|
import { tagValueHash } from '../aux-format-2/AuxOpTypes';
|
|
19
|
-
import {
|
|
19
|
+
import { applyTagEdit, isTagEdit, mergeVersions } from '../aux-format-2';
|
|
20
20
|
import { replaceMacros } from './Transpiler';
|
|
21
21
|
/**
|
|
22
22
|
* Defines an class that is able to manage the runtime state of an AUX.
|
|
@@ -65,6 +65,7 @@ export class AuxRuntime {
|
|
|
65
65
|
*/
|
|
66
66
|
this._autoBatch = true;
|
|
67
67
|
this._forceSyncScripts = false;
|
|
68
|
+
this._currentDebugger = null;
|
|
68
69
|
this._libraryFactory = libraryFactory;
|
|
69
70
|
this._globalContext = new MemoryGlobalContext(version, device, this, this);
|
|
70
71
|
this._forceSyncScripts = forceSyncScripts;
|
|
@@ -73,6 +74,7 @@ export class AuxRuntime {
|
|
|
73
74
|
api: {
|
|
74
75
|
os: {
|
|
75
76
|
createDebugger: this._createDebugger.bind(this),
|
|
77
|
+
getExecutingDebugger: this._getExecutingDebugger.bind(this),
|
|
76
78
|
},
|
|
77
79
|
},
|
|
78
80
|
});
|
|
@@ -196,6 +198,9 @@ export class AuxRuntime {
|
|
|
196
198
|
this._processCore(actions);
|
|
197
199
|
this._processBatch();
|
|
198
200
|
}
|
|
201
|
+
_getExecutingDebugger() {
|
|
202
|
+
return this._currentDebugger;
|
|
203
|
+
}
|
|
199
204
|
_createDebugger(options) {
|
|
200
205
|
const runtime = new AuxRuntime(this._globalContext.version, this._globalContext.device, this._libraryFactory, this._editModeProvider, this._forceSignedScripts, this._exemptSpaces, !(options === null || options === void 0 ? void 0 : options.allowAsynchronousScripts));
|
|
201
206
|
runtime._autoBatch = false;
|
|
@@ -237,7 +242,7 @@ export class AuxRuntime {
|
|
|
237
242
|
runtime.context.createBot(createBot(configBotId, configBotTags, 'tempLocal'));
|
|
238
243
|
runtime.process(this._builtinPortalBots.map((b) => registerBuiltinPortal(b)));
|
|
239
244
|
runtime.userId = configBotId;
|
|
240
|
-
|
|
245
|
+
const debug = Object.assign(Object.assign({}, runtime._library.api), { getAllActions, getCommonActions: () => {
|
|
241
246
|
return getAllActions().filter(isCommonAction);
|
|
242
247
|
}, getBotActions: () => {
|
|
243
248
|
return getAllActions().filter((a) => !isCommonAction(a));
|
|
@@ -246,6 +251,8 @@ export class AuxRuntime {
|
|
|
246
251
|
allErrors.push(...errors);
|
|
247
252
|
return allErrors;
|
|
248
253
|
}, create });
|
|
254
|
+
runtime._currentDebugger = debug;
|
|
255
|
+
return debug;
|
|
249
256
|
}
|
|
250
257
|
_processCore(actions) {
|
|
251
258
|
for (let action of actions) {
|
|
@@ -581,9 +588,11 @@ export class AuxRuntime {
|
|
|
581
588
|
}
|
|
582
589
|
if (!hasChange && removedBots && removedBots.length > 0) {
|
|
583
590
|
for (let bot of removedBots) {
|
|
584
|
-
if (
|
|
585
|
-
|
|
586
|
-
|
|
591
|
+
if (bot) {
|
|
592
|
+
if (isBotInDimension(null, bot, dimension)) {
|
|
593
|
+
hasChange = true;
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
587
596
|
}
|
|
588
597
|
}
|
|
589
598
|
}
|
|
@@ -710,7 +719,7 @@ export class AuxRuntime {
|
|
|
710
719
|
const tagValue = u.tags[tag];
|
|
711
720
|
if (hasValue(tagValue) || tagValue === null) {
|
|
712
721
|
if (isTagEdit(tagValue)) {
|
|
713
|
-
compiled.tags[tag] =
|
|
722
|
+
compiled.tags[tag] = applyTagEdit(compiled.tags[tag], tagValue);
|
|
714
723
|
}
|
|
715
724
|
else {
|
|
716
725
|
compiled.tags[tag] = tagValue;
|
|
@@ -742,7 +751,7 @@ export class AuxRuntime {
|
|
|
742
751
|
delete compiled.masks[space][tag];
|
|
743
752
|
}
|
|
744
753
|
else if (isTagEdit(tagValue)) {
|
|
745
|
-
compiled.masks[space][tag] =
|
|
754
|
+
compiled.masks[space][tag] = applyTagEdit(compiled.masks[space][tag], tagValue);
|
|
746
755
|
}
|
|
747
756
|
else {
|
|
748
757
|
compiled.masks[space][tag] = tagValue;
|
|
@@ -1078,6 +1087,18 @@ export class AuxRuntime {
|
|
|
1078
1087
|
this.getValue(bot, tag);
|
|
1079
1088
|
return bot.listeners[tag] || null;
|
|
1080
1089
|
}
|
|
1090
|
+
getTagLink(bot, tag) {
|
|
1091
|
+
const tagValue = bot.values[tag];
|
|
1092
|
+
if (isBotLink(tagValue)) {
|
|
1093
|
+
const links = parseBotLink(tagValue);
|
|
1094
|
+
const bots = links.map((link) => this.context.state[link] || null);
|
|
1095
|
+
if (bots.length === 1) {
|
|
1096
|
+
return bots[0];
|
|
1097
|
+
}
|
|
1098
|
+
return bots;
|
|
1099
|
+
}
|
|
1100
|
+
return undefined;
|
|
1101
|
+
}
|
|
1081
1102
|
getSignature(bot, signature) {
|
|
1082
1103
|
return !!bot.signatures ? bot.signatures[signature] : undefined;
|
|
1083
1104
|
}
|
|
@@ -1130,7 +1151,7 @@ export class AuxRuntime {
|
|
|
1130
1151
|
}
|
|
1131
1152
|
}
|
|
1132
1153
|
if (isTagEdit(tagValue)) {
|
|
1133
|
-
tagValue = bot.tags[tag] =
|
|
1154
|
+
tagValue = bot.tags[tag] = applyTagEdit(bot.tags[tag], tagValue);
|
|
1134
1155
|
}
|
|
1135
1156
|
else {
|
|
1136
1157
|
if (hasValue(tagValue)) {
|
|
@@ -1233,7 +1254,7 @@ export class AuxRuntime {
|
|
|
1233
1254
|
throw data;
|
|
1234
1255
|
},
|
|
1235
1256
|
constants: Object.assign(Object.assign({}, this._library.api), { tagName: tag, globalThis: this._globalObject }),
|
|
1236
|
-
variables: Object.assign(Object.assign({}, this._library.tagSpecificApi), { this: (ctx) => (ctx.bot ? ctx.bot.script : null), thisBot: (ctx) => (ctx.bot ? ctx.bot.script : null), bot: (ctx) => (ctx.bot ? ctx.bot.script : null), tags: (ctx) => (ctx.bot ? ctx.bot.script.tags : null), raw: (ctx) => (ctx.bot ? ctx.bot.script.raw : null), masks: (ctx) => (ctx.bot ? ctx.bot.script.masks : null), creatorBot: (ctx) => ctx.creator, configBot: () => this.context.playerBot }),
|
|
1257
|
+
variables: Object.assign(Object.assign({}, this._library.tagSpecificApi), { this: (ctx) => (ctx.bot ? ctx.bot.script : null), thisBot: (ctx) => (ctx.bot ? ctx.bot.script : null), bot: (ctx) => (ctx.bot ? ctx.bot.script : null), tags: (ctx) => (ctx.bot ? ctx.bot.script.tags : null), raw: (ctx) => (ctx.bot ? ctx.bot.script.raw : null), masks: (ctx) => (ctx.bot ? ctx.bot.script.masks : null), creatorBot: (ctx) => ctx.creator, configBot: () => this.context.playerBot, links: (ctx) => (ctx.bot ? ctx.bot.script.links : null) }),
|
|
1237
1258
|
arguments: [['that', 'data']],
|
|
1238
1259
|
});
|
|
1239
1260
|
if (hasValue(bot)) {
|