@webspatial/react-sdk 1.2.0 → 1.2.1

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.
@@ -2,7 +2,7 @@
2
2
  (function(){
3
3
  if(typeof window === 'undefined') return;
4
4
  if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
- window.__webspatialsdk__['react-sdk-version'] = "1.2.0"
5
+ window.__webspatialsdk__['react-sdk-version'] = "1.2.1"
6
6
  window.__webspatialsdk__['XR_ENV'] = "avp"
7
7
  })()
8
8
 
@@ -2,7 +2,7 @@
2
2
  (function(){
3
3
  if(typeof window === 'undefined') return;
4
4
  if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
- window.__webspatialsdk__['react-sdk-version'] = "1.2.0"
5
+ window.__webspatialsdk__['react-sdk-version'] = "1.2.1"
6
6
  window.__webspatialsdk__['XR_ENV'] = "web"
7
7
  })()
8
8
 
@@ -2,7 +2,7 @@
2
2
  (function(){
3
3
  if(typeof window === 'undefined') return;
4
4
  if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
- window.__webspatialsdk__['react-sdk-version'] = "1.2.0"
5
+ window.__webspatialsdk__['react-sdk-version'] = "1.2.1"
6
6
  window.__webspatialsdk__['XR_ENV'] = "avp"
7
7
  })()
8
8
 
@@ -2,7 +2,7 @@
2
2
  (function(){
3
3
  if(typeof window === 'undefined') return;
4
4
  if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
- window.__webspatialsdk__['react-sdk-version'] = "1.2.0"
5
+ window.__webspatialsdk__['react-sdk-version'] = "1.2.1"
6
6
  window.__webspatialsdk__['XR_ENV'] = "web"
7
7
  })()
8
8
 
package/dist/web/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  (function(){
3
3
  if(typeof window === 'undefined') return;
4
4
  if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
- window.__webspatialsdk__['react-sdk-version'] = "1.2.0"
5
+ window.__webspatialsdk__['react-sdk-version'] = "1.2.1"
6
6
  window.__webspatialsdk__['XR_ENV'] = "web"
7
7
  })()
8
8
 
@@ -1205,12 +1205,12 @@ function useSync2DFrame(spatialId, portalInstanceObject, spatializedContainerObj
1205
1205
 
1206
1206
  // src/spatialized-container/hooks/useSpatializedElement.ts
1207
1207
  import { useEffect as useEffect6, useState as useState3 } from "react";
1208
- function useSpatializedElement(createSpatializedElement3, portalInstanceObject) {
1208
+ function useSpatializedElement(createSpatializedElement2, portalInstanceObject) {
1209
1209
  const [spatializedElement, setSpatializedElement] = useState3();
1210
1210
  useEffect6(() => {
1211
1211
  let isDestroyed = false;
1212
1212
  let spatializedElement2;
1213
- createSpatializedElement3().then(
1213
+ createSpatializedElement2().then(
1214
1214
  (inSpatializedElement) => {
1215
1215
  if (!isDestroyed) {
1216
1216
  spatializedElement2 = inSpatializedElement;
@@ -1228,7 +1228,7 @@ function useSpatializedElement(createSpatializedElement3, portalInstanceObject)
1228
1228
  spatializedElement2 = void 0;
1229
1229
  }
1230
1230
  };
1231
- }, [createSpatializedElement3, portalInstanceObject]);
1231
+ }, [createSpatializedElement2, portalInstanceObject]);
1232
1232
  return spatializedElement;
1233
1233
  }
1234
1234
 
@@ -1262,7 +1262,7 @@ function renderPlaceholderInSubPortal(portalInstanceObject, El) {
1262
1262
  function PortalSpatializedContainer(props) {
1263
1263
  const {
1264
1264
  spatializedContent: Content,
1265
- createSpatializedElement: createSpatializedElement3,
1265
+ createSpatializedElement: createSpatializedElement2,
1266
1266
  getExtraSpatializedElementProperties: getExtraSpatializedElementProperties2,
1267
1267
  onSpatialTap,
1268
1268
  onSpatialDragStart,
@@ -1296,7 +1296,7 @@ function PortalSpatializedContainer(props) {
1296
1296
  }, []);
1297
1297
  useSync2DFrame(spatialId, portalInstanceObject, spatializedContainerObject);
1298
1298
  const spatializedElement = useSpatializedElement(
1299
- createSpatializedElement3,
1299
+ createSpatializedElement2,
1300
1300
  portalInstanceObject
1301
1301
  );
1302
1302
  const PlaceholderEl = renderPlaceholderInSubPortal(
@@ -1517,7 +1517,7 @@ function SpatializedContainerBase(inprops, ref) {
1517
1517
  const {
1518
1518
  component: Component,
1519
1519
  spatializedContent,
1520
- createSpatializedElement: createSpatializedElement3,
1520
+ createSpatializedElement: createSpatializedElement2,
1521
1521
  getExtraSpatializedElementProperties: getExtraSpatializedElementProperties2,
1522
1522
  onSpatialTap: onSpatialTap2,
1523
1523
  onSpatialDragStart: onSpatialDragStart2,
@@ -1596,7 +1596,7 @@ function SpatializedContainerBase(inprops, ref) {
1596
1596
  }, [spatialContainerRefProxy.current]);
1597
1597
  const {
1598
1598
  spatializedContent,
1599
- createSpatializedElement: createSpatializedElement3,
1599
+ createSpatializedElement: createSpatializedElement2,
1600
1600
  getExtraSpatializedElementProperties: getExtraSpatializedElementProperties2,
1601
1601
  ...restProps
1602
1602
  } = props;
@@ -1646,7 +1646,7 @@ function SpatializedContainerBase(inprops, ref) {
1646
1646
  );
1647
1647
  const {
1648
1648
  spatializedContent,
1649
- createSpatializedElement: createSpatializedElement3,
1649
+ createSpatializedElement: createSpatializedElement2,
1650
1650
  getExtraSpatializedElementProperties: getExtraSpatializedElementProperties2,
1651
1651
  ...restProps
1652
1652
  } = props;
@@ -1856,7 +1856,10 @@ import {
1856
1856
  useCallback as useCallback6,
1857
1857
  useContext as useContext8,
1858
1858
  useEffect as useEffect12,
1859
- useMemo as useMemo3
1859
+ useMemo as useMemo3,
1860
+ useState as useState6,
1861
+ useImperativeHandle,
1862
+ useRef as useRef4
1860
1863
  } from "react";
1861
1864
  import { Fragment as Fragment2, jsx as jsx8 } from "react/jsx-runtime";
1862
1865
  function getAbsoluteURL(url) {
@@ -1930,10 +1933,15 @@ function SpatializedContent2(props) {
1930
1933
  }, [onError]);
1931
1934
  return /* @__PURE__ */ jsx8(Fragment2, {});
1932
1935
  }
1933
- async function createSpatializedElement2() {
1934
- return getSession().createSpatializedStatic3DElement();
1935
- }
1936
1936
  function SpatializedStatic3DElementContainerBase(props, ref) {
1937
+ const containerRef = useRef4(null);
1938
+ const [elementCreated, setElementCreated] = useState6(false);
1939
+ useImperativeHandle(ref, () => elementCreated ? containerRef.current : null, [elementCreated]);
1940
+ const createSpatializedElement2 = useCallback6(async () => {
1941
+ const element = await getSession().createSpatializedStatic3DElement();
1942
+ setElementCreated(true);
1943
+ return element;
1944
+ }, [setElementCreated]);
1937
1945
  const extraRefProps = useCallback6(
1938
1946
  (domProxy) => {
1939
1947
  let modelTransform = new DOMMatrixReadOnly();
@@ -1966,7 +1974,7 @@ function SpatializedStatic3DElementContainerBase(props, ref) {
1966
1974
  return /* @__PURE__ */ jsx8(
1967
1975
  SpatializedContainer,
1968
1976
  {
1969
- ref,
1977
+ ref: containerRef,
1970
1978
  component: "div",
1971
1979
  createSpatializedElement: createSpatializedElement2,
1972
1980
  spatializedContent: SpatializedContent2,
@@ -2028,9 +2036,9 @@ function initScene(name, callback) {
2028
2036
  import { forwardRef as forwardRef9 } from "react";
2029
2037
 
2030
2038
  // src/spatialized-container-monitor/useMonitorDomChange.tsx
2031
- import { useRef as useRef4, useEffect as useEffect13, useMemo as useMemo4 } from "react";
2039
+ import { useRef as useRef5, useEffect as useEffect13, useMemo as useMemo4 } from "react";
2032
2040
  function useMonitorDomChange(inRef) {
2033
- const ref = useRef4(null);
2041
+ const ref = useRef5(null);
2034
2042
  useEffect13(() => {
2035
2043
  const observer = new MutationObserver((mutationsList) => {
2036
2044
  notifyDOMUpdate(mutationsList);
@@ -2139,7 +2147,7 @@ var ParentContext = createContext6(null);
2139
2147
  var useParentContext = () => useContext10(ParentContext);
2140
2148
 
2141
2149
  // src/reality/hooks/useEntityTransform.tsx
2142
- import { useEffect as useEffect15, useRef as useRef5 } from "react";
2150
+ import { useEffect as useEffect15, useRef as useRef6 } from "react";
2143
2151
 
2144
2152
  // src/reality/utils/ResourceRegistry.ts
2145
2153
  var ResourceRegistry = class {
@@ -2220,7 +2228,7 @@ var AbortResourceManager = class {
2220
2228
 
2221
2229
  // src/reality/hooks/useEntityTransform.tsx
2222
2230
  function useEntityTransform(entity, { position, rotation, scale }) {
2223
- const last = useRef5({});
2231
+ const last = useRef6({});
2224
2232
  useEffect15(() => {
2225
2233
  if (!entity) return;
2226
2234
  const shouldUpdate = !shallowEqualVec3(last.current.position, position) || !shallowEqualRotation(last.current.rotation, rotation) || !shallowEqualVec3(last.current.scale, scale);
@@ -2240,7 +2248,7 @@ function useEntityTransform(entity, { position, rotation, scale }) {
2240
2248
  }
2241
2249
 
2242
2250
  // src/reality/hooks/useEntityEvent.tsx
2243
- import { useEffect as useEffect17, useRef as useRef7 } from "react";
2251
+ import { useEffect as useEffect17, useRef as useRef8 } from "react";
2244
2252
 
2245
2253
  // src/reality/type.ts
2246
2254
  var eventMap = {
@@ -2261,9 +2269,9 @@ var eventMap = {
2261
2269
  };
2262
2270
 
2263
2271
  // src/reality/hooks/useEntityRef.tsx
2264
- import { useImperativeHandle } from "react";
2272
+ import { useImperativeHandle as useImperativeHandle2 } from "react";
2265
2273
  var useEntityRef = (ref, instance) => {
2266
- useImperativeHandle(ref, () => instance);
2274
+ useImperativeHandle2(ref, () => instance);
2267
2275
  };
2268
2276
  var EntityRef = class {
2269
2277
  _entity;
@@ -2383,7 +2391,7 @@ function createEventProxy2(ev, instance) {
2383
2391
  });
2384
2392
  }
2385
2393
  var useEntityEvent = ({ instance, ...handlers }) => {
2386
- const eventsSetRef = useRef7(/* @__PURE__ */ new Set());
2394
+ const eventsSetRef = useRef8(/* @__PURE__ */ new Set());
2387
2395
  useEffect17(() => {
2388
2396
  const entity = instance.entity;
2389
2397
  if (!entity) return;
@@ -2425,7 +2433,7 @@ var useEntityId = ({ id, entity }) => {
2425
2433
  };
2426
2434
 
2427
2435
  // src/reality/hooks/useEntity.tsx
2428
- import { useEffect as useEffect19, useRef as useRef8 } from "react";
2436
+ import { useEffect as useEffect19, useRef as useRef9 } from "react";
2429
2437
  var useEntity = ({
2430
2438
  ref,
2431
2439
  id,
@@ -2447,7 +2455,7 @@ var useEntity = ({
2447
2455
  }) => {
2448
2456
  const ctx = useRealityContext();
2449
2457
  const parent = useParentContext();
2450
- const instanceRef = useRef8(new EntityRef(null, ctx));
2458
+ const instanceRef = useRef9(new EntityRef(null, ctx));
2451
2459
  const forceUpdate = useForceUpdate2();
2452
2460
  useEffect19(() => {
2453
2461
  if (!ctx) return;
@@ -2499,9 +2507,9 @@ var useEntity = ({
2499
2507
  };
2500
2508
 
2501
2509
  // src/reality/hooks/useForceUpdate.tsx
2502
- import { useCallback as useCallback7, useState as useState7 } from "react";
2510
+ import { useCallback as useCallback7, useState as useState8 } from "react";
2503
2511
  var useForceUpdate2 = () => {
2504
- const [, setTick] = useState7(0);
2512
+ const [, setTick] = useState8(0);
2505
2513
  return useCallback7(() => setTick((tick) => tick + 1), []);
2506
2514
  };
2507
2515
 
@@ -2606,10 +2614,10 @@ var BoxEntity = forwardRef13(
2606
2614
  );
2607
2615
 
2608
2616
  // src/reality/components/UnlitMaterial.tsx
2609
- import { useEffect as useEffect20, useRef as useRef9 } from "react";
2617
+ import { useEffect as useEffect20, useRef as useRef10 } from "react";
2610
2618
  var UnlitMaterial = ({ children, ...options }) => {
2611
2619
  const ctx = useRealityContext();
2612
- const materialRef = useRef9();
2620
+ const materialRef = useRef10();
2613
2621
  useEffect20(() => {
2614
2622
  if (!ctx) return;
2615
2623
  const { session, reality, resourceRegistry } = ctx;
@@ -2726,7 +2734,7 @@ var SceneGraph = ({ children }) => {
2726
2734
  };
2727
2735
 
2728
2736
  // src/reality/components/ModelAsset.tsx
2729
- import { useEffect as useEffect21, useRef as useRef10 } from "react";
2737
+ import { useEffect as useEffect21, useRef as useRef11 } from "react";
2730
2738
  var resolveAssetUrl = (url) => {
2731
2739
  if (url.startsWith("http://") || url.startsWith("https://")) {
2732
2740
  return url;
@@ -2735,7 +2743,7 @@ var resolveAssetUrl = (url) => {
2735
2743
  };
2736
2744
  var ModelAsset = ({ children, ...options }) => {
2737
2745
  const ctx = useRealityContext();
2738
- const materialRef = useRef10();
2746
+ const materialRef = useRef11();
2739
2747
  useEffect21(() => {
2740
2748
  const controller = new AbortController();
2741
2749
  if (!ctx) return;
@@ -2804,8 +2812,8 @@ import {
2804
2812
  forwardRef as forwardRef19,
2805
2813
  useCallback as useCallback8,
2806
2814
  useEffect as useEffect22,
2807
- useRef as useRef11,
2808
- useState as useState8
2815
+ useRef as useRef12,
2816
+ useState as useState9
2809
2817
  } from "react";
2810
2818
  import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs3 } from "react/jsx-runtime";
2811
2819
  var Reality = forwardRef19(
@@ -2821,9 +2829,9 @@ var Reality = forwardRef19(
2821
2829
  onSpatialMagnifyEnd,
2822
2830
  ...props
2823
2831
  } = inProps;
2824
- const ctxRef = useRef11(null);
2825
- const creationId = useRef11(0);
2826
- const [isReady, setIsReady] = useState8(false);
2832
+ const ctxRef = useRef12(null);
2833
+ const creationId = useRef12(0);
2834
+ const [isReady, setIsReady] = useState9(false);
2827
2835
  const cleanupReality = useCallback8(() => {
2828
2836
  ctxRef.current?.resourceRegistry.destroy();
2829
2837
  ctxRef.current?.reality.destroy();
@@ -2912,7 +2920,7 @@ var Model = withSSRSupported(forwardRef20(ModelBase));
2912
2920
  Model.displayName = "Model";
2913
2921
 
2914
2922
  // src/index.ts
2915
- var version = "1.2.0";
2923
+ var version = "1.2.1";
2916
2924
  if (typeof window !== "undefined") {
2917
2925
  initPolyfill();
2918
2926
  }