@babylonjs/node-geometry-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.
@@ -2805,7 +2805,6 @@ export interface IDisplayManager {
2805
2805
 
2806
2806
  }
2807
2807
  declare module "@babylonjs/node-geometry-editor/modularTool/modularTool" {
2808
- import { IDisposable } from "@babylonjs/core/index";
2809
2808
  import { IExtensionFeed } from "@babylonjs/node-geometry-editor/modularTool/extensibility/extensionFeed";
2810
2809
  import { WeaklyTypedServiceDefinition, ServiceContainer } from "@babylonjs/node-geometry-editor/modularTool/modularity/serviceContainer";
2811
2810
  import { ShellServiceOptions } from "@babylonjs/node-geometry-editor/modularTool/services/shellService";
@@ -2846,7 +2845,65 @@ export type ModularToolOptions = {
2846
2845
  * @param options The options for the tool.
2847
2846
  * @returns A token that can be used to dispose of the tool.
2848
2847
  */
2849
- export function MakeModularTool(options: ModularToolOptions): IDisposable;
2848
+ export function MakeModularTool(options: ModularToolOptions): {
2849
+ dispose: () => Promise<void>;
2850
+ };
2851
+
2852
+ }
2853
+ declare module "@babylonjs/node-geometry-editor/modularTool/modularBridge" {
2854
+ import { IDisposable } from "@babylonjs/core/index";
2855
+ import { WeaklyTypedServiceDefinition, ServiceContainer } from "@babylonjs/node-geometry-editor/modularTool/modularity/serviceContainer";
2856
+ /**
2857
+ * Options for creating a modular bridge container.
2858
+ * @experimental
2859
+ * @internal
2860
+ */
2861
+ export type ModularBridgeOptions = {
2862
+ /**
2863
+ * WebSocket port for the bridge's browser port. Defaults to 4400.
2864
+ */
2865
+ port?: number;
2866
+ /**
2867
+ * Session display name reported to the bridge. Defaults to `document.title`.
2868
+ */
2869
+ name?: string;
2870
+ /**
2871
+ * Whether the bridge should automatically start trying to connect.
2872
+ * Defaults to false.
2873
+ */
2874
+ autoStart?: boolean;
2875
+ /**
2876
+ * Additional service definitions to register with the bridge container.
2877
+ */
2878
+ serviceDefinitions?: readonly WeaklyTypedServiceDefinition[];
2879
+ };
2880
+ /**
2881
+ * A token returned by {@link MakeModularBridge} that owns the headless
2882
+ * {@link ServiceContainer}. Dispose it to tear down the bridge and all services.
2883
+ * @experimental
2884
+ * @internal
2885
+ */
2886
+ export type ModularBridgeToken = IDisposable & {
2887
+ /**
2888
+ * The headless ServiceContainer that hosts the bridge.
2889
+ */
2890
+ readonly serviceContainer: ServiceContainer;
2891
+ /**
2892
+ * Whether this token has been disposed.
2893
+ */
2894
+ readonly isDisposed: boolean;
2895
+ };
2896
+ /**
2897
+ * Creates a headless {@link ServiceContainer} that hosts a bridge service.
2898
+ *
2899
+ * The returned token owns the container. Dispose it to tear down the bridge.
2900
+ *
2901
+ * @param options Optional configuration for the bridge.
2902
+ * @returns A {@link ModularBridgeToken} that owns the container.
2903
+ * @experimental
2904
+ * @internal
2905
+ */
2906
+ export function MakeModularBridge(options?: ModularBridgeOptions): ModularBridgeToken;
2850
2907
 
2851
2908
  }
2852
2909
  declare module "@babylonjs/node-geometry-editor/modularTool/themes/babylonTheme" {
@@ -3326,6 +3383,359 @@ import { ServiceDefinition } from "@babylonjs/node-geometry-editor/modularTool/m
3326
3383
  import { IShellService } from "@babylonjs/node-geometry-editor/modularTool/services/shellService";
3327
3384
  export const ExtensionListServiceDefinition: ServiceDefinition<[], [IShellService]>;
3328
3385
 
3386
+ }
3387
+ declare module "@babylonjs/node-geometry-editor/modularTool/services/cli/protocol" {
3388
+ /**
3389
+ * Serializable description of a command argument, used in protocol messages.
3390
+ */
3391
+ export type CommandArgInfo = {
3392
+ /** The name of the argument. */
3393
+ name: string;
3394
+ /** A human-readable description of the argument. */
3395
+ description: string;
3396
+ /** Whether this argument is required. */
3397
+ required?: boolean;
3398
+ /** The type of the argument. Defaults to "string". When "file", the CLI reads the file and sends its contents. */
3399
+ type?: "string" | "file";
3400
+ };
3401
+ /**
3402
+ * Serializable description of a command, used in protocol messages.
3403
+ */
3404
+ export type CommandInfo = {
3405
+ /** A unique identifier for the command. */
3406
+ id: string;
3407
+ /** A human-readable description of the command. */
3408
+ description: string;
3409
+ /** The arguments this command accepts. */
3410
+ args?: CommandArgInfo[];
3411
+ };
3412
+ /**
3413
+ * Serializable description of a session, used in protocol messages.
3414
+ */
3415
+ export type SessionInfo = {
3416
+ /** The numeric session identifier. */
3417
+ id: number;
3418
+ /** The display name of the session. */
3419
+ name: string;
3420
+ /** ISO 8601 timestamp of when the session connected. */
3421
+ connectedAt: string;
3422
+ };
3423
+ /**
3424
+ * CLI → Bridge: Request the list of active browser sessions.
3425
+ */
3426
+ export type SessionsRequest = {
3427
+ /** The message type discriminator. */
3428
+ type: "sessions";
3429
+ };
3430
+ /**
3431
+ * CLI → Bridge: Request the list of commands available from a session.
3432
+ */
3433
+ export type CommandsRequest = {
3434
+ /** The message type discriminator. */
3435
+ type: "commands";
3436
+ /** The session to query for commands. */
3437
+ sessionId: number;
3438
+ };
3439
+ /**
3440
+ * CLI → Bridge: Execute a command on a session.
3441
+ */
3442
+ export type ExecRequest = {
3443
+ /** The message type discriminator. */
3444
+ type: "exec";
3445
+ /** The session to execute the command on. */
3446
+ sessionId: number;
3447
+ /** The identifier of the command to execute. */
3448
+ commandId: string;
3449
+ /** Key-value pairs of arguments for the command. */
3450
+ args: Record<string, string>;
3451
+ };
3452
+ /**
3453
+ * CLI → Bridge: Stop the bridge process.
3454
+ */
3455
+ export type StopRequest = {
3456
+ /** The message type discriminator. */
3457
+ type: "stop";
3458
+ };
3459
+ /**
3460
+ * All messages that the CLI sends to the bridge.
3461
+ */
3462
+ export type CliRequest = SessionsRequest | CommandsRequest | ExecRequest | StopRequest;
3463
+ /**
3464
+ * Bridge → CLI: Response with the list of active sessions.
3465
+ */
3466
+ export type SessionsResponse = {
3467
+ /** The message type discriminator. */
3468
+ type: "sessionsResponse";
3469
+ /** The list of active sessions. */
3470
+ sessions: SessionInfo[];
3471
+ };
3472
+ /**
3473
+ * Bridge → CLI: Response with the list of commands from a session.
3474
+ */
3475
+ export type CommandsResponse = {
3476
+ /** The message type discriminator. */
3477
+ type: "commandsResponse";
3478
+ /** The list of available commands, if successful. */
3479
+ commands?: CommandInfo[];
3480
+ /** An error message, if the request failed. */
3481
+ error?: string;
3482
+ };
3483
+ /**
3484
+ * Bridge → CLI: Response with the result of a command execution.
3485
+ */
3486
+ export type ExecResponse = {
3487
+ /** The message type discriminator. */
3488
+ type: "execResponse";
3489
+ /** The result of the command execution, if successful. */
3490
+ result?: string;
3491
+ /** An error message, if the execution failed. */
3492
+ error?: string;
3493
+ };
3494
+ /**
3495
+ * Bridge → CLI: Acknowledgement that the bridge is stopping.
3496
+ */
3497
+ export type StopResponse = {
3498
+ /** The message type discriminator. */
3499
+ type: "stopResponse";
3500
+ /** Whether the bridge stopped successfully. */
3501
+ success: boolean;
3502
+ };
3503
+ /**
3504
+ * All messages that the bridge sends to the CLI.
3505
+ */
3506
+ export type CliResponse = SessionsResponse | CommandsResponse | ExecResponse | StopResponse;
3507
+ /**
3508
+ * Browser → Bridge: Register a new session.
3509
+ */
3510
+ export type RegisterRequest = {
3511
+ /** The message type discriminator. */
3512
+ type: "register";
3513
+ /** The display name for this session. */
3514
+ name: string;
3515
+ };
3516
+ /**
3517
+ * Browser → Bridge: Response to a listCommands request from the bridge.
3518
+ */
3519
+ export type CommandListResponse = {
3520
+ /** The message type discriminator. */
3521
+ type: "commandListResponse";
3522
+ /** The identifier of the original request. */
3523
+ requestId: string;
3524
+ /** The list of registered commands. */
3525
+ commands: CommandInfo[];
3526
+ };
3527
+ /**
3528
+ * Browser → Bridge: Response to an execCommand request from the bridge.
3529
+ */
3530
+ export type CommandResponse = {
3531
+ /** The message type discriminator. */
3532
+ type: "commandResponse";
3533
+ /** The identifier of the original request. */
3534
+ requestId: string;
3535
+ /** The result of the command execution, if successful. */
3536
+ result?: string;
3537
+ /** An error message, if the execution failed. */
3538
+ error?: string;
3539
+ };
3540
+ /**
3541
+ * Browser → Bridge: Response to a getInfo request from the bridge.
3542
+ */
3543
+ export type InfoResponse = {
3544
+ /** The message type discriminator. */
3545
+ type: "infoResponse";
3546
+ /** The identifier of the original request. */
3547
+ requestId: string;
3548
+ /** The current display name of the session. */
3549
+ name: string;
3550
+ };
3551
+ /**
3552
+ * All messages that the browser sends to the bridge.
3553
+ */
3554
+ export type BrowserRequest = RegisterRequest | CommandListResponse | CommandResponse | InfoResponse;
3555
+ /**
3556
+ * Bridge → Browser: Request the list of registered commands.
3557
+ */
3558
+ export type ListCommandsRequest = {
3559
+ /** The message type discriminator. */
3560
+ type: "listCommands";
3561
+ /** A unique identifier for this request. */
3562
+ requestId: string;
3563
+ };
3564
+ /**
3565
+ * Bridge → Browser: Request execution of a command.
3566
+ */
3567
+ export type ExecCommandRequest = {
3568
+ /** The message type discriminator. */
3569
+ type: "execCommand";
3570
+ /** A unique identifier for this request. */
3571
+ requestId: string;
3572
+ /** The identifier of the command to execute. */
3573
+ commandId: string;
3574
+ /** Key-value pairs of arguments for the command. */
3575
+ args: Record<string, string>;
3576
+ };
3577
+ /**
3578
+ * Bridge → Browser: Request current session information.
3579
+ */
3580
+ export type GetInfoRequest = {
3581
+ /** The message type discriminator. */
3582
+ type: "getInfo";
3583
+ /** A unique identifier for this request. */
3584
+ requestId: string;
3585
+ };
3586
+ /**
3587
+ * All messages that the bridge sends to the browser.
3588
+ */
3589
+ export type BrowserResponse = ListCommandsRequest | ExecCommandRequest | GetInfoRequest;
3590
+
3591
+ }
3592
+ declare module "@babylonjs/node-geometry-editor/modularTool/services/cli/bridgeService" {
3593
+ import { ServiceDefinition } from "@babylonjs/node-geometry-editor/modularTool/modularity/serviceDefinition";
3594
+ import { ICliConnectionStatus } from "@babylonjs/node-geometry-editor/modularTool/services/cli/bridgeConnectionStatus";
3595
+ import { IBridgeCommandRegistry } from "@babylonjs/node-geometry-editor/modularTool/services/cli/bridgeCommandRegistry";
3596
+ /**
3597
+ * Options for the CLI bridge service.
3598
+ * @experimental
3599
+ * @internal
3600
+ */
3601
+ export type BridgeServiceOptions = {
3602
+ /**
3603
+ * The WebSocket port for the bridge's browser port.
3604
+ */
3605
+ port: number;
3606
+ /**
3607
+ * The session display name sent to the bridge.
3608
+ * Can be a getter to provide a dynamic value that is re-read
3609
+ * each time the bridge queries session information.
3610
+ */
3611
+ name: string;
3612
+ /**
3613
+ * Whether to automatically start connecting when the service is created.
3614
+ */
3615
+ autoStart: boolean;
3616
+ };
3617
+ /**
3618
+ * Creates the service definition for the CLI Bridge Service.
3619
+ * @param options The options for connecting to the bridge.
3620
+ * @returns A service definition that produces an IBridgeCommandRegistry and ICliConnectionStatus.
3621
+ * @experimental
3622
+ * @internal
3623
+ */
3624
+ export function MakeBridgeServiceDefinition(options: BridgeServiceOptions): ServiceDefinition<[IBridgeCommandRegistry, ICliConnectionStatus], []>;
3625
+
3626
+ }
3627
+ declare module "@babylonjs/node-geometry-editor/modularTool/services/cli/bridgeConnectionStatus" {
3628
+ import { IReadonlyObservable } from "@babylonjs/core/index";
3629
+ import { IService } from "@babylonjs/node-geometry-editor/modularTool/modularity/serviceDefinition";
3630
+ /**
3631
+ * The service identity for the CLI connection status.
3632
+ * @experimental
3633
+ * @internal
3634
+ */
3635
+ export const CliConnectionStatusIdentity: unique symbol;
3636
+ /**
3637
+ * Provides the connection status and enable/disable control for the CLI bridge.
3638
+ * @experimental
3639
+ * @internal
3640
+ */
3641
+ export interface ICliConnectionStatus extends IService<typeof CliConnectionStatusIdentity> {
3642
+ /**
3643
+ * Whether the bridge is enabled. When true, the bridge actively tries to
3644
+ * maintain a WebSocket connection. When false, the bridge is disconnected
3645
+ * and idle.
3646
+ */
3647
+ isEnabled: boolean;
3648
+ /**
3649
+ * Whether the bridge WebSocket is currently connected.
3650
+ */
3651
+ readonly isConnected: boolean;
3652
+ /**
3653
+ * Observable that fires when either {@link isEnabled} or {@link isConnected} changes.
3654
+ */
3655
+ readonly onConnectionStatusChanged: IReadonlyObservable<void>;
3656
+ }
3657
+
3658
+ }
3659
+ declare module "@babylonjs/node-geometry-editor/modularTool/services/cli/bridgeCommandRegistry" {
3660
+ import { IDisposable } from "@babylonjs/core/index";
3661
+ import { IService } from "@babylonjs/node-geometry-editor/modularTool/modularity/serviceDefinition";
3662
+ /**
3663
+ * The type of a bridge command argument, which determines how
3664
+ * the CLI processes the value before sending it to the browser.
3665
+ * @experimental
3666
+ * @internal
3667
+ */
3668
+ export type BridgeCommandArgType = "string" | "file";
3669
+ /**
3670
+ * Describes an argument for a bridge command.
3671
+ * @experimental
3672
+ * @internal
3673
+ */
3674
+ export type BridgeCommandArg = {
3675
+ /**
3676
+ * The name of the argument.
3677
+ */
3678
+ name: string;
3679
+ /**
3680
+ * A description of the argument.
3681
+ */
3682
+ description: string;
3683
+ /**
3684
+ * Whether the argument is required.
3685
+ */
3686
+ required?: boolean;
3687
+ /**
3688
+ * The type of the argument. Defaults to "string".
3689
+ * When set to "file", the CLI reads the file at the given path
3690
+ * and passes its contents as the argument value.
3691
+ */
3692
+ type?: BridgeCommandArgType;
3693
+ };
3694
+ /**
3695
+ * Describes a command that can be invoked from the bridge.
3696
+ * @experimental
3697
+ * @internal
3698
+ */
3699
+ export type BridgeCommandDescriptor = {
3700
+ /**
3701
+ * A unique identifier for the command.
3702
+ */
3703
+ id: string;
3704
+ /**
3705
+ * A human-readable description of what the command does.
3706
+ */
3707
+ description: string;
3708
+ /**
3709
+ * The arguments that this command accepts.
3710
+ */
3711
+ args?: BridgeCommandArg[];
3712
+ /**
3713
+ * Executes the command with the given arguments and returns a result string.
3714
+ * @param args A map of argument names to their values.
3715
+ * @returns A promise that resolves to the result string.
3716
+ */
3717
+ executeAsync: (args: Record<string, string>) => Promise<string>;
3718
+ };
3719
+ /**
3720
+ * The service identity for the bridge command registry.
3721
+ * @experimental
3722
+ * @internal
3723
+ */
3724
+ export const BridgeCommandRegistryIdentity: unique symbol;
3725
+ /**
3726
+ * A registry for commands that can be invoked from the bridge.
3727
+ * @experimental
3728
+ * @internal
3729
+ */
3730
+ export interface IBridgeCommandRegistry extends IService<typeof BridgeCommandRegistryIdentity> {
3731
+ /**
3732
+ * Registers a command that can be invoked from the bridge.
3733
+ * @param descriptor The command descriptor.
3734
+ * @returns A disposable token that unregisters the command when disposed.
3735
+ */
3736
+ addCommand(descriptor: BridgeCommandDescriptor): IDisposable;
3737
+ }
3738
+
3329
3739
  }
3330
3740
  declare module "@babylonjs/node-geometry-editor/modularTool/modularity/serviceDefinition" {
3331
3741
  import { IDisposable } from "@babylonjs/core/index";
@@ -3350,14 +3760,13 @@ type ExtractContractIdentities<ServiceContracts extends IService<symbol>[]> = {
3350
3760
  [Index in keyof ServiceContracts]: ExtractContractIdentity<ServiceContracts[Index]>;
3351
3761
  };
3352
3762
  type UnionToIntersection<Union> = (Union extends any ? (k: Union) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
3353
- type MaybePromise<T> = T | Promise<T>;
3354
3763
  /**
3355
3764
  * A factory function responsible for creating a service instance.
3356
3765
  * Consumed services are passed as arguments to the factory function.
3357
- * The returned value must implement all produced services, and may IDisposable.
3358
- * If not services are produced, the returned value may implement IDisposable, otherwise it may return void.
3766
+ * The returned value must implement all produced services, and may implement IDisposable.
3767
+ * If no services are produced, the returned value may implement IDisposable, otherwise it may return void.
3359
3768
  */
3360
- 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]>>;
3769
+ export type ServiceFactory<Produces extends IService<symbol>[], Consumes extends IService<symbol>[]> = (...dependencies: [...Consumes]) => Produces extends [] ? Partial<IDisposable> | void : Partial<IDisposable> & UnionToIntersection<Produces[number]>;
3361
3770
  /**
3362
3771
  * 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).
3363
3772
  */
@@ -3423,20 +3832,19 @@ export class ServiceContainer implements IDisposable {
3423
3832
  */
3424
3833
  constructor(_friendlyName: string, _parent?: ServiceContainer | undefined);
3425
3834
  /**
3426
- * Adds a set of service definitions in the service container.
3835
+ * Adds a set of service definitions to the service container.
3427
3836
  * The services are sorted based on their dependencies.
3428
- * @param args The service definitions to register, and optionally an abort signal.
3429
- * @returns A disposable that will remove the service definition from the service container.
3837
+ * @param serviceDefinitions The service definitions to register.
3838
+ * @returns A disposable that will remove the service definitions from the service container.
3430
3839
  */
3431
- addServicesAsync(...args: WeaklyTypedServiceDefinition[] | [...serviceDefinitions: WeaklyTypedServiceDefinition[], abortSignal: AbortSignal]): Promise<IDisposable>;
3840
+ addServices(...serviceDefinitions: WeaklyTypedServiceDefinition[]): IDisposable;
3432
3841
  /**
3433
3842
  * Registers a service definition in the service container.
3434
3843
  * @param serviceDefinition The service definition to register.
3435
- * @param abortSignal An optional abort signal.
3436
3844
  * @returns A disposable that will remove the service definition from the service container.
3437
3845
  */
3438
- addServiceAsync<Produces extends IService<symbol>[] = [], Consumes extends IService<symbol>[] = []>(serviceDefinition: ServiceDefinition<Produces, Consumes>, abortSignal?: AbortSignal): Promise<IDisposable>;
3439
- private _addServiceAsync;
3846
+ addService<Produces extends IService<symbol>[] = [], Consumes extends IService<symbol>[] = []>(serviceDefinition: ServiceDefinition<Produces, Consumes>): IDisposable;
3847
+ private _addService;
3440
3848
  /**
3441
3849
  * Resolves a dependency by contract identity for a consuming service.
3442
3850
  * Checks local services first, then walks up the parent chain.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/node-geometry-editor",
3
- "version": "9.3.0",
3
+ "version": "9.3.1",
4
4
  "main": "dist/babylon.nodeGeometryEditor.js",
5
5
  "module": "dist/babylon.nodeGeometryEditor.js",
6
6
  "esnext": "dist/babylon.nodeGeometryEditor.js",
@@ -23,7 +23,7 @@
23
23
  "@types/react-dom": ">=16.0.9"
24
24
  },
25
25
  "devDependencies": {
26
- "@babylonjs/core": "9.3.0",
26
+ "@babylonjs/core": "9.3.1",
27
27
  "@tools/node-geometry-editor": "1.0.0",
28
28
  "react": "^18.2.0",
29
29
  "react-dom": "^18.2.0"