@minecraft/server-editor 0.1.0-beta.1.20.60-preview.21 → 0.1.0-beta.1.20.60-preview.23

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 +123 -1
  2. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * ```json
15
15
  * {
16
16
  * "module_name": "@minecraft/server-editor",
17
- * "version": "0.1.0-beta.1.20.60-preview.21"
17
+ * "version": "0.1.0-beta.1.20.60-preview.23"
18
18
  * }
19
19
  * ```
20
20
  *
@@ -1636,6 +1636,17 @@ export class SimulationState {
1636
1636
  */
1637
1637
  export class TransactionManager {
1638
1638
  private constructor();
1639
+ /**
1640
+ * @remarks
1641
+ * This function can't be called in read-only mode.
1642
+ *
1643
+ * @throws This function can throw errors.
1644
+ */
1645
+ addUserDefinedOperation(
1646
+ transactionHandlerId: UserDefinedTransactionHandlerId,
1647
+ operationData: string,
1648
+ operationName?: string,
1649
+ ): void;
1639
1650
  /**
1640
1651
  * @remarks
1641
1652
  * Commit all of the transaction operations currently attached
@@ -1667,6 +1678,16 @@ export class TransactionManager {
1667
1678
  * @throws This function can throw errors.
1668
1679
  */
1669
1680
  commitTrackedChanges(): number;
1681
+ /**
1682
+ * @remarks
1683
+ * This function can't be called in read-only mode.
1684
+ *
1685
+ * @throws This function can throw errors.
1686
+ */
1687
+ createUserDefinedTransactionHandler(
1688
+ undoClosure: (arg: string) => void,
1689
+ redoClosure: (arg: string) => void,
1690
+ ): UserDefinedTransactionHandlerId;
1670
1691
  /**
1671
1692
  * @remarks
1672
1693
  * Discard the currently open transaction without committing it
@@ -1828,6 +1849,54 @@ export class TransactionManager {
1828
1849
  undoSize(): number;
1829
1850
  }
1830
1851
 
1852
+ /**
1853
+ * A strongly typed transaction handle to enforce type safety
1854
+ * when adding user defined transactions.<br> This transaction
1855
+ * handle becomes the context for adding the transaction to the
1856
+ * transaction manager.<br> You can obtain one of these handles
1857
+ * by calling {@link registerUserDefinedTransactionHandler}
1858
+ */
1859
+ export declare class UserDefinedTransactionHandle<T> {
1860
+ /**
1861
+ * @remarks
1862
+ * Constructs a new instance of the
1863
+ * `UserDefinedTransactionHandle` class
1864
+ *
1865
+ */
1866
+ constructor(nativeHandle: UserDefinedTransactionHandlerId, transactionManager: TransactionManager);
1867
+ /**
1868
+ * @remarks
1869
+ * Add a user defined transaction operation to the transaction
1870
+ * manager with a payload of the specified type. This allows
1871
+ * the extension to open a transaction, and insert custom data
1872
+ * objects into the transaction log which are stored until an
1873
+ * undo or redo event occurs. The payload data added here is
1874
+ * stored and then passed to the undo/redo handlers (registered
1875
+ * with {@link registerUserDefinedTransactionHandler}) when an
1876
+ * undo/redo event is requested. NOTE:<br> Transactions can
1877
+ * contain multiple operations - you can open a transaction and
1878
+ * add any (reasonable) number of operations to it (of the same
1879
+ * or differing types) before committing to the transaction
1880
+ * log. NOTE/WARNING:<br> The payload data is serialized to
1881
+ * JSON before being inserted into the transaction log and the
1882
+ * underlying implementation uses the JSON.stringify() function
1883
+ * to serialize the data. Any non-primitive data, such as
1884
+ * classes or minecraft native objects will not serialize to
1885
+ * JSON properly, so you should avoid using them as payload
1886
+ * data.
1887
+ *
1888
+ * @param payload
1889
+ * The data object to be inserted into the transaction log.
1890
+ * @param transactionName
1891
+ * A string name that will be associated with this operation
1892
+ */
1893
+ addUserDefinedOperation(payload: T, transactionName: string): void;
1894
+ }
1895
+
1896
+ export class UserDefinedTransactionHandlerId {
1897
+ private constructor();
1898
+ }
1899
+
1831
1900
  /**
1832
1901
  * Interface used to specify the options when a clipboard item
1833
1902
  * is being written to the world
@@ -2018,6 +2087,7 @@ export interface PlaytestGameOptions {
2018
2087
  showCoordinates?: boolean;
2019
2088
  spawnPosition?: minecraftserver.Vector3;
2020
2089
  timeOfDay?: number;
2090
+ weather?: number;
2021
2091
  }
2022
2092
 
2023
2093
  /**
@@ -2815,4 +2885,56 @@ export declare function registerEditorExtension<PerPlayerStorageType = Record<st
2815
2885
  shutdownFunction: ShutdownFunctionType<PerPlayerStorageType>,
2816
2886
  options?: IRegisterExtensionOptionalParameters,
2817
2887
  ): Extension;
2888
+ /**
2889
+ * @remarks
2890
+ * Creates a strongly typed transaction handle to enforce type
2891
+ * safety when adding user defined transactions. This function
2892
+ * is a wrapper around the more generalized transaction manager
2893
+ * API for script based transactions. Any Editor Extension that
2894
+ * needs to insert data into the transaction log for undo/redo
2895
+ * should use this function to create a handler for the
2896
+ * specific type of data that needs to be inserted. When a
2897
+ * transaction is undone/redone, the associated handler
2898
+ * function will be invoked with a copy of the payload data
2899
+ * that was inserted into the log. As a general rule,
2900
+ * transaction data should contain 2 things:<br> 1. The data
2901
+ * that will be used to perform the operation we're trying to
2902
+ * record<br> 2. The data that will be used to restore the
2903
+ * state of the program to what it was before the
2904
+ * operation.<br> NOTE/WARNING:<br> The payload data is
2905
+ * serialized to JSON before being inserted into the
2906
+ * transaction log and the underlying implementation uses the
2907
+ * JSON.stringify() function to serialize the data. Any
2908
+ * non-primitive data, such as classes or minecraft native
2909
+ * objects will not serialize to JSON properly, so you should
2910
+ * avoid using them as payload data.
2911
+ *
2912
+ * @param transactionManager
2913
+ * A reference to the TransactionManager (from the extension
2914
+ * context for your extension)
2915
+ * @param undoHandler
2916
+ * A function that will be invoked when the transaction is
2917
+ * undone. The function will be passed a copy of the payload
2918
+ * data that was inserted into the transaction log.
2919
+ * @param redoHandler
2920
+ * A function that will be invoked when the transaction is
2921
+ * redone. The function will be passed a copy of the payload
2922
+ * data that was inserted into the transaction log.
2923
+ * @returns
2924
+ * - {@link UserDefinedTransactionHandle} - A strongly typed
2925
+ * transaction handle that can be used to add transactions to
2926
+ * the transaction manager.
2927
+ */
2928
+ export declare function registerUserDefinedTransactionHandler<T>(
2929
+ transactionManager: TransactionManager,
2930
+ undoHandler: (payload: T) => void,
2931
+ redoHandler: (payload: T) => void,
2932
+ ): UserDefinedTransactionHandle<T>;
2933
+ /**
2934
+ * @remarks
2935
+ * Small utility for getting a string from an unknown exception
2936
+ * type
2937
+ *
2938
+ */
2939
+ export declare function stringFromException(e: unknown): string;
2818
2940
  export const editor: MinecraftEditor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minecraft/server-editor",
3
- "version": "0.1.0-beta.1.20.60-preview.21",
3
+ "version": "0.1.0-beta.1.20.60-preview.23",
4
4
  "description": "",
5
5
  "contributors": [
6
6
  {
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@minecraft/common": "^1.0.0",
17
- "@minecraft/server": "^1.9.0-beta.1.20.60-preview.21"
17
+ "@minecraft/server": "^1.9.0-beta.1.20.60-preview.23"
18
18
  },
19
19
  "license": "MIT"
20
20
  }