@ignifx/editor-host 0.12.0 → 0.14.0
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.
- package/dist/index.d.ts +753 -245
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1488 -230
- package/dist/index.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +1 -0
- package/dist/vite.js.map +1 -1
- package/package.json +10 -10
- package/skills/editor-host/SKILL.md +28 -4
package/dist/index.d.ts
CHANGED
|
@@ -87,6 +87,19 @@ export declare const RpcErrorCode: {
|
|
|
87
87
|
readonly notReady: -32_001;
|
|
88
88
|
/** A scene method that needs an open scene was called while none is open (`SceneMethod`). */
|
|
89
89
|
readonly noScene: -32_002;
|
|
90
|
+
/**
|
|
91
|
+
* A play method that needs a running game was called while it does not run. `PlayMethod.screenshot`
|
|
92
|
+
* needs the frame loop: it fails before the game starts it, after `stop`, and after `step`.
|
|
93
|
+
* `PlayMethod.queryRuntime` and `PlayMethod.sendInput` need a game that plays or is paused (a
|
|
94
|
+
* stepped game is paused): they fail before the game starts and after `stop`. Additive in 0.3:
|
|
95
|
+
* only a host that answers one of those methods in the play view sends it.
|
|
96
|
+
*/
|
|
97
|
+
readonly notPlaying: -32_003;
|
|
98
|
+
/**
|
|
99
|
+
* A play method named an entity uid the game's world does not hold (`PlayMethod.queryRuntime`).
|
|
100
|
+
* Additive in 0.3: only a host that answers `queryRuntime` sends it.
|
|
101
|
+
*/
|
|
102
|
+
readonly unknownEntity: -32_004;
|
|
90
103
|
};
|
|
91
104
|
/**
|
|
92
105
|
* The union of the codes in `RpcErrorCode`.
|
|
@@ -285,9 +298,11 @@ export type HostKind = (typeof HostKind)[keyof typeof HostKind];
|
|
|
285
298
|
* The optional features a host lists in its `ready` result.
|
|
286
299
|
*
|
|
287
300
|
* @remarks
|
|
288
|
-
* The play controls send `
|
|
289
|
-
*
|
|
290
|
-
* `
|
|
301
|
+
* The play controls send `"heartbeat"`, `"playControls"`, `"logRelay"` and `"queryRuntime"`, plus
|
|
302
|
+
* `"screenshot"` when the game has a canvas and `"sendInput"` when it has `app.input`. The scene
|
|
303
|
+
* host sends `"heartbeat"` and whichever of `"gizmos"`, `"screenshot"`, `"viewMode2d"`,
|
|
304
|
+
* `"pick2d"`, `"gameView"` and `"thumbnails"` it supports; every `SceneMethod` not tied to one of
|
|
305
|
+
* them is required of a 0.3 scene host.
|
|
291
306
|
*
|
|
292
307
|
* @public
|
|
293
308
|
*/
|
|
@@ -301,7 +316,11 @@ export declare const HostCapability: {
|
|
|
301
316
|
* `transformDragging` and `transformDragged`.
|
|
302
317
|
*/
|
|
303
318
|
readonly gizmos: "gizmos";
|
|
304
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* The host answers `screenshot`: the scene host captures its view, the play controls the game's
|
|
321
|
+
* canvas. The play controls list it from engine ask E47 (additive in 0.3); without it, the play
|
|
322
|
+
* view answers `screenshot` with `RpcErrorCode.methodNotFound`.
|
|
323
|
+
*/
|
|
305
324
|
readonly screenshot: "screenshot";
|
|
306
325
|
/** The scene host accepts `setViewMode` with `"2d"`: a 2D editor camera and planar gizmos. */
|
|
307
326
|
readonly viewMode2d: "viewMode2d";
|
|
@@ -325,6 +344,31 @@ export declare const HostCapability: {
|
|
|
325
344
|
* defaults. Additive in 0.3.
|
|
326
345
|
*/
|
|
327
346
|
readonly hotReloadDefaults: "hotReloadDefaults";
|
|
347
|
+
/**
|
|
348
|
+
* The play controls answer `queryRuntime`: an entity's live state in the scene format. From engine
|
|
349
|
+
* ask E48 (additive in 0.3); without it, the play view answers `queryRuntime` with
|
|
350
|
+
* `RpcErrorCode.methodNotFound`.
|
|
351
|
+
*/
|
|
352
|
+
readonly queryRuntime: "queryRuntime";
|
|
353
|
+
/**
|
|
354
|
+
* The play controls answer `sendInput`: synthetic key and pointer events queued into the game's
|
|
355
|
+
* own input system (`app.input` from `@ignifx/input`), never into the editor's window. Listed only
|
|
356
|
+
* when the game has `app.input`. From engine ask E49 (additive in 0.3); without it, the play view
|
|
357
|
+
* answers `sendInput` with `RpcErrorCode.methodNotFound`.
|
|
358
|
+
*/
|
|
359
|
+
readonly sendInput: "sendInput";
|
|
360
|
+
/**
|
|
361
|
+
* The scene host answers `setGameView` and `gameViewFrame`: the open scene through its own main
|
|
362
|
+
* camera, rendered beside the editor camera (`RenderViewMethod`). From engine ask E8 (additive in
|
|
363
|
+
* 0.3); without it, the host answers both with `RpcErrorCode.methodNotFound`.
|
|
364
|
+
*/
|
|
365
|
+
readonly gameView: "gameView";
|
|
366
|
+
/**
|
|
367
|
+
* The scene host answers `renderThumbnail`: a model or prefab asset rendered on its own
|
|
368
|
+
* (`RenderViewMethod`). From engine ask E8 (additive in 0.3); without it, the host answers it with
|
|
369
|
+
* `RpcErrorCode.methodNotFound`.
|
|
370
|
+
*/
|
|
371
|
+
readonly thumbnails: "thumbnails";
|
|
328
372
|
};
|
|
329
373
|
/**
|
|
330
374
|
* The union of the names in `HostCapability`.
|
|
@@ -489,230 +533,6 @@ export declare const DEFAULT_HEARTBEAT_INTERVAL_MS = 1e3;
|
|
|
489
533
|
*/
|
|
490
534
|
type HeartbeatNotification = RpcNotification<typeof HostNotification.heartbeat, never>;
|
|
491
535
|
//#endregion
|
|
492
|
-
//#region src/protocol/play.d.ts
|
|
493
|
-
/**
|
|
494
|
-
* The methods the play view answers after `ready`. `play`, `pause`, `step` and `stop` answer with a
|
|
495
|
-
* {@link PlayState}; `playState` answers with a {@link PlayStateReport}; `playStats` answers with
|
|
496
|
-
* {@link PlayStats}.
|
|
497
|
-
*
|
|
498
|
-
* @remarks
|
|
499
|
-
* A host that answers them lists `HostCapability.playControls` in `ready`. Sent before `ready`, they
|
|
500
|
-
* fail with `RpcErrorCode.notReady`; sent to a host without them, with `RpcErrorCode.methodNotFound`.
|
|
501
|
-
* `playState` and `playStats` are additive 0.3 methods: a host from before one answers it with
|
|
502
|
-
* `RpcErrorCode.methodNotFound`.
|
|
503
|
-
*
|
|
504
|
-
* @public
|
|
505
|
-
*/
|
|
506
|
-
export declare const PlayMethod: {
|
|
507
|
-
/** Clears `app.time.paused` and starts the frame loop if it is stopped. */
|
|
508
|
-
readonly play: "play";
|
|
509
|
-
/** Sets `app.time.paused`; scripts marked `updateWhenPaused` keep running. */
|
|
510
|
-
readonly pause: "pause";
|
|
511
|
-
/** Stops the frame loop, then advances exactly one frame with `app.step()` and leaves the game paused. */
|
|
512
|
-
readonly step: "step";
|
|
513
|
-
/** Stops the frame loop with `app.stop()`. The editor reloads the view to reset the game. */
|
|
514
|
-
readonly stop: "stop";
|
|
515
|
-
/** Reads the game's state without changing it. Takes no parameters. */
|
|
516
|
-
readonly playState: "playState";
|
|
517
|
-
/**
|
|
518
|
-
* Reads the game's frame rate, frame time, entity count and frame count without changing
|
|
519
|
-
* anything. Takes no parameters. The editor polls it; no notification carries it.
|
|
520
|
-
*/
|
|
521
|
-
readonly playStats: "playStats";
|
|
522
|
-
};
|
|
523
|
-
/**
|
|
524
|
-
* The union of the names in `PlayMethod`.
|
|
525
|
-
*
|
|
526
|
-
* @public
|
|
527
|
-
*/
|
|
528
|
-
export type PlayMethod = (typeof PlayMethod)[keyof typeof PlayMethod];
|
|
529
|
-
/**
|
|
530
|
-
* The parameters of the `step` method.
|
|
531
|
-
*
|
|
532
|
-
* @public
|
|
533
|
-
*/
|
|
534
|
-
interface StepParams {
|
|
535
|
-
/**
|
|
536
|
-
* The frame delta in seconds, a positive finite number. Defaults to `app.time.fixedDeltaTime`;
|
|
537
|
-
* any other value fails with `RpcErrorCode.invalidParams`.
|
|
538
|
-
*/
|
|
539
|
-
readonly deltaSeconds?: number;
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Editor → play view: one of the `PlayMethod`s. Only `step` takes parameters.
|
|
543
|
-
*
|
|
544
|
-
* @public
|
|
545
|
-
*/
|
|
546
|
-
type PlayRequest = RpcRequest<typeof PlayMethod.play, never> | RpcRequest<typeof PlayMethod.pause, never> | RpcRequest<typeof PlayMethod.step, StepParams> | RpcRequest<typeof PlayMethod.stop, never> | RpcRequest<typeof PlayMethod.playState, never> | RpcRequest<typeof PlayMethod.playStats, never>;
|
|
547
|
-
/**
|
|
548
|
-
* What the play view reports after every `PlayMethod`.
|
|
549
|
-
*
|
|
550
|
-
* @public
|
|
551
|
-
*/
|
|
552
|
-
interface PlayState {
|
|
553
|
-
/** Whether the frame loop runs (`app.isRunning`). */
|
|
554
|
-
readonly isRunning: boolean;
|
|
555
|
-
/** Whether game time is paused (`app.time.paused`). */
|
|
556
|
-
readonly isPaused: boolean;
|
|
557
|
-
/** How many frames have started (`app.time.frameCount`). */
|
|
558
|
-
readonly frameCount: number;
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* Play view → editor: the answer to `play`, `pause`, `step` or `stop`.
|
|
562
|
-
*
|
|
563
|
-
* @public
|
|
564
|
-
*/
|
|
565
|
-
type PlayResponse = RpcSuccessResponse<PlayState>;
|
|
566
|
-
/**
|
|
567
|
-
* The notifications the play view sends after `ready`.
|
|
568
|
-
*
|
|
569
|
-
* @remarks
|
|
570
|
-
* Additive in 0.3: a host from before them sends none, and answers `playState` with
|
|
571
|
-
* `RpcErrorCode.methodNotFound`. `log`, `hostError` and `hotReloaded` came later still: only a host
|
|
572
|
-
* that lists `HostCapability.logRelay` in `ready` sends them.
|
|
573
|
-
*
|
|
574
|
-
* @public
|
|
575
|
-
*/
|
|
576
|
-
export declare const PlayNotification: {
|
|
577
|
-
/**
|
|
578
|
-
* After the game's {@link PlayStateReport.state} changed. A change a `PlayMethod` makes is sent
|
|
579
|
-
* right after that method's answer; one the game makes itself, such as setting
|
|
580
|
-
* `app.time.paused`, within one heartbeat interval.
|
|
581
|
-
*/
|
|
582
|
-
readonly playStateChanged: "playStateChanged";
|
|
583
|
-
/**
|
|
584
|
-
* One line from the game's logger, with the same `LogParams` as the scene view's `log`. Sent by a
|
|
585
|
-
* host that lists `HostCapability.logRelay`; lines logged before the handshake are kept (the
|
|
586
|
-
* newest few hundred) and sent right after `ready`.
|
|
587
|
-
*/
|
|
588
|
-
readonly log: "log";
|
|
589
|
-
/**
|
|
590
|
-
* An error the game's app reported through `app.onError`: the same `HostErrorParams` as the scene
|
|
591
|
-
* view's `hostError`, with `AppErrorData` as its `data`. Sent by a host that lists
|
|
592
|
-
* `HostCapability.logRelay`, kept before the handshake as `log` is.
|
|
593
|
-
*/
|
|
594
|
-
readonly hostError: "hostError";
|
|
595
|
-
/**
|
|
596
|
-
* After every `app.hotReload` operation in the game: the same `HotReloadedParams` as the scene
|
|
597
|
-
* view's `hotReloaded`. Sent by a host that lists `HostCapability.logRelay`.
|
|
598
|
-
*/
|
|
599
|
-
readonly hotReloaded: "hotReloaded";
|
|
600
|
-
};
|
|
601
|
-
/**
|
|
602
|
-
* The union of the names in `PlayNotification`.
|
|
603
|
-
*
|
|
604
|
-
* @public
|
|
605
|
-
*/
|
|
606
|
-
export type PlayNotification = (typeof PlayNotification)[keyof typeof PlayNotification];
|
|
607
|
-
/**
|
|
608
|
-
* Whether the game plays, is paused, or is stopped, as {@link PlayStateReport.state} reports it.
|
|
609
|
-
*
|
|
610
|
-
* @public
|
|
611
|
-
*/
|
|
612
|
-
export declare const PlayPhase: {
|
|
613
|
-
/** The frame loop runs (`app.isRunning`) and game time is not paused. */
|
|
614
|
-
readonly playing: "playing";
|
|
615
|
-
/**
|
|
616
|
-
* Game time is paused (`app.time.paused`): after `pause`, or after `step`, which leaves the frame
|
|
617
|
-
* loop stopped on the stepped frame.
|
|
618
|
-
*/
|
|
619
|
-
readonly paused: "paused";
|
|
620
|
-
/** The frame loop does not run: before the game starts it, or after `stop`. */
|
|
621
|
-
readonly stopped: "stopped";
|
|
622
|
-
};
|
|
623
|
-
/**
|
|
624
|
-
* The union of the names in `PlayPhase`.
|
|
625
|
-
*
|
|
626
|
-
* @public
|
|
627
|
-
*/
|
|
628
|
-
export type PlayPhase = (typeof PlayPhase)[keyof typeof PlayPhase];
|
|
629
|
-
/**
|
|
630
|
-
* The game's state as `playState` answers it and `playStateChanged` reports it.
|
|
631
|
-
*
|
|
632
|
-
* @public
|
|
633
|
-
*/
|
|
634
|
-
interface PlayStateReport {
|
|
635
|
-
/** Whether the game plays, is paused, or is stopped. */
|
|
636
|
-
readonly state: PlayPhase;
|
|
637
|
-
/** How many frames have started (`app.time.frameCount`). */
|
|
638
|
-
readonly frameCount: number;
|
|
639
|
-
/** Scaled seconds of game time since the app started running frames (`app.time.time`). */
|
|
640
|
-
readonly time: number;
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Play view → editor: the answer to `playState`.
|
|
644
|
-
*
|
|
645
|
-
* @public
|
|
646
|
-
*/
|
|
647
|
-
type PlayStateResponse = RpcSuccessResponse<PlayStateReport>;
|
|
648
|
-
/**
|
|
649
|
-
* The game's performance as `playStats` answers it.
|
|
650
|
-
*
|
|
651
|
-
* @public
|
|
652
|
-
*/
|
|
653
|
-
interface PlayStats {
|
|
654
|
-
/**
|
|
655
|
-
* Frames per second: `1000 / frameTimeMs`, or `0` when `frameTimeMs` is `0`. Rendered frames
|
|
656
|
-
* count whether or not game time is paused.
|
|
657
|
-
*/
|
|
658
|
-
readonly fps: number;
|
|
659
|
-
/**
|
|
660
|
-
* The mean wall-clock time between the frames of the last second, in milliseconds, from the
|
|
661
|
-
* frame history in `app.diagnostics` (each frame's `rawDeltaMs`); `0` while the frame loop does
|
|
662
|
-
* not run (stopped, or stepped and paused on a frame) or before its first frame.
|
|
663
|
-
*/
|
|
664
|
-
readonly frameTimeMs: number;
|
|
665
|
-
/** How many entities the game's world holds, in every scene instance, persistent ones included. */
|
|
666
|
-
readonly entityCount: number;
|
|
667
|
-
/** How many frames have started (`app.time.frameCount`). */
|
|
668
|
-
readonly frameCount: number;
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Play view → editor: the answer to `playStats`.
|
|
672
|
-
*
|
|
673
|
-
* @public
|
|
674
|
-
*/
|
|
675
|
-
type PlayStatsResponse = RpcSuccessResponse<PlayStats>;
|
|
676
|
-
/**
|
|
677
|
-
* Play view → editor: the game's state changed.
|
|
678
|
-
*
|
|
679
|
-
* @public
|
|
680
|
-
*/
|
|
681
|
-
interface PlayStateChangedNotification extends RpcNotification<typeof PlayNotification.playStateChanged, PlayStateReport> {
|
|
682
|
-
/** The game's state after the change. */
|
|
683
|
-
readonly params: PlayStateReport;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Checks the `result` of a play method's response.
|
|
687
|
-
*
|
|
688
|
-
* @param value - The received `result`.
|
|
689
|
-
* @returns True when `value` has boolean `isRunning` and `isPaused` and a non-negative integer
|
|
690
|
-
* `frameCount`.
|
|
691
|
-
*
|
|
692
|
-
* @public
|
|
693
|
-
*/
|
|
694
|
-
export declare function isPlayState(value: unknown): value is PlayState;
|
|
695
|
-
/**
|
|
696
|
-
* Checks the `result` of `playState` and the `params` of `playStateChanged`.
|
|
697
|
-
*
|
|
698
|
-
* @param value - The received value.
|
|
699
|
-
* @returns True when `value` has a `state` that is a `PlayPhase`, a non-negative integer
|
|
700
|
-
* `frameCount`, and a non-negative finite `time`.
|
|
701
|
-
*
|
|
702
|
-
* @public
|
|
703
|
-
*/
|
|
704
|
-
export declare function isPlayStateReport(value: unknown): value is PlayStateReport;
|
|
705
|
-
/**
|
|
706
|
-
* Checks the `result` of `playStats`.
|
|
707
|
-
*
|
|
708
|
-
* @param value - The received `result`.
|
|
709
|
-
* @returns True when `value` has non-negative finite `fps` and `frameTimeMs` and non-negative
|
|
710
|
-
* integer `entityCount` and `frameCount`.
|
|
711
|
-
*
|
|
712
|
-
* @public
|
|
713
|
-
*/
|
|
714
|
-
export declare function isPlayStats(value: unknown): value is PlayStats;
|
|
715
|
-
//#endregion
|
|
716
536
|
//#region src/protocol/scene-file.d.ts
|
|
717
537
|
/**
|
|
718
538
|
* Any JSON value. The engine's `JsonValue`.
|
|
@@ -2601,24 +2421,705 @@ export declare function isAppErrorData(value: unknown): value is AppErrorData;
|
|
|
2601
2421
|
*/
|
|
2602
2422
|
export declare function isLogParams(value: unknown): value is LogParams;
|
|
2603
2423
|
//#endregion
|
|
2604
|
-
//#region src/
|
|
2424
|
+
//#region src/protocol/play.d.ts
|
|
2605
2425
|
/**
|
|
2606
|
-
*
|
|
2607
|
-
*
|
|
2608
|
-
*
|
|
2426
|
+
* The methods the play view answers after `ready`. `play`, `pause`, `step` and `stop` answer with a
|
|
2427
|
+
* {@link PlayState}; `playState` answers with a {@link PlayStateReport}; `playStats` answers with
|
|
2428
|
+
* {@link PlayStats}; `screenshot` answers with a `ScreenshotResult`; `queryRuntime` answers with a
|
|
2429
|
+
* {@link QueryRuntimeResult}; `sendInput` answers with a {@link SendInputResult}.
|
|
2609
2430
|
*
|
|
2610
|
-
* @
|
|
2431
|
+
* @remarks
|
|
2432
|
+
* A host that answers them lists `HostCapability.playControls` in `ready`. Sent before `ready`, they
|
|
2433
|
+
* fail with `RpcErrorCode.notReady`; sent to a host without them, with `RpcErrorCode.methodNotFound`.
|
|
2434
|
+
* `playState`, `playStats`, `screenshot`, `queryRuntime` and `sendInput` are additive 0.3 methods:
|
|
2435
|
+
* a host from before one answers it with `RpcErrorCode.methodNotFound`. `screenshot`, `queryRuntime`
|
|
2436
|
+
* and `sendInput` also need the `HostCapability` of the same name in the play view's `ready`.
|
|
2437
|
+
*
|
|
2438
|
+
* @public
|
|
2611
2439
|
*/
|
|
2612
|
-
|
|
2613
|
-
/**
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2440
|
+
export declare const PlayMethod: {
|
|
2441
|
+
/** Clears `app.time.paused` and starts the frame loop if it is stopped. */
|
|
2442
|
+
readonly play: "play";
|
|
2443
|
+
/** Sets `app.time.paused`; scripts marked `updateWhenPaused` keep running. */
|
|
2444
|
+
readonly pause: "pause";
|
|
2445
|
+
/** Stops the frame loop, then advances exactly one frame with `app.step()` and leaves the game paused. */
|
|
2446
|
+
readonly step: "step";
|
|
2447
|
+
/** Stops the frame loop with `app.stop()`. The editor reloads the view to reset the game. */
|
|
2448
|
+
readonly stop: "stop";
|
|
2449
|
+
/** Reads the game's state without changing it. Takes no parameters. */
|
|
2450
|
+
readonly playState: "playState";
|
|
2451
|
+
/**
|
|
2452
|
+
* Reads the game's frame rate, frame time, entity count and frame count without changing
|
|
2453
|
+
* anything. Takes no parameters. The editor polls it; no notification carries it.
|
|
2454
|
+
*/
|
|
2455
|
+
readonly playStats: "playStats";
|
|
2456
|
+
/**
|
|
2457
|
+
* Captures the game's canvas as an image, with the scene view's `screenshot` parameters, caps and
|
|
2458
|
+
* answer (`ScreenshotParams`, `ScreenshotResult`). Changes nothing: a paused game is captured
|
|
2459
|
+
* paused. Needs `HostCapability.screenshot`. Fails with `RpcErrorCode.notPlaying` while the frame
|
|
2460
|
+
* loop does not run (before the game starts it, after `stop` or `step`), and with
|
|
2461
|
+
* `RpcErrorCode.notReady` before the game's first frame.
|
|
2462
|
+
*/
|
|
2463
|
+
readonly screenshot: "screenshot";
|
|
2464
|
+
/**
|
|
2465
|
+
* Reads one entity of the running game as the scene format writes it ({@link QueryRuntimeParams},
|
|
2466
|
+
* {@link QueryRuntimeResult}): its live transform, flags and component props, never anything a
|
|
2467
|
+
* component does not serialize, and no expressions. Each value is capped and the whole answer kept
|
|
2468
|
+
* within {@link QUERY_RUNTIME_MAX_JSON_LENGTH}. Changes nothing. Needs
|
|
2469
|
+
* `HostCapability.queryRuntime`. Fails with `RpcErrorCode.notPlaying` while the game is stopped
|
|
2470
|
+
* (before it starts, after `stop`; a stepped game is paused and answers), and with
|
|
2471
|
+
* `RpcErrorCode.unknownEntity` when no entity of the game has the uid.
|
|
2472
|
+
*/
|
|
2473
|
+
readonly queryRuntime: "queryRuntime";
|
|
2474
|
+
/**
|
|
2475
|
+
* Queues synthetic key and pointer events into the game's own input system, as if the game's page
|
|
2476
|
+
* had received them ({@link SendInputParams}, {@link SendInputResult}). Nothing reaches the
|
|
2477
|
+
* editor's window or the operating system. Needs `HostCapability.sendInput`, which a game lists
|
|
2478
|
+
* only when it has `app.input` (`@ignifx/input`). Fails with `RpcErrorCode.notPlaying` while the
|
|
2479
|
+
* game is stopped; a paused or stepped game takes the events and resolves them on its next frame,
|
|
2480
|
+
* which for a stepped game is the next `step`.
|
|
2481
|
+
*/
|
|
2482
|
+
readonly sendInput: "sendInput";
|
|
2483
|
+
};
|
|
2484
|
+
/**
|
|
2485
|
+
* The union of the names in `PlayMethod`.
|
|
2486
|
+
*
|
|
2487
|
+
* @public
|
|
2488
|
+
*/
|
|
2489
|
+
export type PlayMethod = (typeof PlayMethod)[keyof typeof PlayMethod];
|
|
2490
|
+
/**
|
|
2491
|
+
* The parameters of the `step` method.
|
|
2492
|
+
*
|
|
2493
|
+
* @public
|
|
2494
|
+
*/
|
|
2495
|
+
interface StepParams {
|
|
2496
|
+
/**
|
|
2497
|
+
* The frame delta in seconds, a positive finite number. Defaults to `app.time.fixedDeltaTime`;
|
|
2498
|
+
* any other value fails with `RpcErrorCode.invalidParams`.
|
|
2499
|
+
*/
|
|
2500
|
+
readonly deltaSeconds?: number;
|
|
2501
|
+
}
|
|
2502
|
+
/**
|
|
2503
|
+
* The most components a `queryRuntime` answer holds, and the most type ids its `components` filter
|
|
2504
|
+
* may name. Components past it are counted in {@link QueryRuntimeResult.omittedComponents}.
|
|
2505
|
+
*
|
|
2506
|
+
* @public
|
|
2507
|
+
*/
|
|
2508
|
+
export declare const QUERY_RUNTIME_MAX_COMPONENTS = 64;
|
|
2509
|
+
/**
|
|
2510
|
+
* The longest a `queryRuntime` answer may be: its `result` as JSON text, in UTF-16 code units
|
|
2511
|
+
* (`JSON.stringify(result).length`), 256 Ki. Components that would pass it are left out, in order,
|
|
2512
|
+
* and counted in {@link QueryRuntimeResult.omittedComponents}.
|
|
2513
|
+
*
|
|
2514
|
+
* @public
|
|
2515
|
+
*/
|
|
2516
|
+
export declare const QUERY_RUNTIME_MAX_JSON_LENGTH = 262144;
|
|
2517
|
+
/**
|
|
2518
|
+
* In a `queryRuntime` answer, the most keys one object keeps and the longest a key may be; also the
|
|
2519
|
+
* longest the entity's `name`, `layer`, each tag and each component `type` may be, and the most
|
|
2520
|
+
* tags kept. Keys left out are counted in {@link QueryRuntimeResult.omittedEntries}.
|
|
2521
|
+
*
|
|
2522
|
+
* @public
|
|
2523
|
+
*/
|
|
2524
|
+
export declare const QUERY_RUNTIME_MAX_KEYS = 256;
|
|
2525
|
+
/**
|
|
2526
|
+
* In a `queryRuntime` answer, the longest a prop string may be, `… [clipped]` included: 64 Ki, a
|
|
2527
|
+
* quarter of {@link QUERY_RUNTIME_MAX_JSON_LENGTH}, so one long string does not cost its component
|
|
2528
|
+
* its place.
|
|
2529
|
+
*
|
|
2530
|
+
* @public
|
|
2531
|
+
*/
|
|
2532
|
+
export declare const QUERY_RUNTIME_MAX_STRING_LENGTH = 65536;
|
|
2533
|
+
/**
|
|
2534
|
+
* The parameters of the `queryRuntime` method.
|
|
2535
|
+
*
|
|
2536
|
+
* @public
|
|
2537
|
+
*/
|
|
2538
|
+
interface QueryRuntimeParams {
|
|
2539
|
+
/** The entity's uid. A scene's own entities keep their file uids at run time. */
|
|
2540
|
+
readonly entity: string;
|
|
2541
|
+
/**
|
|
2542
|
+
* Only the components of these type ids, at most {@link QUERY_RUNTIME_MAX_COMPONENTS}; absent for
|
|
2543
|
+
* all of them. A type id the entity does not carry matches nothing.
|
|
2544
|
+
*/
|
|
2545
|
+
readonly components?: readonly string[];
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* Play view → editor: the answer to `queryRuntime`.
|
|
2549
|
+
*
|
|
2550
|
+
* @public
|
|
2551
|
+
*/
|
|
2552
|
+
interface QueryRuntimeResult {
|
|
2553
|
+
/**
|
|
2554
|
+
* The entity as `serializeEntity` writes it from the live world, with at most
|
|
2555
|
+
* {@link QUERY_RUNTIME_MAX_COMPONENTS} components (only the filtered ones when `components` was
|
|
2556
|
+
* given), in the entity's order, as many as fit in {@link QUERY_RUNTIME_MAX_JSON_LENGTH}.
|
|
2557
|
+
*
|
|
2558
|
+
* @remarks
|
|
2559
|
+
* Each value is capped too: a prop string is clipped to {@link QUERY_RUNTIME_MAX_STRING_LENGTH}
|
|
2560
|
+
* (ending `… [clipped]`), a list cut to `HOST_LIST_MAX_LENGTH` items, an object to its first
|
|
2561
|
+
* {@link QUERY_RUNTIME_MAX_KEYS} keys, and each key, the `name`, the `layer`, each component
|
|
2562
|
+
* `type` and each of at most {@link QUERY_RUNTIME_MAX_KEYS} tags clipped to
|
|
2563
|
+
* {@link QUERY_RUNTIME_MAX_KEYS} characters. When two keys clip to the same one, the first keeps
|
|
2564
|
+
* it. No marker is written into a value (a map's keys can be any string, so none would be safe):
|
|
2565
|
+
* what was left out is counted in {@link QueryRuntimeResult.omittedEntries}. A value that is not JSON (a non-finite number, a function a custom codec returned)
|
|
2566
|
+
* becomes `null`, and so does anything nested deeper than 256 levels.
|
|
2567
|
+
*/
|
|
2568
|
+
readonly entity: SceneFileEntity;
|
|
2569
|
+
/**
|
|
2570
|
+
* How many matching components were left out: past {@link QUERY_RUNTIME_MAX_COMPONENTS}, or past
|
|
2571
|
+
* the first that did not fit in {@link QUERY_RUNTIME_MAX_JSON_LENGTH}.
|
|
2572
|
+
*/
|
|
2573
|
+
readonly omittedComponents: number;
|
|
2574
|
+
/**
|
|
2575
|
+
* How many object keys, list items and tags the caps left out of the answered entity: past
|
|
2576
|
+
* {@link QUERY_RUNTIME_MAX_KEYS} keys or tags, past `HOST_LIST_MAX_LENGTH` items, or a key that
|
|
2577
|
+
* clipped to one already kept. `0` when every kept component is whole.
|
|
2578
|
+
*/
|
|
2579
|
+
readonly omittedEntries: number;
|
|
2580
|
+
/** How many frames had started when it was read (`app.time.frameCount`). */
|
|
2581
|
+
readonly frameCount: number;
|
|
2582
|
+
/** Scaled seconds of game time when it was read (`app.time.time`). */
|
|
2583
|
+
readonly time: number;
|
|
2584
|
+
}
|
|
2585
|
+
/**
|
|
2586
|
+
* Play view → editor: the answer to `queryRuntime`.
|
|
2587
|
+
*
|
|
2588
|
+
* @public
|
|
2589
|
+
*/
|
|
2590
|
+
type QueryRuntimeResponse = RpcSuccessResponse<QueryRuntimeResult>;
|
|
2591
|
+
/**
|
|
2592
|
+
* The most events one `sendInput` request may carry.
|
|
2593
|
+
*
|
|
2594
|
+
* @public
|
|
2595
|
+
*/
|
|
2596
|
+
export declare const SEND_INPUT_MAX_EVENTS = 64;
|
|
2597
|
+
/**
|
|
2598
|
+
* A key press or release in a `sendInput` request.
|
|
2599
|
+
*
|
|
2600
|
+
* @public
|
|
2601
|
+
*/
|
|
2602
|
+
interface SendInputKeyEvent {
|
|
2603
|
+
/** `"keydown"` presses the key and holds it until a `"keyup"`; `"keyup"` releases it. */
|
|
2604
|
+
readonly type: "keydown" | "keyup";
|
|
2605
|
+
/**
|
|
2606
|
+
* The `<Keyboard>` control name: the physical key's `KeyboardEvent.code` in camelCase without its
|
|
2607
|
+
* `Key` or `Digit` prefix, such as `w`, `1`, `space`, `arrowUp` or `shiftLeft`. Letters and digits
|
|
2608
|
+
* only, at most 64 of them; a name the game's keyboard does not have fails with
|
|
2609
|
+
* `RpcErrorCode.invalidParams`.
|
|
2610
|
+
*/
|
|
2611
|
+
readonly control: string;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* A pointer move, press or release in a `sendInput` request.
|
|
2615
|
+
*
|
|
2616
|
+
* @public
|
|
2617
|
+
*/
|
|
2618
|
+
interface SendInputPointerEvent {
|
|
2619
|
+
/** Which pointer event it is. */
|
|
2620
|
+
readonly type: "pointermove" | "pointerdown" | "pointerup";
|
|
2621
|
+
/** The pointer's x as a fraction of the game's canvas width, from `0` (left) to `1` (right). */
|
|
2622
|
+
readonly x: number;
|
|
2623
|
+
/** The pointer's y as a fraction of the game's canvas height, from `0` (top) to `1` (bottom). */
|
|
2624
|
+
readonly y: number;
|
|
2625
|
+
/** The `PointerEvent.button`, an integer from `0` (main) to `4`. Defaults to `0`. */
|
|
2626
|
+
readonly button?: number;
|
|
2627
|
+
}
|
|
2628
|
+
/**
|
|
2629
|
+
* One event of a `sendInput` request.
|
|
2630
|
+
*
|
|
2631
|
+
* @public
|
|
2632
|
+
*/
|
|
2633
|
+
type SendInputEvent = SendInputKeyEvent | SendInputPointerEvent;
|
|
2634
|
+
/**
|
|
2635
|
+
* The parameters of the `sendInput` method.
|
|
2636
|
+
*
|
|
2637
|
+
* @public
|
|
2638
|
+
*/
|
|
2639
|
+
interface SendInputParams {
|
|
2640
|
+
/** The events, in order: from 1 to {@link SEND_INPUT_MAX_EVENTS} of them. */
|
|
2641
|
+
readonly events: readonly SendInputEvent[];
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Play view → editor: what `sendInput` queued.
|
|
2645
|
+
*
|
|
2646
|
+
* @public
|
|
2647
|
+
*/
|
|
2648
|
+
interface SendInputResult {
|
|
2649
|
+
/** How many events were queued: all of the request's. */
|
|
2650
|
+
readonly queued: number;
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Play view → editor: the answer to `sendInput`.
|
|
2654
|
+
*
|
|
2655
|
+
* @public
|
|
2656
|
+
*/
|
|
2657
|
+
type SendInputResponse = RpcSuccessResponse<SendInputResult>;
|
|
2658
|
+
/**
|
|
2659
|
+
* Editor → play view: one of the `PlayMethod`s. Only `step`, `screenshot`, `queryRuntime` and
|
|
2660
|
+
* `sendInput` take parameters.
|
|
2661
|
+
*
|
|
2662
|
+
* @public
|
|
2663
|
+
*/
|
|
2664
|
+
type PlayRequest = RpcRequest<typeof PlayMethod.play, never> | RpcRequest<typeof PlayMethod.pause, never> | RpcRequest<typeof PlayMethod.step, StepParams> | RpcRequest<typeof PlayMethod.stop, never> | RpcRequest<typeof PlayMethod.playState, never> | RpcRequest<typeof PlayMethod.playStats, never> | RpcRequestWithParams<typeof PlayMethod.screenshot, ScreenshotParams> | RpcRequestWithParams<typeof PlayMethod.queryRuntime, QueryRuntimeParams> | RpcRequestWithParams<typeof PlayMethod.sendInput, SendInputParams>;
|
|
2665
|
+
/**
|
|
2666
|
+
* What the play view reports after every `PlayMethod`.
|
|
2667
|
+
*
|
|
2668
|
+
* @public
|
|
2669
|
+
*/
|
|
2670
|
+
interface PlayState {
|
|
2671
|
+
/** Whether the frame loop runs (`app.isRunning`). */
|
|
2672
|
+
readonly isRunning: boolean;
|
|
2673
|
+
/** Whether game time is paused (`app.time.paused`). */
|
|
2674
|
+
readonly isPaused: boolean;
|
|
2675
|
+
/** How many frames have started (`app.time.frameCount`). */
|
|
2676
|
+
readonly frameCount: number;
|
|
2677
|
+
}
|
|
2678
|
+
/**
|
|
2679
|
+
* Play view → editor: the answer to `play`, `pause`, `step` or `stop`.
|
|
2680
|
+
*
|
|
2681
|
+
* @public
|
|
2682
|
+
*/
|
|
2683
|
+
type PlayResponse = RpcSuccessResponse<PlayState>;
|
|
2684
|
+
/**
|
|
2685
|
+
* The notifications the play view sends after `ready`.
|
|
2686
|
+
*
|
|
2687
|
+
* @remarks
|
|
2688
|
+
* Additive in 0.3: a host from before them sends none, and answers `playState` with
|
|
2689
|
+
* `RpcErrorCode.methodNotFound`. `log`, `hostError` and `hotReloaded` came later still: only a host
|
|
2690
|
+
* that lists `HostCapability.logRelay` in `ready` sends them.
|
|
2691
|
+
*
|
|
2692
|
+
* @public
|
|
2693
|
+
*/
|
|
2694
|
+
export declare const PlayNotification: {
|
|
2695
|
+
/**
|
|
2696
|
+
* After the game's {@link PlayStateReport.state} changed. A change a `PlayMethod` makes is sent
|
|
2697
|
+
* right after that method's answer; one the game makes itself, such as setting
|
|
2698
|
+
* `app.time.paused`, within one heartbeat interval.
|
|
2699
|
+
*/
|
|
2700
|
+
readonly playStateChanged: "playStateChanged";
|
|
2701
|
+
/**
|
|
2702
|
+
* One line from the game's logger, with the same `LogParams` as the scene view's `log`. Sent by a
|
|
2703
|
+
* host that lists `HostCapability.logRelay`; lines logged before the handshake are kept (the
|
|
2704
|
+
* newest few hundred) and sent right after `ready`.
|
|
2705
|
+
*/
|
|
2706
|
+
readonly log: "log";
|
|
2707
|
+
/**
|
|
2708
|
+
* An error the game's app reported through `app.onError`: the same `HostErrorParams` as the scene
|
|
2709
|
+
* view's `hostError`, with `AppErrorData` as its `data`. Sent by a host that lists
|
|
2710
|
+
* `HostCapability.logRelay`, kept before the handshake as `log` is.
|
|
2711
|
+
*/
|
|
2712
|
+
readonly hostError: "hostError";
|
|
2713
|
+
/**
|
|
2714
|
+
* After every `app.hotReload` operation in the game: the same `HotReloadedParams` as the scene
|
|
2715
|
+
* view's `hotReloaded`. Sent by a host that lists `HostCapability.logRelay`.
|
|
2716
|
+
*/
|
|
2717
|
+
readonly hotReloaded: "hotReloaded";
|
|
2718
|
+
};
|
|
2719
|
+
/**
|
|
2720
|
+
* The union of the names in `PlayNotification`.
|
|
2721
|
+
*
|
|
2722
|
+
* @public
|
|
2723
|
+
*/
|
|
2724
|
+
export type PlayNotification = (typeof PlayNotification)[keyof typeof PlayNotification];
|
|
2725
|
+
/**
|
|
2726
|
+
* Whether the game plays, is paused, or is stopped, as {@link PlayStateReport.state} reports it.
|
|
2727
|
+
*
|
|
2728
|
+
* @public
|
|
2729
|
+
*/
|
|
2730
|
+
export declare const PlayPhase: {
|
|
2731
|
+
/** The frame loop runs (`app.isRunning`) and game time is not paused. */
|
|
2732
|
+
readonly playing: "playing";
|
|
2733
|
+
/**
|
|
2734
|
+
* Game time is paused (`app.time.paused`): after `pause`, or after `step`, which leaves the frame
|
|
2735
|
+
* loop stopped on the stepped frame.
|
|
2736
|
+
*/
|
|
2737
|
+
readonly paused: "paused";
|
|
2738
|
+
/** The frame loop does not run: before the game starts it, or after `stop`. */
|
|
2739
|
+
readonly stopped: "stopped";
|
|
2740
|
+
};
|
|
2741
|
+
/**
|
|
2742
|
+
* The union of the names in `PlayPhase`.
|
|
2743
|
+
*
|
|
2744
|
+
* @public
|
|
2745
|
+
*/
|
|
2746
|
+
export type PlayPhase = (typeof PlayPhase)[keyof typeof PlayPhase];
|
|
2747
|
+
/**
|
|
2748
|
+
* The game's state as `playState` answers it and `playStateChanged` reports it.
|
|
2749
|
+
*
|
|
2750
|
+
* @public
|
|
2751
|
+
*/
|
|
2752
|
+
interface PlayStateReport {
|
|
2753
|
+
/** Whether the game plays, is paused, or is stopped. */
|
|
2754
|
+
readonly state: PlayPhase;
|
|
2755
|
+
/** How many frames have started (`app.time.frameCount`). */
|
|
2756
|
+
readonly frameCount: number;
|
|
2757
|
+
/** Scaled seconds of game time since the app started running frames (`app.time.time`). */
|
|
2758
|
+
readonly time: number;
|
|
2759
|
+
}
|
|
2760
|
+
/**
|
|
2761
|
+
* Play view → editor: the answer to `playState`.
|
|
2762
|
+
*
|
|
2763
|
+
* @public
|
|
2764
|
+
*/
|
|
2765
|
+
type PlayStateResponse = RpcSuccessResponse<PlayStateReport>;
|
|
2766
|
+
/**
|
|
2767
|
+
* The game's performance as `playStats` answers it.
|
|
2768
|
+
*
|
|
2769
|
+
* @public
|
|
2770
|
+
*/
|
|
2771
|
+
interface PlayStats {
|
|
2772
|
+
/**
|
|
2773
|
+
* Frames per second: `1000 / frameTimeMs`, or `0` when `frameTimeMs` is `0`. Rendered frames
|
|
2774
|
+
* count whether or not game time is paused.
|
|
2775
|
+
*/
|
|
2776
|
+
readonly fps: number;
|
|
2777
|
+
/**
|
|
2778
|
+
* The mean wall-clock time between the frames of the last second, in milliseconds, from the
|
|
2779
|
+
* frame history in `app.diagnostics` (each frame's `rawDeltaMs`); `0` while the frame loop does
|
|
2780
|
+
* not run (stopped, or stepped and paused on a frame) or before its first frame.
|
|
2781
|
+
*/
|
|
2782
|
+
readonly frameTimeMs: number;
|
|
2783
|
+
/** How many entities the game's world holds, in every scene instance, persistent ones included. */
|
|
2784
|
+
readonly entityCount: number;
|
|
2785
|
+
/** How many frames have started (`app.time.frameCount`). */
|
|
2786
|
+
readonly frameCount: number;
|
|
2787
|
+
}
|
|
2788
|
+
/**
|
|
2789
|
+
* Play view → editor: the answer to `playStats`.
|
|
2790
|
+
*
|
|
2791
|
+
* @public
|
|
2792
|
+
*/
|
|
2793
|
+
type PlayStatsResponse = RpcSuccessResponse<PlayStats>;
|
|
2794
|
+
/**
|
|
2795
|
+
* Play view → editor: the game's state changed.
|
|
2796
|
+
*
|
|
2797
|
+
* @public
|
|
2798
|
+
*/
|
|
2799
|
+
interface PlayStateChangedNotification extends RpcNotification<typeof PlayNotification.playStateChanged, PlayStateReport> {
|
|
2800
|
+
/** The game's state after the change. */
|
|
2801
|
+
readonly params: PlayStateReport;
|
|
2802
|
+
}
|
|
2803
|
+
/**
|
|
2804
|
+
* Checks the `result` of a play method's response.
|
|
2805
|
+
*
|
|
2806
|
+
* @param value - The received `result`.
|
|
2807
|
+
* @returns True when `value` has boolean `isRunning` and `isPaused` and a non-negative integer
|
|
2808
|
+
* `frameCount`.
|
|
2809
|
+
*
|
|
2810
|
+
* @public
|
|
2811
|
+
*/
|
|
2812
|
+
export declare function isPlayState(value: unknown): value is PlayState;
|
|
2813
|
+
/**
|
|
2814
|
+
* Checks the `result` of `playState` and the `params` of `playStateChanged`.
|
|
2815
|
+
*
|
|
2816
|
+
* @param value - The received value.
|
|
2817
|
+
* @returns True when `value` has a `state` that is a `PlayPhase`, a non-negative integer
|
|
2818
|
+
* `frameCount`, and a non-negative finite `time`.
|
|
2819
|
+
*
|
|
2820
|
+
* @public
|
|
2821
|
+
*/
|
|
2822
|
+
export declare function isPlayStateReport(value: unknown): value is PlayStateReport;
|
|
2823
|
+
/**
|
|
2824
|
+
* Checks the `result` of `playStats`.
|
|
2825
|
+
*
|
|
2826
|
+
* @param value - The received `result`.
|
|
2827
|
+
* @returns True when `value` has non-negative finite `fps` and `frameTimeMs` and non-negative
|
|
2828
|
+
* integer `entityCount` and `frameCount`.
|
|
2829
|
+
*
|
|
2830
|
+
* @public
|
|
2831
|
+
*/
|
|
2832
|
+
export declare function isPlayStats(value: unknown): value is PlayStats;
|
|
2833
|
+
/**
|
|
2834
|
+
* Checks the `params` of `queryRuntime`.
|
|
2835
|
+
*
|
|
2836
|
+
* @param value - The received `params`.
|
|
2837
|
+
* @returns True for a non-empty `entity` uid and, when present, a `components` list of at most
|
|
2838
|
+
* {@link QUERY_RUNTIME_MAX_COMPONENTS} non-empty strings.
|
|
2839
|
+
*
|
|
2840
|
+
* @public
|
|
2841
|
+
*/
|
|
2842
|
+
export declare function isQueryRuntimeParams(value: unknown): value is QueryRuntimeParams;
|
|
2843
|
+
/**
|
|
2844
|
+
* Checks the `result` of `queryRuntime`.
|
|
2845
|
+
*
|
|
2846
|
+
* @param value - The received `result`.
|
|
2847
|
+
* @returns True for an entity record with at most {@link QUERY_RUNTIME_MAX_COMPONENTS} components,
|
|
2848
|
+
* non-negative integer `omittedComponents`, `omittedEntries` and `frameCount`, and a non-negative
|
|
2849
|
+
* finite `time`, no longer than {@link QUERY_RUNTIME_MAX_JSON_LENGTH} as JSON.
|
|
2850
|
+
*
|
|
2851
|
+
* @public
|
|
2852
|
+
*/
|
|
2853
|
+
export declare function isQueryRuntimeResult(value: unknown): value is QueryRuntimeResult;
|
|
2854
|
+
/**
|
|
2855
|
+
* Checks one event of a `sendInput` request.
|
|
2856
|
+
*
|
|
2857
|
+
* @param value - The value to test.
|
|
2858
|
+
* @returns True for a key event with a well-formed `control`, or a pointer event with `x` and `y`
|
|
2859
|
+
* from 0 to 1 and, when present, an integer `button` from 0 to 4.
|
|
2860
|
+
*
|
|
2861
|
+
* @public
|
|
2862
|
+
*/
|
|
2863
|
+
export declare function isSendInputEvent(value: unknown): value is SendInputEvent;
|
|
2864
|
+
/**
|
|
2865
|
+
* Checks the `params` of `sendInput`.
|
|
2866
|
+
*
|
|
2867
|
+
* @param value - The received `params`.
|
|
2868
|
+
* @returns True for an `events` list of 1 to {@link SEND_INPUT_MAX_EVENTS} well-formed events.
|
|
2869
|
+
*
|
|
2870
|
+
* @public
|
|
2871
|
+
*/
|
|
2872
|
+
export declare function isSendInputParams(value: unknown): value is SendInputParams;
|
|
2873
|
+
/**
|
|
2874
|
+
* Checks the `result` of `sendInput`.
|
|
2875
|
+
*
|
|
2876
|
+
* @param value - The received `result`.
|
|
2877
|
+
* @returns True for an integer `queued` from 0 to {@link SEND_INPUT_MAX_EVENTS}.
|
|
2878
|
+
*
|
|
2879
|
+
* @public
|
|
2880
|
+
*/
|
|
2881
|
+
export declare function isSendInputResult(value: unknown): value is SendInputResult;
|
|
2882
|
+
//#endregion
|
|
2883
|
+
//#region src/protocol/render-views.d.ts
|
|
2884
|
+
/**
|
|
2885
|
+
* Editor → scene host: the render-view methods, answered after `ready` like every `SceneMethod`.
|
|
2886
|
+
*
|
|
2887
|
+
* @remarks
|
|
2888
|
+
* A host lists `HostCapability.gameView` when it answers the first two and
|
|
2889
|
+
* `HostCapability.thumbnails` when it answers the third; one that does not answers
|
|
2890
|
+
* `RpcErrorCode.methodNotFound`. Additive in 0.3.
|
|
2891
|
+
*
|
|
2892
|
+
* @public
|
|
2893
|
+
*/
|
|
2894
|
+
export declare const RenderViewMethod: {
|
|
2895
|
+
/** Turns the Game panel's view on, off, or to a new size. Answers {@link GameViewState}. */
|
|
2896
|
+
readonly setGameView: "setGameView";
|
|
2897
|
+
/**
|
|
2898
|
+
* Renders the open scene through its own main camera, the one the game would use, and answers
|
|
2899
|
+
* the image: {@link GameViewFrameResult}. Fails with `RpcErrorCode.noScene` while no scene is
|
|
2900
|
+
* open and `RpcErrorCode.invalidRequest` while the game view is off.
|
|
2901
|
+
*/
|
|
2902
|
+
readonly gameViewFrame: "gameViewFrame";
|
|
2903
|
+
/** Renders one model or prefab asset on its own and answers the image: {@link ThumbnailResult}. */
|
|
2904
|
+
readonly renderThumbnail: "renderThumbnail";
|
|
2905
|
+
};
|
|
2906
|
+
/**
|
|
2907
|
+
* The union of the names in `RenderViewMethod`.
|
|
2908
|
+
*
|
|
2909
|
+
* @public
|
|
2910
|
+
*/
|
|
2911
|
+
export type RenderViewMethod = (typeof RenderViewMethod)[keyof typeof RenderViewMethod];
|
|
2912
|
+
/**
|
|
2913
|
+
* The largest width and height, in pixels, of the game view.
|
|
2914
|
+
*
|
|
2915
|
+
* @public
|
|
2916
|
+
*/
|
|
2917
|
+
export declare const GAME_VIEW_MAX_SIZE = 2048;
|
|
2918
|
+
/**
|
|
2919
|
+
* The game view's size until `setGameView` gives one: 640 by 360.
|
|
2920
|
+
*
|
|
2921
|
+
* @public
|
|
2922
|
+
*/
|
|
2923
|
+
export declare const GAME_VIEW_DEFAULT_SIZE: {
|
|
2924
|
+
readonly width: 640;
|
|
2925
|
+
readonly height: 360;
|
|
2926
|
+
};
|
|
2927
|
+
/**
|
|
2928
|
+
* The largest side, in pixels, of a thumbnail.
|
|
2929
|
+
*
|
|
2930
|
+
* @public
|
|
2931
|
+
*/
|
|
2932
|
+
export declare const THUMBNAIL_MAX_SIZE = 1024;
|
|
2933
|
+
/**
|
|
2934
|
+
* A thumbnail's side when the request gives none.
|
|
2935
|
+
*
|
|
2936
|
+
* @public
|
|
2937
|
+
*/
|
|
2938
|
+
export declare const THUMBNAIL_DEFAULT_SIZE = 128;
|
|
2939
|
+
/**
|
|
2940
|
+
* The parameters of `setGameView`.
|
|
2941
|
+
*
|
|
2942
|
+
* @public
|
|
2943
|
+
*/
|
|
2944
|
+
interface SetGameViewParams {
|
|
2945
|
+
/** Whether the view renders. Off frees its texture. */
|
|
2946
|
+
readonly enabled: boolean;
|
|
2947
|
+
/** The width in pixels, 1 to {@link GAME_VIEW_MAX_SIZE}; absent to keep the current one. */
|
|
2948
|
+
readonly width?: number;
|
|
2949
|
+
/** The height in pixels, 1 to {@link GAME_VIEW_MAX_SIZE}; absent to keep the current one. */
|
|
2950
|
+
readonly height?: number;
|
|
2951
|
+
}
|
|
2952
|
+
/**
|
|
2953
|
+
* The answer to `setGameView`: the view as the host now has it.
|
|
2954
|
+
*
|
|
2955
|
+
* @public
|
|
2956
|
+
*/
|
|
2957
|
+
interface GameViewState {
|
|
2958
|
+
/** Whether the view renders. */
|
|
2959
|
+
readonly enabled: boolean;
|
|
2960
|
+
/** Its width in pixels. */
|
|
2961
|
+
readonly width: number;
|
|
2962
|
+
/** Its height in pixels. */
|
|
2963
|
+
readonly height: number;
|
|
2964
|
+
}
|
|
2965
|
+
/**
|
|
2966
|
+
* The parameters of `gameViewFrame`.
|
|
2967
|
+
*
|
|
2968
|
+
* @public
|
|
2969
|
+
*/
|
|
2970
|
+
interface GameViewFrameParams {
|
|
2971
|
+
/** The image format. */
|
|
2972
|
+
readonly format: ScreenshotFormat;
|
|
2973
|
+
/** The JPEG quality, from 0 to 1; the host's default (0.9) when absent. Ignored for PNG. */
|
|
2974
|
+
readonly quality?: number;
|
|
2975
|
+
}
|
|
2976
|
+
/**
|
|
2977
|
+
* The answer to `gameViewFrame`.
|
|
2978
|
+
*
|
|
2979
|
+
* @public
|
|
2980
|
+
*/
|
|
2981
|
+
interface GameViewFrameResult {
|
|
2982
|
+
/**
|
|
2983
|
+
* The image as a PNG or JPEG data URL, at the game view's size; `null` when the open scene has
|
|
2984
|
+
* no enabled camera, so there is nothing to show.
|
|
2985
|
+
*/
|
|
2986
|
+
readonly dataUrl: string | null;
|
|
2987
|
+
/** The image width in pixels. */
|
|
2988
|
+
readonly width: number;
|
|
2989
|
+
/** The image height in pixels. */
|
|
2990
|
+
readonly height: number;
|
|
2991
|
+
/** The uid of the entity whose camera was rendered, or `null` with no image. */
|
|
2992
|
+
readonly camera: string | null;
|
|
2993
|
+
}
|
|
2994
|
+
/**
|
|
2995
|
+
* The parameters of `renderThumbnail`.
|
|
2996
|
+
*
|
|
2997
|
+
* @public
|
|
2998
|
+
*/
|
|
2999
|
+
interface RenderThumbnailParams {
|
|
3000
|
+
/**
|
|
3001
|
+
* The asset: its address, or a reference whose `type` is `"model"` or `"scene"` (a prefab). An
|
|
3002
|
+
* address alone is typed by its extension: `.glb`/`.gltf` for a model, `.prefab.json` or
|
|
3003
|
+
* `.scene.json` for a prefab.
|
|
3004
|
+
*/
|
|
3005
|
+
readonly asset: string | SceneFileAssetRef;
|
|
3006
|
+
/** The square image's side in pixels, 1 to {@link THUMBNAIL_MAX_SIZE}; {@link THUMBNAIL_DEFAULT_SIZE} when absent. */
|
|
3007
|
+
readonly size?: number;
|
|
3008
|
+
/** The image format. */
|
|
3009
|
+
readonly format: ScreenshotFormat;
|
|
3010
|
+
/** The JPEG quality, from 0 to 1; the host's default (0.9) when absent. Ignored for PNG. */
|
|
3011
|
+
readonly quality?: number;
|
|
3012
|
+
}
|
|
3013
|
+
/**
|
|
3014
|
+
* The answer to `renderThumbnail`.
|
|
3015
|
+
*
|
|
3016
|
+
* @public
|
|
3017
|
+
*/
|
|
3018
|
+
interface ThumbnailResult {
|
|
3019
|
+
/** The image as a PNG or JPEG data URL. */
|
|
3020
|
+
readonly dataUrl: string;
|
|
3021
|
+
/** The image width in pixels. */
|
|
3022
|
+
readonly width: number;
|
|
3023
|
+
/** The image height in pixels. */
|
|
3024
|
+
readonly height: number;
|
|
3025
|
+
}
|
|
3026
|
+
/**
|
|
3027
|
+
* Editor → scene host: one of the `RenderViewMethod`s.
|
|
3028
|
+
*
|
|
3029
|
+
* @public
|
|
3030
|
+
*/
|
|
3031
|
+
type RenderViewRequest = RpcRequestWithParams<typeof RenderViewMethod.setGameView, SetGameViewParams> | RpcRequestWithParams<typeof RenderViewMethod.gameViewFrame, GameViewFrameParams> | RpcRequestWithParams<typeof RenderViewMethod.renderThumbnail, RenderThumbnailParams>;
|
|
3032
|
+
/**
|
|
3033
|
+
* The success answer to `setGameView`.
|
|
3034
|
+
*
|
|
3035
|
+
* @public
|
|
3036
|
+
*/
|
|
3037
|
+
type SetGameViewResponse = RpcSuccessResponse<GameViewState>;
|
|
3038
|
+
/**
|
|
3039
|
+
* The success answer to `gameViewFrame`.
|
|
3040
|
+
*
|
|
3041
|
+
* @public
|
|
3042
|
+
*/
|
|
3043
|
+
type GameViewFrameResponse = RpcSuccessResponse<GameViewFrameResult>;
|
|
3044
|
+
/**
|
|
3045
|
+
* The success answer to `renderThumbnail`.
|
|
3046
|
+
*
|
|
3047
|
+
* @public
|
|
3048
|
+
*/
|
|
3049
|
+
type ThumbnailResponse = RpcSuccessResponse<ThumbnailResult>;
|
|
3050
|
+
/**
|
|
3051
|
+
* Checks the parameters of `setGameView`.
|
|
3052
|
+
*
|
|
3053
|
+
* @param value - The received `params`.
|
|
3054
|
+
* @returns True for a boolean `enabled` and sizes in range when given.
|
|
3055
|
+
*
|
|
3056
|
+
* @public
|
|
3057
|
+
*/
|
|
3058
|
+
export declare function isSetGameViewParams(value: unknown): value is SetGameViewParams;
|
|
3059
|
+
/**
|
|
3060
|
+
* Checks the result of `setGameView`.
|
|
3061
|
+
*
|
|
3062
|
+
* @param value - The received `result`.
|
|
3063
|
+
* @returns True for a boolean `enabled` and sizes in range.
|
|
3064
|
+
*
|
|
3065
|
+
* @public
|
|
3066
|
+
*/
|
|
3067
|
+
export declare function isGameViewState(value: unknown): value is GameViewState;
|
|
3068
|
+
/**
|
|
3069
|
+
* Checks the parameters of `gameViewFrame`.
|
|
3070
|
+
*
|
|
3071
|
+
* @param value - The received `params`.
|
|
3072
|
+
* @returns True for a known format and a quality from 0 to 1 when given.
|
|
3073
|
+
*
|
|
3074
|
+
* @public
|
|
3075
|
+
*/
|
|
3076
|
+
export declare function isGameViewFrameParams(value: unknown): value is GameViewFrameParams;
|
|
3077
|
+
/**
|
|
3078
|
+
* Checks the result of `gameViewFrame`.
|
|
3079
|
+
*
|
|
3080
|
+
* @param value - The received `result`.
|
|
3081
|
+
* @returns True for an image and a camera uid, or `null` for both, and sizes in range.
|
|
3082
|
+
*
|
|
3083
|
+
* @public
|
|
3084
|
+
*/
|
|
3085
|
+
export declare function isGameViewFrameResult(value: unknown): value is GameViewFrameResult;
|
|
3086
|
+
/**
|
|
3087
|
+
* Checks the parameters of `renderThumbnail`.
|
|
3088
|
+
*
|
|
3089
|
+
* @param value - The received `params`.
|
|
3090
|
+
* @returns True for an address or asset reference, a size in range when given, and a known format.
|
|
3091
|
+
*
|
|
3092
|
+
* @public
|
|
3093
|
+
*/
|
|
3094
|
+
export declare function isRenderThumbnailParams(value: unknown): value is RenderThumbnailParams;
|
|
3095
|
+
/**
|
|
3096
|
+
* Checks the result of `renderThumbnail`.
|
|
3097
|
+
*
|
|
3098
|
+
* @param value - The received `result`.
|
|
3099
|
+
* @returns True for an image and sizes in range.
|
|
3100
|
+
*
|
|
3101
|
+
* @public
|
|
3102
|
+
*/
|
|
3103
|
+
export declare function isThumbnailResult(value: unknown): value is ThumbnailResult;
|
|
3104
|
+
//#endregion
|
|
3105
|
+
//#region src/channel.d.ts
|
|
3106
|
+
/**
|
|
3107
|
+
* Where a host listens for the editor's connect message: the view's `window` in a browser, or any
|
|
3108
|
+
* `EventTarget` that dispatches `MessageEvent`s, which is how a headless test stands in for one.
|
|
3109
|
+
* Events that are not `MessageEvent`s are ignored.
|
|
3110
|
+
*
|
|
3111
|
+
* @beta
|
|
3112
|
+
*/
|
|
3113
|
+
interface EditorMessageTarget {
|
|
3114
|
+
/**
|
|
3115
|
+
* Subscribes to window messages.
|
|
3116
|
+
*
|
|
3117
|
+
* @param type - Always `"message"`.
|
|
3118
|
+
* @param listener - Receives each message.
|
|
3119
|
+
*/
|
|
3120
|
+
addEventListener(type: "message", listener: (event: Event) => void): void;
|
|
3121
|
+
/**
|
|
3122
|
+
* Unsubscribes a listener added with `addEventListener`.
|
|
2622
3123
|
*
|
|
2623
3124
|
* @param type - Always `"message"`.
|
|
2624
3125
|
* @param listener - The listener to remove.
|
|
@@ -2668,6 +3169,13 @@ interface EditorHostOptions {
|
|
|
2668
3169
|
readonly editMode?: boolean;
|
|
2669
3170
|
/** The project's extensions, in the order its `main.ts` registers them. */
|
|
2670
3171
|
readonly extensions?: readonly Extension[];
|
|
3172
|
+
/**
|
|
3173
|
+
* Builds a fresh list of the project's extensions, for the second app thumbnails render in. An
|
|
3174
|
+
* extension object belongs to one app (`IGX-0411`), so the host cannot reuse `extensions`. The
|
|
3175
|
+
* generated scene view passes the project's own `extensions` function from `src/extensions.ts`.
|
|
3176
|
+
* Without it, a host given `extensions` does not list `HostCapability.thumbnails`.
|
|
3177
|
+
*/
|
|
3178
|
+
readonly createExtensions?: () => readonly Extension[];
|
|
2671
3179
|
/** The project's component classes, registered with `app.registerComponents`. */
|
|
2672
3180
|
readonly scripts?: readonly ConcreteComponentType[];
|
|
2673
3181
|
/** Project settings, as `ignifx.config.ts` supplies them (`import.meta.env.IGNIFX_CONFIG`). */
|
|
@@ -2818,7 +3326,7 @@ interface EditorPlayConnector {
|
|
|
2818
3326
|
}
|
|
2819
3327
|
/**
|
|
2820
3328
|
* Lets the editor drive a running game: answers the handshake with `hostKind: "play"`, then `play`,
|
|
2821
|
-
* `pause`, `step`, `stop`, `playState` and `
|
|
3329
|
+
* `pause`, `step`, `stop`, `playState`, `playStats`, `queryRuntime`, (with a canvas) `screenshot` and (with `app.input`) `sendInput`, and sends `playStateChanged` when the game's phase
|
|
2822
3330
|
* changes, and `log`, `hostError` and `hotReloaded` for the game's log lines, `app.onError` reports
|
|
2823
3331
|
* and hot reloads (the newest 256 from before the handshake right after it).
|
|
2824
3332
|
*
|
|
@@ -2871,5 +3379,5 @@ export declare function startEditorPlayControls(app: App, options: EditorPlayCon
|
|
|
2871
3379
|
*/
|
|
2872
3380
|
export declare function listenForEditorPlayControls(options: EditorPlayControlsOptions): EditorPlayConnector;
|
|
2873
3381
|
//#endregion
|
|
2874
|
-
export { type AddComponentOp, type AppErrorData, type ApplyOpFailure, type ApplyOpsParams, type ApplyOpsResponse, type ApplyOpsResult, type AssetReloadedParams, type ColliderOutlineRecord, type ColliderOutlineSet, type ColliderOutlinesResponse, type CreateEntityOp, type DescribeSettingsResponse, type DestroyEntityOp, type EditorAssetChange, type EditorConnectMessage, type EditorHost, EditorHostErrorCode, type EditorHostOptions, type EditorMessageTarget, type EditorPlayConnector, type EditorPlayControls, type EditorPlayControlsOptions, type EntityField, type EntityFieldValues, type EntitySelection, type FrameParams, type GetSchemasResponse, type GizmoDragMode, type GizmoSnap, type HeartbeatNotification, type HelloParams, type HelloRequest, type HostErrorParams, type HotReloadError, type HotReloadReport, type HotReloadedParams, type IncompatibleProtocolData, type InstantiateOp, type InvalidSceneFileData, type JsonArray, type JsonObject, type JsonPath, type JsonValue, type LogLevel, type LogParams, type LoggedError, type NullResponse, type OpenSceneParams, type OpenSceneResponse, type OpenSceneResult, type PickParams, type PickRay, type PickResponse, type PickResult, type PingRequest, type PlayRequest, type PlayResponse, type PlayState, type PlayStateChangedNotification, type PlayStateReport, type PlayStateResponse, type PlayStats, type PlayStatsResponse, type PongResponse, type ProtocolVersion, type ReadBackParams, type ReadBackResponse, type ReadBackResult, type ReadyResponse, type ReadyResult, type RemoveComponentOp, type RemoveOverrideOp, type ReorderOp, type ReparentOp, type RpcError, type RpcErrorResponse, type RpcId, type RpcMessage, type RpcNotification, type RpcNotificationWithParams, type RpcRequest, type RpcRequestWithParams, type RpcResponse, type RpcSuccessResponse, type SampleAnimationParams, type SampleAnimationResponse, type SampleAnimationResult, type SceneFile, type SceneFileAssetRef, type SceneFileComponent, type SceneFileEntity, type SceneFileInstance, type SceneFileIssue, type SceneFileOverride, type SceneFileTransform, type SceneHostNotification, type SceneIssue, type SceneOp, type SceneOpenedParams, type SceneRequest, type SchemaDescription, type SchemaFieldDescription, type SchemaSet, type ScreenshotParams, type ScreenshotResponse, type ScreenshotResult, type SelectResponse, type SetAnimateMaterialsParams, type SetEntityFieldOp, type SetGizmoParams, type SetOverrideOp, type SetPropOp, type SetSceneSettingOp, type SetTransformOp, type SetViewModeParams, type SettingsSet, type StepParams, type TransformDraggedParams, type TransformDraggingParams, type Vec3, isEditorOrigin };
|
|
3382
|
+
export { type AddComponentOp, type AppErrorData, type ApplyOpFailure, type ApplyOpsParams, type ApplyOpsResponse, type ApplyOpsResult, type AssetReloadedParams, type ColliderOutlineRecord, type ColliderOutlineSet, type ColliderOutlinesResponse, type CreateEntityOp, type DescribeSettingsResponse, type DestroyEntityOp, type EditorAssetChange, type EditorConnectMessage, type EditorHost, EditorHostErrorCode, type EditorHostOptions, type EditorMessageTarget, type EditorPlayConnector, type EditorPlayControls, type EditorPlayControlsOptions, type EntityField, type EntityFieldValues, type EntitySelection, type FrameParams, type GameViewFrameParams, type GameViewFrameResponse, type GameViewFrameResult, type GameViewState, type GetSchemasResponse, type GizmoDragMode, type GizmoSnap, type HeartbeatNotification, type HelloParams, type HelloRequest, type HostErrorParams, type HotReloadError, type HotReloadReport, type HotReloadedParams, type IncompatibleProtocolData, type InstantiateOp, type InvalidSceneFileData, type JsonArray, type JsonObject, type JsonPath, type JsonValue, type LogLevel, type LogParams, type LoggedError, type NullResponse, type OpenSceneParams, type OpenSceneResponse, type OpenSceneResult, type PickParams, type PickRay, type PickResponse, type PickResult, type PingRequest, type PlayRequest, type PlayResponse, type PlayState, type PlayStateChangedNotification, type PlayStateReport, type PlayStateResponse, type PlayStats, type PlayStatsResponse, type PongResponse, type ProtocolVersion, type QueryRuntimeParams, type QueryRuntimeResponse, type QueryRuntimeResult, type ReadBackParams, type ReadBackResponse, type ReadBackResult, type ReadyResponse, type ReadyResult, type RemoveComponentOp, type RemoveOverrideOp, type RenderThumbnailParams, type RenderViewRequest, type ReorderOp, type ReparentOp, type RpcError, type RpcErrorResponse, type RpcId, type RpcMessage, type RpcNotification, type RpcNotificationWithParams, type RpcRequest, type RpcRequestWithParams, type RpcResponse, type RpcSuccessResponse, type SampleAnimationParams, type SampleAnimationResponse, type SampleAnimationResult, type SceneFile, type SceneFileAssetRef, type SceneFileComponent, type SceneFileEntity, type SceneFileInstance, type SceneFileIssue, type SceneFileOverride, type SceneFileTransform, type SceneHostNotification, type SceneIssue, type SceneOp, type SceneOpenedParams, type SceneRequest, type SchemaDescription, type SchemaFieldDescription, type SchemaSet, type ScreenshotParams, type ScreenshotResponse, type ScreenshotResult, type SelectResponse, type SendInputEvent, type SendInputKeyEvent, type SendInputParams, type SendInputPointerEvent, type SendInputResponse, type SendInputResult, type SetAnimateMaterialsParams, type SetEntityFieldOp, type SetGameViewParams, type SetGameViewResponse, type SetGizmoParams, type SetOverrideOp, type SetPropOp, type SetSceneSettingOp, type SetTransformOp, type SetViewModeParams, type SettingsSet, type StepParams, type ThumbnailResponse, type ThumbnailResult, type TransformDraggedParams, type TransformDraggingParams, type Vec3, isEditorOrigin };
|
|
2875
3383
|
//# sourceMappingURL=index.d.ts.map
|