Skip to content

Commit 1fc743f

Browse files
authored
Add jsdocs to editor API typings (JaylyDev#169)
1 parent bb8b736 commit 1fc743f

File tree

3 files changed

+119
-21
lines changed

3 files changed

+119
-21
lines changed

lib/@minecraft/server-editor-bindings/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definition for @minecraft/server-editor-bindings 0.3.1
1+
// Type definition for @minecraft/server-editor-bindings 0.3
22
/**
33
* Manifest details
44
* ```json

lib/@minecraft/server-editor/index.d.ts

Lines changed: 118 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definition for @minecraft/server-editor 0.3.1
1+
// Type definition for @minecraft/server-editor 0.3
22
/**
33
* Manifest details
44
* ```json
@@ -77,7 +77,14 @@ declare class ClientEventDispatcher {
7777
constructor(_system: System);
7878
private _system: System;
7979
initialize(): Player;
80+
/**
81+
* Dispatches and event of type T with the appropriate payload. See ServerEventPayloadMapping for the
82+
* correct mapping of payload to server event type
83+
*/
8084
dispatchEvent(type: any, payload: any, replacer: any): void;
85+
/**
86+
* Fires off all payloads in event queue and removes any tick registration
87+
*/
8188
flush(): void;
8289
}
8390
declare class ModalToolContainer extends BaseControl {
@@ -312,7 +319,9 @@ declare class BaseInputManager {
312319
eventDispatcher: ClientEventDispatcher;
313320
unregisterAllBindings(): void;
314321
}
315-
322+
/**
323+
* @beta
324+
*/
316325
export class GlobalInputManager extends BaseInputManager {
317326
registerKeyBinding(
318327
inputContextId: EditorInputContext,
@@ -323,10 +332,25 @@ export class GlobalInputManager extends BaseInputManager {
323332
}
324333

325334
declare class BuiltInUIManagerImpl {
335+
/**
336+
* Updates the visibility of the control demo
337+
*/
326338
updateUISettingsPanelVisibility(visibility: boolean): void;
339+
/**
340+
* Updates the visibility of the welcome panel
341+
*/
327342
updateWelcomePanelVisibility(visibility: boolean): void;
343+
/**
344+
* Navigates to the pause screen
345+
*/
328346
navigateToPauseScreen(): void;
347+
/**
348+
* Navigates to the documentation site
349+
*/
329350
navigateToDocumentation(): void;
351+
/**
352+
* Navigates to the feedback site
353+
*/
330354
navigateToFeedback(): void;
331355
}
332356

@@ -387,18 +411,40 @@ declare class PlayerUISession {
387411
get builtInUIManager(): BuiltInUIManagerImpl;
388412
get eventSubscriptionCache(): BedrockEventSubscriptionCache;
389413
}
390-
414+
/**
415+
* The types of actions that are supported. This type corresponds to the expected arguments
416+
* passed by the onExecute handler of an action.
417+
* @beta
418+
*/
391419
export enum ActionTypes {
392420
NoArgsAction = "NoArgsAction",
393421
MouseRayCastAction = "MouseRayCastAction",
394422
}
395-
423+
/**
424+
* A cache for bedrock event subscriptions. Stores off a subscription by event key, and upon
425+
* teardown unregisters all subscriptions.
426+
* @beta
427+
*/
396428
export class BedrockEventSubscriptionCache {
397429
constructor(mEvents: Events);
398-
subscribeToBedrockEvent(event: string, ...params: any[]): Function;
430+
/**
431+
* Subcribes to a bedrock event using the key of the desired event. When subscribed, the event handler
432+
* is both returned, but also cached internally for unsubscription. This means the caller of the subscription
433+
* does not need to worry about unsubscription since the cache will automatically unsubscribe handlers
434+
* on overall teardown.
435+
*
436+
* @param event - The event on the bedrock APIs to which to subscribe
437+
* @param params - The parameters to the subscription method for the event. Auto complete will display this for you
438+
*/
439+
subscribeToBedrockEvent<T extends keyof Events>(event: T, ...params: Parameters<Events[T]['subscribe']>): ReturnType<Events[T]['subscribe']>;
399440
teardown(): void;
441+
private mEvents: Events;
442+
private subscribedEvents: object;
400443
}
401-
444+
/**
445+
* Type of item that can be added to the property pane
446+
* @beta
447+
*/
402448
export enum EDITOR_PANE_PROPERTY_ITEM_TYPE {
403449
Number = "editorUI:Number",
404450
String = "editorUI:String",
@@ -410,24 +456,37 @@ export enum EDITOR_PANE_PROPERTY_ITEM_TYPE {
410456
Action = "editorUI:Action",
411457
Vec3 = "editorUI:Vec3",
412458
}
413-
459+
/**
460+
* @beta Global editor input contexts
461+
*/
414462
export enum EditorInputContext {
415463
GlobalEditor = "global.editor",
416464
GlobalToolMode = "global.toolMode",
417465
Viewport = "local.toolMode.viewport",
418466
}
419-
467+
/**
468+
* Types of events that may be sent by the server to the client side UX. These events each have their own
469+
* independent set of payloads in the message that may have a wide set of types of operations. This allows messages to
470+
* be sent with an EventType and Payload, but with easy type safe deduction of the payload type leveraging
471+
* discriminated unions and type fields.
472+
* @internal
473+
*/
420474
export enum EditorServerEventType {
421475
ServerActionEvents = "Editor::ServerActionEvents",
422476
ServerInputBindingEvents = "Editor::ServerInputBindingEvents",
423477
ServerUXEvents = "Editor::ServerUXEvents",
424478
}
425-
479+
/**
480+
* @beta
481+
*/
426482
export enum EditorStatusBarAlignment {
427483
Right = 0,
428484
Left = 1,
429485
}
430-
486+
/**
487+
* Input modifier flags to create chorded bindings
488+
* @beta
489+
*/
431490
export enum InputModifier {
432491
Unused = 0,
433492
None = 1,
@@ -436,11 +495,18 @@ export enum InputModifier {
436495
Shift = 8,
437496
Any = 15,
438497
}
498+
/**
499+
* Keyboard Key Actions
500+
* @beta
501+
*/
439502
export enum KeyInputType {
440503
Press = 1,
441504
Release = 2,
442505
}
443-
506+
/**
507+
* Keyboard key - Reference: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#constants_for_keycode_value
508+
* @beta
509+
*/
444510
export enum KeyboardKey {
445511
BACKSPACE = 8,
446512
TAB = 9,
@@ -535,20 +601,29 @@ export enum KeyboardKey {
535601
BRACKET_CLOSE = 221,
536602
QUOTE = 222,
537603
}
538-
604+
/**
605+
* Mouse device action categories
606+
* @beta
607+
*/
539608
export enum MouseActionCategory {
540609
Button = 1,
541610
Wheel = 2,
542611
Drag = 3,
543612
}
544-
613+
/**
614+
* Detailed mouse device actions
615+
* @beta
616+
*/
545617
export enum MouseActionType {
546618
LeftButton = 1,
547619
MiddleButton = 2,
548620
RightButton = 3,
549621
Wheel = 4,
550622
}
551-
623+
/**
624+
* Input event information about mouse actions
625+
* @beta
626+
*/
552627
export enum MouseInputType {
553628
ButtonDown = 1,
554629
ButtonUp = 2,
@@ -558,7 +633,10 @@ export enum MouseInputType {
558633
Drag = 6,
559634
DragEnd = 7,
560635
}
561-
636+
/**
637+
* The set of events that may be sent by the server side UI pertaining to actions
638+
* @internal
639+
*/
562640
export enum ServerUXEventType {
563641
UpdatePropertyPane = 1,
564642
DestroyPropertyPane = 2,
@@ -579,19 +657,40 @@ export enum ServerUXEventType {
579657
UpdateWelcomePanelVisibility_deprecated = 17,
580658
UpdateClientPanelVisibility = 18,
581659
}
582-
660+
/**
661+
* Takes the input object and bind it to the pane.
662+
* @beta
663+
*/
583664
export function createPaneBindingObject<T>(
584665
propertyPane: PropertyPane,
585666
target: T
586667
): T;
587-
668+
/**
669+
* Executes an operation over a selection via chunks to allow splitting operation over multiple game ticks
670+
* @param selection - the selection to iterator over
671+
* @param operation - the operation to apply over each block location
672+
* @beta
673+
*/
588674
export function executeLargeOperation(
589675
selection: Selection,
590676
operation: (blockLocation: Vector3) => void
591677
): Promise<void>;
592-
678+
/**
679+
* Adds the resource pack editor prefix and returns the full localization ID
680+
* @beta
681+
*/
593682
export function getLocalizationId(locId: string): string;
594-
683+
/**
684+
* Registers an editor extension into Minecraft. This function calls underlying functionality to register an extension but provides
685+
* helpful and contextual wrappers for individual client lifetimes. The onActivation function is called whenever a client
686+
* joins a session, while the shutdown is called when a client leaves. There may be other circumstances in which these are
687+
* called as well based on client state that is an implementation detail of the system.
688+
*
689+
* The generic type parameter exists as a mechanism for provide generic player contextual storage of data on the IPlayerUISession
690+
* object returned during activation. See IPlayerUISession for more information.
691+
*
692+
* @beta
693+
*/
595694
export function registerEditorExtension(
596695
extensionName: string,
597696
activationFunction?: (uiSession: PlayerUISession) => void,

scripts/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
},
1717
"types": [],
1818
"typeRoots": [],
19-
"noEmit": true,
2019
},
2120
"include": ["**/*.ts"]
2221
}

0 commit comments

Comments
 (0)