@webspatial/react-sdk 0.0.0 → 0.0.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.
@@ -31,11 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.ts
32
32
  var src_exports = {};
33
33
  __export(src_exports, {
34
- CSSModel3D: () => CSSModel3D,
35
34
  CSSSpatialDiv: () => CSSSpatialDiv,
36
35
  CSSSpatialPrimitive: () => CSSSpatialPrimitive,
37
36
  Model: () => Model,
38
- Model3D: () => Model3D,
39
37
  SpatialDiv: () => SpatialDiv,
40
38
  SpatialMonitor: () => SpatialMonitor,
41
39
  SpatialPrimitive: () => SpatialPrimitive,
@@ -2060,14 +2058,71 @@ var CSSSpatialPrimitive = {};
2060
2058
  }, "createSpatialPrimitive"))(CSSSpatialPrimitive);
2061
2059
  var CSSSpatialDiv = CSSSpatialPrimitive.div;
2062
2060
 
2061
+ // src/spatial-react-components/SpatialView.tsx
2062
+ var import_core_sdk2 = require("@webspatial/core-sdk");
2063
+ var import_react21 = require("react");
2064
+ var import_jsx_runtime8 = require("react/jsx-runtime");
2065
+ var runAsync = /* @__PURE__ */ __name((fn) => {
2066
+ return fn();
2067
+ }, "runAsync");
2068
+ var SpatialViewEl = (0, import_react21.forwardRef)(
2069
+ (props, ref) => {
2070
+ const divRef = (0, import_react21.useRef)(null);
2071
+ const spatialEntity = (0, import_react21.useRef)(null);
2072
+ const activePromise = (0, import_react21.useRef)(null);
2073
+ (0, import_react21.useImperativeHandle)(ref, () => ({
2074
+ ...divRef.current,
2075
+ getViewEntity: /* @__PURE__ */ __name(async () => {
2076
+ if (activePromise.current) {
2077
+ await activePromise.current;
2078
+ }
2079
+ return spatialEntity.current;
2080
+ }, "getViewEntity")
2081
+ }));
2082
+ if (getSession() == null) {
2083
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
2084
+ }
2085
+ (0, import_react21.useEffect)(() => {
2086
+ if (false) return;
2087
+ activePromise.current = runAsync(async () => {
2088
+ if (activePromise.current) {
2089
+ await activePromise.current;
2090
+ }
2091
+ let sh = new import_core_sdk2.SpatialHelper(getSession());
2092
+ let x = await sh.dom.attachSpatialView(divRef.current);
2093
+ spatialEntity.current = x.entity;
2094
+ if (props.onViewLoad) {
2095
+ props.onViewLoad(x.entity);
2096
+ }
2097
+ });
2098
+ return () => {
2099
+ if (false) return;
2100
+ runAsync(async () => {
2101
+ await activePromise.current;
2102
+ spatialEntity.current?.destroy();
2103
+ if (props.onViewUnload) {
2104
+ props.onViewUnload();
2105
+ }
2106
+ });
2107
+ };
2108
+ }, []);
2109
+ const { onViewLoad, onViewUnload, ...divProps } = props;
2110
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...divProps });
2111
+ }
2112
+ );
2113
+ var SpatialView = SpatialViewEl;
2114
+
2115
+ // src/spatial-react-components/Model/index.tsx
2116
+ var import_react31 = require("react");
2117
+
2063
2118
  // src/spatial-react-components/Model3D/Model3D.tsx
2064
- var import_react26 = require("react");
2119
+ var import_react27 = require("react");
2065
2120
 
2066
2121
  // src/spatial-react-components/Model3D/useDetectLayoutDomUpdated.ts
2067
- var import_react21 = require("react");
2122
+ var import_react22 = require("react");
2068
2123
  function useDetectLayoutDomUpdated(onDomUpdated) {
2069
- const ref = (0, import_react21.useRef)(null);
2070
- (0, import_react21.useEffect)(() => {
2124
+ const ref = (0, import_react22.useRef)(null);
2125
+ (0, import_react22.useEffect)(() => {
2071
2126
  if (!ref.current) {
2072
2127
  console.warn("Ref is not attached to the DOM");
2073
2128
  return;
@@ -2080,7 +2135,7 @@ function useDetectLayoutDomUpdated(onDomUpdated) {
2080
2135
  ro.disconnect();
2081
2136
  };
2082
2137
  }, []);
2083
- (0, import_react21.useEffect)(() => {
2138
+ (0, import_react22.useEffect)(() => {
2084
2139
  if (!ref.current) {
2085
2140
  console.warn("Ref is not attached to the DOM");
2086
2141
  return;
@@ -2102,7 +2157,7 @@ function useDetectLayoutDomUpdated(onDomUpdated) {
2102
2157
  __name(useDetectLayoutDomUpdated, "useDetectLayoutDomUpdated");
2103
2158
 
2104
2159
  // src/spatial-react-components/Model3D/useModel3DNative.ts
2105
- var import_react22 = require("react");
2160
+ var import_react23 = require("react");
2106
2161
 
2107
2162
  // src/spatial-react-components/Model3D/utils.ts
2108
2163
  function PopulatePartialSpatialTransformType(spatialTransform = {}) {
@@ -2330,12 +2385,12 @@ var Model3DNative = class {
2330
2385
 
2331
2386
  // src/spatial-react-components/Model3D/useModel3DNative.ts
2332
2387
  function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DNativeReadyCb) {
2333
- let model3DNativeRef = (0, import_react22.useRef)(null);
2334
- const [phase, setPhase] = (0, import_react22.useState)(
2388
+ let model3DNativeRef = (0, import_react23.useRef)(null);
2389
+ const [phase, setPhase] = (0, import_react23.useState)(
2335
2390
  "loading"
2336
2391
  );
2337
- const [failureReason, setFailureReason] = (0, import_react22.useState)("");
2338
- (0, import_react22.useEffect)(() => {
2392
+ const [failureReason, setFailureReason] = (0, import_react23.useState)("");
2393
+ (0, import_react23.useEffect)(() => {
2339
2394
  let isDestroyed = false;
2340
2395
  const model3DContainer = new Model3DNative(parentEntity);
2341
2396
  model3DContainer.init(
@@ -2362,32 +2417,32 @@ function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DN
2362
2417
  setPhase("loading");
2363
2418
  };
2364
2419
  }, [modelUrl]);
2365
- (0, import_react22.useEffect)(() => {
2420
+ (0, import_react23.useEffect)(() => {
2366
2421
  if (model3DNativeRef.current) {
2367
2422
  model3DNativeRef.current.onDragStart = eventHandlers.onDragStart;
2368
2423
  }
2369
2424
  }, [model3DNativeRef.current, eventHandlers.onDragStart]);
2370
- (0, import_react22.useEffect)(() => {
2425
+ (0, import_react23.useEffect)(() => {
2371
2426
  if (model3DNativeRef.current) {
2372
2427
  model3DNativeRef.current.onDrag = eventHandlers.onDrag;
2373
2428
  }
2374
2429
  }, [model3DNativeRef.current, eventHandlers.onDrag]);
2375
- (0, import_react22.useEffect)(() => {
2430
+ (0, import_react23.useEffect)(() => {
2376
2431
  if (model3DNativeRef.current) {
2377
2432
  model3DNativeRef.current.onDragEnd = eventHandlers.onDragEnd;
2378
2433
  }
2379
2434
  });
2380
- (0, import_react22.useEffect)(() => {
2435
+ (0, import_react23.useEffect)(() => {
2381
2436
  if (model3DNativeRef.current) {
2382
2437
  model3DNativeRef.current.onTap = eventHandlers.onTap;
2383
2438
  }
2384
2439
  }, [model3DNativeRef.current, eventHandlers.onTap]);
2385
- (0, import_react22.useEffect)(() => {
2440
+ (0, import_react23.useEffect)(() => {
2386
2441
  if (model3DNativeRef.current) {
2387
2442
  model3DNativeRef.current.onDoubleTap = eventHandlers.onDoubleTap;
2388
2443
  }
2389
2444
  }, [model3DNativeRef.current, eventHandlers.onDoubleTap]);
2390
- (0, import_react22.useEffect)(() => {
2445
+ (0, import_react23.useEffect)(() => {
2391
2446
  if (model3DNativeRef.current) {
2392
2447
  model3DNativeRef.current.onLongPress = eventHandlers.onLongPress;
2393
2448
  }
@@ -2397,8 +2452,8 @@ function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DN
2397
2452
  __name(useModel3DNative, "useModel3DNative");
2398
2453
 
2399
2454
  // src/spatial-react-components/Model3D/Model3DNotInSpatialDiv.tsx
2400
- var import_react23 = require("react");
2401
- var import_jsx_runtime8 = require("react/jsx-runtime");
2455
+ var import_react24 = require("react");
2456
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2402
2457
  function renderModel3DNotInSpatialDiv(props, refIn) {
2403
2458
  const {
2404
2459
  className,
@@ -2419,7 +2474,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2419
2474
  onLongPress
2420
2475
  } = props;
2421
2476
  const theSpatialTransform = PopulatePartialSpatialTransformType(spatialTransform);
2422
- const onDomUpdated = (0, import_react23.useCallback)(() => {
2477
+ const onDomUpdated = (0, import_react24.useCallback)(() => {
2423
2478
  if (model3DNativeRef.current && layoutInstanceRef.current) {
2424
2479
  const model3DNative = model3DNativeRef.current;
2425
2480
  model3DNative.updateByDom(layoutInstanceRef.current, {
@@ -2438,7 +2493,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2438
2493
  theSpatialTransform.scale.y,
2439
2494
  theSpatialTransform.scale.z
2440
2495
  ]);
2441
- const onModel3DContainerReadyCb = (0, import_react23.useCallback)(() => {
2496
+ const onModel3DContainerReadyCb = (0, import_react24.useCallback)(() => {
2442
2497
  if (model3DNativeRef.current && layoutInstanceRef.current) {
2443
2498
  model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
2444
2499
  spatialTransform: theSpatialTransform
@@ -2456,7 +2511,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2456
2511
  theSpatialTransform.scale.y,
2457
2512
  theSpatialTransform.scale.z
2458
2513
  ]);
2459
- const onDragStartCb = (0, import_react23.useCallback)(
2514
+ const onDragStartCb = (0, import_react24.useCallback)(
2460
2515
  (spatialDragEvent) => {
2461
2516
  if (onDragStart) {
2462
2517
  const dragEvent = {
@@ -2468,7 +2523,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2468
2523
  },
2469
2524
  [onDragStart]
2470
2525
  );
2471
- const onDragCb = (0, import_react23.useCallback)(
2526
+ const onDragCb = (0, import_react24.useCallback)(
2472
2527
  (spatialDragEvent) => {
2473
2528
  if (onDrag) {
2474
2529
  const dragEvent = {
@@ -2480,7 +2535,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2480
2535
  },
2481
2536
  [onDrag]
2482
2537
  );
2483
- const onDragEndCb = (0, import_react23.useCallback)(
2538
+ const onDragEndCb = (0, import_react24.useCallback)(
2484
2539
  (spatialDragEvent) => {
2485
2540
  if (onDragEnd) {
2486
2541
  const dragEvent = {
@@ -2492,7 +2547,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2492
2547
  },
2493
2548
  [onDragEnd]
2494
2549
  );
2495
- const onTapCb = (0, import_react23.useCallback)(() => {
2550
+ const onTapCb = (0, import_react24.useCallback)(() => {
2496
2551
  if (onTap) {
2497
2552
  const event = {
2498
2553
  target: layoutInstanceRef.current
@@ -2500,7 +2555,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2500
2555
  onTap(event);
2501
2556
  }
2502
2557
  }, [onTap]);
2503
- const onDoubleTapCb = (0, import_react23.useCallback)(() => {
2558
+ const onDoubleTapCb = (0, import_react24.useCallback)(() => {
2504
2559
  if (onDoubleTap) {
2505
2560
  const event = {
2506
2561
  target: layoutInstanceRef.current
@@ -2508,7 +2563,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2508
2563
  onDoubleTap(event);
2509
2564
  }
2510
2565
  }, [onDoubleTap]);
2511
- const onLongPressCb = (0, import_react23.useCallback)(() => {
2566
+ const onLongPressCb = (0, import_react24.useCallback)(() => {
2512
2567
  if (onLongPress) {
2513
2568
  const event = {
2514
2569
  target: layoutInstanceRef.current
@@ -2530,7 +2585,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2530
2585
  },
2531
2586
  onModel3DContainerReadyCb
2532
2587
  );
2533
- const onSuccess = (0, import_react23.useCallback)(() => {
2588
+ const onSuccess = (0, import_react24.useCallback)(() => {
2534
2589
  ;
2535
2590
  layoutInstanceRef.current.ready = true;
2536
2591
  if (onLoad) {
@@ -2539,7 +2594,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2539
2594
  });
2540
2595
  }
2541
2596
  }, [onLoad]);
2542
- const onFailure = (0, import_react23.useCallback)(
2597
+ const onFailure = (0, import_react24.useCallback)(
2543
2598
  (_) => {
2544
2599
  const modelElement = layoutInstanceRef.current;
2545
2600
  modelElement.ready = false;
@@ -2551,19 +2606,19 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2551
2606
  },
2552
2607
  [onLoad]
2553
2608
  );
2554
- (0, import_react23.useEffect)(() => {
2609
+ (0, import_react24.useEffect)(() => {
2555
2610
  if (phase === "failure") {
2556
2611
  onFailure(failureReason);
2557
2612
  } else if (phase === "success") {
2558
2613
  onSuccess();
2559
2614
  }
2560
2615
  }, [phase]);
2561
- (0, import_react23.useEffect)(() => {
2616
+ (0, import_react24.useEffect)(() => {
2562
2617
  if (model3DNativeRef.current) {
2563
2618
  model3DNativeRef.current.setVisible(visible);
2564
2619
  }
2565
2620
  }, [model3DNativeRef.current, visible]);
2566
- (0, import_react23.useEffect)(() => {
2621
+ (0, import_react24.useEffect)(() => {
2567
2622
  if (model3DNativeRef.current && layoutInstanceRef.current) {
2568
2623
  model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
2569
2624
  spatialTransform: theSpatialTransform
@@ -2581,17 +2636,17 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2581
2636
  theSpatialTransform.scale.y,
2582
2637
  theSpatialTransform.scale.z
2583
2638
  ]);
2584
- (0, import_react23.useEffect)(() => {
2639
+ (0, import_react24.useEffect)(() => {
2585
2640
  if (model3DNativeRef.current) {
2586
2641
  model3DNativeRef.current.setContentMode(contentMode);
2587
2642
  }
2588
2643
  }, [model3DNativeRef.current, contentMode]);
2589
- (0, import_react23.useEffect)(() => {
2644
+ (0, import_react24.useEffect)(() => {
2590
2645
  if (model3DNativeRef.current) {
2591
2646
  model3DNativeRef.current.setResizable(resizable);
2592
2647
  }
2593
2648
  }, [model3DNativeRef.current, resizable]);
2594
- (0, import_react23.useEffect)(() => {
2649
+ (0, import_react24.useEffect)(() => {
2595
2650
  if (model3DNativeRef.current) {
2596
2651
  model3DNativeRef.current.setAspectRatio(aspectRatio);
2597
2652
  }
@@ -2601,7 +2656,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2601
2656
  visibility: phase === "failure" ? "visible" : "hidden",
2602
2657
  transform: ""
2603
2658
  };
2604
- const proxyRef = (0, import_react23.useMemo)(
2659
+ const proxyRef = (0, import_react24.useMemo)(
2605
2660
  () => new Proxy(layoutInstanceRef, {
2606
2661
  get(target, prop, receiver) {
2607
2662
  return Reflect.get(target, prop, receiver);
@@ -2626,7 +2681,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2626
2681
  }),
2627
2682
  [layoutInstanceRef, refIn]
2628
2683
  );
2629
- (0, import_react23.useEffect)(() => {
2684
+ (0, import_react24.useEffect)(() => {
2630
2685
  return () => {
2631
2686
  if (layoutInstanceRef.current) {
2632
2687
  const modelElement = layoutInstanceRef.current;
@@ -2635,18 +2690,18 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
2635
2690
  }
2636
2691
  };
2637
2692
  }, [modelUrl]);
2638
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className, style: layoutDomStyle, ref: proxyRef, children: phase === "failure" && children });
2693
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, style: layoutDomStyle, ref: proxyRef, children: phase === "failure" && children });
2639
2694
  }
2640
2695
  __name(renderModel3DNotInSpatialDiv, "renderModel3DNotInSpatialDiv");
2641
2696
 
2642
2697
  // src/spatial-react-components/Model3D/Model3DStandardInstance.tsx
2643
- var import_jsx_runtime9 = require("react/jsx-runtime");
2698
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2644
2699
  function renderModel3DStandardInstance(spatialId, props, refIn) {
2645
2700
  const { className, style } = props;
2646
2701
  const extraProps = {
2647
2702
  [SpatialID]: spatialId
2648
2703
  };
2649
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2704
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2650
2705
  "div",
2651
2706
  {
2652
2707
  "data-model3d-spatialid": spatialId,
@@ -2660,28 +2715,28 @@ function renderModel3DStandardInstance(spatialId, props, refIn) {
2660
2715
  __name(renderModel3DStandardInstance, "renderModel3DStandardInstance");
2661
2716
 
2662
2717
  // src/spatial-react-components/Model3D/Model3DPortalInstance.tsx
2663
- var import_react25 = require("react");
2718
+ var import_react26 = require("react");
2664
2719
 
2665
2720
  // src/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.ts
2666
- var import_react24 = require("react");
2721
+ var import_react25 = require("react");
2667
2722
  function useSyncDomInfoFromStandardInstance(spatialId) {
2668
- const [domRect, setDomRect] = (0, import_react24.useState)({
2723
+ const [domRect, setDomRect] = (0, import_react25.useState)({
2669
2724
  x: 0,
2670
2725
  y: 0,
2671
2726
  width: 0,
2672
2727
  height: 0
2673
2728
  });
2674
- const inheritedPortalStyleRef = (0, import_react24.useRef)({});
2675
- const anchorRef = (0, import_react24.useRef)({
2729
+ const inheritedPortalStyleRef = (0, import_react25.useRef)({});
2730
+ const anchorRef = (0, import_react25.useRef)({
2676
2731
  x: 0.5,
2677
2732
  y: 0.5,
2678
2733
  z: 0.5
2679
2734
  });
2680
- const opacityRef = (0, import_react24.useRef)(1);
2681
- const spatialReactContextObject = (0, import_react24.useContext)(SpatialReactContext);
2682
- const inheritedPortalClassNameRef = (0, import_react24.useRef)("");
2683
- const modelRef = (0, import_react24.useRef)(null);
2684
- (0, import_react24.useEffect)(() => {
2735
+ const opacityRef = (0, import_react25.useRef)(1);
2736
+ const spatialReactContextObject = (0, import_react25.useContext)(SpatialReactContext);
2737
+ const inheritedPortalClassNameRef = (0, import_react25.useRef)("");
2738
+ const modelRef = (0, import_react25.useRef)(null);
2739
+ (0, import_react25.useEffect)(() => {
2685
2740
  const syncDomRect = /* @__PURE__ */ __name(() => {
2686
2741
  const dom = spatialReactContextObject?.querySpatialDom(spatialId);
2687
2742
  if (!dom) {
@@ -2723,7 +2778,7 @@ function useSyncDomInfoFromStandardInstance(spatialId) {
2723
2778
  __name(useSyncDomInfoFromStandardInstance, "useSyncDomInfoFromStandardInstance");
2724
2779
 
2725
2780
  // src/spatial-react-components/Model3D/Model3DPortalInstance.tsx
2726
- var import_jsx_runtime10 = require("react/jsx-runtime");
2781
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2727
2782
  function useModelEvents(props, modelRef) {
2728
2783
  const {
2729
2784
  onDragStart,
@@ -2733,7 +2788,7 @@ function useModelEvents(props, modelRef) {
2733
2788
  onDoubleTap,
2734
2789
  onLongPress
2735
2790
  } = props;
2736
- const onDragStartCb = (0, import_react25.useCallback)(
2791
+ const onDragStartCb = (0, import_react26.useCallback)(
2737
2792
  (spatialDragEvent) => {
2738
2793
  if (onDragStart) {
2739
2794
  const dragEvent = {
@@ -2745,7 +2800,7 @@ function useModelEvents(props, modelRef) {
2745
2800
  },
2746
2801
  [onDragStart]
2747
2802
  );
2748
- const onDragCb = (0, import_react25.useCallback)(
2803
+ const onDragCb = (0, import_react26.useCallback)(
2749
2804
  (spatialDragEvent) => {
2750
2805
  if (onDrag) {
2751
2806
  const dragEvent = {
@@ -2757,7 +2812,7 @@ function useModelEvents(props, modelRef) {
2757
2812
  },
2758
2813
  [onDrag]
2759
2814
  );
2760
- const onDragEndCb = (0, import_react25.useCallback)(
2815
+ const onDragEndCb = (0, import_react26.useCallback)(
2761
2816
  (spatialDragEvent) => {
2762
2817
  if (onDragEnd) {
2763
2818
  const dragEvent = {
@@ -2769,7 +2824,7 @@ function useModelEvents(props, modelRef) {
2769
2824
  },
2770
2825
  [onDragEnd]
2771
2826
  );
2772
- const onTapCb = (0, import_react25.useCallback)(() => {
2827
+ const onTapCb = (0, import_react26.useCallback)(() => {
2773
2828
  if (onTap) {
2774
2829
  const event = {
2775
2830
  target: modelRef.current
@@ -2777,7 +2832,7 @@ function useModelEvents(props, modelRef) {
2777
2832
  onTap(event);
2778
2833
  }
2779
2834
  }, [onTap]);
2780
- const onDoubleTapCb = (0, import_react25.useCallback)(() => {
2835
+ const onDoubleTapCb = (0, import_react26.useCallback)(() => {
2781
2836
  if (onDoubleTap) {
2782
2837
  const event = {
2783
2838
  target: modelRef.current
@@ -2785,7 +2840,7 @@ function useModelEvents(props, modelRef) {
2785
2840
  onDoubleTap(event);
2786
2841
  }
2787
2842
  }, [onDoubleTap]);
2788
- const onLongPressCb = (0, import_react25.useCallback)(() => {
2843
+ const onLongPressCb = (0, import_react26.useCallback)(() => {
2789
2844
  if (onLongPress) {
2790
2845
  const event = {
2791
2846
  target: modelRef.current
@@ -2815,7 +2870,7 @@ function renderModel3DPortalInstance(spatialId, props) {
2815
2870
  onLoad,
2816
2871
  children
2817
2872
  } = props;
2818
- const theSpatialTransform = (0, import_react25.useMemo)(() => {
2873
+ const theSpatialTransform = (0, import_react26.useMemo)(() => {
2819
2874
  return PopulatePartialSpatialTransformType(spatialTransform);
2820
2875
  }, [spatialTransform]);
2821
2876
  const {
@@ -2826,7 +2881,7 @@ function renderModel3DPortalInstance(spatialId, props) {
2826
2881
  opacity,
2827
2882
  className
2828
2883
  } = useSyncDomInfoFromStandardInstance(spatialId);
2829
- const parentSpatialWindowManager = (0, import_react25.useContext)(SpatialWindowManagerContext);
2884
+ const parentSpatialWindowManager = (0, import_react26.useContext)(SpatialWindowManagerContext);
2830
2885
  const eventHandlers = useModelEvents(
2831
2886
  props,
2832
2887
  modelRef
@@ -2836,7 +2891,7 @@ function renderModel3DPortalInstance(spatialId, props) {
2836
2891
  parentSpatialWindowManager.entity,
2837
2892
  eventHandlers
2838
2893
  );
2839
- (0, import_react25.useEffect)(() => {
2894
+ (0, import_react26.useEffect)(() => {
2840
2895
  if (model3DNativeRef.current) {
2841
2896
  model3DNativeRef.current.updateRectAndTransform(
2842
2897
  domRect,
@@ -2844,37 +2899,37 @@ function renderModel3DPortalInstance(spatialId, props) {
2844
2899
  );
2845
2900
  }
2846
2901
  }, [model3DNativeRef.current, domRect, theSpatialTransform]);
2847
- (0, import_react25.useEffect)(() => {
2902
+ (0, import_react26.useEffect)(() => {
2848
2903
  if (model3DNativeRef.current) {
2849
2904
  model3DNativeRef.current.setRotationAnchor(anchor);
2850
2905
  }
2851
2906
  }, [model3DNativeRef.current, anchor]);
2852
- (0, import_react25.useEffect)(() => {
2907
+ (0, import_react26.useEffect)(() => {
2853
2908
  if (model3DNativeRef.current) {
2854
2909
  model3DNativeRef.current.setVisible(visible);
2855
2910
  }
2856
2911
  }, [model3DNativeRef.current, visible]);
2857
- (0, import_react25.useEffect)(() => {
2912
+ (0, import_react26.useEffect)(() => {
2858
2913
  if (model3DNativeRef.current) {
2859
2914
  model3DNativeRef.current.setContentMode(contentMode);
2860
2915
  }
2861
2916
  }, [model3DNativeRef.current, contentMode]);
2862
- (0, import_react25.useEffect)(() => {
2917
+ (0, import_react26.useEffect)(() => {
2863
2918
  if (model3DNativeRef.current) {
2864
2919
  model3DNativeRef.current.setResizable(resizable);
2865
2920
  }
2866
2921
  }, [model3DNativeRef.current, resizable]);
2867
- (0, import_react25.useEffect)(() => {
2922
+ (0, import_react26.useEffect)(() => {
2868
2923
  if (model3DNativeRef.current) {
2869
2924
  model3DNativeRef.current.setAspectRatio(aspectRatio);
2870
2925
  }
2871
2926
  }, [model3DNativeRef.current, aspectRatio]);
2872
- (0, import_react25.useEffect)(() => {
2927
+ (0, import_react26.useEffect)(() => {
2873
2928
  if (model3DNativeRef.current) {
2874
2929
  model3DNativeRef.current.setOpacity(opacity);
2875
2930
  }
2876
2931
  }, [model3DNativeRef.current, opacity]);
2877
- const onSuccess = (0, import_react25.useCallback)(() => {
2932
+ const onSuccess = (0, import_react26.useCallback)(() => {
2878
2933
  ;
2879
2934
  modelRef.current.ready = true;
2880
2935
  if (onLoad) {
@@ -2883,7 +2938,7 @@ function renderModel3DPortalInstance(spatialId, props) {
2883
2938
  });
2884
2939
  }
2885
2940
  }, [onLoad]);
2886
- const onFailure = (0, import_react25.useCallback)(
2941
+ const onFailure = (0, import_react26.useCallback)(
2887
2942
  (_2) => {
2888
2943
  const modelElement = modelRef.current;
2889
2944
  modelElement.ready = false;
@@ -2895,14 +2950,14 @@ function renderModel3DPortalInstance(spatialId, props) {
2895
2950
  },
2896
2951
  [onLoad]
2897
2952
  );
2898
- (0, import_react25.useEffect)(() => {
2953
+ (0, import_react26.useEffect)(() => {
2899
2954
  if (phase === "failure") {
2900
2955
  onFailure(failureReason);
2901
2956
  } else if (phase === "success") {
2902
2957
  onSuccess();
2903
2958
  }
2904
2959
  }, [phase]);
2905
- (0, import_react25.useEffect)(() => {
2960
+ (0, import_react26.useEffect)(() => {
2906
2961
  return () => {
2907
2962
  const modelElement = modelRef.current;
2908
2963
  if (modelElement) {
@@ -2913,7 +2968,7 @@ function renderModel3DPortalInstance(spatialId, props) {
2913
2968
  }, [modelUrl]);
2914
2969
  const needRenderPlaceHolder = inheritedPortalStyle.position !== "absolute";
2915
2970
  if (!needRenderPlaceHolder && phase !== "failure") {
2916
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, {});
2971
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, {});
2917
2972
  } else {
2918
2973
  const extraStyle = {
2919
2974
  visibility: "visible",
@@ -2933,7 +2988,7 @@ function renderModel3DPortalInstance(spatialId, props) {
2933
2988
  ...inheritedPortalStyle,
2934
2989
  ...extraStyle
2935
2990
  };
2936
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2991
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2937
2992
  "div",
2938
2993
  {
2939
2994
  "data-model3d-spatialid": spatialId,
@@ -2948,12 +3003,12 @@ __name(renderModel3DPortalInstance, "renderModel3DPortalInstance");
2948
3003
 
2949
3004
  // src/spatial-react-components/Model3D/Model3D.tsx
2950
3005
  function Model3DBase(props, refIn) {
2951
- const parentSpatialReactContextObject = (0, import_react26.useContext)(SpatialReactContext);
3006
+ const parentSpatialReactContextObject = (0, import_react27.useContext)(SpatialReactContext);
2952
3007
  const isInSpatialDiv = !!parentSpatialReactContextObject;
2953
3008
  if (isInSpatialDiv) {
2954
- const layer = (0, import_react26.useContext)(SpatialLayerContext) + 1;
2955
- const isInStandardInstance = !!(0, import_react26.useContext)(SpatialIsStandardInstanceContext);
2956
- const spatialId = (0, import_react26.useMemo)(() => {
3009
+ const layer = (0, import_react27.useContext)(SpatialLayerContext) + 1;
3010
+ const isInStandardInstance = !!(0, import_react27.useContext)(SpatialIsStandardInstanceContext);
3011
+ const spatialId = (0, import_react27.useMemo)(() => {
2957
3012
  return parentSpatialReactContextObject.getSpatialID(
2958
3013
  layer,
2959
3014
  isInStandardInstance,
@@ -2970,14 +3025,14 @@ function Model3DBase(props, refIn) {
2970
3025
  }
2971
3026
  }
2972
3027
  __name(Model3DBase, "Model3DBase");
2973
- var Model3D = (0, import_react26.forwardRef)(Model3DBase);
3028
+ var Model3D = (0, import_react27.forwardRef)(Model3DBase);
2974
3029
  Model3D.displayName = "Model3D";
2975
3030
 
2976
3031
  // src/spatial-react-components/Model3D/CSSModel3D.tsx
2977
- var import_react29 = require("react");
3032
+ var import_react30 = require("react");
2978
3033
 
2979
3034
  // src/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.tsx
2980
- var import_jsx_runtime11 = require("react/jsx-runtime");
3035
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2981
3036
  function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
2982
3037
  const { className, style = {}, ...props } = inProps;
2983
3038
  const cssParserDomStyle = {
@@ -3000,8 +3055,8 @@ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
3000
3055
  ...style,
3001
3056
  transform: "none"
3002
3057
  };
3003
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
3004
- ready && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3058
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
3059
+ ready && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3005
3060
  Model3D,
3006
3061
  {
3007
3062
  className,
@@ -3012,7 +3067,7 @@ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
3012
3067
  ...props
3013
3068
  }
3014
3069
  ),
3015
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3070
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3016
3071
  "div",
3017
3072
  {
3018
3073
  className,
@@ -3025,8 +3080,8 @@ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
3025
3080
  __name(renderCSSModel3DNotInSpatialDiv, "renderCSSModel3DNotInSpatialDiv");
3026
3081
 
3027
3082
  // src/spatial-react-components/Model3D/CSSModel3DStandardInstance.tsx
3028
- var import_react27 = require("react");
3029
- var import_jsx_runtime12 = require("react/jsx-runtime");
3083
+ var import_react28 = require("react");
3084
+ var import_jsx_runtime13 = require("react/jsx-runtime");
3030
3085
  function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
3031
3086
  const { style: inStyle = {}, ...props } = inProps;
3032
3087
  const style = {
@@ -3034,13 +3089,13 @@ function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
3034
3089
  transform: "none",
3035
3090
  visibility: "hidden"
3036
3091
  };
3037
- var cssParserRef = (0, import_react27.useRef)(null);
3092
+ var cssParserRef = (0, import_react28.useRef)(null);
3038
3093
  const ref = useHijackSpatialDivRef(
3039
3094
  refIn,
3040
3095
  cssParserRef
3041
3096
  );
3042
- const rootSpatialReactContextObject = (0, import_react27.useContext)(SpatialReactContext);
3043
- (0, import_react27.useEffect)(() => {
3097
+ const rootSpatialReactContextObject = (0, import_react28.useContext)(SpatialReactContext);
3098
+ (0, import_react28.useEffect)(() => {
3044
3099
  const onSubEvent = /* @__PURE__ */ __name((dom) => {
3045
3100
  cssParserRef.current = dom;
3046
3101
  }, "onSubEvent");
@@ -3049,16 +3104,16 @@ function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
3049
3104
  rootSpatialReactContextObject.offSubDivEvent(spatialId);
3050
3105
  };
3051
3106
  }, []);
3052
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Model3D, { style, ...props, ref, visible: true });
3107
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Model3D, { style, ...props, ref, visible: true });
3053
3108
  }
3054
3109
  __name(renderCSSModel3DStandardInstance, "renderCSSModel3DStandardInstance");
3055
3110
 
3056
3111
  // src/spatial-react-components/Model3D/CSSModel3DPortalInstance.tsx
3057
- var import_react28 = require("react");
3058
- var import_jsx_runtime13 = require("react/jsx-runtime");
3112
+ var import_react29 = require("react");
3113
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3059
3114
  function renderCSSModel3DPortalInstance(spatialId, inProps) {
3060
3115
  const { className, style = {}, ...props } = inProps;
3061
- const rootSpatialReactContextObject = (0, import_react28.useContext)(SpatialReactContext);
3116
+ const rootSpatialReactContextObject = (0, import_react29.useContext)(SpatialReactContext);
3062
3117
  const { ref, spatialStyle, ready } = useSpatialStyle();
3063
3118
  const spatialTransform = {
3064
3119
  position: spatialStyle.position,
@@ -3066,7 +3121,7 @@ function renderCSSModel3DPortalInstance(spatialId, inProps) {
3066
3121
  scale: spatialStyle.scale
3067
3122
  };
3068
3123
  const visible = spatialStyle.visible;
3069
- (0, import_react28.useEffect)(() => {
3124
+ (0, import_react29.useEffect)(() => {
3070
3125
  rootSpatialReactContextObject.notifySubDivEvent(spatialId, ref.current);
3071
3126
  }, [ref.current]);
3072
3127
  const cssParserDomStyle = {
@@ -3078,8 +3133,8 @@ function renderCSSModel3DPortalInstance(spatialId, inProps) {
3078
3133
  ...style,
3079
3134
  transform: "none"
3080
3135
  };
3081
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
3082
- ready && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3136
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
3137
+ ready && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3083
3138
  Model3D,
3084
3139
  {
3085
3140
  className,
@@ -3089,19 +3144,19 @@ function renderCSSModel3DPortalInstance(spatialId, inProps) {
3089
3144
  ...props
3090
3145
  }
3091
3146
  ),
3092
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className, style: cssParserDomStyle, ref })
3147
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className, style: cssParserDomStyle, ref })
3093
3148
  ] });
3094
3149
  }
3095
3150
  __name(renderCSSModel3DPortalInstance, "renderCSSModel3DPortalInstance");
3096
3151
 
3097
3152
  // src/spatial-react-components/Model3D/CSSModel3D.tsx
3098
3153
  function CSSModel3DBase(props, refIn) {
3099
- const rootSpatialReactContextObject = (0, import_react29.useContext)(SpatialReactContext);
3154
+ const rootSpatialReactContextObject = (0, import_react30.useContext)(SpatialReactContext);
3100
3155
  const isInSpatialDiv = !!rootSpatialReactContextObject;
3101
3156
  if (isInSpatialDiv) {
3102
- const layer = (0, import_react29.useContext)(SpatialLayerContext) + 1;
3103
- const isInStandardInstance = !!(0, import_react29.useContext)(SpatialIsStandardInstanceContext);
3104
- const spatialId = (0, import_react29.useMemo)(() => {
3157
+ const layer = (0, import_react30.useContext)(SpatialLayerContext) + 1;
3158
+ const isInStandardInstance = !!(0, import_react30.useContext)(SpatialIsStandardInstanceContext);
3159
+ const spatialId = (0, import_react30.useMemo)(() => {
3105
3160
  return rootSpatialReactContextObject.getSubDivSpatialID(
3106
3161
  layer,
3107
3162
  isInStandardInstance,
@@ -3118,65 +3173,10 @@ function CSSModel3DBase(props, refIn) {
3118
3173
  }
3119
3174
  }
3120
3175
  __name(CSSModel3DBase, "CSSModel3DBase");
3121
- var CSSModel3D = (0, import_react29.forwardRef)(CSSModel3DBase);
3176
+ var CSSModel3D = (0, import_react30.forwardRef)(CSSModel3DBase);
3122
3177
  CSSModel3D.displayName = "CSSModel3D";
3123
3178
 
3124
- // src/spatial-react-components/SpatialView.tsx
3125
- var import_core_sdk2 = require("@webspatial/core-sdk");
3126
- var import_react30 = require("react");
3127
- var import_jsx_runtime14 = require("react/jsx-runtime");
3128
- var runAsync = /* @__PURE__ */ __name((fn) => {
3129
- return fn();
3130
- }, "runAsync");
3131
- var SpatialViewEl = (0, import_react30.forwardRef)(
3132
- (props, ref) => {
3133
- const divRef = (0, import_react30.useRef)(null);
3134
- const spatialEntity = (0, import_react30.useRef)(null);
3135
- const activePromise = (0, import_react30.useRef)(null);
3136
- (0, import_react30.useImperativeHandle)(ref, () => ({
3137
- ...divRef.current,
3138
- getViewEntity: /* @__PURE__ */ __name(async () => {
3139
- if (activePromise.current) {
3140
- await activePromise.current;
3141
- }
3142
- return spatialEntity.current;
3143
- }, "getViewEntity")
3144
- }));
3145
- if (getSession() == null) {
3146
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
3147
- }
3148
- (0, import_react30.useEffect)(() => {
3149
- if (false) return;
3150
- activePromise.current = runAsync(async () => {
3151
- if (activePromise.current) {
3152
- await activePromise.current;
3153
- }
3154
- let sh = new import_core_sdk2.SpatialHelper(getSession());
3155
- let x = await sh.dom.attachSpatialView(divRef.current);
3156
- spatialEntity.current = x.entity;
3157
- if (props.onViewLoad) {
3158
- props.onViewLoad(x.entity);
3159
- }
3160
- });
3161
- return () => {
3162
- if (false) return;
3163
- runAsync(async () => {
3164
- await activePromise.current;
3165
- spatialEntity.current?.destroy();
3166
- if (props.onViewUnload) {
3167
- props.onViewUnload();
3168
- }
3169
- });
3170
- };
3171
- }, []);
3172
- const { onViewLoad, onViewUnload, ...divProps } = props;
3173
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...divProps });
3174
- }
3175
- );
3176
- var SpatialView = SpatialViewEl;
3177
-
3178
3179
  // src/spatial-react-components/Model/index.tsx
3179
- var import_react31 = require("react");
3180
3180
  var import_model_viewer = require("@google/model-viewer");
3181
3181
  var import_jsx_runtime15 = require("react/jsx-runtime");
3182
3182
  function renderInModel3D(inProps, ref, modelUrl, placeHolder) {