@webspatial/core-sdk 0.1.9 → 0.1.11

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.
@@ -0,0 +1,727 @@
1
+ type WindowStyle = 'Plain' | 'Volumetric';
2
+ interface WindowContainerOptions {
3
+ defaultSize?: {
4
+ width: number;
5
+ height: number;
6
+ };
7
+ resizability?: 'automatic' | 'contentSize' | 'contentMinSize';
8
+ }
9
+ type LoadingMethodKind = 'show' | 'hide';
10
+ interface sceneDataShape {
11
+ method?: 'createRoot' | 'showRoot';
12
+ sceneConfig?: WindowContainerOptions;
13
+ url?: string;
14
+ window: Window;
15
+ }
16
+ interface sceneDataJSBShape {
17
+ method?: 'createRoot' | 'showRoot';
18
+ sceneConfig?: WindowContainerOptions;
19
+ url?: string;
20
+ windowID?: string;
21
+ windowContainerID?: string;
22
+ }
23
+
24
+ declare global {
25
+ interface Window {
26
+ __WebSpatialData: {
27
+ androidNativeMessage: Function;
28
+ getNativeVersion: Function;
29
+ };
30
+ __SpatialWebEvent: Function;
31
+ webkit: any;
32
+ __WebSpatialUnloaded: boolean;
33
+ _webSpatialID: string;
34
+ _webSpatialGroupID: string;
35
+ _webSpatialParentGroupID: string;
36
+ WebSpatailNativeVersion: string;
37
+ }
38
+ }
39
+ declare class WindowContainer {
40
+ id: string;
41
+ }
42
+ declare class WebSpatialResource {
43
+ id: string;
44
+ windowContainerId: string;
45
+ data: any;
46
+ receiveEvent(): void;
47
+ }
48
+
49
+ /**
50
+ * @hidden
51
+ * Parent class of spatial objects, should not be used directly
52
+ */
53
+ declare class SpatialObject {
54
+ /** @hidden */
55
+ _resource: WebSpatialResource;
56
+ /** @hidden */
57
+ constructor(
58
+ /** @hidden */
59
+ _resource: WebSpatialResource);
60
+ /**
61
+ * Marks resource to be released (it should no longer be used)
62
+ */
63
+ destroy(): Promise<void>;
64
+ name: string;
65
+ protected onDestroy(): Promise<void>;
66
+ }
67
+
68
+ declare class Vec3 {
69
+ x: number;
70
+ y: number;
71
+ z: number;
72
+ constructor(x?: number, y?: number, z?: number);
73
+ }
74
+ declare class Vec4 {
75
+ x: number;
76
+ y: number;
77
+ z: number;
78
+ w: number;
79
+ constructor(x?: number, y?: number, z?: number, w?: number);
80
+ }
81
+ /**
82
+ * Transform containing position, orientation and scale
83
+ */
84
+ declare class SpatialTransform {
85
+ position: Vec3;
86
+ /** Quaternion value for x,y,z,w */
87
+ orientation: Vec4;
88
+ scale: Vec3;
89
+ }
90
+
91
+ /**
92
+ * Anchored window managed by the OS
93
+ */
94
+ declare class SpatialWindowContainer {
95
+ /** @hidden */
96
+ _wg: WindowContainer;
97
+ /** @hidden */
98
+ constructor(
99
+ /** @hidden */
100
+ _wg: WindowContainer);
101
+ /**
102
+ * @hidden
103
+ * Sets sets the open configuration for opening new window containers
104
+ * @param options style options
105
+ */
106
+ _setOpenSettings(options: {
107
+ resolution: {
108
+ width: number;
109
+ height: number;
110
+ };
111
+ }): Promise<void>;
112
+ /**
113
+ * Retrieves the root entity of the windowContainer
114
+ * @returns the root entity of the windowContainer if one exists
115
+ */
116
+ getRootEntity(): Promise<SpatialEntity | null>;
117
+ setRootEntity(entity: SpatialEntity): Promise<void>;
118
+ }
119
+
120
+ /**
121
+ * Entity used to describe an object that can be added to the scene
122
+ */
123
+ declare class SpatialEntity extends SpatialObject {
124
+ /**
125
+ * Transform corresponding to the entity
126
+ * note: updateTransform must be called for transform to be synced to rendering
127
+ */
128
+ transform: SpatialTransform;
129
+ /** @hidden */
130
+ private _destroyed;
131
+ /** @hidden */
132
+ private get _entity();
133
+ /**
134
+ * Syncs the transform with the renderer, must be called to observe updates
135
+ */
136
+ updateTransform(): Promise<void>;
137
+ /**
138
+ * Syncs the zIndex with the renderer
139
+ */
140
+ updateZIndex(zIndex: number): Promise<void>;
141
+ private components;
142
+ /**
143
+ * Attaches a component to the entity to be displayed
144
+ * [TODO] review pass by value vs ref and ownership model for this
145
+ */
146
+ setComponent(component: SpatialComponent): Promise<void>;
147
+ /**
148
+ * Removes a component from the entity
149
+ */
150
+ removeComponent<T extends SpatialComponent>(type: new (...args: any[]) => T): Promise<void>;
151
+ /**
152
+ * Gets a component from the entity
153
+ */
154
+ getComponent<T extends SpatialComponent>(type: new (...args: any[]) => T): T | undefined;
155
+ /**
156
+ * @hidden
157
+ * Sets the window container that this entity should be rendered by (this does not effect resource ownership)
158
+ * @param wg the window container that should render this entity
159
+ */
160
+ _setParentWindowContainer(wg: SpatialWindowContainer): Promise<void>;
161
+ /**
162
+ * Sets a parent entity, if that entity or its parents are attached to a window container, this entity will be displayed
163
+ * @param e parent entity or null to remove current parent
164
+ */
165
+ setParent(e: SpatialEntity | null): Promise<void>;
166
+ /**
167
+ * Sets the coordinate space of this entity (Default: App)
168
+ * "App" = game engine style coordinates in meters
169
+ * "Dom" = Windowing coordinates in dom units (eg. 0,0,0 is top left of window)
170
+ * "Root" = Coordinate space is ignored and content is displayed and updated as window container's root object, window containers can only have one root entity
171
+ * [TODO] review this api
172
+ * @param space coordinate space mode
173
+ */
174
+ setCoordinateSpace(space: 'App' | 'Dom' | 'Root'): Promise<void>;
175
+ /**
176
+ * Query the 3d boudning box of the entity
177
+ * @returns The bounding box of the entity
178
+ */
179
+ getBoundingBox(): Promise<{
180
+ center: {
181
+ x: number;
182
+ y: number;
183
+ z: number;
184
+ };
185
+ extents: {
186
+ x: number;
187
+ y: number;
188
+ z: number;
189
+ };
190
+ }>;
191
+ /**
192
+ * Sets if the entity should be visible (default: True)
193
+ * @param visible
194
+ */
195
+ setVisible(visible: boolean): Promise<void>;
196
+ /**
197
+ * Removes a reference to the entity by the renderer and this object should no longer be used. [TODO] Attached components will not be destroyed
198
+ */
199
+ destroy(): Promise<void>;
200
+ /**
201
+ * Check if destroy has been called
202
+ */
203
+ isDestroyed(): boolean;
204
+ /** @hidden */
205
+ _setName(name: string): Promise<unknown>;
206
+ }
207
+
208
+ /** @hidden */
209
+ declare class SpatialComponent extends SpatialObject {
210
+ /**
211
+ * Gets the entity this component is attached to
212
+ * @returns entity or null
213
+ */
214
+ getEntity(): Promise<SpatialEntity | null>;
215
+ }
216
+
217
+ /**
218
+ * Material type for SpatialDiv or HTML document.
219
+ *
220
+ * This type defines the background material options for both SpatialDiv elements and HTML documents.
221
+ *
222
+ * - `'none'`: This is the default value.
223
+ * - For HTML documents, the web page window will have the default native background.
224
+ * - For SpatialDiv, the window will have a transparent background.
225
+ * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).
226
+ * - `'thick'`: Represents a thick material in AVP.
227
+ * - `'regular'`: Represents a regular material in AVP.
228
+ * - `'thin'`: Represents a thin material in AVP.
229
+ * - `'transparent'`: Represents a fully transparent background.
230
+ */
231
+ type BackgroundMaterialType = 'none' | 'translucent' | 'thick' | 'regular' | 'thin' | 'transparent';
232
+ type CornerRadius = {
233
+ topLeading: number;
234
+ bottomLeading: number;
235
+ topTrailing: number;
236
+ bottomTrailing: number;
237
+ };
238
+ type StyleParam = {
239
+ material?: {
240
+ type: BackgroundMaterialType;
241
+ };
242
+ cornerRadius?: number | CornerRadius;
243
+ };
244
+ /**
245
+ * Used to position an web window in 3D space
246
+ */
247
+ declare class SpatialWindowComponent extends SpatialComponent {
248
+ /**
249
+ * Loads a url page in the window
250
+ * @param url url to load
251
+ */
252
+ loadURL(url: string): Promise<void>;
253
+ setFromWindow(window: any): Promise<void>;
254
+ /**
255
+ * Sets the resolution of the window, the resulting dimensions when rendered will be equal to 1/1360 units
256
+ * eg. if the resolution is set to 1360x1360 it will be a 1x1 plane
257
+ * See 1360 in spatialViewUI.swift for how this ratio works
258
+ * @param width width in pixels
259
+ * @param height height in pixels
260
+ */
261
+ setResolution(width: number, height: number): Promise<void>;
262
+ /**
263
+ * [Experimental] Sets the anchor which the entity this is attached to will rotate around
264
+ * @param rotationAnchor
265
+ */
266
+ setRotationAnchor(rotationAnchor: Vec3): Promise<void>;
267
+ /**
268
+ * [Experimental] Sets the opacity of the window after apply material
269
+ * @param opacity
270
+ */
271
+ setOpacity(opacity: number): Promise<void>;
272
+ /**
273
+ * Sets the style that should be applied to the window
274
+ * @param options style options
275
+ */
276
+ setStyle(styleParam: StyleParam): Promise<void>;
277
+ /**
278
+ * Modifies the amount the spatial window can be scrolled
279
+ * Should only be used internally
280
+ * See https://developer.apple.com/documentation/uikit/1624475-uiedgeinsetsmake?language=objc
281
+ * @param insets margin to modify scroll distances by
282
+ */
283
+ setScrollEdgeInsets(insets: {
284
+ top: number;
285
+ left: number;
286
+ bottom: number;
287
+ right: number;
288
+ }): Promise<void>;
289
+ /**
290
+ * Enable/Disable scrolling in the window (defaults to enabled), if disabled, scrolling will be applied to the root page
291
+ * @param enabled value to set
292
+ */
293
+ setScrollEnabled(enabled: boolean): Promise<void>;
294
+ /**
295
+ * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
296
+ * @param scrollWithParent value to set
297
+ */
298
+ setScrollWithParent(scrollWithParent: boolean): Promise<void>;
299
+ }
300
+
301
+ /**
302
+ * @description
303
+ * Represents a spatial component that handles events related to spatial interactions.
304
+ * This class extends `SpatialComponent` and provides additional functionality for managing
305
+ * event-driven spatial behaviors.
306
+ *
307
+ * @hidden
308
+ * This class is intended for internal use and should not be exposed in the public API.
309
+ */
310
+ declare abstract class EventSpatialComponent extends SpatialComponent {
311
+ constructor(_resource: WebSpatialResource);
312
+ /**
313
+ * @description
314
+ * Abstract method to be implemented by subclasses. Called when a spatial event is received.
315
+ * @param data The data associated with the received event.
316
+ */
317
+ protected abstract onRecvEvent(data: any): void;
318
+ protected onDestroy(): Promise<void>;
319
+ }
320
+
321
+ /**
322
+ * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
323
+ */
324
+ type TranslateEvent = {
325
+ eventType: 'dragstart' | 'dragend' | 'drag';
326
+ translate?: Vec3;
327
+ };
328
+ /**
329
+ * Used to handle input events on an entity
330
+ */
331
+ declare class SpatialInputComponent extends EventSpatialComponent {
332
+ protected onRecvEvent(data: any): void;
333
+ /**
334
+ * Callback fired when a translate event occurs
335
+ * @param data translate event data
336
+ */
337
+ onTranslate(data: TranslateEvent): void;
338
+ }
339
+
340
+ /**
341
+ * Mesh asset containing geometry
342
+ */
343
+ declare class SpatialMeshResource extends SpatialObject {
344
+ }
345
+
346
+ /**
347
+ * PBR material which can be set on a SpatialModelComponent
348
+ */
349
+ declare class SpatialPhysicallyBasedMaterialResource extends SpatialObject {
350
+ /**
351
+ * Base color of the material containing rgba between 0 and 1
352
+ */
353
+ baseColor: {
354
+ r: number;
355
+ g: number;
356
+ b: number;
357
+ a: number;
358
+ };
359
+ /**
360
+ * PBR metalic value between 0 and 1
361
+ */
362
+ metallic: {
363
+ value: number;
364
+ };
365
+ /**
366
+ * PBR roughness value between 0 and 1
367
+ */
368
+ roughness: {
369
+ value: number;
370
+ };
371
+ _modelComponentAttachedTo: {
372
+ [key: string]: SpatialModelComponent;
373
+ };
374
+ _addToComponent(c: SpatialModelComponent): void;
375
+ /**
376
+ * Syncs state of color, metallic, roupghness to the renderer
377
+ */
378
+ update(): Promise<void>;
379
+ }
380
+
381
+ /**
382
+ * Used to position a model in 3D space, made up of a mesh and materials to be applied to the mesh
383
+ */
384
+ declare class SpatialModelComponent extends SpatialComponent {
385
+ private cachedMaterials;
386
+ /**
387
+ * Sets the mesh to be displayed by the component
388
+ * @param mesh mesh to set
389
+ */
390
+ setMesh(mesh: SpatialMeshResource): Promise<void>;
391
+ /**
392
+ * Sets the materials that should be applied to the mesh
393
+ * @param materials array of materials to set
394
+ */
395
+ setMaterials(materials: Array<SpatialPhysicallyBasedMaterialResource>): Promise<void>;
396
+ /** @hidden */
397
+ _syncMaterials(): Promise<void>;
398
+ }
399
+
400
+ /**
401
+ * Represenets a volume that can be added to the webpage
402
+ * Child entities will be added within this volume's space
403
+ * Defaults to having 1x1x1 meter dimensions
404
+ * Resolution defaults to 100x100 pixels
405
+ * Only will be displayed on entities in "ROOT" or "DOM" space
406
+ * If the resolution of the spatial view is not a square, the volume will be larger based on the ratio with the shortest side being 1 meter.
407
+ * (eg. 200x100 = 2m x 1m x 1m volume)
408
+ */
409
+ declare class SpatialViewComponent extends SpatialComponent {
410
+ /**
411
+ * Sets the resolution of the spatial view in dom pixels
412
+ */
413
+ setResolution(width: number, height: number): Promise<void>;
414
+ /**
415
+ * Sets if content of the spatialView should be within a portal
416
+ * If true, volume will be behind the page, if false, it will be in front of the page
417
+ */
418
+ setIsPortal(isPortal: Boolean): Promise<void>;
419
+ }
420
+
421
+ /**
422
+ * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
423
+ */
424
+ type SpatialModelDragEvent = {
425
+ eventType: 'dragstart' | 'dragend' | 'drag';
426
+ translation3D: Vec3;
427
+ startLocation3D: Vec3;
428
+ };
429
+ /**
430
+ * Used to position a model3d in 3D space
431
+ */
432
+ declare class SpatialModel3DComponent extends EventSpatialComponent {
433
+ protected onRecvEvent(data: any): void;
434
+ /**
435
+ * Sets the resolution of the spatial view in dom pixels
436
+ */
437
+ setResolution(width: number, height: number): Promise<void>;
438
+ setRotationAnchor(rotationAnchor: Vec3): Promise<void>;
439
+ /**
440
+ * Sets the opacity of the model
441
+ * @param opacity
442
+ */
443
+ setOpacity(opacity: number): Promise<void>;
444
+ /**
445
+ * Sets how the model fill the rect
446
+ * @param contentMode
447
+ */
448
+ setContentMode(contentMode: 'fill' | 'fit'): Promise<void>;
449
+ /**
450
+ * Constrains this model dimensions to the specified aspect ratio.
451
+ * with a value of 0, the model will use the original aspect ratio.
452
+ *
453
+ * @param aspectRatio number
454
+ */
455
+ setAspectRatio(aspectRatio: number): Promise<void>;
456
+ /**
457
+ * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
458
+ * @param scrollWithParent value to set
459
+ */
460
+ setScrollWithParent(scrollWithParent: boolean): Promise<void>;
461
+ /**
462
+ * Sets whether the model appear in original size or fit the rect
463
+ * @param resizable
464
+ */
465
+ setResizable(resizable: boolean): Promise<void>;
466
+ /**
467
+ * Callback fired when model load success
468
+ */
469
+ onSuccess?: () => void;
470
+ /**
471
+ * Callback fired when model load failure
472
+ * @param errorReason
473
+ */
474
+ onFailure?: (errorReason: string) => void;
475
+ /**
476
+ * Callback fired when model was dragged at the beginning
477
+ * @param dragEvent
478
+ */
479
+ private _onDragStart?;
480
+ set onDragStart(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
481
+ /**
482
+ * Callback fired when model was dragged
483
+ * @param dragEvent
484
+ */
485
+ private _onDrag?;
486
+ set onDrag(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
487
+ /**
488
+ * Callback fired when model was dragged at the ending
489
+ * @param dragEvent
490
+ */
491
+ private _onDragEnd?;
492
+ set onDragEnd(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
493
+ private get enableDragEvent();
494
+ /**
495
+ * Callback fired when model was tapped
496
+ */
497
+ private _onTap?;
498
+ set onTap(callback: (() => void) | undefined);
499
+ /** Callback fired when model was double tapped */
500
+ private _onDoubleTap?;
501
+ set onDoubleTap(callback: (() => void) | undefined);
502
+ /** Callback fired when model was long pressed */
503
+ private _onLongPress?;
504
+ set onLongPress(callback: (() => void) | undefined);
505
+ }
506
+
507
+ type CreateResourceOptions = {
508
+ windowContainer?: SpatialWindowContainer | null;
509
+ windowComponent?: SpatialWindowComponent | null;
510
+ };
511
+ /**
512
+ * Animation callback with timestamp
513
+ */
514
+ type animCallback = (time: DOMHighResTimeStamp) => Promise<any>;
515
+ /**
516
+ * Session use to establish a connection to the spatial renderer of the system. All resources must be created by the session
517
+ */
518
+ declare class SpatialSession {
519
+ /** @hidden */
520
+ _engineUpdateListeners: animCallback[];
521
+ /** @hidden */
522
+ _frameLoopStarted: boolean;
523
+ /**
524
+ * Add event listener callback to be called each frame
525
+ * @param callback callback to be called each update
526
+ */
527
+ addOnEngineUpdateEventListener(callback: animCallback): void;
528
+ /**
529
+ * Creates a Entity
530
+ * @returns Entity
531
+ */
532
+ createEntity(options?: CreateResourceOptions): Promise<SpatialEntity>;
533
+ /**
534
+ * Creates a WindowComponent
535
+ * [TODO] should creation of components be moved to entity? and these made private?
536
+ * @returns WindowComponent
537
+ */
538
+ createWindowComponent(options?: CreateResourceOptions): Promise<SpatialWindowComponent>;
539
+ /**
540
+ * Creates a ViewComponent used to display 3D content within the entity
541
+ * @returns SpatialViewComponent
542
+ */
543
+ createViewComponent(options?: CreateResourceOptions): Promise<SpatialViewComponent>;
544
+ /**
545
+ * Creates a ModelComponent used to display geometry + material of a 3D model
546
+ * @returns ModelComponent
547
+ */
548
+ createModelComponent(options?: {
549
+ url: string;
550
+ } & CreateResourceOptions): Promise<SpatialModelComponent>;
551
+ /**
552
+ * Creates a Model3DComponent
553
+ * @returns Model3DComponent
554
+ */
555
+ createModel3DComponent(options?: {
556
+ url: string;
557
+ } & CreateResourceOptions): Promise<SpatialModel3DComponent>;
558
+ /**
559
+ * Creates a InputComponent
560
+ * [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model
561
+ * @returns InputComponent
562
+ */
563
+ createInputComponent(options?: CreateResourceOptions): Promise<SpatialInputComponent>;
564
+ /**
565
+ * Creates a MeshResource containing geometry data
566
+ * @returns MeshResource
567
+ */
568
+ createMeshResource(options?: {
569
+ shape?: string;
570
+ } & CreateResourceOptions): Promise<SpatialMeshResource>;
571
+ /**
572
+ * Creates a PhysicallyBasedMaterial containing PBR material data
573
+ * @returns PhysicallyBasedMaterial
574
+ */
575
+ createPhysicallyBasedMaterialResource(options?: {} & CreateResourceOptions): Promise<SpatialPhysicallyBasedMaterialResource>;
576
+ /**
577
+ * Creates a WindowContainer
578
+ * @returns SpatialWindowContainer
579
+ * */
580
+ createWindowContainer(options?: {
581
+ style: WindowStyle;
582
+ } & CreateResourceOptions): Promise<SpatialWindowContainer>;
583
+ /**
584
+ * Creates a Scene to display content within an anchored area managed by the OS
585
+ * @hidden
586
+ * @param {WindowStyle} [style='Plain'] - The style of the Scene container to be created with. Defaults to 'Plain'.
587
+ * @param {Object} [cfg={}] - Configuration object for the Scene.
588
+ * @returns Boolean
589
+ */
590
+ _createScene(style: WindowStyle | undefined, cfg: {
591
+ sceneData: sceneDataShape;
592
+ }): Promise<boolean>;
593
+ /**
594
+ * Retrieves the window for this page
595
+ * @returns the window component corresponding to the js running on this page
596
+ * [TODO] discuss implications of this not being async
597
+ */
598
+ getCurrentWindowComponent(): SpatialWindowComponent;
599
+ /**
600
+ * Retrieves the parent window for this page or null if this is the root page
601
+ * @returns the window component or null
602
+ */
603
+ getParentWindowComponent(): Promise<SpatialWindowComponent | null>;
604
+ /**
605
+ * Logs a message to the native apps console
606
+ * @param msg mesage to log
607
+ */
608
+ log(...msg: any[]): Promise<void>;
609
+ /**
610
+ * @hidden
611
+ * Debugging only, used to ping the native renderer
612
+ */
613
+ _ping(msg: string): Promise<unknown>;
614
+ /**
615
+ * @hidden
616
+ * Debugging to get internal state from native code
617
+ * @returns data as a js object
618
+ */
619
+ _getStats(): Promise<{
620
+ objects: any;
621
+ refObjects: any;
622
+ }>;
623
+ /**
624
+ * @hidden
625
+ */
626
+ _inspect(spatialObjectId?: string): Promise<any>;
627
+ /**
628
+ * @hidden
629
+ */
630
+ _inspectRootWindowContainer(): Promise<any>;
631
+ /** Opens the immersive space */
632
+ openImmersiveSpace(): Promise<void>;
633
+ /** Closes the immersive space */
634
+ dismissImmersiveSpace(): Promise<void>;
635
+ private static _immersiveWindowContainer;
636
+ /**
637
+ * Retreives the window container corresponding to the Immersive space
638
+ * @returns the immersive window container
639
+ */
640
+ getImmersiveWindowContainer(): Promise<SpatialWindowContainer>;
641
+ private static _currentWindowContainer;
642
+ /**
643
+ * Gets the current window container for the window
644
+ * [TODO] discuss what happens if it doesnt yet have a window container
645
+ * @returns the current window container for the window
646
+ */
647
+ getCurrentWindowContainer(): SpatialWindowContainer;
648
+ /**
649
+ * Start a transaction that queues up commands to submit them all at once to reduce ipc overhead
650
+ * @param fn function to be run, within this function, promises will not resolve
651
+ * @returns promise for the entire transaction completion
652
+ */
653
+ transaction(fn: Function): Promise<unknown>;
654
+ /**
655
+ * Creates a window context object that is compatable with SpatialWindowComponent's setFromWindow API
656
+ * @returns window context
657
+ */
658
+ createWindowContext(): Promise<Window | null>;
659
+ /** @hidden */
660
+ _getEntity(id: string): Promise<SpatialEntity>;
661
+ /** @hidden */
662
+ setLoading(method: LoadingMethodKind, style?: string): Promise<unknown>;
663
+ }
664
+
665
+ /**
666
+ * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr
667
+ */
668
+ declare class Spatial {
669
+ /**
670
+ * Requests a session object from the browser
671
+ * @returns The session or null if not availible in the current browser
672
+ * [TODO] discuss implications of this not being async
673
+ */
674
+ requestSession(): SpatialSession | null;
675
+ /**
676
+ * @returns true if web spatial is supported by this webpage
677
+ */
678
+ isSupported(): boolean;
679
+ /**
680
+ * Gets the native version, format is "x.x.x"
681
+ * @returns native version string
682
+ */
683
+ getNativeVersion(): any;
684
+ /**
685
+ * Gets the client version, format is "x.x.x"
686
+ * @returns client version string
687
+ */
688
+ getClientVersion(): string;
689
+ }
690
+
691
+ /**
692
+ * Helper class used to quickly add spatial content to standard web pages
693
+ * [Experimental] expect APIs to potentially change in future versions
694
+ */
695
+ declare class SpatialHelper {
696
+ session: SpatialSession;
697
+ private static _instance;
698
+ static get instance(): SpatialHelper | null;
699
+ constructor(session: SpatialSession);
700
+ shape: {
701
+ createShapeEntity: (shape?: string) => Promise<SpatialEntity>;
702
+ createModelEntity: (url: string) => Promise<SpatialEntity>;
703
+ wrapInBoundingBoxEntity: (entityToWrap: SpatialEntity) => Promise<SpatialEntity>;
704
+ };
705
+ navigation: {
706
+ openPanel: (url: string, options?: {
707
+ resolution: {
708
+ width: number;
709
+ height: number;
710
+ };
711
+ }) => Promise<void>;
712
+ openVolume: (url: string, options?: {
713
+ resolution: {
714
+ width: number;
715
+ height: number;
716
+ };
717
+ }) => Promise<void>;
718
+ };
719
+ dom: {
720
+ attachSpatialView: (divOnPage: HTMLElement) => Promise<{
721
+ entity: SpatialEntity;
722
+ }>;
723
+ };
724
+ setBackgroundStyle: (style: StyleParam, backgroundColor?: string) => Promise<void>;
725
+ }
726
+
727
+ export { type BackgroundMaterialType, type CornerRadius, type LoadingMethodKind, Spatial, SpatialComponent, SpatialEntity, SpatialHelper, SpatialInputComponent, SpatialMeshResource, SpatialModel3DComponent, SpatialModelComponent, type SpatialModelDragEvent, SpatialPhysicallyBasedMaterialResource, SpatialSession, SpatialTransform, SpatialViewComponent, SpatialWindowComponent, SpatialWindowContainer, type StyleParam, Vec3, Vec4, type WindowContainerOptions, type WindowStyle, type sceneDataJSBShape, type sceneDataShape };