@casual-simulation/aux-common 2.0.14 → 2.0.19-alpha.1523438944
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 +78 -0
- package/bots/Bot.js +75 -2
- package/bots/Bot.js.map +1 -1
- package/bots/BotCalculations.d.ts +45 -1
- package/bots/BotCalculations.js +126 -22
- package/bots/BotCalculations.js.map +1 -1
- package/bots/BotEvents.d.ts +1 -65
- package/bots/BotEvents.js +0 -30
- 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 +4 -2
- 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 +23 -5
- package/runtime/AuxLibrary.js +370 -45
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +165 -69
- package/runtime/AuxRuntime.d.ts +3 -0
- package/runtime/AuxRuntime.js +32 -14
- package/runtime/AuxRuntime.js.map +1 -1
- package/runtime/RuntimeBot.d.ts +6 -0
- package/runtime/RuntimeBot.js +107 -5
- 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
|
@@ -251,7 +251,6 @@ declare type AsyncActions =
|
|
|
251
251
|
| BufferSoundAction
|
|
252
252
|
| PlaySoundAction
|
|
253
253
|
| CancelSoundAction
|
|
254
|
-
| OpenCustomPortalAction
|
|
255
254
|
| RegisterPrefixAction
|
|
256
255
|
| FocusOnBotAction
|
|
257
256
|
| FocusOnPositionAction
|
|
@@ -966,6 +965,31 @@ declare interface WebhookOptions {
|
|
|
966
965
|
* The shout that should be made when the request finishes.
|
|
967
966
|
*/
|
|
968
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;
|
|
969
993
|
}
|
|
970
994
|
|
|
971
995
|
/**
|
|
@@ -1911,47 +1935,6 @@ declare type SnapTarget = 'ground' | 'grid' | 'face' | 'bots' | SnapPoint | Snap
|
|
|
1911
1935
|
type: 'enable_custom_dragging';
|
|
1912
1936
|
}
|
|
1913
1937
|
|
|
1914
|
-
/**
|
|
1915
|
-
* The possible options for a custom portal.
|
|
1916
|
-
*/
|
|
1917
|
-
declare interface OpenCustomPortalOptions {
|
|
1918
|
-
/**
|
|
1919
|
-
* The mode that the portal should be opened in.
|
|
1920
|
-
* "Tag" indicates that the portal should watch the given tag and automatically produce bundles for the portal.
|
|
1921
|
-
* "source" indicates that the portal should load the given source directly.
|
|
1922
|
-
*
|
|
1923
|
-
* Defaults to "tag".
|
|
1924
|
-
*/
|
|
1925
|
-
mode?: 'tag' | 'source';
|
|
1926
|
-
|
|
1927
|
-
/**
|
|
1928
|
-
* The CSS styles that should be used for the portal.
|
|
1929
|
-
*/
|
|
1930
|
-
style?: any;
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
|
-
/**
|
|
1934
|
-
* Defines an event that creates a custom portal using the given source code.
|
|
1935
|
-
*/
|
|
1936
|
-
declare interface OpenCustomPortalAction extends AsyncAction {
|
|
1937
|
-
type: 'open_custom_portal';
|
|
1938
|
-
/**
|
|
1939
|
-
* The ID of the portal.
|
|
1940
|
-
*/
|
|
1941
|
-
portalId: string;
|
|
1942
|
-
|
|
1943
|
-
/**
|
|
1944
|
-
* The tag that the portal should use.
|
|
1945
|
-
*/
|
|
1946
|
-
tag: string;
|
|
1947
|
-
|
|
1948
|
-
/**
|
|
1949
|
-
* The options for the portal.
|
|
1950
|
-
*/
|
|
1951
|
-
options: OpenCustomPortalOptions;
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
1938
|
/**
|
|
1956
1939
|
* The list of types of output that custom portals support.
|
|
1957
1940
|
*/
|
|
@@ -1964,8 +1947,6 @@ declare type SnapTarget = 'ground' | 'grid' | 'face' | 'bots' | SnapPoint | Snap
|
|
|
1964
1947
|
|
|
1965
1948
|
/**
|
|
1966
1949
|
* Defines an event that registers a custom portal.
|
|
1967
|
-
* This functions similarly to OpenCustomPortalAction except that it is more
|
|
1968
|
-
* tightly integrated into CasualOS.
|
|
1969
1950
|
*/
|
|
1970
1951
|
export interface RegisterCustomAppAction extends AsyncAction {
|
|
1971
1952
|
type: 'register_custom_app';
|
|
@@ -2476,6 +2457,28 @@ declare interface BotTags {
|
|
|
2476
2457
|
[key: string]: any;
|
|
2477
2458
|
}
|
|
2478
2459
|
|
|
2460
|
+
/**
|
|
2461
|
+
* Defines an interface that represents a bot link that was parsed from a tag.
|
|
2462
|
+
*/
|
|
2463
|
+
declare interface ParsedBotLink {
|
|
2464
|
+
/**
|
|
2465
|
+
* The tag that the link was parsed from.
|
|
2466
|
+
*/
|
|
2467
|
+
tag: string;
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* The bot IDs that the link references.
|
|
2471
|
+
*/
|
|
2472
|
+
botIDs: string[];
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
/**
|
|
2476
|
+
* Defines an interface that represents the bot links a bot can have.
|
|
2477
|
+
*/
|
|
2478
|
+
declare interface BotLinks {
|
|
2479
|
+
[tag: string]: Bot | Bot[];
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2479
2482
|
/**
|
|
2480
2483
|
* Defines the basic structure of a bot.
|
|
2481
2484
|
*/
|
|
@@ -2485,6 +2488,11 @@ export interface Bot {
|
|
|
2485
2488
|
*/
|
|
2486
2489
|
id: string;
|
|
2487
2490
|
|
|
2491
|
+
/**
|
|
2492
|
+
* The link to this bot.
|
|
2493
|
+
*/
|
|
2494
|
+
link: string;
|
|
2495
|
+
|
|
2488
2496
|
/**
|
|
2489
2497
|
* The space the bot lives in.
|
|
2490
2498
|
*/
|
|
@@ -2500,6 +2508,11 @@ export interface Bot {
|
|
|
2500
2508
|
*/
|
|
2501
2509
|
masks: BotTags;
|
|
2502
2510
|
|
|
2511
|
+
/**
|
|
2512
|
+
* The links that this bot has to other bots.
|
|
2513
|
+
*/
|
|
2514
|
+
links: BotLinks;
|
|
2515
|
+
|
|
2503
2516
|
/**
|
|
2504
2517
|
* The raw tag values that the bot contains.
|
|
2505
2518
|
* If you want to access the script code for a formula, use this.
|
|
@@ -2619,6 +2632,11 @@ declare interface BotsState {
|
|
|
2619
2632
|
[id: string]: Bot;
|
|
2620
2633
|
}
|
|
2621
2634
|
|
|
2635
|
+
declare type PartialBot = Partial<Bot>;
|
|
2636
|
+
|
|
2637
|
+
declare interface PartialBotsState {
|
|
2638
|
+
[id: string]: PartialBot;
|
|
2639
|
+
}
|
|
2622
2640
|
|
|
2623
2641
|
/**
|
|
2624
2642
|
* The possible bot spaces.
|
|
@@ -2978,6 +2996,34 @@ declare global {
|
|
|
2978
2996
|
*/
|
|
2979
2997
|
function getJSON(data: any): string;
|
|
2980
2998
|
|
|
2999
|
+
/**
|
|
3000
|
+
* Gets nicely formatted JSON for the given data.
|
|
3001
|
+
* @param data The data.
|
|
3002
|
+
*/
|
|
3003
|
+
function getFormattedJSON(data: any): string;
|
|
3004
|
+
|
|
3005
|
+
/**
|
|
3006
|
+
* Makes a snapshot of the given bot(s).
|
|
3007
|
+
* Snapshots are like mods except they contain multiple bots and include the ID, space, tags, and tag masks of the bots.
|
|
3008
|
+
* @param bots The bots to make a snapshot of.
|
|
3009
|
+
*/
|
|
3010
|
+
function getSnapshot(bots: Bot | Bot[]): BotsState;
|
|
3011
|
+
|
|
3012
|
+
/**
|
|
3013
|
+
* Calculates the difference between the two given snapshots.
|
|
3014
|
+
* @param first The first snapshot.
|
|
3015
|
+
* @param second The second snapshot.
|
|
3016
|
+
*/
|
|
3017
|
+
function diffSnapshots(first: BotsState, second: BotsState): PartialBotsState;
|
|
3018
|
+
|
|
3019
|
+
/**
|
|
3020
|
+
* Applies the given delta to the given snapshot and returns the result.
|
|
3021
|
+
* This is essentially the opposite of diffSnapshots().
|
|
3022
|
+
* @param snapshot The snapshot that the diff should be applied to.
|
|
3023
|
+
* @param diff The delta that should be applied to the snapshot.
|
|
3024
|
+
*/
|
|
3025
|
+
function applyDiffToSnapshot(snapshot: BotsState, diff: PartialBotsState): BotsState;
|
|
3026
|
+
|
|
2981
3027
|
/**
|
|
2982
3028
|
* Shouts the given events in order until a bot returns a result.
|
|
2983
3029
|
* Returns the result that was produced or undefined if no result was produced.
|
|
@@ -2986,6 +3032,26 @@ declare global {
|
|
|
2986
3032
|
*/
|
|
2987
3033
|
function priorityShout(eventNames: string[], arg?: any): any;
|
|
2988
3034
|
|
|
3035
|
+
/**
|
|
3036
|
+
* Creates a tag value that can be used to link to the given bots.
|
|
3037
|
+
* @param bots The bots that the link should point to.
|
|
3038
|
+
*/
|
|
3039
|
+
function createBotLink(...bots: (Bot | string | (Bot | string)[])[]): string;
|
|
3040
|
+
|
|
3041
|
+
/**
|
|
3042
|
+
* Gets the list of bot links that are stored in this bot's tags.
|
|
3043
|
+
* @param bot The bot to get the links for.
|
|
3044
|
+
*/
|
|
3045
|
+
function getBotLinks(bot: Bot): ParsedBotLink[];
|
|
3046
|
+
|
|
3047
|
+
/**
|
|
3048
|
+
* Updates all the links in the given bot using the given ID map.
|
|
3049
|
+
* Useful if you know that the links in the given bot are outdated and you know which IDs map to the new IDs.
|
|
3050
|
+
* @param bot The bot to update.
|
|
3051
|
+
* @param idMap The map of old IDs to new IDs that should be used.
|
|
3052
|
+
*/
|
|
3053
|
+
function updateBotLinks(bot: Bot, idMap: Map<string, string | Bot> | { [id: string]: string | Bot }): void;
|
|
3054
|
+
|
|
2989
3055
|
/**
|
|
2990
3056
|
* Asks every bot in the inst to run the given action.
|
|
2991
3057
|
* In effect, this is like shouting to a bunch of people in a room.
|
|
@@ -3702,14 +3768,62 @@ interface Debugger {
|
|
|
3702
3768
|
* @param data The data.
|
|
3703
3769
|
*/
|
|
3704
3770
|
getJSON(data: any): string;
|
|
3705
|
-
|
|
3771
|
+
|
|
3772
|
+
/**
|
|
3773
|
+
* Gets nicely formatted JSON for the given data.
|
|
3774
|
+
* @param data The data.
|
|
3775
|
+
*/
|
|
3776
|
+
getFormattedJSON(data: any): string;
|
|
3777
|
+
|
|
3778
|
+
/**
|
|
3779
|
+
* Makes a snapshot of the given bot(s).
|
|
3780
|
+
* Snapshots are like mods except they contain multiple bots and include the ID, space, tags, and tag masks of the bots.
|
|
3781
|
+
* @param bots The bots to make a snapshot of.
|
|
3782
|
+
*/
|
|
3783
|
+
getSnapshot(bots: Bot | Bot[]): BotsState;
|
|
3784
|
+
|
|
3785
|
+
/**
|
|
3786
|
+
* Calculates the difference between the two given snapshots.
|
|
3787
|
+
* @param first The first snapshot.
|
|
3788
|
+
* @param second The second snapshot.
|
|
3789
|
+
*/
|
|
3790
|
+
diffSnapshots(first: BotsState, second: BotsState): PartialBotsState;
|
|
3791
|
+
|
|
3792
|
+
/**
|
|
3793
|
+
* Applies the given delta to the given snapshot and returns the result.
|
|
3794
|
+
* This is essentially the opposite of diffSnapshots().
|
|
3795
|
+
* @param snapshot The snapshot that the diff should be applied to.
|
|
3796
|
+
* @param diff The delta that should be applied to the snapshot.
|
|
3797
|
+
*/
|
|
3798
|
+
applyDiffToSnapshot(snapshot: BotsState, diff: PartialBotsState): BotsState;
|
|
3799
|
+
|
|
3800
|
+
/**
|
|
3801
|
+
* Creates a tag value that can be used to link to the given bots.
|
|
3802
|
+
* @param bots The bots that the link should point to.
|
|
3803
|
+
*/
|
|
3804
|
+
createBotLink(...bots: (Bot | string | (Bot | string)[])[]): string;
|
|
3805
|
+
|
|
3806
|
+
/**
|
|
3807
|
+
* Gets the list of bot links that are stored in this bot's tags.
|
|
3808
|
+
* @param bot The bot to get the links for.
|
|
3809
|
+
*/
|
|
3810
|
+
getBotLinks(bot: Bot): ParsedBotLink[];
|
|
3811
|
+
|
|
3812
|
+
/**
|
|
3813
|
+
* Updates all the links in the given bot using the given ID map.
|
|
3814
|
+
* Useful if you know that the links in the given bot are outdated and you know which IDs map to the new IDs.
|
|
3815
|
+
* @param bot The bot to update.
|
|
3816
|
+
* @param idMap The map of old IDs to new IDs that should be used.
|
|
3817
|
+
*/
|
|
3818
|
+
updateBotLinks(bot: Bot, idMap: Map<string, string | Bot> | { [id: string]: string | Bot }): void
|
|
3819
|
+
|
|
3706
3820
|
/**
|
|
3707
3821
|
* Shouts the given events in order until a bot returns a result.
|
|
3708
3822
|
* Returns the result that was produced or undefined if no result was produced.
|
|
3709
3823
|
* @param eventNames The names of the events to shout.
|
|
3710
3824
|
* @param arg The argument to shout.
|
|
3711
3825
|
*/
|
|
3712
|
-
|
|
3826
|
+
priorityShout(eventNames: string[], arg?: any): any;
|
|
3713
3827
|
|
|
3714
3828
|
/**
|
|
3715
3829
|
* Asks every bot in the inst to run the given action.
|
|
@@ -4990,29 +5104,6 @@ interface Os {
|
|
|
4990
5104
|
*/
|
|
4991
5105
|
registerTagPrefix(prefix: string, options?: RegisterPrefixOptions): Promise<void>;
|
|
4992
5106
|
|
|
4993
|
-
/**
|
|
4994
|
-
* Registers a custom executable with the given source code.
|
|
4995
|
-
* Executables can contain arbitrary code that can run anywhere.
|
|
4996
|
-
* As such, executables allow you to add custom functionality that is not deeply integrated into the CasualOS platform.
|
|
4997
|
-
*
|
|
4998
|
-
* @param id The ID of the executable.
|
|
4999
|
-
* @param bot The bot that should be used to configure the executable.
|
|
5000
|
-
* @param tagOrSource The tag or source code that the executable should be created from.
|
|
5001
|
-
* @param options The options for the executable.
|
|
5002
|
-
*/
|
|
5003
|
-
registerExecutable(
|
|
5004
|
-
id: string,
|
|
5005
|
-
bot: Bot | string,
|
|
5006
|
-
tagOrSource?: string,
|
|
5007
|
-
options?: OpenCustomPortalOptions
|
|
5008
|
-
): Promise<void>;
|
|
5009
|
-
|
|
5010
|
-
/**
|
|
5011
|
-
* Builds an executable bundle from the given tag.
|
|
5012
|
-
* @param tag The tag that the bundle should be created from.
|
|
5013
|
-
*/
|
|
5014
|
-
buildExecutable(tag: string): Promise<CodeBundle>;
|
|
5015
|
-
|
|
5016
5107
|
/**
|
|
5017
5108
|
* Gets the number of devices that are viewing the current inst.
|
|
5018
5109
|
* @param inst The inst to get the statistics for. If omitted, then the current inst is used.
|
|
@@ -5054,6 +5145,11 @@ interface Os {
|
|
|
5054
5145
|
* @param options The options that should be used for the debugger.
|
|
5055
5146
|
*/
|
|
5056
5147
|
createDebugger(options?: DebuggerOptions): Debugger;
|
|
5148
|
+
|
|
5149
|
+
/**
|
|
5150
|
+
* Gets the debugger that this script is currently running in.
|
|
5151
|
+
*/
|
|
5152
|
+
getExecutingDebugger(): Debugger;
|
|
5057
5153
|
}
|
|
5058
5154
|
|
|
5059
5155
|
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,
|
|
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) {
|
|
@@ -298,10 +305,6 @@ export class AuxRuntime {
|
|
|
298
305
|
this._actionBatch.push(action);
|
|
299
306
|
}
|
|
300
307
|
}
|
|
301
|
-
else if (action.type === 'open_custom_portal') {
|
|
302
|
-
this._registerPortalBot(action.portalId, action.botId);
|
|
303
|
-
this._actionBatch.push(action);
|
|
304
|
-
}
|
|
305
308
|
else if (action.type === 'register_custom_app') {
|
|
306
309
|
this._registerPortalBot(action.appId, action.botId);
|
|
307
310
|
this._actionBatch.push(action);
|
|
@@ -311,12 +314,13 @@ export class AuxRuntime {
|
|
|
311
314
|
const newBot = this.context.createBot(createBot(this.context.uuid(), undefined, 'tempLocal'));
|
|
312
315
|
this._builtinPortalBots.push(action.portalId);
|
|
313
316
|
this._registerPortalBot(action.portalId, newBot.id);
|
|
314
|
-
this._actionBatch.push(
|
|
317
|
+
this._actionBatch.push(defineGlobalBot(action.portalId, newBot.id));
|
|
315
318
|
}
|
|
316
319
|
}
|
|
317
320
|
else if (action.type === 'define_global_bot') {
|
|
318
321
|
if (this._portalBots.get(action.name) !== action.botId) {
|
|
319
322
|
this._registerPortalBot(action.name, action.botId);
|
|
323
|
+
this._actionBatch.push(action);
|
|
320
324
|
}
|
|
321
325
|
if (hasValue(action.taskId)) {
|
|
322
326
|
this._processCore([asyncResult(action.taskId, null)]);
|
|
@@ -584,9 +588,11 @@ export class AuxRuntime {
|
|
|
584
588
|
}
|
|
585
589
|
if (!hasChange && removedBots && removedBots.length > 0) {
|
|
586
590
|
for (let bot of removedBots) {
|
|
587
|
-
if (
|
|
588
|
-
|
|
589
|
-
|
|
591
|
+
if (bot) {
|
|
592
|
+
if (isBotInDimension(null, bot, dimension)) {
|
|
593
|
+
hasChange = true;
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
590
596
|
}
|
|
591
597
|
}
|
|
592
598
|
}
|
|
@@ -713,7 +719,7 @@ export class AuxRuntime {
|
|
|
713
719
|
const tagValue = u.tags[tag];
|
|
714
720
|
if (hasValue(tagValue) || tagValue === null) {
|
|
715
721
|
if (isTagEdit(tagValue)) {
|
|
716
|
-
compiled.tags[tag] =
|
|
722
|
+
compiled.tags[tag] = applyTagEdit(compiled.tags[tag], tagValue);
|
|
717
723
|
}
|
|
718
724
|
else {
|
|
719
725
|
compiled.tags[tag] = tagValue;
|
|
@@ -745,7 +751,7 @@ export class AuxRuntime {
|
|
|
745
751
|
delete compiled.masks[space][tag];
|
|
746
752
|
}
|
|
747
753
|
else if (isTagEdit(tagValue)) {
|
|
748
|
-
compiled.masks[space][tag] =
|
|
754
|
+
compiled.masks[space][tag] = applyTagEdit(compiled.masks[space][tag], tagValue);
|
|
749
755
|
}
|
|
750
756
|
else {
|
|
751
757
|
compiled.masks[space][tag] = tagValue;
|
|
@@ -1081,6 +1087,18 @@ export class AuxRuntime {
|
|
|
1081
1087
|
this.getValue(bot, tag);
|
|
1082
1088
|
return bot.listeners[tag] || null;
|
|
1083
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
|
+
}
|
|
1084
1102
|
getSignature(bot, signature) {
|
|
1085
1103
|
return !!bot.signatures ? bot.signatures[signature] : undefined;
|
|
1086
1104
|
}
|
|
@@ -1133,7 +1151,7 @@ export class AuxRuntime {
|
|
|
1133
1151
|
}
|
|
1134
1152
|
}
|
|
1135
1153
|
if (isTagEdit(tagValue)) {
|
|
1136
|
-
tagValue = bot.tags[tag] =
|
|
1154
|
+
tagValue = bot.tags[tag] = applyTagEdit(bot.tags[tag], tagValue);
|
|
1137
1155
|
}
|
|
1138
1156
|
else {
|
|
1139
1157
|
if (hasValue(tagValue)) {
|