@gnsx/react-three-fiber 10.0.2 → 10.0.4

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019-2025 Poimandres
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019-2025 Poimandres
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -3453,7 +3453,7 @@ function advance(timestamp) {
3453
3453
  getScheduler().step(timestamp);
3454
3454
  }
3455
3455
 
3456
- const version = "10.0.1";
3456
+ const version = "10.0.4";
3457
3457
  const packageData = {
3458
3458
  version: version};
3459
3459
 
@@ -15210,6 +15210,7 @@ function createRoot(canvas) {
15210
15210
  let pending = null;
15211
15211
  return {
15212
15212
  async configure(props = {}) {
15213
+ if (pending) await pending;
15213
15214
  let resolve;
15214
15215
  pending = new Promise((_resolve) => resolve = _resolve);
15215
15216
  const {
@@ -15506,8 +15507,10 @@ function createRoot(canvas) {
15506
15507
  const unregisterCanvasTarget = scheduler.register(
15507
15508
  () => {
15508
15509
  const state2 = store.getState();
15510
+ if (!state2.internal.active) return;
15509
15511
  if (state2.internal.isMultiCanvas && state2.internal.canvasTarget) {
15510
15512
  const renderer2 = state2.internal.actualRenderer;
15513
+ if (!renderer2) return;
15511
15514
  renderer2.setCanvasTarget(state2.internal.canvasTarget);
15512
15515
  }
15513
15516
  },
@@ -15560,7 +15563,9 @@ function createRoot(canvas) {
15560
15563
  const unregisterRender = scheduler.register(
15561
15564
  () => {
15562
15565
  const state2 = store.getState();
15566
+ if (!state2.internal.active) return;
15563
15567
  const renderer2 = state2.internal.actualRenderer;
15568
+ if (!renderer2) return;
15564
15569
  const userHandlesRender = scheduler.hasUserJobsInPhase("render", newRootId);
15565
15570
  if (userHandlesRender || state2.internal.priority) return;
15566
15571
  try {
@@ -15635,23 +15640,62 @@ function Provider({
15635
15640
  }, []);
15636
15641
  return /* @__PURE__ */ jsxRuntime.jsx(context.Provider, { value: store, children });
15637
15642
  }
15643
+ function releaseSceneR3fLinks(scene, options) {
15644
+ if (!scene) return null;
15645
+ scene.traverse((obj) => {
15646
+ delete obj.__r3f;
15647
+ });
15648
+ delete scene.__r3f;
15649
+ {
15650
+ scene.clear();
15651
+ }
15652
+ return scene;
15653
+ }
15654
+ function releaseRendererRefsFromRootState(state) {
15655
+ const { internal } = state;
15656
+ const renderer = internal.actualRenderer ?? null;
15657
+ internal.actualRenderer = null;
15658
+ internal.canvasTarget = null;
15659
+ internal.pointerMap?.clear();
15660
+ internal.pointerDirty?.clear();
15661
+ return renderer;
15662
+ }
15663
+ function detachRootSceneFromRootState(state) {
15664
+ const scene = releaseSceneR3fLinks(state.scene);
15665
+ state.set((prev) => ({
15666
+ scene: null,
15667
+ rootScene: null,
15668
+ internal: { ...prev.internal, container: null }
15669
+ }));
15670
+ return scene;
15671
+ }
15638
15672
  function unmountComponentAtNode(canvas, callback) {
15639
15673
  const root = _roots.get(canvas);
15640
15674
  const fiber = root?.fiber;
15641
15675
  if (fiber) {
15642
15676
  const state = root?.store.getState();
15643
- if (state) state.internal.active = false;
15677
+ let rendererForCleanup = null;
15678
+ let canvasTargetForCleanup;
15679
+ let sceneForCleanup = null;
15680
+ if (state) {
15681
+ state.internal.active = false;
15682
+ canvasTargetForCleanup = state.internal.canvasTarget;
15683
+ rendererForCleanup = releaseRendererRefsFromRootState(state);
15684
+ const unregisterRoot = state.internal.unregisterRoot;
15685
+ if (unregisterRoot) {
15686
+ unregisterRoot();
15687
+ state.internal.unregisterRoot = void 0;
15688
+ }
15689
+ }
15644
15690
  reconciler.updateContainer(null, fiber, null, () => {
15645
15691
  if (state) {
15692
+ sceneForCleanup = detachRootSceneFromRootState(state);
15646
15693
  setTimeout(() => {
15647
15694
  try {
15648
- const renderer = state.internal.actualRenderer;
15649
- const unregisterRoot = state.internal.unregisterRoot;
15650
- if (unregisterRoot) unregisterRoot();
15695
+ const renderer = rendererForCleanup;
15651
15696
  const unregisterPrimary = state.internal.unregisterPrimary;
15652
15697
  if (unregisterPrimary) unregisterPrimary();
15653
- const canvasTarget = state.internal.canvasTarget;
15654
- if (canvasTarget?.dispose) canvasTarget.dispose();
15698
+ if (canvasTargetForCleanup?.dispose) canvasTargetForCleanup.dispose();
15655
15699
  state.events.disconnect?.();
15656
15700
  cleanupHelperGroup(root.store);
15657
15701
  if (state.isLegacy && renderer) {
@@ -15662,7 +15706,7 @@ function unmountComponentAtNode(canvas, callback) {
15662
15706
  if (!state.internal.isSecondary) {
15663
15707
  if (renderer?.xr) state.xr.disconnect();
15664
15708
  }
15665
- dispose(state.scene);
15709
+ if (sceneForCleanup) dispose(sceneForCleanup);
15666
15710
  _roots.delete(canvas);
15667
15711
  if (callback) callback(canvas);
15668
15712
  } catch {