@webspatial/react-sdk 0.1.11 → 0.1.14

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.
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import * as React$1 from 'react';
2
2
  import React__default, { ReactNode, CSSProperties, ElementType, ForwardedRef } from 'react';
3
3
  import { BackgroundMaterialType, CornerRadius, SpatialEntity, Vec3, SpatialSession, WindowContainerOptions as WindowContainerOptions$1 } from '@webspatial/core-sdk';
4
4
  import { ModelViewerElement } from '@google/model-viewer';
@@ -40,7 +40,7 @@ interface SpatialReactComponentProps {
40
40
  }
41
41
  type SpatialReactComponentRef = ForwardedRef<HTMLDivElement>;
42
42
 
43
- declare const SpatialReactComponent: React.ForwardRefExoticComponent<SpatialReactComponentProps & React.RefAttributes<HTMLDivElement>>;
43
+ declare const SpatialReactComponent: React$1.ForwardRefExoticComponent<SpatialReactComponentProps & React$1.RefAttributes<HTMLDivElement>>;
44
44
 
45
45
  declare function withSpatial(Component: React__default.ElementType): any;
46
46
  declare const SpatialPrimitive: Record<string, typeof SpatialReactComponent>;
@@ -51,7 +51,7 @@ declare function withSpatialMonitor(El: React__default.ElementType): any;
51
51
  type SpatialMonitorProps = {
52
52
  El?: ElementType;
53
53
  };
54
- declare const SpatialMonitor: React.ForwardRefExoticComponent<SpatialMonitorProps & React.RefAttributes<HTMLElement>>;
54
+ declare const SpatialMonitor: React$1.ForwardRefExoticComponent<SpatialMonitorProps & React$1.RefAttributes<HTMLElement>>;
55
55
 
56
56
  /**
57
57
  * External-developers can call this function to sync the standardInstance layout to PortalInstance.
@@ -68,7 +68,7 @@ declare function parseCornerRadius(computedStyle: CSSStyleDeclaration): {
68
68
  bottomTrailing: number;
69
69
  };
70
70
 
71
- declare const CSSSpatialComponent: React.ForwardRefExoticComponent<SpatialReactComponentProps & React.RefAttributes<HTMLDivElement>>;
71
+ declare const CSSSpatialComponent: React$1.ForwardRefExoticComponent<SpatialReactComponentProps & React$1.RefAttributes<HTMLDivElement>>;
72
72
 
73
73
  declare function withCSSSpatial(Component: React__default.ElementType): any;
74
74
  declare const CSSSpatialPrimitive: Record<string, typeof CSSSpatialComponent>;
@@ -86,6 +86,11 @@ interface SpatialViewRef extends HTMLDivElement {
86
86
  */
87
87
  declare const SpatialView: React__default.ForwardRefExoticComponent<SpatialViewProps & React__default.RefAttributes<SpatialViewRef>>;
88
88
 
89
+ type PartialSpatialTransformType = {
90
+ position?: Partial<vecType>;
91
+ rotation?: Partial<quatType>;
92
+ scale?: Partial<vecType>;
93
+ };
89
94
  interface ModelEvent {
90
95
  target: ModelElement;
91
96
  }
@@ -94,10 +99,34 @@ interface ModelDragEvent extends ModelEvent {
94
99
  translation3D: Vec3;
95
100
  startLocation3D: Vec3;
96
101
  }
102
+ interface Model3DProps {
103
+ spatialTransform?: PartialSpatialTransformType;
104
+ modelUrl: string;
105
+ visible: boolean;
106
+ contentMode?: 'fill' | 'fit';
107
+ resizable?: boolean;
108
+ aspectRatio?: number;
109
+ className?: string;
110
+ style?: CSSProperties | undefined;
111
+ children?: React.ReactNode;
112
+ onLoad?: (event: ModelEvent) => void;
113
+ onDragStart?: (dragEvent: ModelDragEvent) => void;
114
+ onDrag?: (dragEvent: ModelDragEvent) => void;
115
+ onDragEnd?: (dragEvent: ModelDragEvent) => void;
116
+ onTap?: (event: ModelEvent) => void;
117
+ onDoubleTap?: (event: ModelEvent) => void;
118
+ onLongPress?: (event: ModelEvent) => void;
119
+ }
97
120
  interface ModelElement extends HTMLDivElement {
98
121
  ready: boolean;
99
122
  currentSrc: string;
100
123
  }
124
+ type ModelElementRef = ForwardedRef<ModelElement>;
125
+ type CSSModel3DProps = Omit<Model3DProps, 'spatialTransform' | 'visible'>;
126
+
127
+ declare const Model3D: React$1.ForwardRefExoticComponent<Model3DProps & React$1.RefAttributes<ModelElement>>;
128
+
129
+ declare const CSSModel3D: React$1.ForwardRefExoticComponent<CSSModel3DProps & React$1.RefAttributes<ModelElement>>;
101
130
 
102
131
  declare global {
103
132
  namespace JSX {
@@ -164,4 +193,6 @@ declare function initScene(name: string, callback: (pre: WindowContainerOptions$
164
193
 
165
194
  declare function spatialPolyfill(): void;
166
195
 
167
- export { CSSSpatialDiv, CSSSpatialPrimitive, Model, type ModelProps, SpatialDiv, type SpatialReactComponentProps as SpatialDivProps, type SpatialReactComponentRef as SpatialDivRef, SpatialMonitor, SpatialPrimitive, type SpatialReactComponentProps, type SpatialReactComponentRef, SpatialView, type SpatialViewRef, XRApp, defaultSceneConfig, enableDebugTool, getSession, initScene, notifyUpdateStandInstanceLayout, parseCornerRadius, spatialPolyfill, withCSSSpatial, withSpatial, withSpatialMonitor };
196
+ declare const version: string;
197
+
198
+ export { CSSModel3D, CSSSpatialDiv, CSSSpatialPrimitive, Model, Model3D, type Model3DProps, type ModelDragEvent, type ModelElement, type ModelElementRef, type ModelEvent, type ModelProps, SpatialDiv, type SpatialReactComponentProps as SpatialDivProps, type SpatialReactComponentRef as SpatialDivRef, SpatialMonitor, SpatialPrimitive, type SpatialReactComponentProps, type SpatialReactComponentRef, SpatialView, type SpatialViewRef, XRApp, defaultSceneConfig, enableDebugTool, getSession, initScene, notifyUpdateStandInstanceLayout, parseCornerRadius, spatialPolyfill, version, withCSSSpatial, withSpatial, withSpatialMonitor };
@@ -1,3 +1,12 @@
1
+
2
+ (function(){
3
+ if(typeof window === 'undefined') return;
4
+ if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
+ window.__webspatialsdk__['react-sdk-version'] = "0.1.14"
6
+ window.__webspatialsdk__['XR_ENV'] = "avp"
7
+ })()
8
+
9
+
1
10
  // src/spatial-react-components/SpatialPrimitive.tsx
2
11
  import { forwardRef as forwardRef3 } from "react";
3
12
 
@@ -659,7 +668,8 @@ function getInheritedStyleProps(computedStyle) {
659
668
  // position also need to be synced
660
669
  "position",
661
670
  "width",
662
- "height"
671
+ "height",
672
+ "display"
663
673
  ];
664
674
  var props = {};
665
675
  for (var cssName of propNames) {
@@ -855,8 +865,7 @@ function renderJSXPortalInstance(inProps, inheritedPortalStyle, className) {
855
865
  marginTop: "0px",
856
866
  marginBottom: "0px",
857
867
  borderRadius: "0px",
858
- overflow: "",
859
- display: "block"
868
+ overflow: ""
860
869
  };
861
870
  const style = {
862
871
  ...inStyle,
@@ -3758,6 +3767,9 @@ function spatialPolyfill() {
3758
3767
  hijackDocumentElementStyle();
3759
3768
  monitorExternalStyleChange();
3760
3769
  }
3770
+
3771
+ // src/index.ts
3772
+ var version = "0.1.14";
3761
3773
  export {
3762
3774
  CSSSpatialDiv,
3763
3775
  CSSSpatialPrimitive,
@@ -3774,6 +3786,7 @@ export {
3774
3786
  notifyUpdateStandInstanceLayout,
3775
3787
  parseCornerRadius,
3776
3788
  spatialPolyfill,
3789
+ version,
3777
3790
  withCSSSpatial,
3778
3791
  withSpatial,
3779
3792
  withSpatialMonitor