@webspatial/core-sdk 1.3.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @webspatial/core-sdk
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3b304a1: Introduces runtime reactivity to our 3D API. Previously, entities were mostly static after instantiation. We can now dynamically update material properties, modify geometry in-place, and apply material overrides to model entities on the fly.
8
+
9
+ ### Patch Changes
10
+
11
+ - c7b240c: Project Swan renamed to Pico OS
12
+
13
+ ## 1.4.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 945856b: add enableInput for Entity
18
+ move reality events definition from specific Entity to top-level Reality
19
+ - 56e98c8: rename innerDepth to xrInnerDepth and outerDepth to xrOuterDepth
20
+ - 0def1ef: Remove deprecated spatial measurement APIs: getBoundingClientRect, getBoundingClientCube, toSceneSpatial, toLocalSpace and their internal message types (CubeInfoMsg, TransformMsg)
21
+ - 58e1f69: Attachment init flow and lifecycle cleanup.
22
+
23
+ - **Core**
24
+ - Split attachment creation into `CreateAttachmentEntityCommand` (window/engine) and `InitializeAttachmentCommand` (send id, parent, position, size over JSB so native initializes after window exists).
25
+ - `createAttachmentEntity()` now runs both; native receives full options via init command.
26
+ - **React**
27
+ - `AttachmentEntity`: inline head-style sync via `MutationObserver` on `document.head`; direct cleanup on unmount (no StrictMode-only logic).
28
+ - `useEntity`: forwards all entity event handlers (tap, drag, rotate, magnify) to `useEntityEvent`.
29
+ - `useSpatializedElement`: ref-based cleanup so elements are destroyed correctly on unmount.
30
+ - Removed React 18 StrictMode–specific deferred cleanup from Reality, useEntity, AttachmentEntity, useSpatializedElement.
31
+ - **visionOS**
32
+ - Attachment manager and JSB handling updated for init command and consolidated window creation.
33
+
34
+ - 087fa12: react-sdk:support convertCoordinate
35
+ - 98fd429: react-sdk support pointToPhysical,physicalToPoint API from useMetrics() hook
36
+ - 8f8c50a: Spatial rotate axis constraint for spatialized elements.
37
+
38
+ - **Core**
39
+ - `SpatializedElementProperties` adds optional `rotateConstrainedToAxis` (Vec3) on partial updates to native.
40
+ - **React**
41
+ - `spatialEventOptions={{ constrainedToAxis: Vec3 | [number, number, number] }}` on spatialized containers and JSX intrinsics (`enable-xr`); omit or `[0,0,0]` means unconstrained.
42
+ - `PortalSpatializedContainer` syncs axis via `updateProperties`; `Model` / degraded paths strip `spatialEventOptions` from DOM.
43
+ - **visionOS**
44
+ - `RotateGesture3D(constrainedToAxis:)` when axis is non-zero; world-space axis, normalized on native.
45
+
46
+ ### Patch Changes
47
+
48
+ - 8c50a0f: chore:update spatialEntityEventtype
49
+ - dabb15f: Update UA injection logic in VisionOS and add WSAppShell version number
50
+ - 2f2a3a8: Model ready promise triggers rejection when URL is changed midway
51
+ - 931f236: rename offsetBack to xrOffsetBack for naming consistency
52
+
3
53
  ## 1.3.0
4
54
 
5
55
  ### Minor Changes
@@ -47,8 +47,6 @@ declare abstract class SpatialMaterial extends SpatialObject {
47
47
  }
48
48
 
49
49
  declare enum SpatialWebMsgType {
50
- cubeInfo = "cubeInfo",
51
- transform = "transform",
52
50
  modelloaded = "modelloaded",
53
51
  modelloadfailed = "modelloadfailed",
54
52
  spatialtap = "spatialtap",
@@ -64,25 +62,6 @@ declare enum SpatialWebMsgType {
64
62
  interface ObjectDestroyMsg {
65
63
  type: SpatialWebMsgType.objectdestroy;
66
64
  }
67
- interface CubeInfoMsg {
68
- type: SpatialWebMsgType.cubeInfo;
69
- origin: Vec3;
70
- size: Size3D;
71
- }
72
- interface CubeInfoMsg {
73
- type: SpatialWebMsgType.cubeInfo;
74
- origin: Vec3;
75
- size: Size3D;
76
- }
77
- interface TransformMsg {
78
- type: SpatialWebMsgType.transform;
79
- detail: {
80
- column0: [number, number, number];
81
- column1: [number, number, number];
82
- column2: [number, number, number];
83
- column3: [number, number, number];
84
- };
85
- }
86
65
  interface SpatialTapMsg {
87
66
  type: SpatialWebMsgType.spatialtap;
88
67
  detail: SpatialTapEventDetail;
@@ -144,7 +123,7 @@ declare abstract class SpatializedElement extends SpatialObject {
144
123
  * Gets the current cube information for this element.
145
124
  * @returns The current CubeInfo or undefined if not set
146
125
  */
147
- get cubeInfo(): CubeInfo$1 | undefined;
126
+ get cubeInfo(): CubeInfo | undefined;
148
127
  /**
149
128
  * The current transformation matrix of this element.
150
129
  */
@@ -169,7 +148,7 @@ declare abstract class SpatializedElement extends SpatialObject {
169
148
  * Handles various spatial events like transforms, gestures, and interactions.
170
149
  * @param data The event data received from the WebSpatial system
171
150
  */
172
- protected onReceiveEvent(data: CubeInfoMsg | TransformMsg | SpatialTapMsg | SpatialDragStartMsg | SpatialDragMsg | SpatialDragEndMsg | SpatialRotateMsg | SpatialRotateEndMsg | ObjectDestroyMsg): void;
151
+ protected onReceiveEvent(data: SpatialTapMsg | SpatialDragStartMsg | SpatialDragMsg | SpatialDragEndMsg | SpatialRotateMsg | SpatialRotateEndMsg | ObjectDestroyMsg): void;
173
152
  private _onSpatialTap?;
174
153
  set onSpatialTap(value: (event: SpatialTapEvent) => void | undefined);
175
154
  private _onSpatialDragStart?;
@@ -195,8 +174,12 @@ declare abstract class SpatializedElement extends SpatialObject {
195
174
 
196
175
  declare class SpatializedDynamic3DElement extends SpatializedElement {
197
176
  children: SpatialEntityOrReality[];
177
+ events: Record<string, (data: any) => void>;
198
178
  constructor(id: string);
199
179
  addEntity(entity: SpatialEntity): Promise<CommandResult>;
180
+ addEvent(type: SpatialEntityEventType, callback: (data: any) => void): void;
181
+ removeEvent(eventName: SpatialEntityEventType): void;
182
+ dispatchEvent(evt: CustomEvent): void;
200
183
  updateProperties(properties: Partial<SpatializedElementProperties>): Promise<CommandResult>;
201
184
  }
202
185
 
@@ -264,6 +247,11 @@ interface SpatializedElementProperties {
264
247
  enableRotateEndGesture: boolean;
265
248
  enableMagnifyGesture: boolean;
266
249
  enableMagnifyEndGesture: boolean;
250
+ /**
251
+ * Optional world-space axis for spatial rotate gesture. Omitted or zero vector
252
+ * means unconstrained rotation (platform default).
253
+ */
254
+ rotateConstrainedToAxis?: Vec3;
267
255
  }
268
256
  interface Spatialized2DElementProperties extends SpatializedElementProperties {
269
257
  scrollPageEnabled: boolean;
@@ -291,6 +279,7 @@ interface SpatialSceneCreationOptions$1 {
291
279
  worldAlignment?: WorldAlignmentType;
292
280
  baseplateVisibility?: BaseplateVisibilityType;
293
281
  }
282
+ type SpatialEntityEventType = 'spatialtap' | 'spatialdragstart' | 'spatialdrag' | 'spatialdragend' | 'spatialrotate' | 'spatialrotateend' | 'spatialmagnify' | 'spatialmagnifyend';
294
283
  declare const BaseplateVisibilityValues: readonly ["automatic", "visible", "hidden"];
295
284
  type BaseplateVisibilityType = (typeof BaseplateVisibilityValues)[number];
296
285
  declare function isValidBaseplateVisibilityType(type: string): Boolean;
@@ -313,7 +302,6 @@ interface SpatialEntityProperties {
313
302
  rotation: Vec3;
314
303
  scale: Vec3;
315
304
  }
316
- type SpatialEntityEventType = 'spatialtap';
317
305
  type SpatialGeometryType = 'BoxGeometry' | 'PlaneGeometry' | 'SphereGeometry' | 'CylinderGeometry' | 'ConeGeometry';
318
306
  interface SpatialBoxGeometryOptions {
319
307
  width?: number;
@@ -383,7 +371,7 @@ interface Size {
383
371
  interface Size3D extends Size {
384
372
  depth: number;
385
373
  }
386
- declare class CubeInfo$1 {
374
+ declare class CubeInfo {
387
375
  size: Size3D;
388
376
  origin: Vec3;
389
377
  constructor(size: Size3D, origin: Vec3);
@@ -439,6 +427,7 @@ interface AttachmentEntityOptions {
439
427
  width: number;
440
428
  height: number;
441
429
  };
430
+ ownerViewId: string;
442
431
  }
443
432
  interface AttachmentEntityUpdateOptions {
444
433
  position?: [number, number, number];
@@ -461,8 +450,12 @@ declare class SpatialEntity extends SpatialObject {
461
450
  events: Record<string, (data: any) => void>;
462
451
  children: SpatialEntity[];
463
452
  parent: SpatialEntityOrReality | null;
453
+ private _enableInput;
454
+ get enableInput(): boolean;
455
+ set enableInput(value: boolean);
464
456
  constructor(id: string, userData?: SpatialEntityUserData | undefined);
465
457
  addComponent(component: SpatialComponent): Promise<CommandResult>;
458
+ removeComponent(component: SpatialComponent): Promise<CommandResult>;
466
459
  setPosition(position: Vec3): Promise<CommandResult>;
467
460
  setRotation(rotation: Vec3): Promise<CommandResult>;
468
461
  setScale(scale: Vec3): Promise<CommandResult>;
@@ -485,6 +478,7 @@ declare class SpatialModelEntity extends SpatialEntity {
485
478
  options?: SpatialModelEntityCreationOptions | undefined;
486
479
  userData?: SpatialEntityUserData | undefined;
487
480
  constructor(id: string, options?: SpatialModelEntityCreationOptions | undefined, userData?: SpatialEntityUserData | undefined);
481
+ setMaterials(materials: SpatialMaterial[]): Promise<CommandResult>;
488
482
  }
489
483
 
490
484
  declare class ModelComponent extends SpatialComponent {
@@ -577,6 +571,7 @@ declare class SpatialScene extends SpatialObject {
577
571
  * @returns The singleton SpatialScene instance
578
572
  */
579
573
  static getInstance(): SpatialScene;
574
+ convertCoordinate(position: Vec3, fromId: string, toId: string): Promise<Vec3>;
580
575
  /**
581
576
  * Updates the properties of the spatial scene.
582
577
  * This can include background settings, lighting, and other scene-wide properties.
@@ -819,6 +814,7 @@ declare class SpatialSession {
819
814
  * This is the main entry point for the WebSpatial SDK, providing access to spatial capabilities.
820
815
  */
821
816
  declare class Spatial {
817
+ private wsAppShellVersionFromUA;
822
818
  /**
823
819
  * Requests a spatial session object from the browser.
824
820
  * This is the primary method to initialize spatial functionality.
@@ -832,6 +828,7 @@ declare class Spatial {
832
828
  * @returns True if running in a spatial web environment, false otherwise
833
829
  */
834
830
  runInSpatialWeb(): boolean;
831
+ getShellVersionFromUA(): string | null;
835
832
  /** @deprecated
836
833
  * Checks if WebSpatial is supported in the current environment.
837
834
  * Verifies compatibility between native and client versions.
@@ -852,6 +849,53 @@ declare class Spatial {
852
849
  getClientVersion(): string;
853
850
  }
854
851
 
852
+ type PhysicalMetricsValueShape = {
853
+ meterToPtUnscaled: number;
854
+ meterToPtScaled: number;
855
+ };
856
+ type WorldScalingCompensation = 'unscaled' | 'scaled';
857
+ type ConvertOption = {
858
+ worldScalingCompensation: WorldScalingCompensation;
859
+ };
860
+ /**
861
+ * Converts scene points (pt) to physical meters (m).
862
+ *
863
+ * @param point Points value to convert.
864
+ * @param options Optional conversion options to select world scaling compensation.
865
+ * @returns Physical length in meters.
866
+ */
867
+ declare function pointToPhysical(point: number, options?: ConvertOption): number;
868
+ /**
869
+ * Converts physical meters (m) to scene points (pt).
870
+ *
871
+ * @param physical Physical length in meters to convert.
872
+ * @param options Optional conversion options to select world scaling compensation.
873
+ * @returns Points length in the scene.
874
+ */
875
+ declare function physicalToPoint(physical: number, options?: ConvertOption): number;
876
+ /**
877
+ * Returns the current physical metrics used for conversions.
878
+ *
879
+ * @returns The current metrics snapshot `{ meterToPtUnscaled, meterToPtScaled }`.
880
+ */
881
+ declare function getValue(): PhysicalMetricsValueShape;
882
+ /**
883
+ * Subscribes to physical metrics changes.
884
+ *
885
+ * @param cb Callback invoked when metrics update is detected.
886
+ * @returns Unsubscribe function to remove the listener.
887
+ */
888
+ declare function subscribe(cb: () => void): () => void;
889
+
890
+ type physicalMetrics_PhysicalMetricsValueShape = PhysicalMetricsValueShape;
891
+ declare const physicalMetrics_getValue: typeof getValue;
892
+ declare const physicalMetrics_physicalToPoint: typeof physicalToPoint;
893
+ declare const physicalMetrics_pointToPhysical: typeof pointToPhysical;
894
+ declare const physicalMetrics_subscribe: typeof subscribe;
895
+ declare namespace physicalMetrics {
896
+ export { type physicalMetrics_PhysicalMetricsValueShape as PhysicalMetricsValueShape, physicalMetrics_getValue as getValue, physicalMetrics_physicalToPoint as physicalToPoint, physicalMetrics_pointToPhysical as pointToPhysical, physicalMetrics_subscribe as subscribe };
897
+ }
898
+
855
899
  declare global {
856
900
  declare const __WEBSPATIAL_CORE_SDK_VERSION__: string
857
901
 
@@ -874,6 +918,11 @@ declare global {
874
918
  webkit: any
875
919
  webspatialBridge: any
876
920
 
921
+ // Project Pico OS browser injects this global object to provide internal capabilities.
922
+ webSpatial?: {
923
+ genToken?: () => string
924
+ }
925
+
877
926
  // Will be removed in favor of __WebSpatialData
878
927
  WebSpatailNativeVersion: string
879
928
 
@@ -882,19 +931,19 @@ declare global {
882
931
  'natvie-version'?: string
883
932
  'react-sdk-version'?: string
884
933
  'core-sdk-version'?: string
934
+ physicalMetrics?: PhysicalMetricsValueShape
885
935
  }
886
936
 
887
- innerDepth: number
888
- outerDepth: number
937
+ xrInnerDepth: number
938
+ xrOuterDepth: number
889
939
  }
890
940
 
891
941
  interface HTMLElement {
892
- offsetBack: number
893
- clientDepth: number
894
- getBoundingClientCube: () => CubeInfo | undefined
942
+ xrOffsetBack: number
943
+ xrClientDepth: number
895
944
  }
896
945
  }
897
946
 
898
947
  declare const isSSREnv: () => boolean;
899
948
 
900
- export { Attachment, type AttachmentEntityOptions, type AttachmentEntityUpdateOptions, type BackgroundMaterialType, type BaseplateVisibilityType, BaseplateVisibilityValues, type CornerRadius, CubeInfo$1 as CubeInfo, type ModelAssetOptions, ModelComponent, type ModelComponentOptions, type Point3D, type Quaternion, type Size, type Size3D, Spatial, SpatialBoxGeometry, type SpatialBoxGeometryOptions, SpatialComponent, SpatialConeGeometry, type SpatialConeGeometryOptions, SpatialCylinderGeometry, type SpatialCylinderGeometryOptions, type SpatialDragEndEvent, type SpatialDragEndEventDetail, type SpatialDragEvent, type SpatialDragEventDetail, type SpatialDragStartEvent, type SpatialDragStartEventDetail, SpatialEntity, type SpatialEntityEventType, type SpatialEntityOrReality, type SpatialEntityProperties, type SpatialEntityUserData, SpatialGeometry, type SpatialGeometryOptions, type SpatialGeometryType, type SpatialMagnifyEndEvent, type SpatialMagnifyEndEventDetail, type SpatialMagnifyEvent, type SpatialMagnifyEventDetail, SpatialMaterial, type SpatialMaterialType, SpatialModelAsset, type SpatialModelDragEvent, SpatialModelEntity, type SpatialModelEntityCreationOptions, SpatialObject, SpatialPlaneGeometry, type SpatialPlaneGeometryOptions, type SpatialRotateEndEvent, type SpatialRotateEndEventDetail, type SpatialRotateEvent, type SpatialRotateEventDetail, SpatialScene, type SpatialSceneCreationOptions$1 as SpatialSceneCreationOptions, type SpatialSceneProperties, SpatialSceneState$1 as SpatialSceneState, type SpatialSceneType$1 as SpatialSceneType, SpatialSceneValues, SpatialSession, SpatialSphereGeometry, type SpatialSphereGeometryOptions, type SpatialTapEvent, type SpatialTapEventDetail, SpatialUnlitMaterial, type SpatialUnlitMaterialOptions, Spatialized2DElement, type Spatialized2DElementProperties, SpatializedDynamic3DElement, SpatializedElement, type SpatializedElementProperties, SpatializedElementType, SpatializedStatic3DElement, type SpatializedStatic3DElementProperties, type Vec3, type WorldAlignmentType, WorldAlignmentValues, type WorldScalingType, WorldScalingValues, createAttachmentEntity, isSSREnv, isValidBaseplateVisibilityType, isValidSceneUnit, isValidSpatialSceneType, isValidWorldAlignmentType, isValidWorldScalingType };
949
+ export { Attachment, type AttachmentEntityOptions, type AttachmentEntityUpdateOptions, type BackgroundMaterialType, type BaseplateVisibilityType, BaseplateVisibilityValues, type CornerRadius, CubeInfo, type ModelAssetOptions, ModelComponent, type ModelComponentOptions, physicalMetrics as PhysicalMetrics, type Point3D, type Quaternion, type Size, type Size3D, Spatial, SpatialBoxGeometry, type SpatialBoxGeometryOptions, SpatialComponent, SpatialConeGeometry, type SpatialConeGeometryOptions, SpatialCylinderGeometry, type SpatialCylinderGeometryOptions, type SpatialDragEndEvent, type SpatialDragEndEventDetail, type SpatialDragEvent, type SpatialDragEventDetail, type SpatialDragStartEvent, type SpatialDragStartEventDetail, SpatialEntity, type SpatialEntityEventType, type SpatialEntityOrReality, type SpatialEntityProperties, type SpatialEntityUserData, SpatialGeometry, type SpatialGeometryOptions, type SpatialGeometryType, type SpatialMagnifyEndEvent, type SpatialMagnifyEndEventDetail, type SpatialMagnifyEvent, type SpatialMagnifyEventDetail, SpatialMaterial, type SpatialMaterialType, SpatialModelAsset, type SpatialModelDragEvent, SpatialModelEntity, type SpatialModelEntityCreationOptions, SpatialObject, SpatialPlaneGeometry, type SpatialPlaneGeometryOptions, type SpatialRotateEndEvent, type SpatialRotateEndEventDetail, type SpatialRotateEvent, type SpatialRotateEventDetail, SpatialScene, type SpatialSceneCreationOptions$1 as SpatialSceneCreationOptions, type SpatialSceneProperties, SpatialSceneState$1 as SpatialSceneState, type SpatialSceneType$1 as SpatialSceneType, SpatialSceneValues, SpatialSession, SpatialSphereGeometry, type SpatialSphereGeometryOptions, type SpatialTapEvent, type SpatialTapEventDetail, SpatialUnlitMaterial, type SpatialUnlitMaterialOptions, Spatialized2DElement, type Spatialized2DElementProperties, SpatializedDynamic3DElement, SpatializedElement, type SpatializedElementProperties, SpatializedElementType, SpatializedStatic3DElement, type SpatializedStatic3DElementProperties, type Vec3, type WorldAlignmentType, WorldAlignmentValues, type WorldScalingType, WorldScalingValues, createAttachmentEntity, isSSREnv, isValidBaseplateVisibilityType, isValidSceneUnit, isValidSpatialSceneType, isValidWorldAlignmentType, isValidWorldScalingType };
@@ -2,19 +2,19 @@
2
2
  (function(){
3
3
  if(typeof window === 'undefined') return;
4
4
  if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
- window.__webspatialsdk__['core-sdk-version'] = "1.3.0"
5
+ window.__webspatialsdk__['core-sdk-version'] = "1.5.0"
6
6
  })()
7
7
 
8
- "use strict";var webspatialCore=(()=>{var Lt=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var h=(i,e)=>()=>(i&&(e=i(i=0)),e);var W=(i,e)=>{for(var t in e)Lt(i,t,{get:e[t],enumerable:!0})},Ne=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ke(e))!Je.call(i,n)&&n!==t&&Lt(i,n,{get:()=>e[n],enumerable:!(r=Fe(e,n))||r.enumerable});return i};var A=i=>Ne(Lt({},"__esModule",{value:!0}),i);var He,G,Bt=h(()=>{"use strict";He=typeof window>"u",G=()=>He});var Q,ne=h(()=>{"use strict";Q=class{callJSB(e,t){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocol(e,t,r,n){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocolSync(e,t,r,n,a){return{success:!0,data:void 0,errorCode:void 0,errorMessage:void 0}}}});function m(i){return{success:!0,data:i,errorCode:"",errorMessage:""}}function S(i,e=""){return{success:!1,data:void 0,errorCode:i,errorMessage:e}}var V=h(()=>{"use strict"});var ae={};W(ae,{PuppeteerPlatform:()=>$t});var $t,oe=h(()=>{"use strict";V();console.log("PuppeteerPlatform");$t=class{iframeRegistry=new Map;constructor(){}callJSB(e,t){return new Promise(r=>{try{if(window.__handleJSBMessage)try{console.log(` core-sdk Puppeteer Platform: callJSB: ${e}::${t}`);let n=window.__handleJSBMessage(`${e}::${t}`);console.log(` core-sdk Puppeteer Platform callJSB result: ${n}`),r(m(n))}catch{r(S("500","JSB execution error"))}else r(m("ok"))}catch(n){console.error(`PuppeteerPlatform cmd Error: ${e}, msg: ${t} error: ${n}`),r(S("500","Internal error"))}})}createSpatializedElementSync(e,t){try{console.log(`[Puppeteer Platform] Creating spatialized element sync with id: ${e}, url: ${t}`);let r=window;if(r.__handleJSBMessage){let n={id:e,url:t};r.__handleJSBMessage(`CreateSpatialized2DElement::${JSON.stringify(n)}`)}}catch(r){console.error("Error creating spatialized element sync:",r)}}callWebSpatialProtocol(e,t,r,n){return console.log(`PuppeteerPlatform: Calling webspatial protocol: webspatial://${e}${t?`?${t}`:""}`),new Promise(a=>{try{let o=`webspatial://${e}${t?`?${t}`:""}`,{spatialId:s,iframe:p,windowProxy:y}=this.createIframeWindow(o,r,n);e==="createSpatialized2DElement"&&this.createSpatializedElementSync(s,o),console.log(`[Puppeteer Platform] iframe created with spatialId: ${s}`),this.iframeRegistry.set(s,p),a(m({windowProxy:y,id:s}))}catch(o){console.error("Error calling webspatial protocol:",o),a(S("500","Failed to call webspatial protocol"))}})}callWebSpatialProtocolSync(e,t,r,n){try{let a=`webspatial://${e}${t?`?${t}`:""}`;console.log(`Calling webspatial protocol sync: ${a}`);let{spatialId:o,iframe:s,windowProxy:p}=this.createIframeWindow(a,r,n);return e==="createSpatialized2DElement"&&this.createSpatializedElementSync(o,a),this.iframeRegistry.set(o,s),m({windowProxy:p,id:o})}catch(a){return console.error("Error calling webspatial protocol sync:",a),S("500","Failed to call webspatial protocol sync")}}createIframeWindow(e,t,r){let n=document.createElement("iframe");n.style.border="none",n.style.display="none",n.style.width="100%",n.style.height="100%";let a=this.generateUUID();n.spatialId=a,n.id=`spatial-iframe-${a}`;let o=this.parseFeatures(r||"");o.width&&(n.style.width=o.width),o.height&&(n.style.height=o.height),o.left&&(n.style.left=o.left,n.style.position="absolute"),o.top&&(n.style.top=o.top,n.style.position="absolute"),document.body.appendChild(n);let s=this.createEnhancedWindowProxy(n,e,a);return n.src="about:blank",console.log(`PuppeteerPlatform created iframe window with spatialId: ${a}, URL: ${e}`),this.initializeIframeContent(n,e,a),{spatialId:a,iframe:n,windowProxy:s}}createEnhancedWindowProxy(e,t,r){return{location:{href:t,toString:()=>t,reload:()=>{e.contentWindow&&e.contentWindow.location.reload()}},navigator:{userAgent:`Mozilla/5.0 (WebKit) SpatialId/${r}`},close:()=>{console.log(`Closing iframe with spatialId: ${r}`),e.remove(),this.iframeRegistry.delete(r)},document:e.contentDocument||{},contentWindow:e.contentWindow||{},postMessage:(n,a)=>{e.contentWindow&&e.contentWindow.postMessage(n,a||"*")},addEventListener:(n,a)=>{e.contentWindow&&e.contentWindow.addEventListener(n,a)},removeEventListener:(n,a)=>{e.contentWindow&&e.contentWindow.removeEventListener(n,a)},executeScript:n=>{if(e.contentWindow)try{return e.contentWindow.eval(n)}catch(a){return console.error(`Error executing script in iframe ${r}:`,a),null}return null},getIframe:()=>e,getSpatialId:()=>r}}initializeIframeContent(e,t,r){try{e.onload=()=>{try{let n=`
9
- // \u6CE8\u5165\u901A\u4FE1\u811A\u672C
8
+ "use strict";var webspatialCore=(()=>{var jt=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var ti=Object.prototype.hasOwnProperty;var h=(i,t)=>()=>(i&&(t=i(i=0)),t);var R=(i,t)=>{for(var e in t)jt(i,e,{get:t[e],enumerable:!0})},ei=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ye(t))!ti.call(i,n)&&n!==e&&jt(i,n,{get:()=>t[n],enumerable:!(r=Ze(t,n))||r.enumerable});return i};var V=i=>ei(jt({},"__esModule",{value:!0}),i);var ii,G,kt=h(()=>{"use strict";ii=typeof window>"u",G=()=>ii});var Z,ue=h(()=>{"use strict";Z=class{callJSB(t,e){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocol(t,e,r,n){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocolSync(t,e,r,n,a){return{success:!0,data:void 0,errorCode:void 0,errorMessage:void 0}}}});function m(i){return{success:!0,data:i,errorCode:"",errorMessage:""}}function g(i,t=""){return{success:!1,data:void 0,errorCode:i,errorMessage:t}}var _=h(()=>{"use strict"});var ye={};R(ye,{PuppeteerPlatform:()=>Jt});var Jt,Se=h(()=>{"use strict";_();console.log("PuppeteerPlatform");Jt=class{iframeRegistry=new Map;constructor(){}callJSB(t,e){return new Promise(r=>{try{if(window.__handleJSBMessage)try{console.log(` core-sdk Puppeteer Platform: callJSB: ${t}::${e}`);let n=window.__handleJSBMessage(`${t}::${e}`);console.log(` core-sdk Puppeteer Platform callJSB result: ${n}`),r(m(n))}catch{r(g("500","JSB execution error"))}else r(m("ok"))}catch(n){console.error(`PuppeteerPlatform cmd Error: ${t}, msg: ${e} error: ${n}`),r(g("500","Internal error"))}})}createSpatializedElementSync(t,e){try{console.log(`[Puppeteer Platform] Creating spatialized element sync with id: ${t}, url: ${e}`);let r=window;if(r.__handleJSBMessage){let n={id:t,url:e};r.__handleJSBMessage(`CreateSpatialized2DElement::${JSON.stringify(n)}`)}}catch(r){console.error("Error creating spatialized element sync:",r)}}callWebSpatialProtocol(t,e,r,n){return console.log(`PuppeteerPlatform: Calling webspatial protocol: webspatial://${t}${e?`?${e}`:""}`),new Promise(a=>{try{let o=`webspatial://${t}${e?`?${e}`:""}`,{spatialId:s,iframe:p,windowProxy:y}=this.createIframeWindow(o,r,n);t==="createSpatialized2DElement"&&this.createSpatializedElementSync(s,o),console.log(`[Puppeteer Platform] iframe created with spatialId: ${s}`),this.iframeRegistry.set(s,p),a(m({windowProxy:y,id:s}))}catch(o){console.error("Error calling webspatial protocol:",o),a(g("500","Failed to call webspatial protocol"))}})}callWebSpatialProtocolSync(t,e,r,n){try{let a=`webspatial://${t}${e?`?${e}`:""}`;console.log(`Calling webspatial protocol sync: ${a}`);let{spatialId:o,iframe:s,windowProxy:p}=this.createIframeWindow(a,r,n);return t==="createSpatialized2DElement"&&this.createSpatializedElementSync(o,a),this.iframeRegistry.set(o,s),m({windowProxy:p,id:o})}catch(a){return console.error("Error calling webspatial protocol sync:",a),g("500","Failed to call webspatial protocol sync")}}createIframeWindow(t,e,r){let n=document.createElement("iframe");n.style.border="none",n.style.display="none",n.style.width="100%",n.style.height="100%";let a=this.generateUUID();n.spatialId=a,n.id=`spatial-iframe-${a}`;let o=this.parseFeatures(r||"");o.width&&(n.style.width=o.width),o.height&&(n.style.height=o.height),o.left&&(n.style.left=o.left,n.style.position="absolute"),o.top&&(n.style.top=o.top,n.style.position="absolute"),document.body.appendChild(n);let s=this.createEnhancedWindowProxy(n,t,a);return n.src="about:blank",console.log(`PuppeteerPlatform created iframe window with spatialId: ${a}, URL: ${t}`),this.initializeIframeContent(n,t,a),{spatialId:a,iframe:n,windowProxy:s}}createEnhancedWindowProxy(t,e,r){return{location:{href:e,toString:()=>e,reload:()=>{t.contentWindow&&t.contentWindow.location.reload()}},navigator:{userAgent:`Mozilla/5.0 (WebKit) SpatialId/${r}`},close:()=>{console.log(`Closing iframe with spatialId: ${r}`),t.remove(),this.iframeRegistry.delete(r)},document:t.contentDocument||{},contentWindow:t.contentWindow||{},postMessage:(n,a)=>{t.contentWindow&&t.contentWindow.postMessage(n,a||"*")},addEventListener:(n,a)=>{t.contentWindow&&t.contentWindow.addEventListener(n,a)},removeEventListener:(n,a)=>{t.contentWindow&&t.contentWindow.removeEventListener(n,a)},executeScript:n=>{if(t.contentWindow)try{return t.contentWindow.eval(n)}catch(a){return console.error(`Error executing script in iframe ${r}:`,a),null}return null},getIframe:()=>t,getSpatialId:()=>r}}initializeIframeContent(t,e,r){try{t.onload=()=>{try{let n=`
9
+ // inject communication script
10
10
  window.webSpatialId = '${r}';
11
11
  window.SpatialId = '${r}';
12
12
 
13
- // \u91CD\u5199window.open\u4EE5\u652F\u6301webspatial\u534F\u8BAE
13
+ // override window.open to support webspatial protocol
14
14
  const originalOpen = window.open;
15
15
  window.open = function(url, target, features) {
16
16
  if (url && url.startsWith('webspatial://')) {
17
- // \u901A\u8FC7windowProxy\u5904\u7406webspatial\u534F\u8BAE
17
+ // handle webspatial protocol through windowProxy
18
18
  const windowProxy = new Proxy({}, {
19
19
  get: function(target, prop) {
20
20
  if (prop === 'toString') {
@@ -28,31 +28,31 @@
28
28
  return originalOpen.call(window, url, target, features);
29
29
  };
30
30
 
31
- // \u8BBE\u7F6Enavigator.userAgent\u4EE5\u8BC6\u522Bwebspatial\u73AF\u5883
31
+ // set navigator.userAgent to identify webspatial environment
32
32
  Object.defineProperty(navigator, 'userAgent', {
33
33
  value: 'WebSpatial/1.0 ' + navigator.userAgent,
34
34
  configurable: true
35
35
  });
36
36
 
37
- // \u53D1\u9001\u52A0\u8F7D\u5B8C\u6210\u6D88\u606F
37
+ // send loaded message
38
38
  window.parent.postMessage({
39
39
  type: 'iframe_loaded',
40
40
  spatialId: '${r}',
41
- url: '${t}'
41
+ url: '${e}'
42
42
  }, '${window.location.origin}');
43
43
 
44
- // \u8BBE\u7F6E\u6D88\u606F\u5904\u7406\u5668
44
+ // set message handler
45
45
  window.addEventListener('message', (event) => {
46
46
  if (event.origin !== window.parent.location.origin) return;
47
47
 
48
48
  const data = event.data;
49
49
  if (data && data.type === 'webspatial_command') {
50
- // \u5904\u7406\u6765\u81EA\u7236\u7A97\u53E3\u7684\u547D\u4EE4
50
+ // handle command from parent window
51
51
  console.log('Received command in iframe from parent:', data.command);
52
- // \u8FD9\u91CC\u53EF\u4EE5\u6DFB\u52A0\u547D\u4EE4\u5904\u7406\u903B\u8F91
52
+ // add command handling logic here
53
53
  }
54
54
  });
55
- `,a=e.contentDocument;a&&(a.open(),a.write(`
55
+ `,a=t.contentDocument;a&&(a.open(),a.write(`
56
56
  <!DOCTYPE html>
57
57
  <html>
58
58
  <head>
@@ -70,6 +70,6 @@
70
70
  <script>${n}</script>
71
71
  </body>
72
72
  </html>
73
- `),a.close())}catch(n){console.error("Error initializing iframe content:",n)}}}catch(n){console.error("Error setting up iframe:",n)}}parseFeatures(e){let t={};return e.split(",").forEach(n=>{let[a,o]=n.split("=").map(s=>s.trim());a&&o&&(t[a]=o)}),t}sendMessageToIframe(e,t){let r=this.iframeRegistry.get(e);return r&&r.contentWindow?(r.contentWindow.postMessage(t,window.location.origin),!0):!1}getAllActiveIframes(){let e=[];return this.iframeRegistry.forEach((t,r)=>{e.push({spatialId:r,iframe:t})}),e}dispose(){this.iframeRegistry.forEach((e,t)=>{console.log(`Disposing iframe with spatialId: ${t}`),e.remove()}),this.iframeRegistry.clear()}generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16).toUpperCase()})}}});var c,P=h(()=>{"use strict";c=class i{static eventReceiver={};static init(){window.__SpatialWebEvent=({id:e,data:t})=>{i.eventReceiver[e]?.(t)}}static addEventReceiver(e,t){i.eventReceiver[e]=t}static removeEventReceiver(e){delete i.eventReceiver[e]}}});var pe={};W(pe,{XRPlatform:()=>jt});function se(){return Ut=(Ut+1)%qe,`rId_${Ut}`}var Ut,qe,jt,le=h(()=>{"use strict";V();P();Ut=0,qe=1e5;jt=class{async callJSB(e,t){return new Promise((r,n)=>{try{let a=se();c.addEventReceiver(a,s=>{if(c.removeEventReceiver(a),s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(S(p,y))}});let o=window.webspatialBridge.postMessage(a,e,t);if(o!==""){c.removeEventReceiver(a);let s=JSON.parse(o);if(s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(S(p,y))}}}catch(a){console.error(`XRPlatform cmd: ${e}, msg: ${t} error: ${a}`);let{code:o,message:s}=a;r(S(o,s))}})}async callWebSpatialProtocol(e,t,r,n){return new Promise((a,o)=>{let s=se();try{let p=null;c.addEventReceiver(s,y=>{console.log("createdId",s,y.spatialId),a(m({windowProxy:p,id:y.spatialId})),c.removeEventReceiver(s)}),p=this.openWindow(e,t,r,n).windowProxy,p?.open(`about:blank?rid=${s}`,"_self")}catch(p){console.error(`open window error: ${p}`);let{code:y,message:_t}=p;c.removeEventReceiver(s),a(S(y,_t))}})}callWebSpatialProtocolSync(e,t,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(e,t,r,n);return m({windowProxy:o,id:a})}openWindow(e,t,r,n){return{spatialId:"",windowProxy:window.open(`webspatial://${e}?${t||""}`,r,n)}}}});var ce={};W(ce,{AndroidPlatform:()=>Jt});function Ke(){return kt=(kt+1)%Xe,`rId_${kt}`}var Ft,kt,Xe,Jt,de=h(()=>{"use strict";V();g();P();Ft=0,kt=0,Xe=1e5;Jt=class{async callJSB(e,t){return new Promise((r,n)=>{try{let a=Ke();c.addEventReceiver(a,s=>{if(c.removeEventReceiver(a),s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(S(p,y))}});let o=window.webspatialBridge.postMessage(a,e,t);if(o!==""){c.removeEventReceiver(a);let s=JSON.parse(o);if(s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(S(p,y))}}}catch(a){console.error(`AndroidPlatform cmd: ${e}, msg: ${t} error: ${a}`);let{code:o,message:s}=a;r(S(o,s))}})}async callWebSpatialProtocol(e,t,r,n){await new Promise(p=>setTimeout(p,16*Ft)),Ft++;let a=await new _().execute();for(;!a.data.can;)await new Promise(p=>setTimeout(p,16)),a=await new _().execute();let{windowProxy:o}=this.openWindow(e,t,r,n);for(;!o?.open;)await new Promise(p=>setTimeout(p,16));for(o?.open("about:blank","_self");!o?.__SpatialId;)await new Promise(p=>setTimeout(p,16));let s=o?.__SpatialId;return Ft--,Promise.resolve(m({windowProxy:o,id:s}))}callWebSpatialProtocolSync(e,t,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(e,t,r,n);return m({windowProxy:o,id:a})}openWindow(e,t,r,n){return{spatialId:"",windowProxy:window.open(`webspatial://${e}?${t||""}`,r,n)}}}});var me={};W(me,{VisionOSPlatform:()=>Nt});var Nt,ue=h(()=>{"use strict";V();Nt=class{async callJSB(e,t){try{let r=await window.webkit.messageHandlers.bridge.postMessage(`${e}::${t}`);return m(r)}catch(r){let{code:n,message:a}=JSON.parse(r.message);return S(n,a)}}callWebSpatialProtocol(e,t,r,n){let{spatialId:a,windowProxy:o}=this.openWindow(e,t,r,n);return Promise.resolve(m({windowProxy:o,id:a}))}callWebSpatialProtocolSync(e,t,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(e,t,r,n);return m({windowProxy:o,id:a})}openWindow(e,t,r,n){let a=window.open(`webspatial://${e}?${t||""}`,r,n);return{spatialId:a?.navigator.userAgent?.match(/\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\b/gi)?.[0],windowProxy:a}}}});function Qe(i){let e=i.match(/WebSpatial\/(\d+)\.(\d+)\.(\d+)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null}function Ye(i,e){if(!i)return!1;for(let t=0;t<3;t+=1){let r=i[t]-e[t];if(r>0)return!0;if(r<0)return!1}return!1}function ye(){if(G())return new Q;let i=window.navigator.userAgent,e=Qe(i);if(window.navigator.userAgent.includes("Puppeteer")){let t=(oe(),A(ae)).PuppeteerPlatform;return new t}else if(i.includes("PicoWebApp")&&Ye(e,[0,0,1])){let t=(le(),A(pe)).XRPlatform;return new t}else if(i.includes("Android")||i.includes("Linux")){let t=(de(),A(ce)).AndroidPlatform;return new t}else{let t=(ue(),A(me)).VisionOSPlatform;return new t}}var Se=h(()=>{"use strict";Bt();ne()});function Y(i,e){return i===""?0:i.endsWith("%")?e*parseFloat(i)/100:parseFloat(i)}function ge(i){let e=parseFloat(i.getPropertyValue("width")),t=i.getPropertyValue("border-top-left-radius"),r=i.getPropertyValue("border-top-right-radius"),n=i.getPropertyValue("border-bottom-left-radius"),a=i.getPropertyValue("border-bottom-right-radius");return{topLeading:Y(t,e),bottomLeading:Y(n,e),topTrailing:Y(r,e),bottomTrailing:Y(a,e)}}function fe(i,e,t){let{x:r,y:n,z:a}=i,{x:o,y:s,z:p}=e,{x:y,y:_t,z:je}=t,v=new DOMMatrix;return v=v.translate(r,n,a),v=v.rotate(o,s,p),v=v.scale(y,_t,je),v}var Ht=h(()=>{"use strict"});var qt,l,Z,tt,et,it,rt,nt,x,at,ot,st,pt,lt,ct,dt,mt,ut,yt,St,gt,ft,ht,Et,bt,M,xt,wt,vt,Pt,Mt,_,L,Dt,Rt,Ct,Tt,g=h(()=>{"use strict";Se();Ht();qt=ye(),l=class{commandType="";async execute(){let e=this.getParams(),t=e?JSON.stringify(e):"";return qt.callJSB(this.commandType,t)}},Z=class extends l{constructor(t,r){super();this.entity=t;this.properties=r}commandType="UpdateEntityProperties";getParams(){let t=fe(this.properties.position??this.entity.position,this.properties.rotation??this.entity.rotation,this.properties.scale??this.entity.scale).toFloat64Array();return{entityId:this.entity.id,transform:t}}},tt=class extends l{constructor(t,r,n){super();this.entity=t;this.type=r;this.isEnable=n}commandType="UpdateEntityEvent";getParams(){return{type:this.type,entityId:this.entity.id,isEnable:this.isEnable}}},et=class extends l{properties;commandType="UpdateSpatialSceneProperties";constructor(e){super(),this.properties=e}getParams(){return this.properties}},it=class extends l{config;commandType="UpdateSceneConfig";constructor(e){super(),this.config=e}getParams(){return{config:this.config}}},rt=class extends l{constructor(t){super();this.id=t}commandType="FocusScene";getParams(){return{id:this.id}}},nt=class extends l{commandType="GetSpatialSceneState";constructor(){super()}getParams(){return{}}},x=class extends l{constructor(t){super();this.spatialObject=t}getParams(){let t=this.getExtraParams();return{id:this.spatialObject.id,...t}}},at=class extends x{properties;commandType="UpdateSpatialized2DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},ot=class extends x{properties;commandType="UpdateSpatializedDynamic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return{id:this.spatialObject.id,...this.properties}}},st=class extends x{properties;commandType="UpdateUnlitMaterialProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},pt=class extends x{matrix;commandType="UpdateSpatializedElementTransform";constructor(e,t){super(e),this.matrix=t}getExtraParams(){return{matrix:Array.from(this.matrix.toFloat64Array())}}},lt=class extends x{properties;commandType="UpdateSpatializedStatic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},ct=class extends x{commandType="AddSpatializedElementToSpatialized2DElement";spatializedElement;constructor(e,t){super(e),this.spatializedElement=t}getExtraParams(){return{spatializedElementId:this.spatializedElement.id}}},dt=class extends l{commandType="AddSpatializedElementToSpatialScene";spatializedElement;constructor(e){super(),this.spatializedElement=e}getParams(){return{spatializedElementId:this.spatializedElement.id}}},mt=class extends l{constructor(t){super();this.modelURL=t;this.modelURL=t}commandType="CreateSpatializedStatic3DElement";getParams(){return{modelURL:this.modelURL}}},ut=class extends l{getParams(){return{test:!0}}commandType="CreateSpatializedDynamic3DElement"},yt=class extends l{constructor(t){super();this.name=t}getParams(){return{name:this.name}}commandType="CreateSpatialEntity"},St=class extends l{constructor(t){super();this.options=t}getParams(){let t=this.options.mesh.id,r=this.options.materials.map(n=>n.id);return{geometryId:t,materialIds:r}}commandType="CreateModelComponent"},gt=class extends l{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateSpatialModelEntity"},ft=class extends l{constructor(t){super();this.options=t}getParams(){return{url:this.options.url}}commandType="CreateModelAsset"},ht=class extends l{constructor(t,r={}){super();this.type=t;this.options=r}getParams(){return{type:this.type,...this.options}}commandType="CreateGeometry"},Et=class extends l{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateUnlitMaterial"},bt=class extends l{constructor(t,r){super();this.entity=t;this.comp=r}getParams(){return{entityId:this.entity.id,componentId:this.comp.id}}commandType="AddComponentToEntity"},M=class extends l{constructor(t,r){super();this.childId=t;this.parentId=r}getParams(){return{childId:this.childId,parentId:this.parentId}}commandType="SetParentToEntity"},xt=class extends l{constructor(t,r,n){super();this.fromEntityId=t;this.toEntityId=r;this.fromPosition=n}getParams(){return{fromEntityId:this.fromEntityId,toEntityId:this.toEntityId,position:this.fromPosition}}commandType="ConvertFromEntityToEntity"},wt=class extends l{constructor(t,r){super();this.fromEntityId=t;this.position=r}getParams(){return{fromEntityId:this.fromEntityId,position:this.position}}commandType="ConvertFromEntityToScene"},vt=class extends l{constructor(t,r){super();this.entityId=t;this.position=r}getParams(){return{entityId:this.entityId,position:this.position}}commandType="ConvertFromSceneToEntity"},Pt=class extends l{constructor(t=""){super();this.id=t}commandType="Inspect";getParams(){return this.id?{id:this.id}:{id:""}}},Mt=class extends l{constructor(t){super();this.id=t}commandType="Destroy";getParams(){return{id:this.id}}},_=class extends l{constructor(t=""){super();this.id=t}commandType="CheckWebViewCanCreate";getParams(){return{id:this.id}}},L=class extends l{target;features;async execute(){let e=this.getQuery();return qt.callWebSpatialProtocol(this.commandType,e,this.target,this.features)}executeSync(){let e=this.getQuery();return qt.callWebSpatialProtocolSync(this.commandType,e,this.target,this.features)}getQuery(){let e,t=this.getParams();return t&&(e=Object.keys(t).map(r=>{let n=t[r],a=typeof n=="object"?JSON.stringify(n):n;return`${r}=${encodeURIComponent(a)}`}).join("&")),e}},Dt=class extends L{commandType="createSpatialized2DElement";constructor(){super()}getParams(){return{}}},Rt=class extends L{constructor(t,r,n,a){super();this.url=t;this.config=r;this.target=n;this.features=a}commandType="createSpatialScene";getParams(){return{url:this.url,config:this.config}}},Ct=class extends L{constructor(t){super();this.options=t}commandType="createAttachment";getParams(){return{parentEntityId:this.options.parentEntityId,position:this.options.position??[0,0,0],size:this.options.size}}},Tt=class extends l{constructor(t,r){super();this.attachmentId=t;this.options=r}commandType="UpdateAttachmentEntity";getParams(){return{id:this.attachmentId,...this.options}}}});var di={};W(di,{Attachment:()=>It,BaseplateVisibilityValues:()=>Ee,CubeInfo:()=>B,ModelComponent:()=>j,Spatial:()=>I,SpatialBoxGeometry:()=>N,SpatialComponent:()=>U,SpatialConeGeometry:()=>K,SpatialCylinderGeometry:()=>q,SpatialEntity:()=>D,SpatialGeometry:()=>f,SpatialMaterial:()=>F,SpatialModelAsset:()=>J,SpatialModelEntity:()=>$,SpatialObject:()=>d,SpatialPlaneGeometry:()=>X,SpatialScene:()=>b,SpatialSceneState:()=>te,SpatialSceneValues:()=>we,SpatialSession:()=>z,SpatialSphereGeometry:()=>H,SpatialUnlitMaterial:()=>k,Spatialized2DElement:()=>R,SpatializedDynamic3DElement:()=>T,SpatializedElement:()=>E,SpatializedElementType:()=>he,SpatializedStatic3DElement:()=>C,WorldAlignmentValues:()=>xe,WorldScalingValues:()=>be,createAttachmentEntity:()=>re,isSSREnv:()=>G,isValidBaseplateVisibilityType:()=>Kt,isValidSceneUnit:()=>Ot,isValidSpatialSceneType:()=>Zt,isValidWorldAlignmentType:()=>Yt,isValidWorldScalingType:()=>Qt});g();var d=class{constructor(e){this.id=e}name;isDestroyed=!1;async inspect(){let e=await new Pt(this.id).execute();if(e.success)return e.data;throw new Error(e.errorMessage)}async destroy(){if(this.isDestroyed)return;let e=await new Mt(this.id).execute();if(e.success)return this.onDestroy(),this.isDestroyed=!0,e.data;if(this.isDestroyed)return;throw new Error(e.errorMessage)}onDestroy(){}};g();g();var Xt,b=class i extends d{static getInstance(){return Xt||(Xt=new i("")),Xt}async updateSpatialProperties(e){return new et(e).execute()}async addSpatializedElement(e){return new dt(e).execute()}async updateSceneCreationConfig(e){return new it(e).execute()}async getState(){return(await new nt().execute()).data.name}};var he=(r=>(r[r.Spatialized2DElement=0]="Spatialized2DElement",r[r.SpatializedStatic3DElement=1]="SpatializedStatic3DElement",r[r.SpatializedDynamic3DElement=2]="SpatializedDynamic3DElement",r))(he||{}),Ee=["automatic","visible","hidden"];function Kt(i){return Ee.includes(i)}var be=["automatic","dynamic"];function Qt(i){return be.includes(i)}var xe=["adaptive","automatic","gravityAligned"];function Yt(i){return xe.includes(i)}var we=["window","volume"];function Zt(i){return we.includes(i)}function Ot(i){if(typeof i=="number")return i>=0;if(typeof i=="string"){if(i.endsWith("px"))return isNaN(Number(i.slice(0,-2)))?!1:Number(i.slice(0,-2))>=0;if(i.endsWith("m"))return isNaN(Number(i.slice(0,-1)))?!1:Number(i.slice(0,-1))>=0}return!1}var te=(a=>(a.idle="idle",a.pending="pending",a.willVisible="willVisible",a.visible="visible",a.fail="fail",a))(te||{}),B=class{constructor(e,t){this.size=e;this.origin=t;this.size=e,this.origin=t}get x(){return this.origin.x}get y(){return this.origin.y}get z(){return this.origin.z}get width(){return this.size.width}get height(){return this.size.height}get depth(){return this.size.depth}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get back(){return this.z}get front(){return this.z+this.depth}};var Ze={defaultSize:{width:1280,height:720}},ti={defaultSize:{width:.94,height:.94,depth:.94}},ei="webspatial://",zt=class i{originalOpen;static instance;static getInstance(){return i.instance||(i.instance=new i),i.instance}init(e){this.originalOpen=e.open.bind(e),e.open=this.open}configMap={};getConfig(e){if(!(e===void 0||!this.configMap[e]))return this.configMap[e]}ensureAbsoluteUrl(e){if(!e||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e))return e;if(e.startsWith("//"))return`${window.location.protocol}${e}`;try{return new URL(e,document.baseURI).toString()}catch{return e}}open=(e,t,r)=>{if(e?.startsWith(ei))return this.originalOpen(e,t,r);if(e=this.ensureAbsoluteUrl(e),t==="_self"||t==="_parent"||t==="_top")return this.originalOpen(e,t,r);let n=t?this.getConfig(t):void 0,o=new Rt(e,n,t,r).executeSync(),s=o.data?.id;return s&&new rt(s).execute(),o.data?.windowProxy};initScene(e,t,r){let n=r?.type??"window",a=ie(n),o=t({...a}),[s,p]=De(o,n);p.length>0&&console.warn(`initScene ${e} with errors: ${p.join(", ")}`),this.configMap[e]={...s,type:n}}};function ve(i){return i/1360}function Pe(i){return i*1360}function Me(i,e,t){if(typeof i=="number")return t==="px"&&e==="px"||t==="m"&&e==="m"?i:t==="px"&&e==="m"?ve(i):t==="m"&&e==="px"?Pe(i):i;if(e==="m"){if(i.endsWith("m"))return Number(i.slice(0,-1));if(i.endsWith("px"))return ve(Number(i.slice(0,-2)));throw new Error("formatToNumber: invalid str")}else if(e==="px"){if(i.endsWith("px"))return Number(i.slice(0,-2));if(i.endsWith("m"))return Pe(Number(i.slice(0,-1)));throw new Error("formatToNumber: invalid str")}else throw new Error("formatToNumber: invalid targetUnit")}function De(i,e){let t=ie(e),r=[],n=e==="window";if(Zt(e)||r.push("sceneType"),i.defaultSize){let a=["width","height","depth"];for(let o of a)o in i.defaultSize&&(Ot(i.defaultSize[o])?i.defaultSize[o]=Me(i.defaultSize[o],n?"px":"m",n?"px":"m"):(i.defaultSize[o]=t.defaultSize[o],r.push(`defaultSize.${o}`)))}if(i.resizability){let a=["minWidth","minHeight","maxWidth","maxHeight"];for(let o of a)o in i.resizability&&(Ot(i.resizability[o])?i.resizability[o]=Me(i.resizability[o],"px",n?"px":"m"):(i.resizability[o]=void 0,r.push(`resizability.${o}`)))}return i.worldScaling&&(Qt(i.worldScaling)||(i.worldScaling="automatic",r.push("worldScaling"))),i.worldAlignment&&(Yt(i.worldAlignment)||(i.worldAlignment="automatic",r.push("worldAlignment"))),i.baseplateVisibility&&(Kt(i.baseplateVisibility)||(i.baseplateVisibility="automatic",r.push("baseplateVisibility"))),[i,r]}function Re(i,e,t){return zt.getInstance().initScene(i,e,t)}function ii(i){zt.getInstance().init(i)}function ee(i){i.document.onclick=function(e){let t=e.target,r=!1;for(;!r;){if(t&&t.tagName=="A")return!ri(e);if(t&&t.parentElement)t=t.parentElement;else break}}}function ri(i){let e=i.target;if(e.tagName==="A"){let t=e,r=t.target,n=t.href;if(r&&r!=="_self")return i.preventDefault(),window.open(n,r),!0}}function ie(i){return i==="window"?Ze:ti}async function ni(){if(!window.opener||await b.getInstance().getState()!=="pending")return;function e(t){document.readyState==="interactive"||document.readyState==="complete"?t():document.addEventListener("DOMContentLoaded",t)}e(async()=>{let t=ie(window.xrCurrentSceneType??"window"),r=t;if(typeof window.xrCurrentSceneDefaults=="function")try{r=await window.xrCurrentSceneDefaults?.(t)}catch(s){console.error(s)}await new Promise((s,p)=>{setTimeout(()=>{s(null)},1e3)});let n=window.xrCurrentSceneType??"window",[a,o]=De(r,n);o.length>0&&console.warn(`window.xrCurrentSceneDefaults with errors: ${o.join(", ")}`),await b.getInstance().updateSceneCreationConfig({...a,type:n})})}function Ce(){ii(window),ee(window),ni()}g();g();g();P();function u(i,e){return new CustomEvent(i,{bubbles:!0,cancelable:!1,detail:e})}var E=class extends d{constructor(t){super(t);this.id=t;c.addEventReceiver(t,this.onReceiveEvent.bind(this))}async updateTransform(t){return new pt(this,t).execute()}_cubeInfo;get cubeInfo(){return this._cubeInfo}_transform;_transformInv;get transform(){return this._transform}get transformInv(){return this._transformInv}onReceiveEvent(t){let{type:r}=t;if(r==="objectdestroy")this.isDestroyed=!0;else if(r==="cubeInfo"){let n=t;this._cubeInfo=new B(n.size,n.origin)}else if(r==="transform")this._transform=new DOMMatrix([t.detail.column0[0],t.detail.column0[1],t.detail.column0[2],0,t.detail.column1[0],t.detail.column1[1],t.detail.column1[2],0,t.detail.column2[0],t.detail.column2[1],t.detail.column2[2],0,t.detail.column3[0],t.detail.column3[1],t.detail.column3[2],1]),this._transformInv=this._transform.inverse();else if(r==="spatialtap"){let n=u("spatialtap",t.detail);this._onSpatialTap?.(n)}else if(r==="spatialdragstart"){let n=u("spatialdragstart",t.detail);this._onSpatialDragStart?.(n)}else if(r==="spatialdrag"){let n=u("spatialdrag",t.detail);this._onSpatialDrag?.(n)}else if(r==="spatialdragend"){let n=u("spatialdragend",t.detail);this._onSpatialDragEnd?.(n)}else if(r==="spatialrotate"){let n=u("spatialrotate",t.detail);this._onSpatialRotate?.(n)}else if(r==="spatialrotateend"){let n=u("spatialrotateend",t.detail);this._onSpatialRotateEnd?.(n)}else if(r==="spatialmagnify"){let n=u("spatialmagnify",t.detail);this._onSpatialMagnify?.(n)}else if(r==="spatialmagnifyend"){let n=u("spatialmagnifyend",t.detail);this._onSpatialMagnifyEnd?.(n)}}_onSpatialTap;set onSpatialTap(t){this._onSpatialTap=t,this.updateProperties({enableTapGesture:t!==void 0})}_onSpatialDragStart;set onSpatialDragStart(t){this._onSpatialDragStart=t,this.updateProperties({enableDragStartGesture:this._onSpatialDragStart!==void 0})}_onSpatialDrag;set onSpatialDrag(t){this._onSpatialDrag=t,this.updateProperties({enableDragGesture:this._onSpatialDrag!==void 0})}_onSpatialDragEnd;set onSpatialDragEnd(t){this._onSpatialDragEnd=t,this.updateProperties({enableDragEndGesture:t!==void 0})}_onSpatialRotate;set onSpatialRotate(t){this._onSpatialRotate=t,this.updateProperties({enableRotateGesture:this._onSpatialRotate!==void 0})}_onSpatialRotateEnd;set onSpatialRotateEnd(t){this._onSpatialRotateEnd=t,this.updateProperties({enableRotateEndGesture:t!==void 0})}_onSpatialMagnify;set onSpatialMagnify(t){this._onSpatialMagnify=t,this.updateProperties({enableMagnifyGesture:t!==void 0})}_onSpatialMagnifyEnd;set onSpatialMagnifyEnd(t){this._onSpatialMagnifyEnd=t,this.updateProperties({enableMagnifyEndGesture:t!==void 0})}onDestroy(){c.removeEventReceiver(this.id)}};var R=class extends E{constructor(t,r){super(t);this.windowProxy=r;ee(r)}async updateProperties(t){return new at(this,t).execute()}async addSpatializedElement(t){return new ct(this,t).execute()}};g();var C=class extends E{constructor(e,t){super(e),this.modelURL=t}_readyResolve;modelURL;createReadyPromise(){return new Promise(e=>{this._readyResolve=e})}ready=this.createReadyPromise();async updateProperties(e){return e.modelURL!==void 0&&this.modelURL!==e.modelURL&&(this.modelURL=e.modelURL,this.ready=this.createReadyPromise()),new lt(this,e).execute()}onReceiveEvent(e){e.type==="modelloaded"?(this._onLoadCallback?.(),this._readyResolve?.(!0)):e.type==="modelloadfailed"?(this._onLoadFailureCallback?.(),this._readyResolve?.(!1)):super.onReceiveEvent(e)}_onLoadCallback;set onLoadCallback(e){this._onLoadCallback=e}_onLoadFailureCallback;set onLoadFailureCallback(e){this._onLoadFailureCallback=e}updateModelTransform(e){let t=Array.from(e.toFloat64Array());this.updateProperties({modelTransform:t})}};g();var T=class extends E{children=[];constructor(e){super(e)}async addEntity(e){let t=new M(e.id,this.id).execute();return this.children.push(e),e.parent=this,t}async updateProperties(e){return new ot(this,e).execute()}};async function Te(){let i=await new Dt().execute();if(i.success){let{id:e,windowProxy:t}=i.data;return t.document.head.innerHTML=`<meta name="viewport" content="width=device-width, initial-scale=1">
74
- <base href="${document.baseURI}">`,new R(e,t)}else throw new Error("createSpatialized2DElement failed")}async function Oe(i){let e=await new mt(i).execute();if(e.success){let{id:t}=e.data;return new C(t,i)}else throw new Error("createSpatializedStatic3DElement failed")}async function ze(){let i=await new ut().execute();if(i.success){let{id:e}=i.data;return new T(e)}else throw new Error("createSpatializedDynamic3DElement failed")}g();var It=class extends d{constructor(t,r,n){super(t);this.windowProxy=r;this.options=n}getContainer(){return this.windowProxy.document.body}getWindowProxy(){return this.windowProxy}async update(t){if(!this.isDestroyed)return t.position&&(this.options.position=t.position),t.size&&(this.options.size=t.size),new Tt(this.id,t).execute()}};async function re(i){let e=await new Ct(i).execute();if(!e.success)throw new Error("createAttachmentEntity failed: "+e?.errorMessage);let{id:t,windowProxy:r}=e.data;return new It(t,r,i)}g();g();g();P();var D=class i extends d{constructor(t,r){super(t);this.userData=r;c.addEventReceiver(t,this.onReceiveEvent)}position={x:0,y:0,z:0};rotation={x:0,y:0,z:0};scale={x:1,y:1,z:1};events={};children=[];parent=null;async addComponent(t){return new bt(this,t).execute()}async setPosition(t){return this.updateTransform({position:t})}async setRotation(t){return this.updateTransform({rotation:t})}async setScale(t){return this.updateTransform({scale:t})}async addEntity(t){let r=await new M(t.id,this.id).execute();return this.children.push(t),t.parent=this,r}async removeFromParent(){let t=await new M(this.id,void 0).execute();return this.parent&&(this.parent.children=this.parent.children.filter(r=>r.id!==this.id),this.parent=null),t}async updateTransform(t){return this.position=t.position??this.position,this.rotation=t.rotation??this.rotation,this.scale=t.scale??this.scale,new Z(this,t).execute()}async addEvent(t,r){if(this.events[t])this.events[t]=r;else try{await this.updateEntityEvent(t,!0),this.events[t]=r}catch{console.error("addEvent failed",t)}}async removeEvent(t){if(this.events[t]){delete this.events[t];try{await this.updateEntityEvent(t,!1)}catch{console.error("removeEvent failed",t)}}}async updateEntityEvent(t,r){return new tt(this,t,r).execute()}onReceiveEvent=t=>{let{type:r}=t;if(r==="objectdestroy")this.isDestroyed=!0;else if(r==="spatialtap"){let n=u("spatialtap",t.detail);this.dispatchEvent(n)}else if(r==="spatialdragstart"){let n=u("spatialdragstart",t.detail);this.dispatchEvent(n)}else if(r==="spatialdrag"){let n=u("spatialdrag",t.detail);this.dispatchEvent(n)}else if(r==="spatialdragend"){let n=u("spatialdragend",t.detail);this.dispatchEvent(n)}else if(r==="spatialrotate"){let n=u("spatialrotate",t.detail);this.dispatchEvent(n)}else if(r==="spatialrotateend"){let n=u("spatialrotateend",t.detail);this.dispatchEvent(n)}else if(r==="spatialmagnify"){let n=u("spatialmagnify",t.detail);this.dispatchEvent(n)}else if(r==="spatialmagnifyend"){let n=u("spatialmagnifyend",t.detail);this.dispatchEvent(n)}};dispatchEvent(t){t.__origin||Object.defineProperty(t,"__origin",{value:this,enumerable:!1}),this.events[t.type]?.(t),t.bubbles&&!t.cancelBubble&&this.parent&&this.parent instanceof i&&this.parent.dispatchEvent(t)}onDestroy(){c.removeEventReceiver(this.id),this.children.forEach(t=>{t.parent=null}),this.children=[],this.parent&&(this.parent.children=this.parent.children.filter(t=>t.id!==this.id),this.parent=null)}async convertFromEntityToEntity(t,r,n){return new xt(t,r,n).execute()}async convertFromEntityToScene(t,r){return new wt(t,r).execute()}async convertFromSceneToEntity(t,r){return new vt(t,r).execute()}};var $=class extends D{constructor(t,r,n){super(t,n);this.id=t;this.options=r;this.userData=n}};P();var U=class extends d{constructor(e){super(e),c.addEventReceiver(e,this.onReceiveEvent)}onReceiveEvent=e=>{let{type:t}=e;t==="objectdestroy"&&(this.isDestroyed=!0)}};var j=class extends U{constructor(t,r){super(t);this.options=r}};g();var F=class extends d{constructor(t,r){super(t);this.id=t;this.type=r;this.type=r}};var k=class extends F{constructor(t,r){super(t,"unlit");this.id=t;this.options=r}updateProperties(t){return new st(this,t).execute()}};var J=class extends d{constructor(t,r){super(t);this.id=t;this.options=r}};async function Ie(i){let e=await new yt(i?.name).execute();if(e.success){let{id:t}=e.data;return new D(t,i)}else throw new Error("createSpatialEntity failed:"+e?.errorMessage)}async function O(i,e){let t=await new ht(i.type,e).execute();if(t.success){let{id:r}=t.data;return new i(r,e)}else throw new Error("createSpatialGeometry failed:"+t?.errorMessage)}async function We(i){let e=await new Et(i).execute();if(e.success){let{id:t}=e.data;return new k(t,i)}else throw new Error("createSpatialUnlitMaterial failed:"+e?.errorMessage)}async function Ae(i){let e=await new St(i).execute();if(e.success){let{id:t}=e.data;return new j(t,i)}else throw new Error("createModelComponent failed:"+e?.errorMessage)}async function Ge(i,e){let t=await new gt(i).execute();if(t.success){let{id:r}=t.data;return new $(r,i,e)}else throw new Error("createSpatialModelEntity failed:"+t?.errorMessage)}async function Ve(i){let e=await new ft(i).execute();if(e.success){let{id:t}=e.data;return new J(t,i)}else throw new Error("createModelAsset failed:"+e?.errorMessage)}var f=class extends d{constructor(t,r){super(t);this.id=t;this.options=r}static type};var N=class extends f{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="BoxGeometry"};var H=class extends f{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="SphereGeometry"};var q=class extends f{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="CylinderGeometry"};var X=class extends f{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="PlaneGeometry"};var K=class extends f{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="ConeGeometry"};var z=class{getSpatialScene(){return b.getInstance()}createSpatialized2DElement(){return Te()}createSpatializedStatic3DElement(e){return Oe(e)}initScene=Re;createSpatializedDynamic3DElement(){return ze()}createEntity(e){return Ie(e)}createBoxGeometry(e={}){return O(N,e)}createPlaneGeometry(e={}){return O(X,e)}createSphereGeometry(e={}){return O(H,e)}createConeGeometry(e){return O(K,e)}createCylinderGeometry(e){return O(q,e)}createModelComponent(e){return Ae(e)}createUnlitMaterial(e){return We(e)}createModelAsset(e){return Ve(e)}createSpatialModelEntity(e,t){return Ge(e,t)}createAttachmentEntity(e){return re(e)}};P();var I=class{requestSession(){return this.runInSpatialWeb()?(c.init(),new z):null}runInSpatialWeb(){return navigator.userAgent.indexOf("WebSpatial/")>0}isSupported(){return!0}getNativeVersion(){return window.__WebSpatialData&&window.__WebSpatialData.getNativeVersion?window.__WebSpatialData.getNativeVersion():window.WebSpatailNativeVersion==="PACKAGE_VERSION"?this.getClientVersion():window.WebSpatailNativeVersion}getClientVersion(){return"1.3.0"}};Bt();Ht();var _e=new I,Vt,Wt={backgroundMaterial:"--xr-background-material"},Le="";function At(i){i!==Le&&(Vt?.getSpatialScene()?.updateSpatialProperties({material:i}),Le=i)}function ai(){let e=getComputedStyle(document.documentElement).getPropertyValue(Wt.backgroundMaterial);At(e||"none")}var w={topLeading:0,bottomLeading:0,topTrailing:0,bottomTrailing:0};function Be(){let i=getComputedStyle(document.documentElement),e=ge(i);oi(e)}function oi(i){(w.topLeading!==i.topLeading||w.bottomLeading!==i.bottomLeading||w.topTrailing!==i.topTrailing||w.bottomTrailing!==i.bottomTrailing)&&(Vt?.getSpatialScene()?.updateSpatialProperties({cornerRadius:i}),w.topLeading=i.topLeading,w.bottomLeading=i.bottomLeading,w.topTrailing=i.topTrailing,w.bottomTrailing=i.bottomTrailing)}function si(i){Vt?.getSpatialScene().updateSpatialProperties({opacity:i})}function $e(){let i=getComputedStyle(document.documentElement),e=parseFloat(i.getPropertyValue("opacity"));si(e)}function pi(){let i=document.documentElement.style,e=new Proxy(i,{set:function(t,r,n){let a=Reflect.set(t,r,n);return r===Wt.backgroundMaterial&&At(n),(r==="border-radius"||r==="borderRadius"||r==="border-top-left-radius"||r==="borderTopLeftRadius"||r==="border-top-right-radius"||r==="borderTopRightRadius"||r==="border-bottom-left-radius"||r==="borderBottomLeftRadius"||r==="border-bottom-right-radius"||r==="borderBottomRightRadius")&&Be(),r==="opacity"&&$e(),a},get:function(t,r){return typeof t[r]=="function"?function(...n){if(r==="setProperty"){let[a,o]=n;a===Wt.backgroundMaterial&&At(o)}else if(r==="removeProperty"){let[a]=n;a===Wt.backgroundMaterial&&At("none")}return t[r](...n)}:Reflect.get(t,r)}});Object.defineProperty(document.documentElement,"style",{get:function(){return e}})}function li(){new MutationObserver(Gt).observe(document.head,{childList:!0,subtree:!0})}function Gt(){ai(),Be(),$e()}function ci(){new MutationObserver(e=>{e.forEach(t=>{t.type==="attributes"&&t.attributeName&&Gt()})}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}async function Ue(){_e.runInSpatialWeb()&&(Vt=await _e.requestSession(),document.readyState==="complete"?Gt():window.addEventListener("load",()=>{Gt()}),pi(),li(),ci())}!G()&&navigator.userAgent.indexOf("WebSpatial/")>0&&(Ce(),Ue());return A(di);})();
73
+ `),a.close())}catch(n){console.error("Error initializing iframe content:",n)}}}catch(n){console.error("Error setting up iframe:",n)}}parseFeatures(t){let e={};return t.split(",").forEach(n=>{let[a,o]=n.split("=").map(s=>s.trim());a&&o&&(e[a]=o)}),e}sendMessageToIframe(t,e){let r=this.iframeRegistry.get(t);return r&&r.contentWindow?(r.contentWindow.postMessage(e,window.location.origin),!0):!1}getAllActiveIframes(){let t=[];return this.iframeRegistry.forEach((e,r)=>{t.push({spatialId:r,iframe:e})}),t}dispose(){this.iframeRegistry.forEach((t,e)=>{console.log(`Disposing iframe with spatialId: ${e}`),t.remove()}),this.iframeRegistry.clear()}generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16).toUpperCase()})}}});var c,v=h(()=>{"use strict";c=class i{static eventReceiver={};static init(){window.__SpatialWebEvent=({id:t,data:e})=>{i.eventReceiver[t]?.(e)}}static addEventReceiver(t,e){i.eventReceiver[t]=e}static removeEventReceiver(t){delete i.eventReceiver[t]}}});var fe={};R(fe,{PicoOSPlatform:()=>Ht});function ge(){return Nt=(Nt+1)%ri,`rId_${Nt}`}var Nt,ri,Ht,he=h(()=>{"use strict";_();v();Nt=0,ri=1e5;Ht=class{async callJSB(t,e){return new Promise((r,n)=>{try{let a=ge();c.addEventReceiver(a,s=>{if(c.removeEventReceiver(a),s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(g(p,y))}});let o=window.webspatialBridge.postMessage(a,t,e);if(o!==""){c.removeEventReceiver(a);let s=JSON.parse(o);if(s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(g(p,y))}}}catch(a){console.error(`SwanPlatform cmd: ${t}, msg: ${e} error: ${a}`);let{code:o,message:s}=a;r(g(o,s))}})}async callWebSpatialProtocol(t,e,r,n){return new Promise((a,o)=>{let s=ge();try{let p=null;c.addEventReceiver(s,y=>{a(m({windowProxy:p,id:y.spatialId})),c.removeEventReceiver(s)}),p=this.openWindow(t,"rid="+s,r,n).windowProxy}catch(p){let{code:y,message:X}=p;c.removeEventReceiver(s),a(g(y,X))}})}callWebSpatialProtocolSync(t,e,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(t,e,r,n);return m({windowProxy:o,id:a})}openWindow(t,e,r,n){return{spatialId:"",windowProxy:window.open(`webspatial://${t}?${e||""}`,r,n)}}}});var Ee={};R(Ee,{AndroidPlatform:()=>Kt});function ai(){return Qt=(Qt+1)%ni,`rId_${Qt}`}var qt,Qt,ni,Kt,be=h(()=>{"use strict";_();S();v();qt=0,Qt=0,ni=1e5;Kt=class{async callJSB(t,e){return new Promise((r,n)=>{try{let a=ai();c.addEventReceiver(a,s=>{if(c.removeEventReceiver(a),s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(g(p,y))}});let o=window.webspatialBridge.postMessage(a,t,e);if(o!==""){c.removeEventReceiver(a);let s=JSON.parse(o);if(s.success)r(m(s.data));else{let{code:p,message:y}=s.data;r(g(p,y))}}}catch(a){console.error(`AndroidPlatform cmd: ${t}, msg: ${e} error: ${a}`);let{code:o,message:s}=a;r(g(o,s))}})}async callWebSpatialProtocol(t,e,r,n){await new Promise(p=>setTimeout(p,16*qt)),qt++;let a=await new U().execute();for(;!a.data.can;)await new Promise(p=>setTimeout(p,16)),a=await new U().execute();let{windowProxy:o}=this.openWindow(t,e,r,n);for(;!o?.open;)await new Promise(p=>setTimeout(p,16));for(o?.open("about:blank","_self");!o?.__SpatialId;)await new Promise(p=>setTimeout(p,16));let s=o?.__SpatialId;return qt--,Promise.resolve(m({windowProxy:o,id:s}))}callWebSpatialProtocolSync(t,e,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(t,e,r,n);return m({windowProxy:o,id:a})}openWindow(t,e,r,n){return{spatialId:"",windowProxy:window.open(`webspatial://${t}?${e||""}`,r,n)}}}});var xe={};R(xe,{VisionOSPlatform:()=>Xt});var Xt,we=h(()=>{"use strict";_();Xt=class{async callJSB(t,e){try{let r=await window.webkit.messageHandlers.bridge.postMessage(`${t}::${e}`);return m(r)}catch(r){let{code:n,message:a}=JSON.parse(r.message);return g(n,a)}}callWebSpatialProtocol(t,e,r,n){let{spatialId:a,windowProxy:o}=this.openWindow(t,e,r,n);return Promise.resolve(m({windowProxy:o,id:a}))}callWebSpatialProtocolSync(t,e,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(t,e,r,n);return m({windowProxy:o,id:a})}openWindow(t,e,r,n){let a=window.open(`webspatial://${t}?${e||""}`,r,n);return{spatialId:a?.navigator.userAgent?.match(/\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\b/gi)?.[0],windowProxy:a}}}});function oi(i){let t=i.match(/WebSpatial\/(\d+)\.(\d+)\.(\d+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function si(i,t){if(!i)return!1;for(let e=0;e<3;e+=1){let r=i[e]-t[e];if(r>0)return!0;if(r<0)return!1}return!1}function ve(){if(G())return new Z;let i=window.navigator.userAgent,t=oi(i);if(window.navigator.userAgent.includes("Puppeteer")){let e=(Se(),V(ye)).PuppeteerPlatform;return new e}else if(i.includes("PicoWebApp")&&si(t,[0,0,1])){let e=(he(),V(fe)).PicoOSPlatform;return new e}else if(i.includes("Android")||i.includes("Linux")){let e=(be(),V(Ee)).AndroidPlatform;return new e}else{let e=(we(),V(xe)).VisionOSPlatform;return new e}}var Pe=h(()=>{"use strict";kt();ue()});function Y(i,t){return i===""?0:i.endsWith("%")?t*parseFloat(i)/100:parseFloat(i)}function Me(i){let t=parseFloat(i.getPropertyValue("width")),e=i.getPropertyValue("border-top-left-radius"),r=i.getPropertyValue("border-top-right-radius"),n=i.getPropertyValue("border-bottom-left-radius"),a=i.getPropertyValue("border-bottom-right-radius");return{topLeading:Y(e,t),bottomLeading:Y(n,t),topTrailing:Y(r,t),bottomTrailing:Y(a,t)}}function Te(i,t,e){let{x:r,y:n,z:a}=i,{x:o,y:s,z:p}=t,{x:y,y:X,z:Ft}=e,E=new DOMMatrix;return E=E.translate(r,n,a),E=E.rotate(o,s,p),E=E.scale(y,X,Ft),E}var Zt=h(()=>{"use strict"});var Yt,l,tt,et,it,rt,nt,at,P,ot,st,pt,lt,ct,dt,mt,ut,yt,St,gt,ft,ht,Et,bt,xt,wt,vt,T,Pt,Mt,Tt,Dt,Rt,Ct,U,L,Ot,It,zt,Wt,At,S=h(()=>{"use strict";Pe();Zt();Yt=ve(),l=class{commandType="";async execute(){let t=this.getParams(),e=t?JSON.stringify(t):"";return Yt.callJSB(this.commandType,e)}},tt=class extends l{constructor(e,r){super();this.entity=e;this.properties=r}commandType="UpdateEntityProperties";getParams(){let e=Te(this.properties.position??this.entity.position,this.properties.rotation??this.entity.rotation,this.properties.scale??this.entity.scale).toFloat64Array();return{entityId:this.entity.id,transform:e}}},et=class extends l{constructor(e,r,n){super();this.entity=e;this.type=r;this.isEnable=n}commandType="UpdateEntityEvent";getParams(){return{type:this.type,entityId:this.entity.id,isEnable:this.isEnable}}},it=class extends l{properties;commandType="UpdateSpatialSceneProperties";constructor(t){super(),this.properties=t}getParams(){return this.properties}},rt=class extends l{config;commandType="UpdateSceneConfig";constructor(t){super(),this.config=t}getParams(){return{config:this.config}}},nt=class extends l{constructor(e){super();this.id=e}commandType="FocusScene";getParams(){return{id:this.id}}},at=class extends l{commandType="GetSpatialSceneState";constructor(){super()}getParams(){return{}}},P=class extends l{constructor(e){super();this.spatialObject=e}getParams(){let e=this.getExtraParams();return{id:this.spatialObject.id,...e}}},ot=class extends P{properties;commandType="UpdateSpatialized2DElementProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return this.properties}},st=class extends P{properties;commandType="UpdateSpatializedDynamic3DElementProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return{id:this.spatialObject.id,...this.properties}}},pt=class extends P{properties;commandType="UpdateUnlitMaterialProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return this.properties}},lt=class extends P{matrix;commandType="UpdateSpatializedElementTransform";constructor(t,e){super(t),this.matrix=e}getExtraParams(){return{matrix:Array.from(this.matrix.toFloat64Array())}}},ct=class extends P{properties;commandType="UpdateSpatializedStatic3DElementProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return this.properties}},dt=class extends P{commandType="AddSpatializedElementToSpatialized2DElement";spatializedElement;constructor(t,e){super(t),this.spatializedElement=e}getExtraParams(){return{spatializedElementId:this.spatializedElement.id}}},mt=class extends l{commandType="AddSpatializedElementToSpatialScene";spatializedElement;constructor(t){super(),this.spatializedElement=t}getParams(){return{spatializedElementId:this.spatializedElement.id}}},ut=class extends l{constructor(e){super();this.modelURL=e;this.modelURL=e}commandType="CreateSpatializedStatic3DElement";getParams(){return{modelURL:this.modelURL}}},yt=class extends l{getParams(){return{test:!0}}commandType="CreateSpatializedDynamic3DElement"},St=class extends l{constructor(e){super();this.name=e}getParams(){return{name:this.name}}commandType="CreateSpatialEntity"},gt=class extends l{constructor(e){super();this.options=e}getParams(){let e=this.options.mesh.id,r=this.options.materials.map(n=>n.id);return{geometryId:e,materialIds:r}}commandType="CreateModelComponent"},ft=class extends l{constructor(e){super();this.options=e}getParams(){return this.options}commandType="CreateSpatialModelEntity"},ht=class extends l{constructor(e){super();this.options=e}getParams(){return{url:this.options.url}}commandType="CreateModelAsset"},Et=class extends l{constructor(e,r={}){super();this.type=e;this.options=r}getParams(){return{type:this.type,...this.options}}commandType="CreateGeometry"},bt=class extends l{constructor(e){super();this.options=e}getParams(){return this.options}commandType="CreateUnlitMaterial"},xt=class extends l{constructor(e,r){super();this.entity=e;this.comp=r}getParams(){return{entityId:this.entity.id,componentId:this.comp.id}}commandType="AddComponentToEntity"},wt=class extends l{constructor(e,r){super();this.entity=e;this.comp=r}getParams(){return{entityId:this.entity.id,componentId:this.comp.id}}commandType="RemoveComponentFromEntity"},vt=class extends l{constructor(e,r){super();this.entityId=e;this.materials=r}getParams(){return{entityId:this.entityId,materialIds:this.materials.map(e=>e.id)}}commandType="SetMaterialsOnEntity"},T=class extends l{constructor(e,r){super();this.childId=e;this.parentId=r}getParams(){return{childId:this.childId,parentId:this.parentId}}commandType="SetParentToEntity"},Pt=class extends l{constructor(e,r,n){super();this.fromEntityId=e;this.toEntityId=r;this.fromPosition=n}getParams(){return{fromEntityId:this.fromEntityId,toEntityId:this.toEntityId,position:this.fromPosition}}commandType="ConvertFromEntityToEntity"},Mt=class extends l{constructor(e,r){super();this.fromEntityId=e;this.position=r}getParams(){return{fromEntityId:this.fromEntityId,position:this.position}}commandType="ConvertFromEntityToScene"},Tt=class extends l{constructor(e,r){super();this.entityId=e;this.position=r}getParams(){return{entityId:this.entityId,position:this.position}}commandType="ConvertFromSceneToEntity"},Dt=class extends l{constructor(e,r,n){super();this.position=e;this.fromId=r;this.toId=n}getParams(){return{position:this.position,fromId:this.fromId,toId:this.toId}}commandType="ConvertCoordinate"},Rt=class extends l{constructor(e=""){super();this.id=e}commandType="Inspect";getParams(){return this.id?{id:this.id}:{id:""}}},Ct=class extends l{constructor(e){super();this.id=e}commandType="Destroy";getParams(){return{id:this.id}}},U=class extends l{constructor(e=""){super();this.id=e}commandType="CheckWebViewCanCreate";getParams(){return{id:this.id}}},L=class extends l{target;features;async execute(){let t=this.getQuery();return Yt.callWebSpatialProtocol(this.commandType,t,this.target,this.features)}executeSync(){let t=this.getQuery();return Yt.callWebSpatialProtocolSync(this.commandType,t,this.target,this.features)}getQuery(){let t,e=this.getParams();return e&&(t=Object.keys(e).map(r=>{let n=e[r],a=typeof n=="object"?JSON.stringify(n):n;return`${r}=${encodeURIComponent(a)}`}).join("&")),t}},Ot=class extends L{commandType="createSpatialized2DElement";constructor(){super()}getParams(){return{}}},It=class extends L{constructor(e,r,n,a){super();this.url=e;this.config=r;this.target=n;this.features=a}commandType="createSpatialScene";getParams(){return{url:this.url,config:this.config}}},zt=class extends L{constructor(e){super();this.options=e}commandType="createAttachment";getParams(){return{}}},Wt=class extends l{constructor(e,r){super();this.attachmentId=e;this.options=r}commandType="InitializeAttachment";getParams(){return{id:this.attachmentId,parentEntityId:this.options.parentEntityId,position:this.options.position??[0,0,0],size:this.options.size,ownerViewId:this.options.ownerViewId}}},At=class extends l{constructor(e,r){super();this.attachmentId=e;this.options=r}commandType="UpdateAttachmentEntity";getParams(){return{id:this.attachmentId,...this.options}}}});var Pi={};R(Pi,{Attachment:()=>_t,BaseplateVisibilityValues:()=>Re,CubeInfo:()=>ee,ModelComponent:()=>F,PhysicalMetrics:()=>de,Spatial:()=>A,SpatialBoxGeometry:()=>N,SpatialComponent:()=>$,SpatialConeGeometry:()=>K,SpatialCylinderGeometry:()=>q,SpatialEntity:()=>D,SpatialGeometry:()=>f,SpatialMaterial:()=>j,SpatialModelAsset:()=>J,SpatialModelEntity:()=>B,SpatialObject:()=>d,SpatialPlaneGeometry:()=>Q,SpatialScene:()=>w,SpatialSceneState:()=>oe,SpatialSceneValues:()=>Ie,SpatialSession:()=>W,SpatialSphereGeometry:()=>H,SpatialUnlitMaterial:()=>k,Spatialized2DElement:()=>C,SpatializedDynamic3DElement:()=>I,SpatializedElement:()=>b,SpatializedElementType:()=>De,SpatializedStatic3DElement:()=>O,WorldAlignmentValues:()=>Oe,WorldScalingValues:()=>Ce,createAttachmentEntity:()=>le,isSSREnv:()=>G,isValidBaseplateVisibilityType:()=>ie,isValidSceneUnit:()=>Vt,isValidSpatialSceneType:()=>ae,isValidWorldAlignmentType:()=>ne,isValidWorldScalingType:()=>re});S();var d=class{constructor(t){this.id=t}name;isDestroyed=!1;async inspect(){let t=await new Rt(this.id).execute();if(t.success)return t.data;throw new Error(t.errorMessage)}async destroy(){if(this.isDestroyed)return;let t=await new Ct(this.id).execute();if(t.success)return this.onDestroy(),this.isDestroyed=!0,t.data;if(this.isDestroyed)return;throw new Error(t.errorMessage)}onDestroy(){}};S();S();S();var te,w=class i extends d{static getInstance(){return te||(te=new i("")),te}async convertCoordinate(t,e,r){try{return(await new Dt(t,e,r).execute())?.data??t}catch(n){throw console.warn("SpatialScene.convertCoordinate error:",n),n}}async updateSpatialProperties(t){return new it(t).execute()}async addSpatializedElement(t){return new mt(t).execute()}async updateSceneCreationConfig(t){return new rt(t).execute()}async getState(){return(await new at().execute()).data.name}};var De=(r=>(r[r.Spatialized2DElement=0]="Spatialized2DElement",r[r.SpatializedStatic3DElement=1]="SpatializedStatic3DElement",r[r.SpatializedDynamic3DElement=2]="SpatializedDynamic3DElement",r))(De||{}),Re=["automatic","visible","hidden"];function ie(i){return Re.includes(i)}var Ce=["automatic","dynamic"];function re(i){return Ce.includes(i)}var Oe=["adaptive","automatic","gravityAligned"];function ne(i){return Oe.includes(i)}var Ie=["window","volume"];function ae(i){return Ie.includes(i)}function Vt(i){if(typeof i=="number")return i>=0;if(typeof i=="string"){if(i.endsWith("px"))return isNaN(Number(i.slice(0,-2)))?!1:Number(i.slice(0,-2))>=0;if(i.endsWith("m"))return isNaN(Number(i.slice(0,-1)))?!1:Number(i.slice(0,-1))>=0}return!1}var oe=(a=>(a.idle="idle",a.pending="pending",a.willVisible="willVisible",a.visible="visible",a.fail="fail",a))(oe||{}),ee=class{constructor(t,e){this.size=t;this.origin=e;this.size=t,this.origin=e}get x(){return this.origin.x}get y(){return this.origin.y}get z(){return this.origin.z}get width(){return this.size.width}get height(){return this.size.height}get depth(){return this.size.depth}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get back(){return this.z}get front(){return this.z+this.depth}};var pi={defaultSize:{width:1280,height:720}},li={defaultSize:{width:.94,height:.94,depth:.94}},ci="webspatial://",Gt=class i{originalOpen;static instance;static getInstance(){return i.instance||(i.instance=new i),i.instance}init(t){this.originalOpen=t.open.bind(t),t.open=this.open}configMap={};getConfig(t){if(!(t===void 0||!this.configMap[t]))return this.configMap[t]}ensureAbsoluteUrl(t){if(!t||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t))return t;if(t.startsWith("//"))return`${window.location.protocol}${t}`;try{return new URL(t,document.baseURI).toString()}catch{return t}}open=(t,e,r)=>{if(t?.startsWith(ci)){if(t.includes("createSpatialized2DElement")){let p=window.webSpatial?.genToken?.();if(p){let y=window.location.host,Ft=`${window.location.protocol}//${y}/${p}/?command=createSpatialized2DElement`,E=new URL(t).searchParams.get("rid"),me=new URL(Ft);return E&&me.searchParams.set("rid",E),this.originalOpen(me.toString(),e,r)}}return this.originalOpen(t,e,r)}if(t=this.ensureAbsoluteUrl(t),e==="_self"||e==="_parent"||e==="_top")return this.originalOpen(t,e,r);let n=e?this.getConfig(e):void 0,o=new It(t,n,e,r).executeSync(),s=o.data?.id;return s&&new nt(s).execute(),o.data?.windowProxy};initScene(t,e,r){let n=r?.type??"window",a=pe(n),o=e({...a}),[s,p]=Ve(o,n);p.length>0&&console.warn(`initScene ${t} with errors: ${p.join(", ")}`),this.configMap[t]={...s,type:n}}};function ze(i){return i/1360}function We(i){return i*1360}function Ae(i,t,e){if(typeof i=="number")return e==="px"&&t==="px"||e==="m"&&t==="m"?i:e==="px"&&t==="m"?ze(i):e==="m"&&t==="px"?We(i):i;if(t==="m"){if(i.endsWith("m"))return Number(i.slice(0,-1));if(i.endsWith("px"))return ze(Number(i.slice(0,-2)));throw new Error("formatToNumber: invalid str")}else if(t==="px"){if(i.endsWith("px"))return Number(i.slice(0,-2));if(i.endsWith("m"))return We(Number(i.slice(0,-1)));throw new Error("formatToNumber: invalid str")}else throw new Error("formatToNumber: invalid targetUnit")}function Ve(i,t){let e=pe(t),r=[],n=t==="window";if(ae(t)||r.push("sceneType"),i.defaultSize){let a=["width","height","depth"];for(let o of a)o in i.defaultSize&&(Vt(i.defaultSize[o])?i.defaultSize[o]=Ae(i.defaultSize[o],n?"px":"m",n?"px":"m"):(i.defaultSize[o]=e.defaultSize[o],r.push(`defaultSize.${o}`)))}if(i.resizability){let a=["minWidth","minHeight","maxWidth","maxHeight"];for(let o of a)o in i.resizability&&(Vt(i.resizability[o])?i.resizability[o]=Ae(i.resizability[o],"px",n?"px":"m"):(i.resizability[o]=void 0,r.push(`resizability.${o}`)))}return i.worldScaling&&(re(i.worldScaling)||(i.worldScaling="automatic",r.push("worldScaling"))),i.worldAlignment&&(ne(i.worldAlignment)||(i.worldAlignment="automatic",r.push("worldAlignment"))),i.baseplateVisibility&&(ie(i.baseplateVisibility)||(i.baseplateVisibility="automatic",r.push("baseplateVisibility"))),[i,r]}function Ge(i,t,e){return Gt.getInstance().initScene(i,t,e)}function di(i){Gt.getInstance().init(i)}function se(i){i.document.onclick=function(t){let e=t.target,r=!1;for(;!r;){if(e&&e.tagName=="A")return!mi(t);if(e&&e.parentElement)e=e.parentElement;else break}}}function mi(i){let t=i.target;if(t.tagName==="A"){let e=t,r=e.target,n=e.href;if(r&&r!=="_self")return i.preventDefault(),window.open(n,r),!0}}function pe(i){return i==="window"?pi:li}async function ui(){if(!window.opener||await w.getInstance().getState()!=="pending")return;function t(e){document.readyState==="interactive"||document.readyState==="complete"?e():document.addEventListener("DOMContentLoaded",e)}t(async()=>{let e=pe(window.xrCurrentSceneType??"window"),r=e;if(typeof window.xrCurrentSceneDefaults=="function")try{r=await window.xrCurrentSceneDefaults?.(e)}catch(s){console.error(s)}await new Promise((s,p)=>{setTimeout(()=>{s(null)},1e3)});let n=window.xrCurrentSceneType??"window",[a,o]=Ve(r,n);o.length>0&&console.warn(`window.xrCurrentSceneDefaults with errors: ${o.join(", ")}`),await w.getInstance().updateSceneCreationConfig({...a,type:n})})}function _e(){di(window),se(window),ui()}S();S();S();v();function u(i,t){return new CustomEvent(i,{bubbles:!0,cancelable:!1,detail:t})}var b=class extends d{constructor(e){super(e);this.id=e;c.addEventReceiver(e,this.onReceiveEvent.bind(this))}async updateTransform(e){return new lt(this,e).execute()}_cubeInfo;get cubeInfo(){return this._cubeInfo}_transform;_transformInv;get transform(){return this._transform}get transformInv(){return this._transformInv}onReceiveEvent(e){let{type:r}=e;if(r==="objectdestroy")this.isDestroyed=!0;else if(r==="spatialtap"){let n=u("spatialtap",e.detail);this._onSpatialTap?.(n)}else if(r==="spatialdragstart"){let n=u("spatialdragstart",e.detail);this._onSpatialDragStart?.(n)}else if(r==="spatialdrag"){let n=u("spatialdrag",e.detail);this._onSpatialDrag?.(n)}else if(r==="spatialdragend"){let n=u("spatialdragend",e.detail);this._onSpatialDragEnd?.(n)}else if(r==="spatialrotate"){let n=u("spatialrotate",e.detail);this._onSpatialRotate?.(n)}else if(r==="spatialrotateend"){let n=u("spatialrotateend",e.detail);this._onSpatialRotateEnd?.(n)}else if(r==="spatialmagnify"){let n=u("spatialmagnify",e.detail);this._onSpatialMagnify?.(n)}else if(r==="spatialmagnifyend"){let n=u("spatialmagnifyend",e.detail);this._onSpatialMagnifyEnd?.(n)}}_onSpatialTap;set onSpatialTap(e){this._onSpatialTap=e,this.updateProperties({enableTapGesture:e!==void 0})}_onSpatialDragStart;set onSpatialDragStart(e){this._onSpatialDragStart=e,this.updateProperties({enableDragStartGesture:this._onSpatialDragStart!==void 0})}_onSpatialDrag;set onSpatialDrag(e){this._onSpatialDrag=e,this.updateProperties({enableDragGesture:this._onSpatialDrag!==void 0})}_onSpatialDragEnd;set onSpatialDragEnd(e){this._onSpatialDragEnd=e,this.updateProperties({enableDragEndGesture:e!==void 0})}_onSpatialRotate;set onSpatialRotate(e){this._onSpatialRotate=e,this.updateProperties({enableRotateGesture:this._onSpatialRotate!==void 0})}_onSpatialRotateEnd;set onSpatialRotateEnd(e){this._onSpatialRotateEnd=e,this.updateProperties({enableRotateEndGesture:e!==void 0})}_onSpatialMagnify;set onSpatialMagnify(e){this._onSpatialMagnify=e,this.updateProperties({enableMagnifyGesture:e!==void 0})}_onSpatialMagnifyEnd;set onSpatialMagnifyEnd(e){this._onSpatialMagnifyEnd=e,this.updateProperties({enableMagnifyEndGesture:e!==void 0})}onDestroy(){c.removeEventReceiver(this.id)}};var C=class extends b{constructor(e,r){super(e);this.windowProxy=r;se(r)}async updateProperties(e){return new ot(this,e).execute()}async addSpatializedElement(e){return new dt(this,e).execute()}};S();var O=class extends b{constructor(t,e){super(t),this.modelURL=e}_readyResolve;modelURL;createReadyPromise(){return this._readyResolve?.(!1),new Promise(t=>{this._readyResolve=t})}ready=this.createReadyPromise();async updateProperties(t){return t.modelURL!==void 0&&this.modelURL!==t.modelURL&&(this.modelURL=t.modelURL,this.ready=this.createReadyPromise()),new ct(this,t).execute()}onReceiveEvent(t){t.type==="modelloaded"?(this._onLoadCallback?.(),this._readyResolve?.(!0)):t.type==="modelloadfailed"?(this._onLoadFailureCallback?.(),this._readyResolve?.(!1)):super.onReceiveEvent(t)}_onLoadCallback;set onLoadCallback(t){this._onLoadCallback=t}_onLoadFailureCallback;set onLoadFailureCallback(t){this._onLoadFailureCallback=t}updateModelTransform(t){let e=Array.from(t.toFloat64Array());this.updateProperties({modelTransform:e})}};S();var I=class extends b{children=[];events={};constructor(t){super(t)}async addEntity(t){let e=new T(t.id,this.id).execute();return this.children.push(t),t.parent=this,e}addEvent(t,e){this.events[t]=e}removeEvent(t){this.events[t]&&delete this.events[t]}dispatchEvent(t){this.events[t.type]?.(t)}async updateProperties(t){return new st(this,t).execute()}};async function Ue(){let i=await new Ot().execute();if(i.success){let{id:t,windowProxy:e}=i.data;return e.document.head.innerHTML=`<meta name="viewport" content="width=device-width, initial-scale=1">
74
+ <base href="${document.baseURI}">`,new C(t,e)}else throw new Error("createSpatialized2DElement failed")}async function Le(i){let t=await new ut(i).execute();if(t.success){let{id:e}=t.data;return new O(e,i)}else throw new Error("createSpatializedStatic3DElement failed")}async function Be(){let i=await new yt().execute();if(i.success){let{id:t}=i.data;return new I(t)}else throw new Error("createSpatializedDynamic3DElement failed")}S();var _t=class extends d{constructor(e,r,n){super(e);this.windowProxy=r;this.options=n}getContainer(){return this.windowProxy.document.body}getWindowProxy(){return this.windowProxy}async update(e){if(!this.isDestroyed)return e.position&&(this.options.position=e.position),e.size&&(this.options.size=e.size),new At(this.id,e).execute()}};async function le(i){let t=await new zt(i).execute();if(!t.success)throw new Error("createAttachmentEntity failed: "+t?.errorMessage);let{id:e,windowProxy:r}=t.data;return await new Wt(e,i).execute(),new _t(e,r,i)}S();S();S();v();var D=class extends d{constructor(e,r){super(e);this.userData=r;c.addEventReceiver(e,this.onReceiveEvent)}position={x:0,y:0,z:0};rotation={x:0,y:0,z:0};scale={x:1,y:1,z:1};events={};children=[];parent=null;_enableInput=!1;get enableInput(){return this._enableInput}set enableInput(e){this._enableInput!==e&&(this._enableInput=e,this.updateEntityEvent("spatialtap",e).catch(r=>{console.error("enableInput updateEntityEvent failed","spatialtap",r),this._enableInput===e&&(this._enableInput=!e)}))}async addComponent(e){return new xt(this,e).execute()}async removeComponent(e){return new wt(this,e).execute()}async setPosition(e){return this.updateTransform({position:e})}async setRotation(e){return this.updateTransform({rotation:e})}async setScale(e){return this.updateTransform({scale:e})}async addEntity(e){let r=await new T(e.id,this.id).execute();return this.children.push(e),e.parent=this,r}async removeFromParent(){let e=await new T(this.id,void 0).execute();return this.parent&&(this.parent.children=this.parent.children.filter(r=>r.id!==this.id),this.parent=null),e}async updateTransform(e){return this.position=e.position??this.position,this.rotation=e.rotation??this.rotation,this.scale=e.scale??this.scale,new tt(this,e).execute()}async addEvent(e,r){if(this.events[e])this.events[e]=r;else try{await this.updateEntityEvent(e,!0),this.events[e]=r}catch{console.error("addEvent failed",e)}}async removeEvent(e){if(this.events[e]){delete this.events[e];try{await this.updateEntityEvent(e,!1)}catch{console.error("removeEvent failed",e)}}}async updateEntityEvent(e,r){return new et(this,e,r).execute()}onReceiveEvent=e=>{let{type:r}=e;if(r==="objectdestroy")this.isDestroyed=!0;else if(r==="spatialtap"){let n=u("spatialtap",e.detail);this.dispatchEvent(n)}else if(r==="spatialdragstart"){let n=u("spatialdragstart",e.detail);this.dispatchEvent(n)}else if(r==="spatialdrag"){let n=u("spatialdrag",e.detail);this.dispatchEvent(n)}else if(r==="spatialdragend"){let n=u("spatialdragend",e.detail);this.dispatchEvent(n)}else if(r==="spatialrotate"){let n=u("spatialrotate",e.detail);this.dispatchEvent(n)}else if(r==="spatialrotateend"){let n=u("spatialrotateend",e.detail);this.dispatchEvent(n)}else if(r==="spatialmagnify"){let n=u("spatialmagnify",e.detail);this.dispatchEvent(n)}else if(r==="spatialmagnifyend"){let n=u("spatialmagnifyend",e.detail);this.dispatchEvent(n)}};dispatchEvent(e){e.__origin||Object.defineProperty(e,"__origin",{value:this,enumerable:!1}),this.events[e.type]?.(e),e.bubbles&&!e.cancelBubble&&this.parent&&this.parent.dispatchEvent(e)}onDestroy(){c.removeEventReceiver(this.id),this.children.forEach(e=>{e.parent=null}),this.children=[],this.parent&&(this.parent.children=this.parent.children.filter(e=>e.id!==this.id),this.parent=null)}async convertFromEntityToEntity(e,r,n){return new Pt(e,r,n).execute()}async convertFromEntityToScene(e,r){return new Mt(e,r).execute()}async convertFromSceneToEntity(e,r){return new Tt(e,r).execute()}};S();var B=class extends D{constructor(e,r,n){super(e,n);this.id=e;this.options=r;this.userData=n}async setMaterials(e){return new vt(this.id,e).execute()}};v();var $=class extends d{constructor(t){super(t),c.addEventReceiver(t,this.onReceiveEvent)}onReceiveEvent=t=>{let{type:e}=t;e==="objectdestroy"&&(this.isDestroyed=!0)}};var F=class extends ${constructor(e,r){super(e);this.options=r}};S();var j=class extends d{constructor(e,r){super(e);this.id=e;this.type=r;this.type=r}};var k=class extends j{constructor(e,r){super(e,"unlit");this.id=e;this.options=r}updateProperties(e){return new pt(this,e).execute()}};var J=class extends d{constructor(e,r){super(e);this.id=e;this.options=r}};async function $e(i){let t=await new St(i?.name).execute();if(t.success){let{id:e}=t.data;return new D(e,i)}else throw new Error("createSpatialEntity failed:"+t?.errorMessage)}async function z(i,t){let e=await new Et(i.type,t).execute();if(e.success){let{id:r}=e.data;return new i(r,t)}else throw new Error("createSpatialGeometry failed:"+e?.errorMessage)}async function Fe(i){let t=await new bt(i).execute();if(t.success){let{id:e}=t.data;return new k(e,i)}else throw new Error("createSpatialUnlitMaterial failed:"+t?.errorMessage)}async function je(i){let t=await new gt(i).execute();if(t.success){let{id:e}=t.data;return new F(e,i)}else throw new Error("createModelComponent failed:"+t?.errorMessage)}async function ke(i,t){let e=await new ft(i).execute();if(e.success){let{id:r}=e.data;return new B(r,i,t)}else throw new Error("createSpatialModelEntity failed:"+e?.errorMessage)}async function Je(i){let t=await new ht(i).execute();if(t.success){let{id:e}=t.data;return new J(e,i)}else throw new Error("createModelAsset failed:"+t?.errorMessage)}var f=class extends d{constructor(e,r){super(e);this.id=e;this.options=r}static type};var N=class extends f{constructor(e,r){super(e,r);this.id=e;this.options=r}static type="BoxGeometry"};var H=class extends f{constructor(e,r){super(e,r);this.id=e;this.options=r}static type="SphereGeometry"};var q=class extends f{constructor(e,r){super(e,r);this.id=e;this.options=r}static type="CylinderGeometry"};var Q=class extends f{constructor(e,r){super(e,r);this.id=e;this.options=r}static type="PlaneGeometry"};var K=class extends f{constructor(e,r){super(e,r);this.id=e;this.options=r}static type="ConeGeometry"};var W=class{getSpatialScene(){return w.getInstance()}createSpatialized2DElement(){return Ue()}createSpatializedStatic3DElement(t){return Le(t)}initScene=Ge;createSpatializedDynamic3DElement(){return Be()}createEntity(t){return $e(t)}createBoxGeometry(t={}){return z(N,t)}createPlaneGeometry(t={}){return z(Q,t)}createSphereGeometry(t={}){return z(H,t)}createConeGeometry(t){return z(K,t)}createCylinderGeometry(t){return z(q,t)}createModelComponent(t){return je(t)}createUnlitMaterial(t){return Fe(t)}createModelAsset(t){return Je(t)}createSpatialModelEntity(t,e){return ke(t,e)}createAttachmentEntity(t){return le(t)}};v();var A=class{wsAppShellVersionFromUA;requestSession(){return this.runInSpatialWeb()?(c.init(),new W):null}runInSpatialWeb(){return navigator.userAgent.indexOf("WebSpatial/")>0}getShellVersionFromUA(){if(this.wsAppShellVersionFromUA!==void 0)return this.wsAppShellVersionFromUA;if(typeof navigator>"u"||typeof navigator.userAgent!="string")return this.wsAppShellVersionFromUA=null,null;let t=navigator.userAgent.match(/WSAppShell\/(\d+(?:\.\d+){2}(?:[-+][0-9A-Za-z.-]+)*)/);return this.wsAppShellVersionFromUA=t?t[1]:"1.3.0",this.wsAppShellVersionFromUA}isSupported(){return!0}getNativeVersion(){return window.__WebSpatialData&&window.__WebSpatialData.getNativeVersion?window.__WebSpatialData.getNativeVersion():window.WebSpatailNativeVersion==="WS_SHELL_VERSION"?this.getClientVersion():window.WebSpatailNativeVersion}getClientVersion(){return"1.5.0"}};var de={};R(de,{getValue:()=>gi,physicalToPoint:()=>Si,pointToPhysical:()=>yi,subscribe:()=>fi});v();var x={meterToPtUnscaled:1360,meterToPtScaled:1360};function Ne(i){return i?.worldScalingCompensation??"scaled"}function yi(i,t){return ce(),Ne(t)==="unscaled"?i/x.meterToPtUnscaled:i/x.meterToPtScaled}function Si(i,t){return ce(),Ne(t)==="unscaled"?i*x.meterToPtUnscaled:i*x.meterToPtScaled}function ce(){if(typeof window>"u")return;let i=window.__webspatialsdk__?.physicalMetrics;if(!i)return;let t={meterToPtScaled:i.meterToPtScaled??x.meterToPtScaled,meterToPtUnscaled:i.meterToPtUnscaled??x.meterToPtUnscaled};(t.meterToPtScaled!==x.meterToPtScaled||t.meterToPtUnscaled!==x.meterToPtUnscaled)&&(x=t)}function gi(){return ce(),x}function fi(i){if(typeof window>"u")return()=>{};let t=()=>{i()};return c.addEventReceiver("window",t),()=>{c.removeEventReceiver("window")}}kt();Zt();var He=new A,$t,Ut={backgroundMaterial:"--xr-background-material"},qe="";function Lt(i){i!==qe&&($t?.getSpatialScene()?.updateSpatialProperties({material:i}),qe=i)}function hi(){let t=getComputedStyle(document.documentElement).getPropertyValue(Ut.backgroundMaterial);Lt(t||"none")}var M={topLeading:0,bottomLeading:0,topTrailing:0,bottomTrailing:0};function Qe(){let i=getComputedStyle(document.documentElement),t=Me(i);Ei(t)}function Ei(i){(M.topLeading!==i.topLeading||M.bottomLeading!==i.bottomLeading||M.topTrailing!==i.topTrailing||M.bottomTrailing!==i.bottomTrailing)&&($t?.getSpatialScene()?.updateSpatialProperties({cornerRadius:i}),M.topLeading=i.topLeading,M.bottomLeading=i.bottomLeading,M.topTrailing=i.topTrailing,M.bottomTrailing=i.bottomTrailing)}function bi(i){$t?.getSpatialScene().updateSpatialProperties({opacity:i})}function Ke(){let i=getComputedStyle(document.documentElement),t=parseFloat(i.getPropertyValue("opacity"));bi(t)}function xi(){let i=document.documentElement.style,t=new Proxy(i,{set:function(e,r,n){let a=Reflect.set(e,r,n);return r===Ut.backgroundMaterial&&Lt(n),(r==="border-radius"||r==="borderRadius"||r==="border-top-left-radius"||r==="borderTopLeftRadius"||r==="border-top-right-radius"||r==="borderTopRightRadius"||r==="border-bottom-left-radius"||r==="borderBottomLeftRadius"||r==="border-bottom-right-radius"||r==="borderBottomRightRadius")&&Qe(),r==="opacity"&&Ke(),a},get:function(e,r){return typeof e[r]=="function"?function(...n){if(r==="setProperty"){let[a,o]=n;a===Ut.backgroundMaterial&&Lt(o)}else if(r==="removeProperty"){let[a]=n;a===Ut.backgroundMaterial&&Lt("none")}return e[r](...n)}:Reflect.get(e,r)}});Object.defineProperty(document.documentElement,"style",{get:function(){return t}})}function wi(){new MutationObserver(Bt).observe(document.head,{childList:!0,subtree:!0})}function Bt(){hi(),Qe(),Ke()}function vi(){new MutationObserver(t=>{t.forEach(e=>{e.type==="attributes"&&e.attributeName&&Bt()})}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}async function Xe(){He.runInSpatialWeb()&&($t=await He.requestSession(),document.readyState==="complete"?Bt():window.addEventListener("load",()=>{Bt()}),xi(),wi(),vi())}!G()&&navigator.userAgent.indexOf("WebSpatial/")>0&&(_e(),Xe());return V(Pi);})();
75
75
  //# sourceMappingURL=index.global.js.map