@react-three/fiber 10.0.0-canary.f75fbf6 → 10.0.0-canary.fbd44ae

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.
Files changed (34) hide show
  1. package/dist/extension.cjs +8 -8
  2. package/dist/extension.d.cts +4 -4
  3. package/dist/extension.d.mts +4 -4
  4. package/dist/extension.d.ts +4 -4
  5. package/dist/extension.mjs +1 -1
  6. package/dist/index.cjs +13 -13
  7. package/dist/index.d.cts +6 -6
  8. package/dist/index.d.mts +6 -6
  9. package/dist/index.d.ts +6 -6
  10. package/dist/index.mjs +3 -3
  11. package/dist/legacy.cjs +13 -13
  12. package/dist/legacy.d.cts +10 -7
  13. package/dist/legacy.d.mts +10 -7
  14. package/dist/legacy.d.ts +10 -7
  15. package/dist/legacy.mjs +4 -4
  16. package/dist/shared/{fiber.DH-VJXM_.d.ts → fiber.3jeDXXYd.d.mts} +82 -458
  17. package/dist/shared/{fiber.AN9kOS0N.d.mts → fiber.B_KQAb3I.d.ts} +82 -458
  18. package/dist/shared/{fiber.EDf0d92E.cjs → fiber.Bi_S5KAx.cjs} +2213 -1675
  19. package/dist/shared/{fiber.BgP4izaL.d.cts → fiber.C6hitYDY.d.cts} +1 -1
  20. package/dist/shared/{fiber.BgxhptM_.mjs → fiber.CFK811nR.mjs} +2099 -1561
  21. package/dist/shared/{fiber.Dh8K6RJr.d.cts → fiber.C_MFx7We.d.cts} +472 -20
  22. package/dist/shared/{fiber.Dh8K6RJr.d.mts → fiber.C_MFx7We.d.mts} +472 -20
  23. package/dist/shared/{fiber.Dh8K6RJr.d.ts → fiber.C_MFx7We.d.ts} +472 -20
  24. package/dist/shared/{fiber.BcX0-yko.d.mts → fiber.D4fD6H74.d.mts} +1 -1
  25. package/dist/shared/{fiber.B0oukOFO.mjs → fiber.QxL_6jra.mjs} +80 -54
  26. package/dist/shared/{fiber.BIhZnMzg.d.ts → fiber.YgTUGbja.d.ts} +1 -1
  27. package/dist/shared/{fiber.khFlPHPf.cjs → fiber.eR9ie2vQ.cjs} +80 -52
  28. package/dist/shared/{fiber.cO-9hDzr.d.cts → fiber.fR3DaJb1.d.cts} +82 -458
  29. package/dist/webgpu/index.cjs +13 -13
  30. package/dist/webgpu/index.d.cts +5 -5
  31. package/dist/webgpu/index.d.mts +5 -5
  32. package/dist/webgpu/index.d.ts +5 -5
  33. package/dist/webgpu/index.mjs +4 -4
  34. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useContext } from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
- import { useFiber, useContextBridge, traverseFiber } from 'its-fine';
4
+ import { useFiber, useContextBridge, useActivityBridge as useActivityBridge$1, traverseFiber } from 'its-fine';
5
5
  import { getScheduler } from '@pmndrs/scheduler';
6
6
 
7
7
  var __defProp = Object.defineProperty;
@@ -13,16 +13,18 @@ function useMutableCallback(fn) {
13
13
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
14
14
  return ref;
15
15
  }
16
+ const useActivityBridge = React["Activity"] ? useActivityBridge$1 : () => React.Fragment;
16
17
  function useBridge() {
17
18
  const fiber = useFiber();
18
19
  const ContextBridge = useContextBridge();
20
+ const ActivityBridge = useActivityBridge();
19
21
  return React.useMemo(
20
22
  () => ({ children }) => {
21
23
  const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
22
24
  const Root = strict ? React.StrictMode : React.Fragment;
23
- return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
25
+ return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ActivityBridge, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) }) });
24
26
  },
25
- [fiber, ContextBridge]
27
+ [fiber, ContextBridge, ActivityBridge]
26
28
  );
27
29
  }
28
30
  function Block({ set }) {
@@ -47,6 +49,23 @@ const ErrorBoundary = /* @__PURE__ */ (() => {
47
49
  }
48
50
  }, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
49
51
  })();
52
+ const noop = () => {
53
+ };
54
+ function Gate({ promise, onSettled }) {
55
+ React.use(promise);
56
+ useIsomorphicLayoutEffect(onSettled, [onSettled]);
57
+ return null;
58
+ }
59
+ function useGate() {
60
+ const [promise, setPromise] = React.useState(null);
61
+ const onSettled = React.useCallback(() => setPromise(null), []);
62
+ const waitFor = React.useCallback(
63
+ (next) => setPromise((current) => current ?? Promise.resolve(next).then(noop, noop)),
64
+ []
65
+ );
66
+ const gate = promise ? /* @__PURE__ */ jsx(React.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Gate, { promise, onSettled }) }) : null;
67
+ return [gate, waitFor];
68
+ }
50
69
 
51
70
  const shownNotices = /* @__PURE__ */ new Set();
52
71
  function notifyDepreciated({ heading, body, link }) {
@@ -104,10 +123,67 @@ function notifyAlpha({ message, link }) {
104
123
  console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
105
124
  }
106
125
  }
126
+ function isDevelopment() {
127
+ try {
128
+ return process.env.NODE_ENV !== "production";
129
+ } catch {
130
+ return true;
131
+ }
132
+ }
107
133
 
108
134
  const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
109
135
  const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
110
136
 
137
+ const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
138
+ function getRegistry() {
139
+ return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
140
+ extensions: /* @__PURE__ */ new Map(),
141
+ roots: /* @__PURE__ */ new Set(),
142
+ applied: /* @__PURE__ */ new WeakMap()
143
+ });
144
+ }
145
+ function setupRoot(registry, store, extension) {
146
+ let applied = registry.applied.get(store);
147
+ if (!applied) registry.applied.set(store, applied = /* @__PURE__ */ new Map());
148
+ if (applied.has(extension.name)) return;
149
+ applied.set(extension.name, extension);
150
+ const patch = extension.setup?.(store);
151
+ if (patch) store.setState(patch);
152
+ }
153
+ function registerRootExtension(extension) {
154
+ const registry = getRegistry();
155
+ registry.extensions.set(extension.name, extension);
156
+ for (const store of registry.roots) setupRoot(registry, store, extension);
157
+ return () => {
158
+ if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
159
+ };
160
+ }
161
+ function setRenderOverride(store, render) {
162
+ store.getState().internal.renderOverride = render;
163
+ }
164
+ function attachRootExtensions(store) {
165
+ const registry = getRegistry();
166
+ registry.roots.add(store);
167
+ for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
168
+ }
169
+ function current(registry, setUpBy) {
170
+ return registry.extensions.get(setUpBy.name) ?? setUpBy;
171
+ }
172
+ function detachRootExtensions(store) {
173
+ const registry = getRegistry();
174
+ if (!registry.roots.delete(store)) return;
175
+ const applied = registry.applied.get(store);
176
+ registry.applied.delete(store);
177
+ if (!applied) return;
178
+ for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
179
+ }
180
+ function notifyRootExtensionsHmr(store) {
181
+ const registry = getRegistry();
182
+ const applied = registry.applied.get(store);
183
+ if (!applied) return;
184
+ for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
185
+ }
186
+
111
187
  function useStore() {
112
188
  const store = useContext(context);
113
189
  if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
@@ -311,54 +387,4 @@ function getTextureView(store) {
311
387
  return view;
312
388
  }
313
389
 
314
- const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
315
- function getRegistry() {
316
- return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
317
- extensions: /* @__PURE__ */ new Map(),
318
- roots: /* @__PURE__ */ new Set(),
319
- applied: /* @__PURE__ */ new WeakMap()
320
- });
321
- }
322
- function setupRoot(registry, store, extension) {
323
- let applied = registry.applied.get(store);
324
- if (!applied) registry.applied.set(store, applied = /* @__PURE__ */ new Map());
325
- if (applied.has(extension.name)) return;
326
- applied.set(extension.name, extension);
327
- const patch = extension.setup?.(store);
328
- if (patch) store.setState(patch);
329
- }
330
- function registerRootExtension(extension) {
331
- const registry = getRegistry();
332
- registry.extensions.set(extension.name, extension);
333
- for (const store of registry.roots) setupRoot(registry, store, extension);
334
- return () => {
335
- if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
336
- };
337
- }
338
- function setRenderOverride(store, render) {
339
- store.getState().internal.renderOverride = render;
340
- }
341
- function attachRootExtensions(store) {
342
- const registry = getRegistry();
343
- registry.roots.add(store);
344
- for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
345
- }
346
- function current(registry, setUpBy) {
347
- return registry.extensions.get(setUpBy.name) ?? setUpBy;
348
- }
349
- function detachRootExtensions(store) {
350
- const registry = getRegistry();
351
- if (!registry.roots.delete(store)) return;
352
- const applied = registry.applied.get(store);
353
- registry.applied.delete(store);
354
- if (!applied) return;
355
- for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
356
- }
357
- function notifyRootExtensionsHmr(store) {
358
- const registry = getRegistry();
359
- const applied = registry.applied.get(store);
360
- if (!applied) return;
361
- for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
362
- }
363
-
364
- export { Block as B, ErrorBoundary as E, useThree as a, useFrame as b, context as c, useIsomorphicLayoutEffect as d, useMutableCallback as e, useBridge as f, getTextureView as g, unstageTextures as h, stageTextures as i, detachRootExtensions as j, attachRootExtensions as k, notifyAlpha as l, notifyRootExtensionsHmr as m, notifyDepreciated as n, registerRootExtension as r, setRenderOverride as s, useStore as u };
390
+ export { Block as B, ErrorBoundary as E, useThree as a, useFrame as b, context as c, useIsomorphicLayoutEffect as d, useMutableCallback as e, useBridge as f, getTextureView as g, detachRootExtensions as h, isDevelopment as i, attachRootExtensions as j, unstageTextures as k, stageTextures as l, useGate as m, notifyDepreciated as n, notifyAlpha as o, notifyRootExtensionsHmr as p, registerRootExtension as r, setRenderOverride as s, useStore as u };
@@ -1,4 +1,4 @@
1
- import { a3 as FrameNextCallback } from './fiber.Dh8K6RJr.js';
1
+ import { aO as FrameNextCallback } from './fiber.C_MFx7We.js';
2
2
  import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
3
3
 
4
4
  /**
@@ -28,16 +28,18 @@ function useMutableCallback(fn) {
28
28
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
29
29
  return ref;
30
30
  }
31
+ const useActivityBridge = React__namespace["Activity"] ? itsFine.useActivityBridge : () => React__namespace.Fragment;
31
32
  function useBridge() {
32
33
  const fiber = itsFine.useFiber();
33
34
  const ContextBridge = itsFine.useContextBridge();
35
+ const ActivityBridge = useActivityBridge();
34
36
  return React__namespace.useMemo(
35
37
  () => ({ children }) => {
36
38
  const strict = !!itsFine.traverseFiber(fiber, true, (node) => node.type === React__namespace.StrictMode);
37
39
  const Root = strict ? React__namespace.StrictMode : React__namespace.Fragment;
38
- return /* @__PURE__ */ jsxRuntime.jsx(Root, { children: /* @__PURE__ */ jsxRuntime.jsx(ContextBridge, { children }) });
40
+ return /* @__PURE__ */ jsxRuntime.jsx(Root, { children: /* @__PURE__ */ jsxRuntime.jsx(ActivityBridge, { children: /* @__PURE__ */ jsxRuntime.jsx(ContextBridge, { children }) }) });
39
41
  },
40
- [fiber, ContextBridge]
42
+ [fiber, ContextBridge, ActivityBridge]
41
43
  );
42
44
  }
43
45
  function Block({ set }) {
@@ -62,6 +64,23 @@ const ErrorBoundary = /* @__PURE__ */ (() => {
62
64
  }
63
65
  }, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
64
66
  })();
67
+ const noop = () => {
68
+ };
69
+ function Gate({ promise, onSettled }) {
70
+ React__namespace.use(promise);
71
+ useIsomorphicLayoutEffect(onSettled, [onSettled]);
72
+ return null;
73
+ }
74
+ function useGate() {
75
+ const [promise, setPromise] = React__namespace.useState(null);
76
+ const onSettled = React__namespace.useCallback(() => setPromise(null), []);
77
+ const waitFor = React__namespace.useCallback(
78
+ (next) => setPromise((current) => current ?? Promise.resolve(next).then(noop, noop)),
79
+ []
80
+ );
81
+ const gate = promise ? /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(Gate, { promise, onSettled }) }) : null;
82
+ return [gate, waitFor];
83
+ }
65
84
 
66
85
  const shownNotices = /* @__PURE__ */ new Set();
67
86
  function notifyDepreciated({ heading, body, link }) {
@@ -119,10 +138,67 @@ function notifyAlpha({ message, link }) {
119
138
  console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
120
139
  }
121
140
  }
141
+ function isDevelopment() {
142
+ try {
143
+ return process.env.NODE_ENV !== "production";
144
+ } catch {
145
+ return true;
146
+ }
147
+ }
122
148
 
123
149
  const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
124
150
  const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React__namespace.createContext(null));
125
151
 
152
+ const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
153
+ function getRegistry() {
154
+ return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
155
+ extensions: /* @__PURE__ */ new Map(),
156
+ roots: /* @__PURE__ */ new Set(),
157
+ applied: /* @__PURE__ */ new WeakMap()
158
+ });
159
+ }
160
+ function setupRoot(registry, store, extension) {
161
+ let applied = registry.applied.get(store);
162
+ if (!applied) registry.applied.set(store, applied = /* @__PURE__ */ new Map());
163
+ if (applied.has(extension.name)) return;
164
+ applied.set(extension.name, extension);
165
+ const patch = extension.setup?.(store);
166
+ if (patch) store.setState(patch);
167
+ }
168
+ function registerRootExtension(extension) {
169
+ const registry = getRegistry();
170
+ registry.extensions.set(extension.name, extension);
171
+ for (const store of registry.roots) setupRoot(registry, store, extension);
172
+ return () => {
173
+ if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
174
+ };
175
+ }
176
+ function setRenderOverride(store, render) {
177
+ store.getState().internal.renderOverride = render;
178
+ }
179
+ function attachRootExtensions(store) {
180
+ const registry = getRegistry();
181
+ registry.roots.add(store);
182
+ for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
183
+ }
184
+ function current(registry, setUpBy) {
185
+ return registry.extensions.get(setUpBy.name) ?? setUpBy;
186
+ }
187
+ function detachRootExtensions(store) {
188
+ const registry = getRegistry();
189
+ if (!registry.roots.delete(store)) return;
190
+ const applied = registry.applied.get(store);
191
+ registry.applied.delete(store);
192
+ if (!applied) return;
193
+ for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
194
+ }
195
+ function notifyRootExtensionsHmr(store) {
196
+ const registry = getRegistry();
197
+ const applied = registry.applied.get(store);
198
+ if (!applied) return;
199
+ for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
200
+ }
201
+
126
202
  function useStore() {
127
203
  const store = React.useContext(context);
128
204
  if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
@@ -326,62 +402,13 @@ function getTextureView(store) {
326
402
  return view;
327
403
  }
328
404
 
329
- const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
330
- function getRegistry() {
331
- return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
332
- extensions: /* @__PURE__ */ new Map(),
333
- roots: /* @__PURE__ */ new Set(),
334
- applied: /* @__PURE__ */ new WeakMap()
335
- });
336
- }
337
- function setupRoot(registry, store, extension) {
338
- let applied = registry.applied.get(store);
339
- if (!applied) registry.applied.set(store, applied = /* @__PURE__ */ new Map());
340
- if (applied.has(extension.name)) return;
341
- applied.set(extension.name, extension);
342
- const patch = extension.setup?.(store);
343
- if (patch) store.setState(patch);
344
- }
345
- function registerRootExtension(extension) {
346
- const registry = getRegistry();
347
- registry.extensions.set(extension.name, extension);
348
- for (const store of registry.roots) setupRoot(registry, store, extension);
349
- return () => {
350
- if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
351
- };
352
- }
353
- function setRenderOverride(store, render) {
354
- store.getState().internal.renderOverride = render;
355
- }
356
- function attachRootExtensions(store) {
357
- const registry = getRegistry();
358
- registry.roots.add(store);
359
- for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
360
- }
361
- function current(registry, setUpBy) {
362
- return registry.extensions.get(setUpBy.name) ?? setUpBy;
363
- }
364
- function detachRootExtensions(store) {
365
- const registry = getRegistry();
366
- if (!registry.roots.delete(store)) return;
367
- const applied = registry.applied.get(store);
368
- registry.applied.delete(store);
369
- if (!applied) return;
370
- for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
371
- }
372
- function notifyRootExtensionsHmr(store) {
373
- const registry = getRegistry();
374
- const applied = registry.applied.get(store);
375
- if (!applied) return;
376
- for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
377
- }
378
-
379
405
  exports.Block = Block;
380
406
  exports.ErrorBoundary = ErrorBoundary;
381
407
  exports.attachRootExtensions = attachRootExtensions;
382
408
  exports.context = context;
383
409
  exports.detachRootExtensions = detachRootExtensions;
384
410
  exports.getTextureView = getTextureView;
411
+ exports.isDevelopment = isDevelopment;
385
412
  exports.notifyAlpha = notifyAlpha;
386
413
  exports.notifyDepreciated = notifyDepreciated;
387
414
  exports.notifyRootExtensionsHmr = notifyRootExtensionsHmr;
@@ -391,6 +418,7 @@ exports.stageTextures = stageTextures;
391
418
  exports.unstageTextures = unstageTextures;
392
419
  exports.useBridge = useBridge;
393
420
  exports.useFrame = useFrame;
421
+ exports.useGate = useGate;
394
422
  exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
395
423
  exports.useMutableCallback = useMutableCallback;
396
424
  exports.useStore = useStore;