@webspatial/core-sdk 0.1.10 → 0.1.13

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