@casual-simulation/aux-common 3.1.35 → 3.2.0

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/bots/Bot.d.ts CHANGED
@@ -41,10 +41,28 @@ export declare const REPLACE_BOT_SYMBOL: unique symbol;
41
41
  * are calculated values and raw is the original tag values.
42
42
  *
43
43
  * i.e. tags will evaluate formulas while raw will return the formula scripts themselves.
44
+ *
45
+ * @dochash types/core
46
+ * @docgroup 01-core
47
+ * @doctitle Core Types
48
+ * @docsidebar Core
49
+ * @docdescription Documentation for core types that are used throughout CasualOS.
50
+ * @docid RuntimeBot
51
+ * @docname Bot
44
52
  */
45
53
  export interface RuntimeBot {
54
+ /**
55
+ * The ID of the bot.
56
+ */
46
57
  id: string;
58
+ /**
59
+ * The link to the bot.
60
+ */
47
61
  link: string;
62
+ /**
63
+ * The space that the bot is in.
64
+ * Defaults to `"shared"`
65
+ */
48
66
  space?: BotSpace;
49
67
  /**
50
68
  * The calculated tag values.
@@ -77,6 +95,8 @@ export interface RuntimeBot {
77
95
  maskChanges: BotTagMasks;
78
96
  /**
79
97
  * The signatures that are on the bot.
98
+ *
99
+ * @hidden
80
100
  */
81
101
  signatures: BotSignatures;
82
102
  /**
@@ -86,40 +106,74 @@ export interface RuntimeBot {
86
106
  listeners: CompiledBotListeners;
87
107
  /**
88
108
  * A function that can clear all the changes from the runtime bot.
109
+ *
110
+ * @hidden
89
111
  */
90
112
  [CLEAR_CHANGES_SYMBOL]: () => void;
91
113
  /**
92
114
  * A function that can set a tag mask on the bot.
115
+ *
116
+ * @hidden
93
117
  */
94
118
  [SET_TAG_MASK_SYMBOL]: (tag: string, value: any, space?: string) => void;
95
119
  /**
96
120
  * A function that can be used to get the tag masks for a bot.
121
+ *
122
+ * @hidden
97
123
  */
98
124
  [GET_TAG_MASKS_SYMBOL]: () => BotTagMasks;
99
125
  /**
100
126
  * A function that can clear the tag masks from the bot.
101
127
  * @param space The space that the masks should be cleared from. If not specified then all tag masks in all spaces will be cleared.
128
+ *
129
+ * @hidden
102
130
  */
103
131
  [CLEAR_TAG_MASKS_SYMBOL]: (space?: string) => any;
104
132
  /**
105
133
  * A function that can manipulate a tag using the given edit operations.
134
+ *
135
+ * @hidden
106
136
  */
107
137
  [EDIT_TAG_SYMBOL]: (tag: string, ops: TagEditOp[]) => any;
108
138
  /**
109
139
  * A function that can manipulate a tag mask using the given edit operations.
140
+ *
141
+ * @hidden
110
142
  */
111
143
  [EDIT_TAG_MASK_SYMBOL]: (tag: string, ops: TagEditOp[], space: string) => any;
112
144
  /**
113
145
  * A function that can cause all tags to be fowarded to the given bot.
146
+ *
147
+ * @hidden
114
148
  */
115
149
  [REPLACE_BOT_SYMBOL]: (bot: RuntimeBot) => void;
116
150
  /**
117
- * Gets the listener with the given name.
151
+ * Gets the listener or bot property with the given name.
152
+ *
153
+ * If given a property name, like `"tags"` or `"vars"`, then it will return the value of that property.
154
+ * Alternatively, if the name does not match an existing property on the bot, then it will return the listener with the given name.
155
+ *
156
+ * @example Get the tags of a bot
157
+ * let tags = bot.tags;
158
+ *
159
+ * @example Get the links of a bot
160
+ * let links = bot.links;
161
+ *
162
+ * @example Get the @onClick listener of a bot
163
+ * let onClick = bot.onClick;
164
+ *
165
+ * @example Get a property on a bot by a variable
166
+ * let propertyToGet = 'tags';
167
+ * let tags = bot[propertyToGet];
118
168
  */
119
- [listener: string]: CompiledBotListener | any;
169
+ [listenerOrProperty: string]: ((arg?: any) => any) | any;
120
170
  }
121
171
  /**
122
172
  * Defines an interface that represents a bot link that was parsed from a tag.
173
+ *
174
+ * @dochash types/core
175
+ * @docgroup 01-core
176
+ * @docname ParsedBotLink
123
177
  */
124
178
  export interface ParsedBotLink {
125
179
  /**
@@ -133,24 +187,79 @@ export interface ParsedBotLink {
133
187
  }
134
188
  /**
135
189
  * Defines an interface that represents the bot links a bot can have.
190
+ *
191
+ * ```typescript
192
+ * interface Links {
193
+ * [link: string]: Bot | Bot[];
194
+ * }
195
+ * ```
196
+ *
197
+ * @dochash types/core
198
+ * @docgroup 01-core
199
+ * @docname Links
200
+ * @docid RuntimeBotLinks
136
201
  */
137
202
  export interface RuntimeBotLinks {
203
+ /**
204
+ * Gets the bot or bots that are linked in the given tag.
205
+ *
206
+ * @example Get a bot that is linked in the #manager tag
207
+ * let managerBot = thisBot.links.manager;
208
+ *
209
+ * @example Link a bot to another bot in the #manager tag
210
+ * thisBot.links.manager = managerBot;
211
+ */
138
212
  [tag: string]: RuntimeBot | RuntimeBot[];
139
213
  }
140
214
  /**
141
215
  * Defines an interface that represents the variables a bot can have.
216
+ * Variables are useful for storing data that is not able to be saved to a tag.
217
+ *
218
+ * ```typescript
219
+ * interface Variables {
220
+ * [variable: string]: any;
221
+ * }
222
+ * ```
223
+ *
224
+ * @dochash types/core
225
+ * @docgroup 01-core
226
+ * @docname Variables
227
+ * @docid RuntimeBotVars
142
228
  */
143
229
  export interface RuntimeBotVars {
230
+ /**
231
+ * Gets or sets a variable on the bot.
232
+ *
233
+ * @example Get a variable on thisBot
234
+ * let variable = thisBot.vars.variable;
235
+ *
236
+ * @example Save a variable on thisBot
237
+ * thisBot.vars.variable = variable;
238
+ */
144
239
  [variable: string]: any;
145
240
  }
146
241
  /**
147
242
  * An interface that maps tag names to compiled listener functions.
243
+ *
244
+ * ```typescript
245
+ * interface Listeners {
246
+ * [tag: string]: (arg?: any) => any;
247
+ * }
248
+ * ```
249
+ *
250
+ * @dochash types/core
251
+ * @docgroup 01-core
252
+ * @docname Listeners
253
+ * @docid CompiledBotListeners
148
254
  */
149
255
  export interface CompiledBotListeners {
150
- [tag: string]: CompiledBotListener;
256
+ /**
257
+ * Gets the listener in the given tag.
258
+ */
259
+ [tag: string]: (arg?: any) => any;
151
260
  }
152
261
  /**
153
- * The type of a compiled bot listener.
262
+ * The function signature of a bot listener.
154
263
  */
155
264
  export type CompiledBotListener = (arg?: any) => any;
156
265
  /**
@@ -174,6 +283,9 @@ export interface PrecalculatedTags {
174
283
  }
175
284
  /**
176
285
  * Defines an interface for a bot.
286
+ *
287
+ * @docid Bot
288
+ * @docrename RuntimeBot
177
289
  */
178
290
  export interface Bot {
179
291
  /**
@@ -254,16 +366,18 @@ export interface UpdatedBot {
254
366
  signatures?: string[];
255
367
  }
256
368
  /**
257
- * The possible bot types.
369
+ * The possible bot spaces.
370
+ *
371
+ * - `"shared"` means that the bot is a normal bot.
372
+ * - `"local"` means that the bot is stored in the [local storage](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Client-side_storage) partition.
373
+ * - `"tempLocal"` means that the bot is stored in the [temporary](https://en.wikipedia.org/wiki/In-memory_database) partition.
374
+ * - `"tempShared"` means that the bot is temporary and shared with other devices.
375
+ * - `"remoteTempShared"` means that the bot is temporary and shared with this device from a remote device.
258
376
  *
259
- * - "shared" means that the bot is a normal bot.
260
- * - "local" means that the bot is stored in the local storage partition.
261
- * - "tempLocal" means that the bot is stored in the temporary partition.
262
- * - "history" means that the bot represents a version of another space.
263
- * - "admin" means that the bot is shared across all instances.
264
- * - "tempShared" means that the bot is temporary and shared with other devices.
265
- * - "remoteTempShared" means that the bot is temporary and shared with this device from a remote device.
266
- * - "certified" means that the bot is a certificate.
377
+ * @dochash types/core
378
+ * @docgroup 01-core
379
+ * @docname Space
380
+ * @docid BotSpace
267
381
  */
268
382
  export type BotSpace = 'shared' | 'local' | 'tempLocal' | 'history' | 'admin' | 'tempShared' | 'remoteTempShared' | 'certified';
269
383
  /**
@@ -281,8 +395,15 @@ export type RecordSpace = 'tempGlobal' | 'tempRestricted' | 'permanentGlobal' |
281
395
  export declare const DEFAULT_RECORD_SPACE: RecordSpace;
282
396
  /**
283
397
  * The possible portal types.
398
+ *
399
+ * @dochash types/core
400
+ * @docname PortalType
284
401
  */
285
402
  export type PortalType = 'grid' | 'miniGrid' | 'menu' | 'sheet' | 'meet' | 'system' | string;
403
+ /**
404
+ * @docid ScriptTags
405
+ * @docrename BotTags
406
+ */
286
407
  export interface ScriptTags extends PrecalculatedTags {
287
408
  toJSON(): any;
288
409
  }
@@ -307,122 +428,381 @@ export interface BotSignatures {
307
428
  * The actual data structure is similar to the bot tags structure except that tags are additionally
308
429
  * split by the space that they originated from. This makes it possible to identify which space a tag came from and also
309
430
  * prevents cross-space conflicts.
431
+ *
432
+ * ```typescript
433
+ * interface TagMasks {
434
+ * [space: string]: Tags;
435
+ * }
436
+ * ```
437
+ *
438
+ * @dochash types/core
439
+ * @docgroup 01-core
440
+ * @docname TagMasks
441
+ * @docid BotTagMasks
310
442
  */
311
443
  export interface BotTagMasks {
444
+ /**
445
+ * Gets or sets the tag masks that are specific to the given space.
446
+ */
312
447
  [space: string]: BotTags;
313
448
  }
449
+ /**
450
+ * Defines an interface that represents a set of tags and their related values.
451
+ *
452
+ * ```typescript
453
+ * interface Tags {
454
+ * [tag: string]: any
455
+ * }
456
+ * ```
457
+ *
458
+ * @dochash types/core
459
+ * @docgroup 01-core
460
+ * @docname Tags
461
+ * @docid BotTags
462
+ */
314
463
  export interface BotTags {
464
+ /**
465
+ * @hidden
466
+ */
315
467
  ['color']?: unknown;
468
+ /**
469
+ * @hidden
470
+ */
316
471
  ['draggable']?: unknown;
472
+ /**
473
+ * @hidden
474
+ */
317
475
  ['draggableMode']?: unknown;
476
+ /**
477
+ * @hidden
478
+ */
318
479
  ['destroyable']?: unknown;
480
+ /**
481
+ * @hidden
482
+ */
319
483
  ['editable']?: unknown;
484
+ /**
485
+ * @hidden
486
+ */
320
487
  ['strokeColor']?: unknown;
488
+ /**
489
+ * @hidden
490
+ */
321
491
  ['strokeWidth']?: unknown;
492
+ /**
493
+ * @hidden
494
+ */
322
495
  ['scale']?: number;
496
+ /**
497
+ * @hidden
498
+ */
323
499
  ['scaleX']?: number;
500
+ /**
501
+ * @hidden
502
+ */
324
503
  ['scaleY']?: number;
504
+ /**
505
+ * @hidden
506
+ */
325
507
  ['scaleZ']?: number;
508
+ /**
509
+ * @hidden
510
+ */
326
511
  ['scaleMode']?: BotScaleMode | null | string;
512
+ /**
513
+ * @hidden
514
+ */
327
515
  ['lineTo']?: unknown;
516
+ /**
517
+ * @hidden
518
+ */
328
519
  ['lineWidth']?: number;
520
+ /**
521
+ * @hidden
522
+ */
329
523
  ['lineStyle']?: unknown;
524
+ /**
525
+ * @hidden
526
+ */
330
527
  ['lineColor']?: unknown;
528
+ /**
529
+ * @hidden
530
+ */
331
531
  ['label']?: unknown;
532
+ /**
533
+ * @hidden
534
+ */
332
535
  ['labelColor']?: unknown;
536
+ /**
537
+ * @hidden
538
+ */
333
539
  ['labelSize']?: unknown;
540
+ /**
541
+ * @hidden
542
+ */
334
543
  ['labelSizeMode']?: 'auto' | null;
544
+ /**
545
+ * @hidden
546
+ */
335
547
  ['labelPosition']?: BotLabelAnchor | null | string;
548
+ /**
549
+ * @hidden
550
+ */
336
551
  ['labelAlignment']?: BotLabelAlignment | null | string;
552
+ /**
553
+ * @hidden
554
+ */
337
555
  ['labelFontAddress']?: BotLabelFontAddress;
556
+ /**
557
+ * @hidden
558
+ */
338
559
  ['listening']?: unknown;
560
+ /**
561
+ * @hidden
562
+ */
339
563
  ['form']?: BotShape;
564
+ /**
565
+ * @hidden
566
+ */
340
567
  ['formAnimation']?: string;
568
+ /**
569
+ * @hidden
570
+ */
341
571
  ['formAddress']?: string;
572
+ /**
573
+ * @hidden
574
+ */
342
575
  ['formOpacity']?: unknown;
576
+ /**
577
+ * @hidden
578
+ */
343
579
  ['orientationMode']?: string;
580
+ /**
581
+ * @hidden
582
+ */
344
583
  ['anchorPoint']?: string;
584
+ /**
585
+ * @hidden
586
+ */
345
587
  ['creator']?: string;
588
+ /**
589
+ * @hidden
590
+ */
346
591
  ['progressBar']?: unknown;
592
+ /**
593
+ * @hidden
594
+ */
347
595
  ['progressBarColor']?: unknown;
596
+ /**
597
+ * @hidden
598
+ */
348
599
  ['progressBarBackgroundColor']?: unknown;
600
+ /**
601
+ * @hidden
602
+ */
349
603
  ['progressBarPosition']?: unknown;
604
+ /**
605
+ * @hidden
606
+ */
350
607
  ['pointable']?: unknown;
608
+ /**
609
+ * @hidden
610
+ */
351
611
  ['focusable']?: unknown;
612
+ /**
613
+ * @hidden
614
+ */
352
615
  ['auxPlayerActive']?: boolean;
616
+ /**
617
+ * @hidden
618
+ */
353
619
  ['gridPortal']?: string | boolean;
620
+ /**
621
+ * @hidden
622
+ */
354
623
  ['sheetPortal']?: string | boolean;
624
+ /**
625
+ * @hidden
626
+ */
355
627
  ['inst']?: string | string[];
628
+ /**
629
+ * @hidden
630
+ */
356
631
  ['miniGridPortal']?: string;
632
+ /**
633
+ * @hidden
634
+ */
357
635
  ['menuPortal']?: string;
636
+ /**
637
+ * @hidden
638
+ */
358
639
  ['leftWristPortal']?: string;
640
+ /**
641
+ * @hidden
642
+ */
359
643
  ['rightWristPortal']?: string;
644
+ /**
645
+ * @hidden
646
+ */
360
647
  ['editingBot']?: string;
648
+ /**
649
+ * @hidden
650
+ */
361
651
  cursorStartIndex?: number;
652
+ /**
653
+ * @hidden
654
+ */
362
655
  cursorEndIndex?: number;
656
+ /**
657
+ * @hidden
658
+ */
363
659
  ['pixelWidth']?: number;
660
+ /**
661
+ * @hidden
662
+ */
364
663
  ['pixelHeight']?: number;
365
- ['auxRunningTasks']?: boolean;
366
- ['auxFinishedTasks']?: boolean;
367
- ['taskOutput']?: unknown;
368
- ['taskError']?: unknown;
369
- ['taskTime']?: unknown;
370
- ['taskShell']?: string;
371
- ['taskBackup']?: boolean;
372
- ['taskBackupType']?: BackupType;
373
- ['taskBackupUrl']?: string;
664
+ /**
665
+ * @hidden
666
+ */
374
667
  ['portalColor']?: string;
668
+ /**
669
+ * @hidden
670
+ */
375
671
  ['portalLocked']?: unknown;
672
+ /**
673
+ * @hidden
674
+ */
376
675
  ['portalGridScale']?: number;
676
+ /**
677
+ * @hidden
678
+ */
377
679
  ['portalSurfaceScale']?: number;
680
+ /**
681
+ * @hidden
682
+ */
378
683
  ['portalCameraRotationX']?: number;
684
+ /**
685
+ * @hidden
686
+ */
379
687
  ['portalCameraRotationY']?: number;
688
+ /**
689
+ * @hidden
690
+ */
380
691
  ['portalCameraZoom']?: number;
692
+ /**
693
+ * @hidden
694
+ */
381
695
  ['portalPannable']?: number | null;
696
+ /**
697
+ * @hidden
698
+ */
382
699
  [`portalPannableMinX`]?: number | null;
700
+ /**
701
+ * @hidden
702
+ */
383
703
  [`portalPannableMaxX`]?: number | null;
704
+ /**
705
+ * @hidden
706
+ */
384
707
  [`portalPannableMinY`]?: number | null;
708
+ /**
709
+ * @hidden
710
+ */
385
711
  [`portalPannableMaxY`]?: number | null;
712
+ /**
713
+ * @hidden
714
+ */
386
715
  ['portalZoomable']?: number | null;
716
+ /**
717
+ * @hidden
718
+ */
387
719
  [`portalZoomableMin`]?: number | null;
720
+ /**
721
+ * @hidden
722
+ */
388
723
  [`portalZoomableMax`]?: number | null;
724
+ /**
725
+ * @hidden
726
+ */
389
727
  ['portalRotatable']?: number | null;
728
+ /**
729
+ * @hidden
730
+ */
390
731
  ['portalShowFocusPoint']?: boolean | null;
732
+ /**
733
+ * @hidden
734
+ */
391
735
  ['portalDisableCanvasTransparency']?: boolean;
736
+ /**
737
+ * @hidden
738
+ */
392
739
  ['miniPortalHeight']?: unknown;
740
+ /**
741
+ * @hidden
742
+ */
393
743
  ['miniPortalResizable']?: boolean;
744
+ /**
745
+ * @hidden
746
+ */
394
747
  ['wristPortalHeight']?: number;
748
+ /**
749
+ * @hidden
750
+ */
395
751
  ['wristPortalWidth']?: number;
396
- ['stripeCharges']?: boolean;
397
- ['stripeSuccessfulCharges']?: boolean;
398
- ['stripeFailedCharges']?: boolean;
399
- ['stripeCharge']?: string;
400
- ['stripeChargeReceiptUrl']?: string;
401
- ['stripeChargeReceiptNumber']?: string;
402
- ['stripeChargeDescription']?: string;
403
- ['stripeOutcomeNetworkStatus']?: string;
404
- ['stripeOutcomeReason']?: string;
405
- ['stripeOutcomeRiskLevel']?: string;
406
- ['stripeOutcomeRiskScore']?: number;
407
- ['stripeOutcomeRule']?: string | string[];
408
- ['stripeOutcomeSellerMessage']?: string;
409
- ['stripeOutcomeType']?: string;
410
- ['stripeErrors']?: boolean;
411
- ['stripeError']?: string;
412
- ['stripeErrorType']?: string;
413
- [key: string]: any;
752
+ /**
753
+ * Gets or sets the given tag on the bot.
754
+ *
755
+ * @example Get the #color on this bot
756
+ * let color = thisBot.tags.color;
757
+ *
758
+ * @example Get a raw tag on this bot
759
+ * let rawTag = thisBot.raw.tag;
760
+ *
761
+ * @example Set the #color tag to "red" on this bot
762
+ * thisBot.tags.color = "red";
763
+ *
764
+ * @example Set a tempLocal tag mask for #color on this bot
765
+ * thisBot.masks.color = "red";
766
+ */
767
+ [tag: string]: any;
414
768
  }
415
769
  /**
416
- * Defines an interface for the state that an AUX bot can contain.
770
+ * Defines an interface that contains a set of bots that have been indexed by their IDs.
771
+ *
772
+ * Generally, this is only used when working with groups of bots.
773
+ * For example, the {@link diffSnapshots} function takes two bot states and produces the difference between them.
774
+ *
775
+ * @dochash types/core
776
+ * @docgroup 01-core
777
+ * @docname BotState
778
+ *
779
+ * @example Create a bot state with two bots
780
+ * let state = {
781
+ * [bot1.id]: bot1,
782
+ * [bot2.id]: bot2
783
+ * };
784
+ *
785
+ * @example Get a bot by its ID from a bot state
786
+ * let bot = state[botId];
417
787
  */
418
788
  export interface BotsState {
789
+ /**
790
+ * Gets or sets the bot in the state with the given ID.
791
+ */
419
792
  [id: string]: Bot;
420
793
  }
421
794
  /**
422
- * Defines an interface for a partial bot state.
795
+ * Defines an interface that contains a set of partial bots that have been indexed by their IDs.
796
+ *
797
+ * Generally, this is only used when working with differences between groups of bots.
798
+ * For example, the {@link applyDiffToSnapshot} function takes a bot state and a partial bot state and produces a final state that contains the combined result.
799
+ *
800
+ * @dochash types/core
801
+ * @docgroup 01-core
802
+ * @docname PartialBotState
423
803
  */
424
804
  export interface PartialBotsState {
425
- [id: string]: PartialBot;
805
+ [id: string]: Partial<Bot>;
426
806
  }
427
807
  /**
428
808
  * Defines an interface for a set of bots that have precalculated formulas.
@@ -509,6 +889,9 @@ export type BotLabelWordWrap = 'breakWords' | 'breakCharacters' | 'none';
509
889
  export type BotOrientationMode = 'absolute' | 'billboard' | 'billboardTop' | 'billboardFront';
510
890
  /**
511
891
  * Defines the possible bot anchor points.
892
+ *
893
+ * @dochash types/core
894
+ * @docname BotAnchorPoint
512
895
  */
513
896
  export type BotAnchorPoint = 'top' | 'front' | 'back' | 'left' | 'right' | 'bottom' | 'center' | readonly [number, number, number];
514
897
  /**