@webspatial/core-sdk 1.3.0 → 1.4.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,45 @@
1
1
  # @webspatial/core-sdk
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 945856b: add enableInput for Entity
8
+ move reality events definition from specific Entity to top-level Reality
9
+ - 56e98c8: rename innerDepth to xrInnerDepth and outerDepth to xrOuterDepth
10
+ - 0def1ef: Remove deprecated spatial measurement APIs: getBoundingClientRect, getBoundingClientCube, toSceneSpatial, toLocalSpace and their internal message types (CubeInfoMsg, TransformMsg)
11
+ - 58e1f69: Attachment init flow and lifecycle cleanup.
12
+
13
+ - **Core**
14
+ - Split attachment creation into `CreateAttachmentEntityCommand` (window/engine) and `InitializeAttachmentCommand` (send id, parent, position, size over JSB so native initializes after window exists).
15
+ - `createAttachmentEntity()` now runs both; native receives full options via init command.
16
+ - **React**
17
+ - `AttachmentEntity`: inline head-style sync via `MutationObserver` on `document.head`; direct cleanup on unmount (no StrictMode-only logic).
18
+ - `useEntity`: forwards all entity event handlers (tap, drag, rotate, magnify) to `useEntityEvent`.
19
+ - `useSpatializedElement`: ref-based cleanup so elements are destroyed correctly on unmount.
20
+ - Removed React 18 StrictMode–specific deferred cleanup from Reality, useEntity, AttachmentEntity, useSpatializedElement.
21
+ - **visionOS**
22
+ - Attachment manager and JSB handling updated for init command and consolidated window creation.
23
+
24
+ - 087fa12: react-sdk:support convertCoordinate
25
+ - 98fd429: react-sdk support pointToPhysical,physicalToPoint API from useMetrics() hook
26
+ - 8f8c50a: Spatial rotate axis constraint for spatialized elements.
27
+
28
+ - **Core**
29
+ - `SpatializedElementProperties` adds optional `rotateConstrainedToAxis` (Vec3) on partial updates to native.
30
+ - **React**
31
+ - `spatialEventOptions={{ constrainedToAxis: Vec3 | [number, number, number] }}` on spatialized containers and JSX intrinsics (`enable-xr`); omit or `[0,0,0]` means unconstrained.
32
+ - `PortalSpatializedContainer` syncs axis via `updateProperties`; `Model` / degraded paths strip `spatialEventOptions` from DOM.
33
+ - **visionOS**
34
+ - `RotateGesture3D(constrainedToAxis:)` when axis is non-zero; world-space axis, normalized on native.
35
+
36
+ ### Patch Changes
37
+
38
+ - 8c50a0f: chore:update spatialEntityEventtype
39
+ - dabb15f: Update UA injection logic in VisionOS and add WSAppShell version number
40
+ - 2f2a3a8: Model ready promise triggers rejection when URL is changed midway
41
+ - 931f236: rename offsetBack to xrOffsetBack for naming consistency
42
+
3
43
  ## 1.3.0
4
44
 
5
45
  ### Minor Changes
@@ -177,4 +217,4 @@
177
217
 
178
218
  ### Patch Changes
179
219
 
180
- - 456d15f: change ModelDragEvent to SpatialModelDragEvent in coresdk
220
+ - 456d15f: change ModelDragEvent to SpatialModelDragEvent in coresdk
@@ -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,6 +450,9 @@ 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>;
466
458
  setPosition(position: Vec3): Promise<CommandResult>;
@@ -577,6 +569,7 @@ declare class SpatialScene extends SpatialObject {
577
569
  * @returns The singleton SpatialScene instance
578
570
  */
579
571
  static getInstance(): SpatialScene;
572
+ convertCoordinate(position: Vec3, fromId: string, toId: string): Promise<Vec3>;
580
573
  /**
581
574
  * Updates the properties of the spatial scene.
582
575
  * This can include background settings, lighting, and other scene-wide properties.
@@ -819,6 +812,7 @@ declare class SpatialSession {
819
812
  * This is the main entry point for the WebSpatial SDK, providing access to spatial capabilities.
820
813
  */
821
814
  declare class Spatial {
815
+ private wsAppShellVersionFromUA;
822
816
  /**
823
817
  * Requests a spatial session object from the browser.
824
818
  * This is the primary method to initialize spatial functionality.
@@ -832,6 +826,7 @@ declare class Spatial {
832
826
  * @returns True if running in a spatial web environment, false otherwise
833
827
  */
834
828
  runInSpatialWeb(): boolean;
829
+ getShellVersionFromUA(): string | null;
835
830
  /** @deprecated
836
831
  * Checks if WebSpatial is supported in the current environment.
837
832
  * Verifies compatibility between native and client versions.
@@ -852,6 +847,53 @@ declare class Spatial {
852
847
  getClientVersion(): string;
853
848
  }
854
849
 
850
+ type PhysicalMetricsValueShape = {
851
+ meterToPtUnscaled: number;
852
+ meterToPtScaled: number;
853
+ };
854
+ type WorldScalingCompensation = 'unscaled' | 'scaled';
855
+ type ConvertOption = {
856
+ worldScalingCompensation: WorldScalingCompensation;
857
+ };
858
+ /**
859
+ * Converts scene points (pt) to physical meters (m).
860
+ *
861
+ * @param point Points value to convert.
862
+ * @param options Optional conversion options to select world scaling compensation.
863
+ * @returns Physical length in meters.
864
+ */
865
+ declare function pointToPhysical(point: number, options?: ConvertOption): number;
866
+ /**
867
+ * Converts physical meters (m) to scene points (pt).
868
+ *
869
+ * @param physical Physical length in meters to convert.
870
+ * @param options Optional conversion options to select world scaling compensation.
871
+ * @returns Points length in the scene.
872
+ */
873
+ declare function physicalToPoint(physical: number, options?: ConvertOption): number;
874
+ /**
875
+ * Returns the current physical metrics used for conversions.
876
+ *
877
+ * @returns The current metrics snapshot `{ meterToPtUnscaled, meterToPtScaled }`.
878
+ */
879
+ declare function getValue(): PhysicalMetricsValueShape;
880
+ /**
881
+ * Subscribes to physical metrics changes.
882
+ *
883
+ * @param cb Callback invoked when metrics update is detected.
884
+ * @returns Unsubscribe function to remove the listener.
885
+ */
886
+ declare function subscribe(cb: () => void): () => void;
887
+
888
+ type physicalMetrics_PhysicalMetricsValueShape = PhysicalMetricsValueShape;
889
+ declare const physicalMetrics_getValue: typeof getValue;
890
+ declare const physicalMetrics_physicalToPoint: typeof physicalToPoint;
891
+ declare const physicalMetrics_pointToPhysical: typeof pointToPhysical;
892
+ declare const physicalMetrics_subscribe: typeof subscribe;
893
+ declare namespace physicalMetrics {
894
+ export { type physicalMetrics_PhysicalMetricsValueShape as PhysicalMetricsValueShape, physicalMetrics_getValue as getValue, physicalMetrics_physicalToPoint as physicalToPoint, physicalMetrics_pointToPhysical as pointToPhysical, physicalMetrics_subscribe as subscribe };
895
+ }
896
+
855
897
  declare global {
856
898
  declare const __WEBSPATIAL_CORE_SDK_VERSION__: string
857
899
 
@@ -882,19 +924,19 @@ declare global {
882
924
  'natvie-version'?: string
883
925
  'react-sdk-version'?: string
884
926
  'core-sdk-version'?: string
927
+ physicalMetrics?: PhysicalMetricsValueShape
885
928
  }
886
929
 
887
- innerDepth: number
888
- outerDepth: number
930
+ xrInnerDepth: number
931
+ xrOuterDepth: number
889
932
  }
890
933
 
891
934
  interface HTMLElement {
892
- offsetBack: number
893
- clientDepth: number
894
- getBoundingClientCube: () => CubeInfo | undefined
935
+ xrOffsetBack: number
936
+ xrClientDepth: number
895
937
  }
896
938
  }
897
939
 
898
940
  declare const isSSREnv: () => boolean;
899
941
 
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 };
942
+ 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.4.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 Bt=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Qe=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var h=(i,t)=>()=>(i&&(t=i(i=0)),t);var R=(i,t)=>{for(var e in t)Bt(i,e,{get:t[e],enumerable:!0})},Ze=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qe(t))!Ke.call(i,n)&&n!==e&&Bt(i,n,{get:()=>t[n],enumerable:!(r=Xe(t,n))||r.enumerable});return i};var V=i=>Ze(Bt({},"__esModule",{value:!0}),i);var Ye,G,$t=h(()=>{"use strict";Ye=typeof window>"u",G=()=>Ye});var K,le=h(()=>{"use strict";K=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 S(i,t=""){return{success:!1,data:void 0,errorCode:i,errorMessage:t}}var _=h(()=>{"use strict"});var ce={};R(ce,{PuppeteerPlatform:()=>Ft});var Ft,de=h(()=>{"use strict";_();console.log("PuppeteerPlatform");Ft=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(S("500","JSB execution error"))}else r(m("ok"))}catch(n){console.error(`PuppeteerPlatform cmd Error: ${t}, msg: ${e} error: ${n}`),r(S("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(S("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),S("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,w=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 ue={};R(ue,{XRPlatform:()=>kt});function me(){return jt=(jt+1)%ti,`rId_${jt}`}var jt,ti,kt,ye=h(()=>{"use strict";_();w();jt=0,ti=1e5;kt=class{async callJSB(t,e){return new Promise((r,n)=>{try{let a=me();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,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(S(p,y))}}}catch(a){console.error(`XRPlatform cmd: ${t}, msg: ${e} error: ${a}`);let{code:o,message:s}=a;r(S(o,s))}})}async callWebSpatialProtocol(t,e,r,n){return new Promise((a,o)=>{let s=me();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(t,e,r,n).windowProxy,p?.open(`about:blank?rid=${s}`,"_self")}catch(p){console.error(`open window error: ${p}`);let{code:y,message:Lt}=p;c.removeEventReceiver(s),a(S(y,Lt))}})}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 Se={};R(Se,{AndroidPlatform:()=>Ht});function ii(){return Nt=(Nt+1)%ei,`rId_${Nt}`}var Jt,Nt,ei,Ht,ge=h(()=>{"use strict";_();g();w();Jt=0,Nt=0,ei=1e5;Ht=class{async callJSB(t,e){return new Promise((r,n)=>{try{let a=ii();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,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(S(p,y))}}}catch(a){console.error(`AndroidPlatform cmd: ${t}, msg: ${e} error: ${a}`);let{code:o,message:s}=a;r(S(o,s))}})}async callWebSpatialProtocol(t,e,r,n){await new Promise(p=>setTimeout(p,16*Jt)),Jt++;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 Jt--,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 fe={};R(fe,{VisionOSPlatform:()=>qt});var qt,he=h(()=>{"use strict";_();qt=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 S(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 ri(i){let t=i.match(/WebSpatial\/(\d+)\.(\d+)\.(\d+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function ni(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 Ee(){if(G())return new K;let i=window.navigator.userAgent,t=ri(i);if(window.navigator.userAgent.includes("Puppeteer")){let e=(de(),V(ce)).PuppeteerPlatform;return new e}else if(i.includes("PicoWebApp")&&ni(t,[0,0,1])){let e=(ye(),V(ue)).XRPlatform;return new e}else if(i.includes("Android")||i.includes("Linux")){let e=(ge(),V(Se)).AndroidPlatform;return new e}else{let e=(he(),V(fe)).VisionOSPlatform;return new e}}var be=h(()=>{"use strict";$t();le()});function Z(i,t){return i===""?0:i.endsWith("%")?t*parseFloat(i)/100:parseFloat(i)}function xe(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:Z(e,t),bottomLeading:Z(n,t),topTrailing:Z(r,t),bottomTrailing:Z(a,t)}}function we(i,t,e){let{x:r,y:n,z:a}=i,{x:o,y:s,z:p}=t,{x:y,y:Lt,z:qe}=e,M=new DOMMatrix;return M=M.translate(r,n,a),M=M.rotate(o,s,p),M=M.scale(y,Lt,qe),M}var Xt=h(()=>{"use strict"});var Qt,l,Y,tt,et,it,rt,nt,v,at,ot,st,pt,lt,ct,dt,mt,ut,yt,St,gt,ft,ht,Et,bt,D,xt,wt,vt,Pt,Mt,Dt,U,L,Tt,Rt,Ct,Ot,It,g=h(()=>{"use strict";be();Xt();Qt=Ee(),l=class{commandType="";async execute(){let t=this.getParams(),e=t?JSON.stringify(t):"";return Qt.callJSB(this.commandType,e)}},Y=class extends l{constructor(e,r){super();this.entity=e;this.properties=r}commandType="UpdateEntityProperties";getParams(){let e=we(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}}},tt=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}}},et=class extends l{properties;commandType="UpdateSpatialSceneProperties";constructor(t){super(),this.properties=t}getParams(){return this.properties}},it=class extends l{config;commandType="UpdateSceneConfig";constructor(t){super(),this.config=t}getParams(){return{config:this.config}}},rt=class extends l{constructor(e){super();this.id=e}commandType="FocusScene";getParams(){return{id:this.id}}},nt=class extends l{commandType="GetSpatialSceneState";constructor(){super()}getParams(){return{}}},v=class extends l{constructor(e){super();this.spatialObject=e}getParams(){let e=this.getExtraParams();return{id:this.spatialObject.id,...e}}},at=class extends v{properties;commandType="UpdateSpatialized2DElementProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return this.properties}},ot=class extends v{properties;commandType="UpdateSpatializedDynamic3DElementProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return{id:this.spatialObject.id,...this.properties}}},st=class extends v{properties;commandType="UpdateUnlitMaterialProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return this.properties}},pt=class extends v{matrix;commandType="UpdateSpatializedElementTransform";constructor(t,e){super(t),this.matrix=e}getExtraParams(){return{matrix:Array.from(this.matrix.toFloat64Array())}}},lt=class extends v{properties;commandType="UpdateSpatializedStatic3DElementProperties";constructor(t,e){super(t),this.properties=e}getExtraParams(){return this.properties}},ct=class extends v{commandType="AddSpatializedElementToSpatialized2DElement";spatializedElement;constructor(t,e){super(t),this.spatializedElement=e}getExtraParams(){return{spatializedElementId:this.spatializedElement.id}}},dt=class extends l{commandType="AddSpatializedElementToSpatialScene";spatializedElement;constructor(t){super(),this.spatializedElement=t}getParams(){return{spatializedElementId:this.spatializedElement.id}}},mt=class extends l{constructor(e){super();this.modelURL=e;this.modelURL=e}commandType="CreateSpatializedStatic3DElement";getParams(){return{modelURL:this.modelURL}}},ut=class extends l{getParams(){return{test:!0}}commandType="CreateSpatializedDynamic3DElement"},yt=class extends l{constructor(e){super();this.name=e}getParams(){return{name:this.name}}commandType="CreateSpatialEntity"},St=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"},gt=class extends l{constructor(e){super();this.options=e}getParams(){return this.options}commandType="CreateSpatialModelEntity"},ft=class extends l{constructor(e){super();this.options=e}getParams(){return{url:this.options.url}}commandType="CreateModelAsset"},ht=class extends l{constructor(e,r={}){super();this.type=e;this.options=r}getParams(){return{type:this.type,...this.options}}commandType="CreateGeometry"},Et=class extends l{constructor(e){super();this.options=e}getParams(){return this.options}commandType="CreateUnlitMaterial"},bt=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"},D=class extends l{constructor(e,r){super();this.childId=e;this.parentId=r}getParams(){return{childId:this.childId,parentId:this.parentId}}commandType="SetParentToEntity"},xt=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"},wt=class extends l{constructor(e,r){super();this.fromEntityId=e;this.position=r}getParams(){return{fromEntityId:this.fromEntityId,position:this.position}}commandType="ConvertFromEntityToScene"},vt=class extends l{constructor(e,r){super();this.entityId=e;this.position=r}getParams(){return{entityId:this.entityId,position:this.position}}commandType="ConvertFromSceneToEntity"},Pt=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"},Mt=class extends l{constructor(e=""){super();this.id=e}commandType="Inspect";getParams(){return this.id?{id:this.id}:{id:""}}},Dt=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 Qt.callWebSpatialProtocol(this.commandType,t,this.target,this.features)}executeSync(){let t=this.getQuery();return Qt.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}},Tt=class extends L{commandType="createSpatialized2DElement";constructor(){super()}getParams(){return{}}},Rt=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}}},Ct=class extends L{constructor(e){super();this.options=e}commandType="createAttachment";getParams(){return{}}},Ot=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}}},It=class extends l{constructor(e,r){super();this.attachmentId=e;this.options=r}commandType="UpdateAttachmentEntity";getParams(){return{id:this.attachmentId,...this.options}}}});var xi={};R(xi,{Attachment:()=>At,BaseplateVisibilityValues:()=>Pe,CubeInfo:()=>Zt,ModelComponent:()=>F,PhysicalMetrics:()=>pe,Spatial:()=>A,SpatialBoxGeometry:()=>N,SpatialComponent:()=>$,SpatialConeGeometry:()=>Q,SpatialCylinderGeometry:()=>q,SpatialEntity:()=>T,SpatialGeometry:()=>f,SpatialMaterial:()=>j,SpatialModelAsset:()=>J,SpatialModelEntity:()=>B,SpatialObject:()=>d,SpatialPlaneGeometry:()=>X,SpatialScene:()=>x,SpatialSceneState:()=>re,SpatialSceneValues:()=>Te,SpatialSession:()=>W,SpatialSphereGeometry:()=>H,SpatialUnlitMaterial:()=>k,Spatialized2DElement:()=>C,SpatializedDynamic3DElement:()=>I,SpatializedElement:()=>E,SpatializedElementType:()=>ve,SpatializedStatic3DElement:()=>O,WorldAlignmentValues:()=>De,WorldScalingValues:()=>Me,createAttachmentEntity:()=>oe,isSSREnv:()=>G,isValidBaseplateVisibilityType:()=>Yt,isValidSceneUnit:()=>zt,isValidSpatialSceneType:()=>ie,isValidWorldAlignmentType:()=>ee,isValidWorldScalingType:()=>te});g();var d=class{constructor(t){this.id=t}name;isDestroyed=!1;async inspect(){let t=await new Mt(this.id).execute();if(t.success)return t.data;throw new Error(t.errorMessage)}async destroy(){if(this.isDestroyed)return;let t=await new Dt(this.id).execute();if(t.success)return this.onDestroy(),this.isDestroyed=!0,t.data;if(this.isDestroyed)return;throw new Error(t.errorMessage)}onDestroy(){}};g();g();g();var Kt,x=class i extends d{static getInstance(){return Kt||(Kt=new i("")),Kt}async convertCoordinate(t,e,r){try{return(await new Pt(t,e,r).execute())?.data??t}catch(n){throw console.warn("SpatialScene.convertCoordinate error:",n),n}}async updateSpatialProperties(t){return new et(t).execute()}async addSpatializedElement(t){return new dt(t).execute()}async updateSceneCreationConfig(t){return new it(t).execute()}async getState(){return(await new nt().execute()).data.name}};var ve=(r=>(r[r.Spatialized2DElement=0]="Spatialized2DElement",r[r.SpatializedStatic3DElement=1]="SpatializedStatic3DElement",r[r.SpatializedDynamic3DElement=2]="SpatializedDynamic3DElement",r))(ve||{}),Pe=["automatic","visible","hidden"];function Yt(i){return Pe.includes(i)}var Me=["automatic","dynamic"];function te(i){return Me.includes(i)}var De=["adaptive","automatic","gravityAligned"];function ee(i){return De.includes(i)}var Te=["window","volume"];function ie(i){return Te.includes(i)}function zt(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 re=(a=>(a.idle="idle",a.pending="pending",a.willVisible="willVisible",a.visible="visible",a.fail="fail",a))(re||{}),Zt=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 ai={defaultSize:{width:1280,height:720}},oi={defaultSize:{width:.94,height:.94,depth:.94}},si="webspatial://",Wt=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(si))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 Rt(t,n,e,r).executeSync(),s=o.data?.id;return s&&new rt(s).execute(),o.data?.windowProxy};initScene(t,e,r){let n=r?.type??"window",a=ae(n),o=e({...a}),[s,p]=Ie(o,n);p.length>0&&console.warn(`initScene ${t} with errors: ${p.join(", ")}`),this.configMap[t]={...s,type:n}}};function Re(i){return i/1360}function Ce(i){return i*1360}function Oe(i,t,e){if(typeof i=="number")return e==="px"&&t==="px"||e==="m"&&t==="m"?i:e==="px"&&t==="m"?Re(i):e==="m"&&t==="px"?Ce(i):i;if(t==="m"){if(i.endsWith("m"))return Number(i.slice(0,-1));if(i.endsWith("px"))return Re(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 Ce(Number(i.slice(0,-1)));throw new Error("formatToNumber: invalid str")}else throw new Error("formatToNumber: invalid targetUnit")}function Ie(i,t){let e=ae(t),r=[],n=t==="window";if(ie(t)||r.push("sceneType"),i.defaultSize){let a=["width","height","depth"];for(let o of a)o in i.defaultSize&&(zt(i.defaultSize[o])?i.defaultSize[o]=Oe(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&&(zt(i.resizability[o])?i.resizability[o]=Oe(i.resizability[o],"px",n?"px":"m"):(i.resizability[o]=void 0,r.push(`resizability.${o}`)))}return i.worldScaling&&(te(i.worldScaling)||(i.worldScaling="automatic",r.push("worldScaling"))),i.worldAlignment&&(ee(i.worldAlignment)||(i.worldAlignment="automatic",r.push("worldAlignment"))),i.baseplateVisibility&&(Yt(i.baseplateVisibility)||(i.baseplateVisibility="automatic",r.push("baseplateVisibility"))),[i,r]}function ze(i,t,e){return Wt.getInstance().initScene(i,t,e)}function pi(i){Wt.getInstance().init(i)}function ne(i){i.document.onclick=function(t){let e=t.target,r=!1;for(;!r;){if(e&&e.tagName=="A")return!li(t);if(e&&e.parentElement)e=e.parentElement;else break}}}function li(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 ae(i){return i==="window"?ai:oi}async function ci(){if(!window.opener||await x.getInstance().getState()!=="pending")return;function t(e){document.readyState==="interactive"||document.readyState==="complete"?e():document.addEventListener("DOMContentLoaded",e)}t(async()=>{let e=ae(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]=Ie(r,n);o.length>0&&console.warn(`window.xrCurrentSceneDefaults with errors: ${o.join(", ")}`),await x.getInstance().updateSceneCreationConfig({...a,type:n})})}function We(){pi(window),ne(window),ci()}g();g();g();w();function u(i,t){return new CustomEvent(i,{bubbles:!0,cancelable:!1,detail:t})}var E=class extends d{constructor(e){super(e);this.id=e;c.addEventReceiver(e,this.onReceiveEvent.bind(this))}async updateTransform(e){return new pt(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 E{constructor(e,r){super(e);this.windowProxy=r;ne(r)}async updateProperties(e){return new at(this,e).execute()}async addSpatializedElement(e){return new ct(this,e).execute()}};g();var O=class extends E{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 lt(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})}};g();var I=class extends E{children=[];events={};constructor(t){super(t)}async addEntity(t){let e=new D(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 ot(this,t).execute()}};async function Ae(){let i=await new Tt().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 Ve(i){let t=await new mt(i).execute();if(t.success){let{id:e}=t.data;return new O(e,i)}else throw new Error("createSpatializedStatic3DElement failed")}async function Ge(){let i=await new ut().execute();if(i.success){let{id:t}=i.data;return new I(t)}else throw new Error("createSpatializedDynamic3DElement failed")}g();var At=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 It(this.id,e).execute()}};async function oe(i){let t=await new Ct(i).execute();if(!t.success)throw new Error("createAttachmentEntity failed: "+t?.errorMessage);let{id:e,windowProxy:r}=t.data;return await new Ot(e,i).execute(),new At(e,r,i)}g();g();g();w();var T=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 bt(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 D(e.id,this.id).execute();return this.children.push(e),e.parent=this,r}async removeFromParent(){let e=await new D(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 Y(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 tt(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 xt(e,r,n).execute()}async convertFromEntityToScene(e,r){return new wt(e,r).execute()}async convertFromSceneToEntity(e,r){return new vt(e,r).execute()}};var B=class extends T{constructor(e,r,n){super(e,n);this.id=e;this.options=r;this.userData=n}};w();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}};g();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 st(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 yt(i?.name).execute();if(t.success){let{id:e}=t.data;return new T(e,i)}else throw new Error("createSpatialEntity failed:"+t?.errorMessage)}async function z(i,t){let e=await new ht(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 Ue(i){let t=await new Et(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 Le(i){let t=await new St(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 Be(i,t){let e=await new gt(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 $e(i){let t=await new ft(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 X=class extends f{constructor(e,r){super(e,r);this.id=e;this.options=r}static type="PlaneGeometry"};var Q=class extends f{constructor(e,r){super(e,r);this.id=e;this.options=r}static type="ConeGeometry"};var W=class{getSpatialScene(){return x.getInstance()}createSpatialized2DElement(){return Ae()}createSpatializedStatic3DElement(t){return Ve(t)}initScene=ze;createSpatializedDynamic3DElement(){return Ge()}createEntity(t){return _e(t)}createBoxGeometry(t={}){return z(N,t)}createPlaneGeometry(t={}){return z(X,t)}createSphereGeometry(t={}){return z(H,t)}createConeGeometry(t){return z(Q,t)}createCylinderGeometry(t){return z(q,t)}createModelComponent(t){return Le(t)}createUnlitMaterial(t){return Ue(t)}createModelAsset(t){return $e(t)}createSpatialModelEntity(t,e){return Be(t,e)}createAttachmentEntity(t){return oe(t)}};w();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.4.0"}};var pe={};R(pe,{getValue:()=>ui,physicalToPoint:()=>mi,pointToPhysical:()=>di,subscribe:()=>yi});w();var b={meterToPtUnscaled:1360,meterToPtScaled:1360};function Fe(i){return i?.worldScalingCompensation??"scaled"}function di(i,t){return se(),Fe(t)==="unscaled"?i/b.meterToPtUnscaled:i/b.meterToPtScaled}function mi(i,t){return se(),Fe(t)==="unscaled"?i*b.meterToPtUnscaled:i*b.meterToPtScaled}function se(){if(typeof window>"u")return;let i=window.__webspatialsdk__?.physicalMetrics;if(!i)return;let t={meterToPtScaled:i.meterToPtScaled??b.meterToPtScaled,meterToPtUnscaled:i.meterToPtUnscaled??b.meterToPtUnscaled};(t.meterToPtScaled!==b.meterToPtScaled||t.meterToPtUnscaled!==b.meterToPtUnscaled)&&(b=t)}function ui(){return se(),b}function yi(i){if(typeof window>"u")return()=>{};let t=()=>{i()};return c.addEventReceiver("window",t),()=>{c.removeEventReceiver("window")}}$t();Xt();var je=new A,Ut,Vt={backgroundMaterial:"--xr-background-material"},ke="";function Gt(i){i!==ke&&(Ut?.getSpatialScene()?.updateSpatialProperties({material:i}),ke=i)}function Si(){let t=getComputedStyle(document.documentElement).getPropertyValue(Vt.backgroundMaterial);Gt(t||"none")}var P={topLeading:0,bottomLeading:0,topTrailing:0,bottomTrailing:0};function Je(){let i=getComputedStyle(document.documentElement),t=xe(i);gi(t)}function gi(i){(P.topLeading!==i.topLeading||P.bottomLeading!==i.bottomLeading||P.topTrailing!==i.topTrailing||P.bottomTrailing!==i.bottomTrailing)&&(Ut?.getSpatialScene()?.updateSpatialProperties({cornerRadius:i}),P.topLeading=i.topLeading,P.bottomLeading=i.bottomLeading,P.topTrailing=i.topTrailing,P.bottomTrailing=i.bottomTrailing)}function fi(i){Ut?.getSpatialScene().updateSpatialProperties({opacity:i})}function Ne(){let i=getComputedStyle(document.documentElement),t=parseFloat(i.getPropertyValue("opacity"));fi(t)}function hi(){let i=document.documentElement.style,t=new Proxy(i,{set:function(e,r,n){let a=Reflect.set(e,r,n);return r===Vt.backgroundMaterial&&Gt(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")&&Je(),r==="opacity"&&Ne(),a},get:function(e,r){return typeof e[r]=="function"?function(...n){if(r==="setProperty"){let[a,o]=n;a===Vt.backgroundMaterial&&Gt(o)}else if(r==="removeProperty"){let[a]=n;a===Vt.backgroundMaterial&&Gt("none")}return e[r](...n)}:Reflect.get(e,r)}});Object.defineProperty(document.documentElement,"style",{get:function(){return t}})}function Ei(){new MutationObserver(_t).observe(document.head,{childList:!0,subtree:!0})}function _t(){Si(),Je(),Ne()}function bi(){new MutationObserver(t=>{t.forEach(e=>{e.type==="attributes"&&e.attributeName&&_t()})}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}async function He(){je.runInSpatialWeb()&&(Ut=await je.requestSession(),document.readyState==="complete"?_t():window.addEventListener("load",()=>{_t()}),hi(),Ei(),bi())}!G()&&navigator.userAgent.indexOf("WebSpatial/")>0&&(We(),He());return V(xi);})();
75
75
  //# sourceMappingURL=index.global.js.map