@minecraft/server-ui 2.1.0-beta.1.26.30-preview.27 → 2.1.0-rc.1.26.30-preview.30

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.
Files changed (2) hide show
  1. package/index.d.ts +118 -27
  2. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  Copyright (c) Microsoft Corporation.
8
8
  ***************************************************************************** */
9
9
  /**
10
- * @beta
10
+ * @preview
11
11
  * @packageDocumentation
12
12
  * The `@minecraft/server-ui` module contains types for
13
13
  * expressing simple dialog-based user experiences.
@@ -26,7 +26,7 @@
26
26
  * ```json
27
27
  * {
28
28
  * "module_name": "@minecraft/server-ui",
29
- * "version": "2.1.0-beta"
29
+ * "version": "2.1.0"
30
30
  * }
31
31
  * ```
32
32
  *
@@ -34,7 +34,7 @@
34
34
  import * as minecraftcommon from '@minecraft/common';
35
35
  import * as minecraftserver from '@minecraft/server';
36
36
  /**
37
- * @beta
37
+ * @rc
38
38
  * The reason why a data driven UI screen (MessageBox or
39
39
  * CustomForm) was closed.
40
40
  */
@@ -63,19 +63,54 @@ export enum DataDrivenScreenClosedReason {
63
63
  UserBusy = 'UserBusy',
64
64
  }
65
65
 
66
+ /**
67
+ * An enum representing the reasons why a form was canceled.
68
+ */
66
69
  export enum FormCancelationReason {
70
+ /**
71
+ * @remarks
72
+ * The form was canceled because the player was busy with
73
+ * another UI interaction.
74
+ *
75
+ */
67
76
  UserBusy = 'UserBusy',
77
+ /**
78
+ * @remarks
79
+ * The form was canceled because the player closed it.
80
+ *
81
+ */
68
82
  UserClosed = 'UserClosed',
69
83
  }
70
84
 
85
+ /**
86
+ * An enum representing the reasons why a form was rejected.
87
+ */
71
88
  export enum FormRejectReason {
89
+ /**
90
+ * @remarks
91
+ * The form was rejected because the response from the client
92
+ * was malformed or could not be parsed.
93
+ *
94
+ */
72
95
  MalformedResponse = 'MalformedResponse',
96
+ /**
97
+ * @remarks
98
+ * The form was rejected because the player quit the game
99
+ * before responding.
100
+ *
101
+ */
73
102
  PlayerQuit = 'PlayerQuit',
103
+ /**
104
+ * @remarks
105
+ * The form was rejected because the server shut down before
106
+ * the player responded.
107
+ *
108
+ */
74
109
  ServerShutdown = 'ServerShutdown',
75
110
  }
76
111
 
77
112
  /**
78
- * @beta
113
+ * @rc
79
114
  * The reason why a form visibility operation failed.
80
115
  */
81
116
  export enum FormVisibilityErrorReason {
@@ -96,7 +131,7 @@ export enum FormVisibilityErrorReason {
96
131
  }
97
132
 
98
133
  /**
99
- * @beta
134
+ * @rc
100
135
  * An enum representing the errors that can occur during text
101
136
  * filtering. This is used to provide more context about the
102
137
  * filtering process.
@@ -323,7 +358,7 @@ export class ActionFormResponse extends FormResponse {
323
358
  }
324
359
 
325
360
  /**
326
- * @beta
361
+ * @rc
327
362
  * A customizable data driven (DDUI) form that lets you add
328
363
  * buttons, labels, toggles, dropdowns, sliders, text fields,
329
364
  * and more. The form layout is built by calling methods to add
@@ -440,6 +475,8 @@ export class CustomForm {
440
475
  * @throws This function can throw errors.
441
476
  *
442
477
  * {@link InvalidFormModificationError}
478
+ *
479
+ * {@link InvalidObservableError}
443
480
  */
444
481
  dropdown(
445
482
  label: ObservableString | ObservableUIRawMessage | string | UIRawMessage,
@@ -531,6 +568,8 @@ export class CustomForm {
531
568
  * @throws This function can throw errors.
532
569
  *
533
570
  * {@link InvalidFormModificationError}
571
+ *
572
+ * {@link InvalidObservableError}
534
573
  */
535
574
  slider(
536
575
  label: ObservableString | ObservableUIRawMessage | string | UIRawMessage,
@@ -574,6 +613,8 @@ export class CustomForm {
574
613
  * @throws This function can throw errors.
575
614
  *
576
615
  * {@link InvalidFormModificationError}
616
+ *
617
+ * {@link InvalidObservableError}
577
618
  */
578
619
  textField(
579
620
  label: ObservableString | ObservableUIRawMessage | string | UIRawMessage,
@@ -600,6 +641,8 @@ export class CustomForm {
600
641
  * @throws This function can throw errors.
601
642
  *
602
643
  * {@link InvalidFormModificationError}
644
+ *
645
+ * {@link InvalidObservableError}
603
646
  */
604
647
  toggle(
605
648
  label: ObservableString | ObservableUIRawMessage | string | UIRawMessage,
@@ -629,7 +672,7 @@ export class FormResponse {
629
672
  }
630
673
 
631
674
  /**
632
- * @beta
675
+ * @rc
633
676
  * A simple message form with two buttons and a text body. Use
634
677
  * this class to show a basic dialog to a player and handle the
635
678
  * player's button selection.
@@ -1136,7 +1179,7 @@ export class ModalFormResponse extends FormResponse {
1136
1179
  }
1137
1180
 
1138
1181
  /**
1139
- * @beta
1182
+ * @rc
1140
1183
  * An observable that holds a boolean value. Listeners are
1141
1184
  * notified whenever the value changes.
1142
1185
  */
@@ -1213,7 +1256,7 @@ export class ObservableBoolean {
1213
1256
  }
1214
1257
 
1215
1258
  /**
1216
- * @beta
1259
+ * @rc
1217
1260
  * An observable that holds a numeric value. Listeners are
1218
1261
  * notified whenever the value changes.
1219
1262
  */
@@ -1290,7 +1333,7 @@ export class ObservableNumber {
1290
1333
  }
1291
1334
 
1292
1335
  /**
1293
- * @beta
1336
+ * @rc
1294
1337
  * An observable that holds a string value. Listeners are
1295
1338
  * notified whenever the value changes.
1296
1339
  */
@@ -1386,19 +1429,32 @@ export class ObservableString {
1386
1429
  }
1387
1430
 
1388
1431
  /**
1389
- * @beta
1432
+ * @rc
1433
+ * An observable that holds a UIRawMessage value. Listeners are
1434
+ * notified whenever the value changes.
1390
1435
  */
1391
1436
  export class ObservableUIRawMessage {
1392
1437
  /**
1393
1438
  * @remarks
1439
+ * Creates a new ObservableUIRawMessage with the provided
1440
+ * initial UIRawMessage value.
1441
+ *
1394
1442
  * This function can't be called in restricted-execution mode.
1395
1443
  *
1396
1444
  * This function can be called in early-execution mode.
1397
1445
  *
1446
+ * @param data
1447
+ * The initial UIRawMessage value for this observable.
1448
+ * @param options
1449
+ * Optional configuration for the observable, such as whether
1450
+ * the value can be written by the client.
1398
1451
  */
1399
1452
  constructor(data: UIRawMessage, options?: ObservableOptions);
1400
1453
  /**
1401
1454
  * @remarks
1455
+ * Returns the current UIRawMessage value held by this
1456
+ * observable.
1457
+ *
1402
1458
  * This function can't be called in restricted-execution mode.
1403
1459
  *
1404
1460
  * This function can be called in early-execution mode.
@@ -1407,26 +1463,45 @@ export class ObservableUIRawMessage {
1407
1463
  getData(): UIRawMessage;
1408
1464
  /**
1409
1465
  * @remarks
1466
+ * Updates the UIRawMessage value held by this observable. If
1467
+ * the new value differs from the current value, all subscribed
1468
+ * listeners are notified with the new value.
1469
+ *
1410
1470
  * This function can't be called in restricted-execution mode.
1411
1471
  *
1412
1472
  * This function can be called in early-execution mode.
1413
1473
  *
1474
+ * @param data
1475
+ * The new UIRawMessage value to set.
1414
1476
  */
1415
1477
  setData(data: UIRawMessage): void;
1416
1478
  /**
1417
1479
  * @remarks
1480
+ * Registers a callback to be invoked whenever the observable's
1481
+ * value changes. Returns the callback, which can be passed to
1482
+ * unsubscribe to remove the listener.
1483
+ *
1418
1484
  * This function can't be called in restricted-execution mode.
1419
1485
  *
1420
1486
  * This function can be called in early-execution mode.
1421
1487
  *
1488
+ * @param callback
1489
+ * A function that receives the new UIRawMessage value each
1490
+ * time the observable changes.
1422
1491
  */
1423
1492
  subscribe(callback: (arg0: UIRawMessage) => void): (arg0: UIRawMessage) => void;
1424
1493
  /**
1425
1494
  * @remarks
1495
+ * Removes a previously registered listener from this
1496
+ * observable. Returns true if the listener was found and
1497
+ * removed, false if it was not found.
1498
+ *
1426
1499
  * This function can't be called in restricted-execution mode.
1427
1500
  *
1428
1501
  * This function can be called in early-execution mode.
1429
1502
  *
1503
+ * @param callback
1504
+ * The callback handle previously returned by subscribe.
1430
1505
  */
1431
1506
  unsubscribe(callback: (arg0: UIRawMessage) => void): boolean;
1432
1507
  }
@@ -1443,7 +1518,7 @@ export class UIManager {
1443
1518
  }
1444
1519
 
1445
1520
  /**
1446
- * @beta
1521
+ * @rc
1447
1522
  * Options for configuring a button component.
1448
1523
  */
1449
1524
  export interface ButtonOptions {
@@ -1471,7 +1546,7 @@ export interface ButtonOptions {
1471
1546
  }
1472
1547
 
1473
1548
  /**
1474
- * @beta
1549
+ * @rc
1475
1550
  * Options for configuring a divider component in a CustomForm.
1476
1551
  */
1477
1552
  export interface DividerOptions {
@@ -1485,7 +1560,7 @@ export interface DividerOptions {
1485
1560
  }
1486
1561
 
1487
1562
  /**
1488
- * @beta
1563
+ * @rc
1489
1564
  * Represents a single item in a dropdown component.
1490
1565
  */
1491
1566
  export interface DropdownItemData {
@@ -1513,7 +1588,7 @@ export interface DropdownItemData {
1513
1588
  }
1514
1589
 
1515
1590
  /**
1516
- * @beta
1591
+ * @rc
1517
1592
  * Options for configuring a dropdown component.
1518
1593
  */
1519
1594
  export interface DropdownOptions {
@@ -1541,7 +1616,7 @@ export interface DropdownOptions {
1541
1616
  }
1542
1617
 
1543
1618
  /**
1544
- * @beta
1619
+ * @rc
1545
1620
  * The result returned when an MessageBox is closed. Contains
1546
1621
  * the reason the message box was closed and the player's
1547
1622
  * button selection, if applicable.
@@ -1656,7 +1731,7 @@ export interface ModalFormDataToggleOptions {
1656
1731
  }
1657
1732
 
1658
1733
  /**
1659
- * @beta
1734
+ * @rc
1660
1735
  * Configuration options for creating an Observable. Controls
1661
1736
  * how the observable value can be accessed and modified.
1662
1737
  */
@@ -1672,7 +1747,7 @@ export interface ObservableOptions {
1672
1747
  }
1673
1748
 
1674
1749
  /**
1675
- * @beta
1750
+ * @rc
1676
1751
  * Options for configuring a slider component.
1677
1752
  */
1678
1753
  export interface SliderOptions {
@@ -1707,7 +1782,7 @@ export interface SliderOptions {
1707
1782
  }
1708
1783
 
1709
1784
  /**
1710
- * @beta
1785
+ * @rc
1711
1786
  * Options for configuring a spacer component.
1712
1787
  */
1713
1788
  export interface SpacingOptions {
@@ -1721,7 +1796,7 @@ export interface SpacingOptions {
1721
1796
  }
1722
1797
 
1723
1798
  /**
1724
- * @beta
1799
+ * @rc
1725
1800
  * Options for configuring a text field component.
1726
1801
  */
1727
1802
  export interface TextFieldOptions {
@@ -1749,7 +1824,7 @@ export interface TextFieldOptions {
1749
1824
  }
1750
1825
 
1751
1826
  /**
1752
- * @beta
1827
+ * @rc
1753
1828
  * Options for configuring a text component (label or header).
1754
1829
  */
1755
1830
  export interface TextOptions {
@@ -1763,7 +1838,7 @@ export interface TextOptions {
1763
1838
  }
1764
1839
 
1765
1840
  /**
1766
- * @beta
1841
+ * @rc
1767
1842
  * Options for configuring a toggle component.
1768
1843
  */
1769
1844
  export interface ToggleOptions {
@@ -1791,7 +1866,7 @@ export interface ToggleOptions {
1791
1866
  }
1792
1867
 
1793
1868
  /**
1794
- * @beta
1869
+ * @rc
1795
1870
  * A message that can be sent to the client. This is a subset
1796
1871
  * of the RawMessage type, and is used for UI messages.
1797
1872
  */
@@ -1826,11 +1901,17 @@ export interface UIRawMessage {
1826
1901
  with?: string[] | UIRawMessage;
1827
1902
  }
1828
1903
 
1904
+ /**
1905
+ * Thrown when a form is rejected. Contains the reason for the
1906
+ * rejection.
1907
+ */
1829
1908
  // @ts-ignore Class inheritance allowed for native defined classes
1830
1909
  export class FormRejectError extends Error {
1831
1910
  private constructor();
1832
1911
  /**
1833
1912
  * @remarks
1913
+ * The reason the form was rejected.
1914
+ *
1834
1915
  * This property can be read in early-execution mode.
1835
1916
  *
1836
1917
  */
@@ -1838,7 +1919,7 @@ export class FormRejectError extends Error {
1838
1919
  }
1839
1920
 
1840
1921
  /**
1841
- * @beta
1922
+ * @rc
1842
1923
  * Thrown when a form visibility operation fails, such as
1843
1924
  * attempting to show a form that is already showing or
1844
1925
  * attempting to close a form that is not currently open.
@@ -1865,7 +1946,7 @@ export class FormVisibilityError extends Error {
1865
1946
  }
1866
1947
 
1867
1948
  /**
1868
- * @beta
1949
+ * @rc
1869
1950
  * Thrown when attempting to interact with a form using an
1870
1951
  * invalid or unknown form identifier.
1871
1952
  */
@@ -1883,7 +1964,7 @@ export class InvalidFormError extends Error {
1883
1964
  }
1884
1965
 
1885
1966
  /**
1886
- * @beta
1967
+ * @rc
1887
1968
  * Thrown when attempting to modify a form after it has already
1888
1969
  * been shown to a player. Form properties cannot be changed
1889
1970
  * while the form is active.
@@ -1903,7 +1984,17 @@ export class InvalidFormModificationError extends Error {
1903
1984
  }
1904
1985
 
1905
1986
  /**
1906
- * @beta
1987
+ * @rc
1988
+ * Thrown when an observable value is expected to be writable,
1989
+ * but it is not.
1990
+ */
1991
+ // @ts-ignore Class inheritance allowed for native defined classes
1992
+ export class InvalidObservableError extends Error {
1993
+ private constructor();
1994
+ }
1995
+
1996
+ /**
1997
+ * @rc
1907
1998
  * Thrown when a form operation fails because the target player
1908
1999
  * has left the game.
1909
2000
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minecraft/server-ui",
3
- "version": "2.1.0-beta.1.26.30-preview.27",
3
+ "version": "2.1.0-rc.1.26.30-preview.30",
4
4
  "description": "",
5
5
  "contributors": [
6
6
  {
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "peerDependencies": {
16
16
  "@minecraft/common": "^1.0.0",
17
- "@minecraft/server": "^2.0.0 || ^2.9.0-beta.1.26.30-preview.27"
17
+ "@minecraft/server": "^2.0.0"
18
18
  },
19
19
  "license": "MIT"
20
20
  }