@vulfram/engine 0.5.8-alpha → 0.17.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +106 -0
  2. package/package.json +55 -4
  3. package/src/core.ts +14 -0
  4. package/src/ecs.ts +1 -0
  5. package/src/engine/api.ts +234 -23
  6. package/src/engine/bridge/dispatch.ts +265 -40
  7. package/src/engine/bridge/guards.ts +4 -1
  8. package/src/engine/bridge/protocol.ts +72 -54
  9. package/src/engine/ecs/index.ts +187 -42
  10. package/src/engine/state.ts +133 -2
  11. package/src/engine/systems/command-intent.ts +153 -3
  12. package/src/engine/systems/constraint-solve.ts +167 -0
  13. package/src/engine/systems/core-command-builder.ts +9 -265
  14. package/src/engine/systems/diagnostics.ts +20 -19
  15. package/src/engine/systems/index.ts +3 -1
  16. package/src/engine/systems/input-mirror.ts +101 -3
  17. package/src/engine/systems/resource-upload.ts +96 -44
  18. package/src/engine/systems/response-decode.ts +69 -15
  19. package/src/engine/systems/scene-sync.ts +306 -0
  20. package/src/engine/systems/ui-bridge.ts +360 -0
  21. package/src/engine/systems/utils.ts +43 -1
  22. package/src/engine/systems/world-lifecycle.ts +72 -103
  23. package/src/engine/window/manager.ts +168 -0
  24. package/src/engine/world/entities.ts +931 -33
  25. package/src/engine/world/mount.ts +174 -0
  26. package/src/engine/world/types.ts +71 -0
  27. package/src/engine/world/world-ui.ts +266 -0
  28. package/src/engine/world/world3d.ts +280 -0
  29. package/src/index.ts +30 -1
  30. package/src/mount.ts +2 -0
  31. package/src/types/cmds/audio.ts +189 -0
  32. package/src/types/cmds/camera.ts +18 -13
  33. package/src/types/cmds/environment.ts +47 -4
  34. package/src/types/cmds/geometry.ts +18 -16
  35. package/src/types/cmds/index.ts +203 -132
  36. package/src/types/cmds/light.ts +17 -13
  37. package/src/types/cmds/material.ts +14 -13
  38. package/src/types/cmds/model.ts +40 -16
  39. package/src/types/cmds/realm.ts +25 -0
  40. package/src/types/cmds/render-graph.ts +49 -0
  41. package/src/types/cmds/resources.ts +4 -0
  42. package/src/types/cmds/shadow.ts +7 -7
  43. package/src/types/cmds/system.ts +29 -0
  44. package/src/types/cmds/target.ts +82 -0
  45. package/src/types/cmds/texture.ts +19 -5
  46. package/src/types/cmds/ui.ts +220 -0
  47. package/src/types/cmds/window.ts +41 -204
  48. package/src/types/events/index.ts +4 -1
  49. package/src/types/events/pointer.ts +42 -13
  50. package/src/types/events/system.ts +150 -7
  51. package/src/types/events/ui.ts +21 -0
  52. package/src/types/index.ts +1 -0
  53. package/src/types/json.ts +15 -0
  54. package/src/types/kinds.ts +3 -0
  55. package/src/window.ts +8 -0
  56. package/src/world-ui.ts +2 -0
  57. package/src/world3d.ts +10 -0
  58. package/tsconfig.json +0 -29
@@ -1,4 +1,5 @@
1
1
  import type { PrimitiveShape } from '../kinds';
2
+ import type { ResourceEntry } from './resources';
2
3
 
3
4
  /** Primitive attribute semantic identifiers. */
4
5
  export type GeometryPrimitiveType =
@@ -31,35 +32,35 @@ export interface GeometryPrimitiveEntry {
31
32
 
32
33
  /** Command payload for creating geometry from buffers. */
33
34
  export interface CmdGeometryCreateArgs {
34
- windowId: number;
35
35
  geometryId: number;
36
36
  label?: string;
37
37
  entries: GeometryPrimitiveEntry[];
38
38
  }
39
39
 
40
- /** Result payload for geometry create. */
41
- export interface CmdResultGeometryCreate {
42
- success: boolean;
43
- message: string;
44
- }
45
-
46
40
  /** Command payload for updating geometry buffers or label. */
47
41
  export interface CmdGeometryUpdateArgs {
48
- windowId: number;
49
42
  geometryId: number;
50
43
  label?: string;
51
- entries: GeometryPrimitiveEntry[];
44
+ entries?: GeometryPrimitiveEntry[];
52
45
  }
53
46
 
54
- /** Result payload for geometry update. */
55
- export interface CmdResultGeometryUpdate {
47
+ /** Result payload for geometry upsert. */
48
+ export interface CmdResultGeometryUpsert {
56
49
  success: boolean;
57
50
  message: string;
58
51
  }
59
52
 
53
+ /** Upsert payload accepted by the core (`create` or `update`). */
54
+ export type CmdGeometryUpsertArgs =
55
+ | CmdGeometryCreateArgs
56
+ | CmdGeometryUpdateArgs;
57
+
58
+ /** Backward-compatible aliases. */
59
+ export type CmdResultGeometryCreate = CmdResultGeometryUpsert;
60
+ export type CmdResultGeometryUpdate = CmdResultGeometryUpsert;
61
+
60
62
  /** Command payload for disposing geometry. */
61
63
  export interface CmdGeometryDisposeArgs {
62
- windowId: number;
63
64
  geometryId: number;
64
65
  }
65
66
 
@@ -120,11 +121,10 @@ export type PrimitiveOptions =
120
121
 
121
122
  /** Command payload for creating a primitive geometry. */
122
123
  export interface CmdPrimitiveGeometryCreateArgs {
123
- windowId: number;
124
124
  geometryId: number;
125
125
  label?: string;
126
126
  shape: PrimitiveShape;
127
- options: PrimitiveOptions;
127
+ options?: PrimitiveOptions;
128
128
  }
129
129
 
130
130
  /** Result payload for primitive geometry create. */
@@ -134,11 +134,13 @@ export interface CmdResultPrimitiveGeometryCreate {
134
134
  }
135
135
 
136
136
  /** Command payload for listing geometry resources. */
137
- export interface CmdGeometryListArgs {}
137
+ export interface CmdGeometryListArgs {
138
+ windowId: number;
139
+ }
138
140
 
139
141
  /** Result payload for geometry list. */
140
142
  export interface CmdResultGeometryList {
141
143
  success: boolean;
142
144
  message: string;
143
- content: number[]; // List of geometry IDs
145
+ geometries: ResourceEntry[];
144
146
  }
@@ -1,107 +1,157 @@
1
- import * as Sys from './system';
2
- import * as Win from './window';
1
+ import * as Audio from './audio';
3
2
  import * as Cam from './camera';
4
- import * as Mod from './model';
3
+ import * as Env from './environment';
4
+ import * as Geo from './geometry';
5
+ import * as Giz from './gizmo';
5
6
  import * as Lite from './light';
6
7
  import * as Mat from './material';
8
+ import * as Mod from './model';
9
+ import * as Realm from './realm';
10
+ import * as Sys from './system';
11
+ import * as Target from './target';
7
12
  import * as Tex from './texture';
8
- import * as Geo from './geometry';
9
- import * as Shad from './shadow';
10
- import * as Giz from './gizmo';
11
- import * as Env from './environment';
13
+ import * as Ui from './ui';
14
+ import * as Win from './window';
12
15
 
13
- export * from './system';
14
- export * from './window';
16
+ export * from './audio';
15
17
  export * from './camera';
16
- export * from './model';
18
+ export * from './environment';
19
+ export * from './geometry';
20
+ export * from './gizmo';
17
21
  export * from './light';
18
22
  export * from './material';
19
- export * from './texture';
20
- export * from './geometry';
23
+ export * from './model';
24
+ export * from './realm';
25
+ export * from './render-graph';
26
+ export * from './resources';
21
27
  export * from './shadow';
22
- export * from './gizmo';
23
- export * from './environment';
28
+ export * from './system';
29
+ export * from './target';
30
+ export * from './texture';
31
+ export * from './ui';
32
+ export * from './window';
24
33
 
25
- /** Discriminated union of all core commands. */
34
+ /**
35
+ * Discriminated union of all commands accepted by core.
36
+ *
37
+ * Routing convention:
38
+ * - world-scoped commands are dispatched through the world command queue
39
+ * - global commands are dispatched through the global command queue
40
+ */
26
41
  export type EngineCmd =
27
42
  | { type: 'cmd-notification-send'; content: Sys.CmdNotificationSendArgs }
43
+ | {
44
+ type: 'cmd-system-diagnostics-set';
45
+ content: Sys.CmdSystemDiagnosticsSetArgs;
46
+ }
28
47
  | { type: 'cmd-window-create'; content: Win.CmdWindowCreateArgs }
29
48
  | { type: 'cmd-window-close'; content: Win.CmdWindowCloseArgs }
30
- | { type: 'cmd-window-set-title'; content: Win.CmdWindowSetTitleArgs }
31
- | { type: 'cmd-window-set-position'; content: Win.CmdWindowSetPositionArgs }
32
- | { type: 'cmd-window-get-position'; content: Win.CmdWindowGetPositionArgs }
33
- | { type: 'cmd-window-set-size'; content: Win.CmdWindowSetSizeArgs }
34
- | { type: 'cmd-window-get-size'; content: Win.CmdWindowGetSizeArgs }
49
+ | { type: 'cmd-window-measurement'; content: Win.CmdWindowMeasurementArgs }
50
+ | { type: 'cmd-window-cursor'; content: Win.CmdWindowCursorArgs }
51
+ | { type: 'cmd-window-state'; content: Win.CmdWindowStateArgs }
35
52
  | {
36
- type: 'cmd-window-get-outer-size';
37
- content: Win.CmdWindowGetOuterSizeArgs;
53
+ type: 'cmd-upload-buffer-discard-all';
54
+ content: Sys.CmdUploadBufferDiscardAllArgs;
38
55
  }
56
+ | { type: 'cmd-camera-upsert'; content: Cam.CmdCameraUpsertArgs }
57
+ | { type: 'cmd-camera-dispose'; content: Cam.CmdCameraDisposeArgs }
58
+ | { type: 'cmd-model-upsert'; content: Mod.CmdModelUpsertArgs }
59
+ | { type: 'cmd-pose-update'; content: Mod.CmdPoseUpdateArgs }
60
+ | { type: 'cmd-model-dispose'; content: Mod.CmdModelDisposeArgs }
61
+ | { type: 'cmd-light-upsert'; content: Lite.CmdLightUpsertArgs }
62
+ | { type: 'cmd-light-dispose'; content: Lite.CmdLightDisposeArgs }
63
+ | { type: 'cmd-material-upsert'; content: Mat.CmdMaterialUpsertArgs }
64
+ | { type: 'cmd-material-dispose'; content: Mat.CmdMaterialDisposeArgs }
39
65
  | {
40
- type: 'cmd-window-get-surface-size';
41
- content: Win.CmdWindowGetSurfaceSizeArgs;
66
+ type: 'cmd-texture-create-from-buffer';
67
+ content: Tex.CmdTextureCreateFromBufferArgs;
42
68
  }
43
- | { type: 'cmd-window-set-state'; content: Win.CmdWindowSetStateArgs }
44
- | { type: 'cmd-window-get-state'; content: Win.CmdWindowGetStateArgs }
45
- | { type: 'cmd-window-set-icon'; content: Win.CmdWindowSetIconArgs }
46
69
  | {
47
- type: 'cmd-window-set-decorations';
48
- content: Win.CmdWindowSetDecorationsArgs;
70
+ type: 'cmd-texture-create-solid-color';
71
+ content: Tex.CmdTextureCreateSolidColorArgs;
49
72
  }
73
+ | { type: 'cmd-texture-dispose'; content: Tex.CmdTextureDisposeArgs }
74
+ | { type: 'cmd-texture-bind-target'; content: Tex.CmdTextureBindTargetArgs }
50
75
  | {
51
- type: 'cmd-window-has-decorations';
52
- content: Win.CmdWindowHasDecorationsArgs;
76
+ type: 'cmd-audio-listener-upsert';
77
+ content: Audio.CmdAudioListenerUpsertArgs;
53
78
  }
54
- | { type: 'cmd-window-set-resizable'; content: Win.CmdWindowSetResizableArgs }
55
- | { type: 'cmd-window-is-resizable'; content: Win.CmdWindowIsResizableArgs }
56
79
  | {
57
- type: 'cmd-window-request-attention';
58
- content: Win.CmdWindowRequestAttentionArgs;
80
+ type: 'cmd-audio-listener-dispose';
81
+ content: Audio.CmdAudioListenerDisposeArgs;
59
82
  }
60
- | { type: 'cmd-window-focus'; content: Win.CmdWindowFocusArgs }
61
83
  | {
62
- type: 'cmd-window-set-cursor-visible';
63
- content: Win.CmdWindowSetCursorVisibleArgs;
84
+ type: 'cmd-audio-source-upsert';
85
+ content: Audio.CmdAudioSourceUpsertArgs;
64
86
  }
65
87
  | {
66
- type: 'cmd-window-set-cursor-grab';
67
- content: Win.CmdWindowSetCursorGrabArgs;
88
+ type: 'cmd-audio-resource-upsert';
89
+ content: Audio.CmdAudioResourceUpsertArgs;
68
90
  }
69
91
  | {
70
- type: 'cmd-window-set-cursor-icon';
71
- content: Win.CmdWindowSetCursorIconArgs;
92
+ type: 'cmd-audio-source-transport';
93
+ content: Audio.CmdAudioSourceTransportArgs;
72
94
  }
73
- | { type: 'cmd-camera-create'; content: Cam.CmdCameraCreateArgs }
74
- | { type: 'cmd-camera-update'; content: Cam.CmdCameraUpdateArgs }
75
- | { type: 'cmd-camera-dispose'; content: Cam.CmdCameraDisposeArgs }
76
- | { type: 'cmd-model-create'; content: Mod.CmdModelCreateArgs }
77
- | { type: 'cmd-model-update'; content: Mod.CmdModelUpdateArgs }
78
- | { type: 'cmd-model-dispose'; content: Mod.CmdModelDisposeArgs }
79
- | { type: 'cmd-light-create'; content: Lite.CmdLightCreateArgs }
80
- | { type: 'cmd-light-update'; content: Lite.CmdLightUpdateArgs }
81
- | { type: 'cmd-light-dispose'; content: Lite.CmdLightDisposeArgs }
82
- | { type: 'cmd-material-create'; content: Mat.CmdMaterialCreateArgs }
83
- | { type: 'cmd-material-update'; content: Mat.CmdMaterialUpdateArgs }
84
- | { type: 'cmd-material-dispose'; content: Mat.CmdMaterialDisposeArgs }
95
+ | { type: 'cmd-audio-state-get'; content: Audio.CmdAudioStateGetArgs }
85
96
  | {
86
- type: 'cmd-texture-create-from-buffer';
87
- content: Tex.CmdTextureCreateFromBufferArgs;
97
+ type: 'cmd-audio-source-dispose';
98
+ content: Audio.CmdAudioSourceDisposeArgs;
88
99
  }
89
100
  | {
90
- type: 'cmd-texture-create-solid-color';
91
- content: Tex.CmdTextureCreateSolidColorArgs;
101
+ type: 'cmd-audio-resource-dispose';
102
+ content: Audio.CmdAudioResourceDisposeArgs;
92
103
  }
93
- | { type: 'cmd-texture-dispose'; content: Tex.CmdTextureDisposeArgs }
94
- | { type: 'cmd-geometry-create'; content: Geo.CmdGeometryCreateArgs }
95
- | { type: 'cmd-geometry-update'; content: Geo.CmdGeometryUpdateArgs }
104
+ | { type: 'cmd-geometry-upsert'; content: Geo.CmdGeometryUpsertArgs }
96
105
  | { type: 'cmd-geometry-dispose'; content: Geo.CmdGeometryDisposeArgs }
97
106
  | {
98
107
  type: 'cmd-primitive-geometry-create';
99
108
  content: Geo.CmdPrimitiveGeometryCreateArgs;
100
109
  }
101
- | { type: 'cmd-environment-create'; content: Env.CmdEnvironmentCreateArgs }
102
- | { type: 'cmd-environment-update'; content: Env.CmdEnvironmentUpdateArgs }
103
- | { type: 'cmd-environment-dispose'; content: Env.CmdEnvironmentDisposeArgs }
104
- | { type: 'cmd-shadow-configure'; content: Shad.CmdShadowConfigureArgs }
110
+ | { type: 'cmd-environment-upsert'; content: Env.CmdEnvironmentUpsertArgs }
111
+ | {
112
+ type: 'cmd-environment-dispose';
113
+ content: Env.CmdEnvironmentDisposeArgs;
114
+ }
115
+ | { type: 'cmd-shadow-configure'; content: import('./shadow').CmdShadowConfigureArgs }
116
+ | { type: 'cmd-realm-create'; content: Realm.CmdRealmCreateArgs }
117
+ | { type: 'cmd-realm-dispose'; content: Realm.CmdRealmDisposeArgs }
118
+ | { type: 'cmd-target-upsert'; content: Target.CmdTargetUpsertArgs }
119
+ | { type: 'cmd-target-dispose'; content: Target.CmdTargetDisposeArgs }
120
+ | {
121
+ type: 'cmd-target-layer-upsert';
122
+ content: Target.CmdTargetLayerUpsertArgs;
123
+ }
124
+ | {
125
+ type: 'cmd-target-layer-dispose';
126
+ content: Target.CmdTargetLayerDisposeArgs;
127
+ }
128
+ | { type: 'cmd-ui-theme-define'; content: Ui.CmdUiThemeDefineArgs }
129
+ | { type: 'cmd-ui-theme-dispose'; content: Ui.CmdUiThemeDisposeArgs }
130
+ | { type: 'cmd-ui-document-create'; content: Ui.CmdUiDocumentCreateArgs }
131
+ | { type: 'cmd-ui-document-dispose'; content: Ui.CmdUiDocumentDisposeArgs }
132
+ | { type: 'cmd-ui-document-set-rect'; content: Ui.CmdUiDocumentSetRectArgs }
133
+ | { type: 'cmd-ui-document-set-theme'; content: Ui.CmdUiDocumentSetThemeArgs }
134
+ | { type: 'cmd-ui-document-get-tree'; content: Ui.CmdUiDocumentGetTreeArgs }
135
+ | {
136
+ type: 'cmd-ui-document-get-layout-rects';
137
+ content: Ui.CmdUiDocumentGetLayoutRectsArgs;
138
+ }
139
+ | { type: 'cmd-ui-apply-ops'; content: Ui.CmdUiApplyOpsArgs }
140
+ | { type: 'cmd-ui-debug-set'; content: Ui.CmdUiDebugSetArgs }
141
+ | { type: 'cmd-ui-focus-set'; content: Ui.CmdUiFocusSetArgs }
142
+ | { type: 'cmd-ui-focus-get'; content: Ui.CmdUiFocusGetArgs }
143
+ | { type: 'cmd-ui-event-trace-set'; content: Ui.CmdUiEventTraceSetArgs }
144
+ | {
145
+ type: 'cmd-ui-image-create-from-buffer';
146
+ content: Ui.CmdUiImageCreateFromBufferArgs;
147
+ }
148
+ | { type: 'cmd-ui-image-dispose'; content: Ui.CmdUiImageDisposeArgs }
149
+ | { type: 'cmd-ui-clipboard-paste'; content: Ui.CmdUiClipboardPasteArgs }
150
+ | { type: 'cmd-ui-screenshot-reply'; content: Ui.CmdUiScreenshotReplyArgs }
151
+ | {
152
+ type: 'cmd-ui-access-kit-action-request';
153
+ content: Ui.CmdUiAccessKitActionRequestArgs;
154
+ }
105
155
  | { type: 'cmd-model-list'; content: Mod.CmdModelListArgs }
106
156
  | { type: 'cmd-material-list'; content: Mat.CmdMaterialListArgs }
107
157
  | { type: 'cmd-texture-list'; content: Tex.CmdTextureListArgs }
@@ -111,83 +161,118 @@ export type EngineCmd =
111
161
  | { type: 'cmd-gizmo-draw-line'; content: Giz.CmdGizmoDrawLineArgs }
112
162
  | { type: 'cmd-gizmo-draw-aabb'; content: Giz.CmdGizmoDrawAabbArgs };
113
163
 
114
- /** Discriminated union of all core command responses. */
164
+ /** Discriminated union of all command responses returned by core. */
115
165
  export type CommandResponse =
116
166
  | { type: 'notification-send'; content: Sys.CmdResultNotificationSend }
167
+ | {
168
+ type: 'system-diagnostics-set';
169
+ content: Sys.CmdResultSystemDiagnosticsSet;
170
+ }
117
171
  | { type: 'window-create'; content: Win.CmdResultWindowCreate }
118
172
  | { type: 'window-close'; content: Win.CmdResultWindowClose }
119
- | { type: 'window-set-title'; content: Win.CmdResultWindowSetTitle }
120
- | { type: 'window-set-position'; content: Win.CmdResultWindowSetPosition }
121
- | { type: 'window-get-position'; content: Win.CmdResultWindowGetPosition }
122
- | { type: 'window-set-size'; content: Win.CmdResultWindowSetSize }
123
- | { type: 'window-get-size'; content: Win.CmdResultWindowGetSize }
124
- | { type: 'window-get-outer-size'; content: Win.CmdResultWindowGetOuterSize }
173
+ | { type: 'window-measurement'; content: Win.CmdResultWindowMeasurement }
174
+ | { type: 'window-cursor'; content: Win.CmdResultWindowCursor }
175
+ | { type: 'window-state'; content: Win.CmdResultWindowState }
125
176
  | {
126
- type: 'window-get-surface-size';
127
- content: Win.CmdResultWindowGetSurfaceSize;
177
+ type: 'upload-buffer-discard-all';
178
+ content: Sys.CmdResultUploadBufferDiscardAll;
128
179
  }
129
- | { type: 'window-set-state'; content: Win.CmdResultWindowSetState }
130
- | { type: 'window-get-state'; content: Win.CmdResultWindowGetState }
131
- | { type: 'window-set-icon'; content: Win.CmdResultWindowSetIcon }
180
+ | { type: 'camera-upsert'; content: Cam.CmdResultCameraUpsert }
181
+ | { type: 'camera-dispose'; content: Cam.CmdResultCameraDispose }
182
+ | { type: 'model-upsert'; content: Mod.CmdResultModelUpsert }
183
+ | { type: 'pose-update'; content: Mod.CmdResultPoseUpdate }
184
+ | { type: 'model-dispose'; content: Mod.CmdResultModelDispose }
185
+ | { type: 'light-upsert'; content: Lite.CmdResultLightUpsert }
186
+ | { type: 'light-dispose'; content: Lite.CmdResultLightDispose }
187
+ | { type: 'material-upsert'; content: Mat.CmdResultMaterialUpsert }
188
+ | { type: 'material-dispose'; content: Mat.CmdResultMaterialDispose }
132
189
  | {
133
- type: 'window-set-decorations';
134
- content: Win.CmdResultWindowSetDecorations;
190
+ type: 'texture-create-from-buffer';
191
+ content: Tex.CmdResultTextureCreateFromBuffer;
135
192
  }
136
193
  | {
137
- type: 'window-has-decorations';
138
- content: Win.CmdResultWindowHasDecorations;
194
+ type: 'texture-create-solid-color';
195
+ content: Tex.CmdResultTextureCreateSolidColor;
139
196
  }
140
- | { type: 'window-set-resizable'; content: Win.CmdResultWindowSetResizable }
141
- | { type: 'window-is-resizable'; content: Win.CmdResultWindowIsResizable }
197
+ | { type: 'texture-dispose'; content: Tex.CmdResultTextureDispose }
198
+ | { type: 'texture-bind-target'; content: Tex.CmdResultTextureBindTarget }
142
199
  | {
143
- type: 'window-request-attention';
144
- content: Win.CmdResultWindowRequestAttention;
200
+ type: 'audio-listener-upsert';
201
+ content: Audio.CmdResultAudioListenerUpsert;
145
202
  }
146
- | { type: 'window-focus'; content: Win.CmdResultWindowFocus }
147
203
  | {
148
- type: 'window-set-cursor-visible';
149
- content: Win.CmdResultWindowSetCursorVisible;
204
+ type: 'audio-listener-dispose';
205
+ content: Audio.CmdResultAudioListenerDispose;
150
206
  }
151
207
  | {
152
- type: 'window-set-cursor-grab';
153
- content: Win.CmdResultWindowSetCursorGrab;
208
+ type: 'audio-source-upsert';
209
+ content: Audio.CmdResultAudioSourceUpsert;
154
210
  }
155
211
  | {
156
- type: 'window-set-cursor-icon';
157
- content: Win.CmdResultWindowSetCursorIcon;
212
+ type: 'audio-resource-upsert';
213
+ content: Audio.CmdResultAudioResourceUpsert;
158
214
  }
159
- | { type: 'camera-create'; content: Cam.CmdResultCameraCreate }
160
- | { type: 'camera-update'; content: Cam.CmdResultCameraUpdate }
161
- | { type: 'camera-dispose'; content: Cam.CmdResultCameraDispose }
162
- | { type: 'model-create'; content: Mod.CmdResultModelCreate }
163
- | { type: 'model-update'; content: Mod.CmdResultModelUpdate }
164
- | { type: 'model-dispose'; content: Mod.CmdResultModelDispose }
165
- | { type: 'light-create'; content: Lite.CmdResultLightCreate }
166
- | { type: 'light-update'; content: Lite.CmdResultLightUpdate }
167
- | { type: 'light-dispose'; content: Lite.CmdResultLightDispose }
168
- | { type: 'material-create'; content: Mat.CmdResultMaterialCreate }
169
- | { type: 'material-update'; content: Mat.CmdResultMaterialUpdate }
170
- | { type: 'material-dispose'; content: Mat.CmdResultMaterialDispose }
171
215
  | {
172
- type: 'texture-create-from-buffer';
173
- content: Tex.CmdResultTextureCreateFromBuffer;
216
+ type: 'audio-source-transport';
217
+ content: Audio.CmdResultAudioSourceTransport;
174
218
  }
219
+ | { type: 'audio-state-get'; content: Audio.CmdResultAudioStateGet }
175
220
  | {
176
- type: 'texture-create-solid-color';
177
- content: Tex.CmdResultTextureCreateSolidColor;
221
+ type: 'audio-source-dispose';
222
+ content: Audio.CmdResultAudioSourceDispose;
178
223
  }
179
- | { type: 'texture-dispose'; content: Tex.CmdResultTextureDispose }
180
- | { type: 'geometry-create'; content: Geo.CmdResultGeometryCreate }
181
- | { type: 'geometry-update'; content: Geo.CmdResultGeometryUpdate }
224
+ | {
225
+ type: 'audio-resource-dispose';
226
+ content: Audio.CmdResultAudioResourceDispose;
227
+ }
228
+ | { type: 'geometry-upsert'; content: Geo.CmdResultGeometryUpsert }
182
229
  | { type: 'geometry-dispose'; content: Geo.CmdResultGeometryDispose }
183
230
  | {
184
231
  type: 'primitive-geometry-create';
185
232
  content: Geo.CmdResultPrimitiveGeometryCreate;
186
233
  }
187
- | { type: 'environment-create'; content: Env.CmdResultEnvironment }
188
- | { type: 'environment-update'; content: Env.CmdResultEnvironment }
234
+ | { type: 'environment-upsert'; content: Env.CmdResultEnvironment }
189
235
  | { type: 'environment-dispose'; content: Env.CmdResultEnvironment }
190
- | { type: 'shadow-configure'; content: Shad.CmdResultShadowConfigure }
236
+ | {
237
+ type: 'shadow-configure';
238
+ content: import('./shadow').CmdResultShadowConfigure;
239
+ }
240
+ | { type: 'realm-create'; content: Realm.CmdResultRealmCreate }
241
+ | { type: 'realm-dispose'; content: Realm.CmdResultRealmDispose }
242
+ | { type: 'target-upsert'; content: Target.CmdResultTargetUpsert }
243
+ | { type: 'target-dispose'; content: Target.CmdResultTargetDispose }
244
+ | {
245
+ type: 'target-layer-upsert';
246
+ content: Target.CmdResultTargetLayerUpsert;
247
+ }
248
+ | {
249
+ type: 'target-layer-dispose';
250
+ content: Target.CmdResultTargetLayerDispose;
251
+ }
252
+ | { type: 'ui-theme-define'; content: Ui.CmdResultUiThemeDefine }
253
+ | { type: 'ui-theme-dispose'; content: Ui.CmdResultUiThemeDispose }
254
+ | { type: 'ui-document-create'; content: Ui.CmdResultUiDocumentCreate }
255
+ | { type: 'ui-document-dispose'; content: Ui.CmdResultUiDocumentDispose }
256
+ | { type: 'ui-document-set-rect'; content: Ui.CmdResultUiDocumentSetRect }
257
+ | { type: 'ui-document-set-theme'; content: Ui.CmdResultUiDocumentSetTheme }
258
+ | { type: 'ui-document-get-tree'; content: Ui.CmdResultUiDocumentGetTree }
259
+ | {
260
+ type: 'ui-document-get-layout-rects';
261
+ content: Ui.CmdResultUiDocumentGetLayoutRects;
262
+ }
263
+ | { type: 'ui-apply-ops'; content: Ui.CmdResultUiApplyOps }
264
+ | { type: 'ui-debug-set'; content: Ui.CmdResultUiDebugSet }
265
+ | { type: 'ui-focus-set'; content: Ui.CmdResultUiFocusSet }
266
+ | { type: 'ui-focus-get'; content: Ui.CmdResultUiFocusGet }
267
+ | { type: 'ui-event-trace-set'; content: Ui.CmdResultUiEventTraceSet }
268
+ | {
269
+ type: 'ui-image-create-from-buffer';
270
+ content: Ui.CmdResultUiImageCreateFromBuffer;
271
+ }
272
+ | { type: 'ui-image-dispose'; content: Ui.CmdResultUiImageDispose }
273
+ | { type: 'ui-clipboard-paste'; content: Ui.CmdResultUiInputEvent }
274
+ | { type: 'ui-screenshot-reply'; content: Ui.CmdResultUiInputEvent }
275
+ | { type: 'ui-access-kit-action-request'; content: Ui.CmdResultUiInputEvent }
191
276
  | { type: 'model-list'; content: Mod.CmdResultModelList }
192
277
  | { type: 'material-list'; content: Mat.CmdResultMaterialList }
193
278
  | { type: 'texture-list'; content: Tex.CmdResultTextureList }
@@ -197,35 +282,21 @@ export type CommandResponse =
197
282
  | { type: 'gizmo-draw-line'; content: Giz.CmdResultGizmoDraw }
198
283
  | { type: 'gizmo-draw-aabb'; content: Giz.CmdResultGizmoDraw };
199
284
 
200
- /** Envelope used when batching commands to the core. */
285
+ /** Command envelope used in batched transport payloads. */
201
286
  export interface EngineCmdEnvelope {
202
287
  id: number;
203
288
  type: EngineCmd['type'];
204
289
  content: EngineCmd['content'];
205
290
  }
206
291
 
207
- /** Envelope used when decoding responses from the core. */
292
+ /** Response envelope returned by queue polling and routed by command id. */
208
293
  export interface CommandResponseEnvelope {
209
294
  id: number;
210
295
  type: CommandResponse['type'];
211
296
  content: CommandResponse['content'];
212
297
  }
213
298
 
214
- /** Batch of commands sent in a single tick. */
299
+ /** Batched commands payload sent to transport. */
215
300
  export type EngineBatchCmds = EngineCmdEnvelope[];
216
-
217
- /** Batch of responses received from the core. */
301
+ /** Batched responses payload decoded from transport. */
218
302
  export type EngineBatchResponses = CommandResponseEnvelope[];
219
-
220
- /** Result codes returned by core entrypoints. */
221
- export enum VulframResult {
222
- Success = 0,
223
- UnknownError = 1,
224
- NotInitialized = 2,
225
- AlreadyInitialized = 3,
226
- WrongThread = 4,
227
- CmdInvalidMessagePackError = 5,
228
- BufferNotFound = 6,
229
- BufferIdCollision = 7,
230
- InvalidUploadType = 8,
231
- }
@@ -1,8 +1,9 @@
1
1
  import type { LightKind } from '../kinds';
2
+ import type { ResourceEntry } from './resources';
2
3
 
3
4
  /** Command payload for creating a light. */
4
5
  export interface CmdLightCreateArgs {
5
- windowId: number;
6
+ realmId: number;
6
7
  lightId: number;
7
8
  label?: string;
8
9
  kind?: LightKind;
@@ -17,15 +18,9 @@ export interface CmdLightCreateArgs {
17
18
  castShadow?: boolean;
18
19
  }
19
20
 
20
- /** Result payload for light create. */
21
- export interface CmdResultLightCreate {
22
- success: boolean;
23
- message: string;
24
- }
25
-
26
21
  /** Command payload for updating a light. */
27
22
  export interface CmdLightUpdateArgs {
28
- windowId: number;
23
+ realmId: number;
29
24
  lightId: number;
30
25
  label?: string;
31
26
  kind?: LightKind;
@@ -40,15 +35,22 @@ export interface CmdLightUpdateArgs {
40
35
  castShadow?: boolean;
41
36
  }
42
37
 
43
- /** Result payload for light update. */
44
- export interface CmdResultLightUpdate {
38
+ /** Result payload for light upsert. */
39
+ export interface CmdResultLightUpsert {
45
40
  success: boolean;
46
41
  message: string;
47
42
  }
48
43
 
44
+ /** Upsert payload accepted by the core (`create` or `update`). */
45
+ export type CmdLightUpsertArgs = CmdLightCreateArgs | CmdLightUpdateArgs;
46
+
47
+ /** Backward-compatible aliases. */
48
+ export type CmdResultLightCreate = CmdResultLightUpsert;
49
+ export type CmdResultLightUpdate = CmdResultLightUpsert;
50
+
49
51
  /** Command payload for disposing a light. */
50
52
  export interface CmdLightDisposeArgs {
51
- windowId: number;
53
+ realmId: number;
52
54
  lightId: number;
53
55
  }
54
56
 
@@ -59,11 +61,13 @@ export interface CmdResultLightDispose {
59
61
  }
60
62
 
61
63
  /** Command payload for listing lights. */
62
- export interface CmdLightListArgs {}
64
+ export interface CmdLightListArgs {
65
+ windowId: number;
66
+ }
63
67
 
64
68
  /** Result payload for light list. */
65
69
  export interface CmdResultLightList {
66
70
  success: boolean;
67
71
  message: string;
68
- content: number[]; // List of light IDs
72
+ lights: ResourceEntry[];
69
73
  }
@@ -1,4 +1,5 @@
1
1
  import type { MaterialKind, TransparencyMode, SamplerMode } from '../kinds';
2
+ import type { ResourceEntry } from './resources';
2
3
 
3
4
  /** Standard material options. */
4
5
  export interface StandardOptions {
@@ -47,37 +48,35 @@ export type MaterialOptions =
47
48
 
48
49
  /** Command payload for creating a material. */
49
50
  export interface CmdMaterialCreateArgs {
50
- windowId: number;
51
51
  materialId: number;
52
52
  label?: string;
53
53
  kind: MaterialKind;
54
54
  options?: MaterialOptions;
55
55
  }
56
56
 
57
- /** Result payload for material create. */
58
- export interface CmdResultMaterialCreate {
59
- success: boolean;
60
- message: string;
61
- }
62
-
63
57
  /** Command payload for updating a material. */
64
58
  export interface CmdMaterialUpdateArgs {
65
- windowId: number;
66
59
  materialId: number;
67
60
  label?: string;
68
61
  kind?: MaterialKind;
69
62
  options?: MaterialOptions;
70
63
  }
71
64
 
72
- /** Result payload for material update. */
73
- export interface CmdResultMaterialUpdate {
65
+ /** Result payload for material upsert. */
66
+ export interface CmdResultMaterialUpsert {
74
67
  success: boolean;
75
68
  message: string;
76
69
  }
77
70
 
71
+ /** Upsert payload accepted by the core (`create` or `update`). */
72
+ export type CmdMaterialUpsertArgs = CmdMaterialCreateArgs | CmdMaterialUpdateArgs;
73
+
74
+ /** Backward-compatible aliases. */
75
+ export type CmdResultMaterialCreate = CmdResultMaterialUpsert;
76
+ export type CmdResultMaterialUpdate = CmdResultMaterialUpsert;
77
+
78
78
  /** Command payload for disposing a material. */
79
79
  export interface CmdMaterialDisposeArgs {
80
- windowId: number;
81
80
  materialId: number;
82
81
  }
83
82
 
@@ -88,11 +87,13 @@ export interface CmdResultMaterialDispose {
88
87
  }
89
88
 
90
89
  /** Command payload for listing materials. */
91
- export interface CmdMaterialListArgs {}
90
+ export interface CmdMaterialListArgs {
91
+ windowId: number;
92
+ }
92
93
 
93
94
  /** Result payload for material list. */
94
95
  export interface CmdResultMaterialList {
95
96
  success: boolean;
96
97
  message: string;
97
- content: number[]; // List of material IDs
98
+ materials: ResourceEntry[];
98
99
  }