babylonjs-gui-editor 9.3.0 → 9.3.1

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.
@@ -3116,7 +3116,69 @@ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3116
3116
  * @param options The options for the tool.
3117
3117
  * @returns A token that can be used to dispose of the tool.
3118
3118
  */
3119
- export function MakeModularTool(options: ModularToolOptions): IDisposable;
3119
+ export function MakeModularTool(options: ModularToolOptions): {
3120
+ dispose: () => Promise<void>;
3121
+ };
3122
+
3123
+
3124
+
3125
+ }
3126
+ declare namespace BABYLON {
3127
+
3128
+
3129
+ }
3130
+ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3131
+ /**
3132
+ * Options for creating a modular bridge container.
3133
+ * @experimental
3134
+ * @internal
3135
+ */
3136
+ export type ModularBridgeOptions = {
3137
+ /**
3138
+ * WebSocket port for the bridge's browser port. Defaults to 4400.
3139
+ */
3140
+ port?: number;
3141
+ /**
3142
+ * Session display name reported to the bridge. Defaults to `document.title`.
3143
+ */
3144
+ name?: string;
3145
+ /**
3146
+ * Whether the bridge should automatically start trying to connect.
3147
+ * Defaults to false.
3148
+ */
3149
+ autoStart?: boolean;
3150
+ /**
3151
+ * Additional service definitions to register with the bridge container.
3152
+ */
3153
+ serviceDefinitions?: readonly BABYLON.GuiEditor.SharedUIComponents.WeaklyTypedServiceDefinition[];
3154
+ };
3155
+ /**
3156
+ * A token returned by {@link MakeModularBridge} that owns the headless
3157
+ * {@link BABYLON.GuiEditor.SharedUIComponents.ServiceContainer}. Dispose it to tear down the bridge and all services.
3158
+ * @experimental
3159
+ * @internal
3160
+ */
3161
+ export type ModularBridgeToken = IDisposable & {
3162
+ /**
3163
+ * The headless BABYLON.GuiEditor.SharedUIComponents.ServiceContainer that hosts the bridge.
3164
+ */
3165
+ readonly serviceContainer: BABYLON.GuiEditor.SharedUIComponents.ServiceContainer;
3166
+ /**
3167
+ * Whether this token has been disposed.
3168
+ */
3169
+ readonly isDisposed: boolean;
3170
+ };
3171
+ /**
3172
+ * Creates a headless {@link BABYLON.GuiEditor.SharedUIComponents.ServiceContainer} that hosts a bridge service.
3173
+ *
3174
+ * The returned token owns the container. Dispose it to tear down the bridge.
3175
+ *
3176
+ * @param options Optional configuration for the bridge.
3177
+ * @returns A {@link ModularBridgeToken} that owns the container.
3178
+ * @experimental
3179
+ * @internal
3180
+ */
3181
+ export function MakeModularBridge(options?: ModularBridgeOptions): ModularBridgeToken;
3120
3182
 
3121
3183
 
3122
3184
 
@@ -3636,6 +3698,376 @@ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3636
3698
 
3637
3699
 
3638
3700
 
3701
+ }
3702
+ declare namespace BABYLON {
3703
+
3704
+
3705
+ }
3706
+ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3707
+ /**
3708
+ * Serializable description of a command argument, used in protocol messages.
3709
+ */
3710
+ export type CommandArgInfo = {
3711
+ /** The name of the argument. */
3712
+ name: string;
3713
+ /** A human-readable description of the argument. */
3714
+ description: string;
3715
+ /** Whether this argument is required. */
3716
+ required?: boolean;
3717
+ /** The type of the argument. Defaults to "string". When "file", the CLI reads the file and sends its contents. */
3718
+ type?: "string" | "file";
3719
+ };
3720
+ /**
3721
+ * Serializable description of a command, used in protocol messages.
3722
+ */
3723
+ export type CommandInfo = {
3724
+ /** A unique identifier for the command. */
3725
+ id: string;
3726
+ /** A human-readable description of the command. */
3727
+ description: string;
3728
+ /** The arguments this command accepts. */
3729
+ args?: CommandArgInfo[];
3730
+ };
3731
+ /**
3732
+ * Serializable description of a session, used in protocol messages.
3733
+ */
3734
+ export type SessionInfo = {
3735
+ /** The numeric session identifier. */
3736
+ id: number;
3737
+ /** The display name of the session. */
3738
+ name: string;
3739
+ /** ISO 8601 timestamp of when the session connected. */
3740
+ connectedAt: string;
3741
+ };
3742
+ /**
3743
+ * CLI → Bridge: Request the list of active browser sessions.
3744
+ */
3745
+ export type SessionsRequest = {
3746
+ /** The message type discriminator. */
3747
+ type: "sessions";
3748
+ };
3749
+ /**
3750
+ * CLI → Bridge: Request the list of commands available from a session.
3751
+ */
3752
+ export type CommandsRequest = {
3753
+ /** The message type discriminator. */
3754
+ type: "commands";
3755
+ /** The session to query for commands. */
3756
+ sessionId: number;
3757
+ };
3758
+ /**
3759
+ * CLI → Bridge: Execute a command on a session.
3760
+ */
3761
+ export type ExecRequest = {
3762
+ /** The message type discriminator. */
3763
+ type: "exec";
3764
+ /** The session to execute the command on. */
3765
+ sessionId: number;
3766
+ /** The identifier of the command to execute. */
3767
+ commandId: string;
3768
+ /** Key-value pairs of arguments for the command. */
3769
+ args: Record<string, string>;
3770
+ };
3771
+ /**
3772
+ * CLI → Bridge: Stop the bridge process.
3773
+ */
3774
+ export type StopRequest = {
3775
+ /** The message type discriminator. */
3776
+ type: "stop";
3777
+ };
3778
+ /**
3779
+ * All messages that the CLI sends to the bridge.
3780
+ */
3781
+ export type CliRequest = SessionsRequest | CommandsRequest | ExecRequest | StopRequest;
3782
+ /**
3783
+ * Bridge → CLI: Response with the list of active sessions.
3784
+ */
3785
+ export type SessionsResponse = {
3786
+ /** The message type discriminator. */
3787
+ type: "sessionsResponse";
3788
+ /** The list of active sessions. */
3789
+ sessions: SessionInfo[];
3790
+ };
3791
+ /**
3792
+ * Bridge → CLI: Response with the list of commands from a session.
3793
+ */
3794
+ export type CommandsResponse = {
3795
+ /** The message type discriminator. */
3796
+ type: "commandsResponse";
3797
+ /** The list of available commands, if successful. */
3798
+ commands?: CommandInfo[];
3799
+ /** An error message, if the request failed. */
3800
+ error?: string;
3801
+ };
3802
+ /**
3803
+ * Bridge → CLI: Response with the result of a command execution.
3804
+ */
3805
+ export type ExecResponse = {
3806
+ /** The message type discriminator. */
3807
+ type: "execResponse";
3808
+ /** The result of the command execution, if successful. */
3809
+ result?: string;
3810
+ /** An error message, if the execution failed. */
3811
+ error?: string;
3812
+ };
3813
+ /**
3814
+ * Bridge → CLI: Acknowledgement that the bridge is stopping.
3815
+ */
3816
+ export type StopResponse = {
3817
+ /** The message type discriminator. */
3818
+ type: "stopResponse";
3819
+ /** Whether the bridge stopped successfully. */
3820
+ success: boolean;
3821
+ };
3822
+ /**
3823
+ * All messages that the bridge sends to the CLI.
3824
+ */
3825
+ export type CliResponse = SessionsResponse | CommandsResponse | ExecResponse | StopResponse;
3826
+ /**
3827
+ * Browser → Bridge: Register a new session.
3828
+ */
3829
+ export type RegisterRequest = {
3830
+ /** The message type discriminator. */
3831
+ type: "register";
3832
+ /** The display name for this session. */
3833
+ name: string;
3834
+ };
3835
+ /**
3836
+ * Browser → Bridge: Response to a listCommands request from the bridge.
3837
+ */
3838
+ export type CommandListResponse = {
3839
+ /** The message type discriminator. */
3840
+ type: "commandListResponse";
3841
+ /** The identifier of the original request. */
3842
+ requestId: string;
3843
+ /** The list of registered commands. */
3844
+ commands: CommandInfo[];
3845
+ };
3846
+ /**
3847
+ * Browser → Bridge: Response to an execCommand request from the bridge.
3848
+ */
3849
+ export type CommandResponse = {
3850
+ /** The message type discriminator. */
3851
+ type: "commandResponse";
3852
+ /** The identifier of the original request. */
3853
+ requestId: string;
3854
+ /** The result of the command execution, if successful. */
3855
+ result?: string;
3856
+ /** An error message, if the execution failed. */
3857
+ error?: string;
3858
+ };
3859
+ /**
3860
+ * Browser → Bridge: Response to a getInfo request from the bridge.
3861
+ */
3862
+ export type InfoResponse = {
3863
+ /** The message type discriminator. */
3864
+ type: "infoResponse";
3865
+ /** The identifier of the original request. */
3866
+ requestId: string;
3867
+ /** The current display name of the session. */
3868
+ name: string;
3869
+ };
3870
+ /**
3871
+ * All messages that the browser sends to the bridge.
3872
+ */
3873
+ export type BrowserRequest = RegisterRequest | CommandListResponse | CommandResponse | InfoResponse;
3874
+ /**
3875
+ * Bridge → Browser: Request the list of registered commands.
3876
+ */
3877
+ export type ListCommandsRequest = {
3878
+ /** The message type discriminator. */
3879
+ type: "listCommands";
3880
+ /** A unique identifier for this request. */
3881
+ requestId: string;
3882
+ };
3883
+ /**
3884
+ * Bridge → Browser: Request execution of a command.
3885
+ */
3886
+ export type ExecCommandRequest = {
3887
+ /** The message type discriminator. */
3888
+ type: "execCommand";
3889
+ /** A unique identifier for this request. */
3890
+ requestId: string;
3891
+ /** The identifier of the command to execute. */
3892
+ commandId: string;
3893
+ /** Key-value pairs of arguments for the command. */
3894
+ args: Record<string, string>;
3895
+ };
3896
+ /**
3897
+ * Bridge → Browser: Request current session information.
3898
+ */
3899
+ export type GetInfoRequest = {
3900
+ /** The message type discriminator. */
3901
+ type: "getInfo";
3902
+ /** A unique identifier for this request. */
3903
+ requestId: string;
3904
+ };
3905
+ /**
3906
+ * All messages that the bridge sends to the browser.
3907
+ */
3908
+ export type BrowserResponse = ListCommandsRequest | ExecCommandRequest | GetInfoRequest;
3909
+
3910
+
3911
+
3912
+ }
3913
+ declare namespace BABYLON {
3914
+
3915
+
3916
+ }
3917
+ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3918
+ /**
3919
+ * Options for the CLI bridge service.
3920
+ * @experimental
3921
+ * @internal
3922
+ */
3923
+ export type BridgeServiceOptions = {
3924
+ /**
3925
+ * The WebSocket port for the bridge's browser port.
3926
+ */
3927
+ port: number;
3928
+ /**
3929
+ * The session display name sent to the bridge.
3930
+ * Can be a getter to provide a dynamic value that is re-read
3931
+ * each time the bridge queries session information.
3932
+ */
3933
+ name: string;
3934
+ /**
3935
+ * Whether to automatically start connecting when the service is created.
3936
+ */
3937
+ autoStart: boolean;
3938
+ };
3939
+ /**
3940
+ * Creates the service definition for the CLI Bridge Service.
3941
+ * @param options The options for connecting to the bridge.
3942
+ * @returns A service definition that produces an BABYLON.GuiEditor.SharedUIComponents.IBridgeCommandRegistry and BABYLON.GuiEditor.SharedUIComponents.ICliConnectionStatus.
3943
+ * @experimental
3944
+ * @internal
3945
+ */
3946
+ export function MakeBridgeServiceDefinition(options: BridgeServiceOptions): BABYLON.GuiEditor.SharedUIComponents.ServiceDefinition<[IBridgeCommandRegistry, BABYLON.GuiEditor.SharedUIComponents.ICliConnectionStatus], []>;
3947
+
3948
+
3949
+
3950
+ }
3951
+ declare namespace BABYLON {
3952
+
3953
+
3954
+ }
3955
+ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3956
+ /**
3957
+ * The service identity for the CLI connection status.
3958
+ * @experimental
3959
+ * @internal
3960
+ */
3961
+ export var CliConnectionStatusIdentity: unique symbol;
3962
+ /**
3963
+ * Provides the connection status and enable/disable control for the CLI bridge.
3964
+ * @experimental
3965
+ * @internal
3966
+ */
3967
+ export interface ICliConnectionStatus extends BABYLON.GuiEditor.SharedUIComponents.IService<typeof CliConnectionStatusIdentity> {
3968
+ /**
3969
+ * Whether the bridge is enabled. When true, the bridge actively tries to
3970
+ * maintain a WebSocket connection. When false, the bridge is disconnected
3971
+ * and idle.
3972
+ */
3973
+ isEnabled: boolean;
3974
+ /**
3975
+ * Whether the bridge WebSocket is currently connected.
3976
+ */
3977
+ readonly isConnected: boolean;
3978
+ /**
3979
+ * Observable that fires when either {@link isEnabled} or {@link isConnected} changes.
3980
+ */
3981
+ readonly onConnectionStatusChanged: IReadonlyObservable<void>;
3982
+ }
3983
+
3984
+
3985
+
3986
+ }
3987
+ declare namespace BABYLON {
3988
+
3989
+
3990
+ }
3991
+ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3992
+ /**
3993
+ * The type of a bridge command argument, which determines how
3994
+ * the CLI processes the value before sending it to the browser.
3995
+ * @experimental
3996
+ * @internal
3997
+ */
3998
+ export type BridgeCommandArgType = "string" | "file";
3999
+ /**
4000
+ * Describes an argument for a bridge command.
4001
+ * @experimental
4002
+ * @internal
4003
+ */
4004
+ export type BridgeCommandArg = {
4005
+ /**
4006
+ * The name of the argument.
4007
+ */
4008
+ name: string;
4009
+ /**
4010
+ * A description of the argument.
4011
+ */
4012
+ description: string;
4013
+ /**
4014
+ * Whether the argument is required.
4015
+ */
4016
+ required?: boolean;
4017
+ /**
4018
+ * The type of the argument. Defaults to "string".
4019
+ * When set to "file", the CLI reads the file at the given path
4020
+ * and passes its contents as the argument value.
4021
+ */
4022
+ type?: BridgeCommandArgType;
4023
+ };
4024
+ /**
4025
+ * Describes a command that can be invoked from the bridge.
4026
+ * @experimental
4027
+ * @internal
4028
+ */
4029
+ export type BridgeCommandDescriptor = {
4030
+ /**
4031
+ * A unique identifier for the command.
4032
+ */
4033
+ id: string;
4034
+ /**
4035
+ * A human-readable description of what the command does.
4036
+ */
4037
+ description: string;
4038
+ /**
4039
+ * The arguments that this command accepts.
4040
+ */
4041
+ args?: BridgeCommandArg[];
4042
+ /**
4043
+ * Executes the command with the given arguments and returns a result string.
4044
+ * @param args A map of argument names to their values.
4045
+ * @returns A promise that resolves to the result string.
4046
+ */
4047
+ executeAsync: (args: Record<string, string>) => Promise<string>;
4048
+ };
4049
+ /**
4050
+ * The service identity for the bridge command registry.
4051
+ * @experimental
4052
+ * @internal
4053
+ */
4054
+ export var BridgeCommandRegistryIdentity: unique symbol;
4055
+ /**
4056
+ * A registry for commands that can be invoked from the bridge.
4057
+ * @experimental
4058
+ * @internal
4059
+ */
4060
+ export interface IBridgeCommandRegistry extends BABYLON.GuiEditor.SharedUIComponents.IService<typeof BridgeCommandRegistryIdentity> {
4061
+ /**
4062
+ * Registers a command that can be invoked from the bridge.
4063
+ * @param descriptor The command descriptor.
4064
+ * @returns A disposable token that unregisters the command when disposed.
4065
+ */
4066
+ addCommand(descriptor: BridgeCommandDescriptor): IDisposable;
4067
+ }
4068
+
4069
+
4070
+
3639
4071
  }
3640
4072
  declare namespace BABYLON {
3641
4073
 
@@ -3663,14 +4095,13 @@ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3663
4095
  [Index in keyof ServiceContracts]: ExtractContractIdentity<ServiceContracts[Index]>;
3664
4096
  };
3665
4097
  type UnionToIntersection<Union> = (Union extends any ? (k: Union) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
3666
- type MaybePromise<T> = T | Promise<T>;
3667
4098
  /**
3668
4099
  * A factory function responsible for creating a service instance.
3669
4100
  * Consumed services are passed as arguments to the factory function.
3670
- * The returned value must implement all produced services, and may IDisposable.
3671
- * If not services are produced, the returned value may implement IDisposable, otherwise it may return void.
4101
+ * The returned value must implement all produced services, and may implement IDisposable.
4102
+ * If no services are produced, the returned value may implement IDisposable, otherwise it may return void.
3672
4103
  */
3673
- export type ServiceFactory<Produces extends IService<symbol>[], Consumes extends IService<symbol>[]> = (...dependencies: [...Consumes, abortSignal?: AbortSignal]) => MaybePromise<Produces extends [] ? Partial<IDisposable> | void : Partial<IDisposable> & UnionToIntersection<Produces[number]>>;
4104
+ export type ServiceFactory<Produces extends IService<symbol>[], Consumes extends IService<symbol>[]> = (...dependencies: [...Consumes]) => Produces extends [] ? Partial<IDisposable> | void : Partial<IDisposable> & UnionToIntersection<Produces[number]>;
3674
4105
  /**
3675
4106
  * Defines a service, which is a logical unit that consumes other services (dependencies), and optionally produces services that can be consumed by other services (dependents).
3676
4107
  */
@@ -3739,20 +4170,19 @@ declare namespace BABYLON.GuiEditor.SharedUIComponents {
3739
4170
  */
3740
4171
  constructor(_friendlyName: string, _parent?: ServiceContainer | undefined);
3741
4172
  /**
3742
- * Adds a set of service definitions in the service container.
4173
+ * Adds a set of service definitions to the service container.
3743
4174
  * The services are sorted based on their dependencies.
3744
- * @param args The service definitions to register, and optionally an abort signal.
3745
- * @returns A disposable that will remove the service definition from the service container.
4175
+ * @param serviceDefinitions The service definitions to register.
4176
+ * @returns A disposable that will remove the service definitions from the service container.
3746
4177
  */
3747
- addServicesAsync(...args: WeaklyTypedServiceDefinition[] | [...serviceDefinitions: WeaklyTypedServiceDefinition[], abortSignal: AbortSignal]): Promise<IDisposable>;
4178
+ addServices(...serviceDefinitions: WeaklyTypedServiceDefinition[]): IDisposable;
3748
4179
  /**
3749
4180
  * Registers a service definition in the service container.
3750
4181
  * @param serviceDefinition The service definition to register.
3751
- * @param abortSignal An optional abort signal.
3752
4182
  * @returns A disposable that will remove the service definition from the service container.
3753
4183
  */
3754
- addServiceAsync<Produces extends BABYLON.GuiEditor.SharedUIComponents.IService<symbol>[] = [], Consumes extends BABYLON.GuiEditor.SharedUIComponents.IService<symbol>[] = []>(serviceDefinition: BABYLON.GuiEditor.SharedUIComponents.ServiceDefinition<Produces, Consumes>, abortSignal?: AbortSignal): Promise<IDisposable>;
3755
- private _addServiceAsync;
4184
+ addService<Produces extends BABYLON.GuiEditor.SharedUIComponents.IService<symbol>[] = [], Consumes extends BABYLON.GuiEditor.SharedUIComponents.IService<symbol>[] = []>(serviceDefinition: BABYLON.GuiEditor.SharedUIComponents.ServiceDefinition<Produces, Consumes>): IDisposable;
4185
+ private _addService;
3756
4186
  /**
3757
4187
  * Resolves a dependency by contract identity for a consuming service.
3758
4188
  * Checks local services first, then walks up the parent chain.