@react-three/fiber 10.0.0-canary.f81281f → 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.
- package/dist/extension.cjs +8 -7
- package/dist/extension.d.cts +10 -47
- package/dist/extension.d.mts +10 -47
- package/dist/extension.d.ts +10 -47
- package/dist/extension.mjs +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.d.cts +8 -9
- package/dist/index.d.mts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.mjs +3 -3
- package/dist/legacy.cjs +13 -13
- package/dist/legacy.d.cts +10 -7
- package/dist/legacy.d.mts +10 -7
- package/dist/legacy.d.ts +10 -7
- package/dist/legacy.mjs +4 -4
- package/dist/shared/{fiber.DAg-9ieU.d.ts → fiber.3jeDXXYd.d.mts} +183 -542
- package/dist/shared/{fiber.Ddgoyqql.d.mts → fiber.B_KQAb3I.d.ts} +183 -542
- package/dist/shared/fiber.Bi_S5KAx.cjs +16630 -0
- package/dist/shared/fiber.C6hitYDY.d.cts +48 -0
- package/dist/shared/fiber.CFK811nR.mjs +16532 -0
- package/dist/shared/{fiber.Bw8YnGg5.d.ts → fiber.C_MFx7We.d.cts} +555 -19
- package/dist/shared/{fiber.Bw8YnGg5.d.cts → fiber.C_MFx7We.d.mts} +555 -19
- package/dist/shared/{fiber.Bw8YnGg5.d.mts → fiber.C_MFx7We.d.ts} +555 -19
- package/dist/shared/fiber.D4fD6H74.d.mts +48 -0
- package/dist/shared/{fiber.C_v1rkNg.mjs → fiber.QxL_6jra.mjs} +113 -52
- package/dist/shared/fiber.YgTUGbja.d.ts +48 -0
- package/dist/shared/{fiber.B6zNSmwj.cjs → fiber.eR9ie2vQ.cjs} +116 -50
- package/dist/shared/{fiber.DiPB625B.d.cts → fiber.fR3DaJb1.d.cts} +183 -542
- package/dist/webgpu/index.cjs +13 -13
- package/dist/webgpu/index.d.cts +5 -6
- package/dist/webgpu/index.d.mts +5 -6
- package/dist/webgpu/index.d.ts +5 -6
- package/dist/webgpu/index.mjs +4 -4
- package/package.json +7 -7
- package/readme.md +1 -1
- package/dist/shared/fiber.BGL2rpse.cjs +0 -15129
- package/dist/shared/fiber.Ch4JrXS2.mjs +0 -15031
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { aO as FrameNextCallback } from './fiber.C_MFx7We.mjs';
|
|
2
|
+
import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
6
|
+
*
|
|
7
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
8
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
9
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
10
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
11
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
12
|
+
*
|
|
13
|
+
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
14
|
+
*
|
|
15
|
+
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
16
|
+
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
17
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Simple priority (backwards compat)
|
|
21
|
+
* useFrame((state, delta) => { ... }, 5)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // With phase-based ordering
|
|
25
|
+
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
29
|
+
* function UI() {
|
|
30
|
+
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
31
|
+
* return <button>...</button>;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
36
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
37
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Scheduler-only access (no callback)
|
|
41
|
+
* const { scheduler } = useFrame()
|
|
42
|
+
* scheduler.pauseJob('some-job-id')
|
|
43
|
+
*
|
|
44
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
45
|
+
*/
|
|
46
|
+
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
47
|
+
|
|
48
|
+
export { useFrame as u };
|
|
@@ -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!");
|
|
@@ -138,8 +214,16 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
138
214
|
const id = options.id ?? reactId;
|
|
139
215
|
const callbackRef = useMutableCallback(callback);
|
|
140
216
|
const isLegacyPriority = typeof priorityOrOptions === "number" && priorityOrOptions > 0;
|
|
217
|
+
const isLegacyOrdering = typeof priorityOrOptions === "number" && priorityOrOptions < 0;
|
|
141
218
|
useIsomorphicLayoutEffect(() => {
|
|
142
219
|
if (!callback) return;
|
|
220
|
+
if (isLegacyOrdering) {
|
|
221
|
+
notifyDepreciated({
|
|
222
|
+
heading: "useFrame numeric priority order is reversed in v10",
|
|
223
|
+
body: "useFrame(callback, number) is deprecated and its ordering direction is reversed from v9: v9 ran lower numbers first, v10 maps the number to { priority } and runs higher numbers first, so a negative priority now runs after default-priority jobs.\n\nUse { before, after } to name the dependency, or { priority } with the v10 direction (higher = earlier).",
|
|
224
|
+
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
225
|
+
});
|
|
226
|
+
}
|
|
143
227
|
if (isInsideCanvas) {
|
|
144
228
|
const state = store.getState();
|
|
145
229
|
const rootId = state.internal.rootId;
|
|
@@ -153,7 +237,7 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
153
237
|
}
|
|
154
238
|
notifyDepreciated({
|
|
155
239
|
heading: "useFrame with numeric priority is deprecated",
|
|
156
|
-
body: 'Using useFrame(callback, number) to control render order is deprecated.\n\nFor custom rendering, use: useFrame(callback, { phase: "render" })\nFor execution order within
|
|
240
|
+
body: 'Using useFrame(callback, number) to control render order is deprecated.\n\nFor custom rendering, use: useFrame(callback, { phase: "render" })\nFor execution order within a phase, use: useFrame(callback, { priority: number }) \u2014 higher runs first, the reverse of v9',
|
|
157
241
|
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
158
242
|
});
|
|
159
243
|
}
|
|
@@ -198,7 +282,7 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
198
282
|
{ id, ...options }
|
|
199
283
|
);
|
|
200
284
|
}
|
|
201
|
-
}, [store, scheduler, id, optionsKey, isLegacyPriority, isInsideCanvas]);
|
|
285
|
+
}, [store, scheduler, id, optionsKey, isLegacyPriority, isLegacyOrdering, isInsideCanvas]);
|
|
202
286
|
const isPaused = React.useSyncExternalStore(
|
|
203
287
|
// Subscribe function
|
|
204
288
|
React.useCallback(
|
|
@@ -276,54 +360,31 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
276
360
|
return controls;
|
|
277
361
|
}
|
|
278
362
|
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (applied.has(extension.name)) return;
|
|
291
|
-
applied.set(extension.name, extension);
|
|
292
|
-
const patch = extension.setup?.(store);
|
|
293
|
-
if (patch) store.setState(patch);
|
|
294
|
-
}
|
|
295
|
-
function registerRootExtension(extension) {
|
|
296
|
-
const registry = getRegistry();
|
|
297
|
-
registry.extensions.set(extension.name, extension);
|
|
298
|
-
for (const store of registry.roots) setupRoot(registry, store, extension);
|
|
299
|
-
return () => {
|
|
300
|
-
if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function setRenderOverride(store, render) {
|
|
304
|
-
store.getState().internal.renderOverride = render;
|
|
305
|
-
}
|
|
306
|
-
function attachRootExtensions(store) {
|
|
307
|
-
const registry = getRegistry();
|
|
308
|
-
registry.roots.add(store);
|
|
309
|
-
for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
|
|
310
|
-
}
|
|
311
|
-
function current(registry, setUpBy) {
|
|
312
|
-
return registry.extensions.get(setUpBy.name) ?? setUpBy;
|
|
363
|
+
const R3F_STAGED_TEXTURES = Symbol.for("@react-three/fiber.stagedTextures");
|
|
364
|
+
const globalStaging = globalThis;
|
|
365
|
+
const staging = globalStaging[R3F_STAGED_TEXTURES] ?? (globalStaging[R3F_STAGED_TEXTURES] = /* @__PURE__ */ new WeakMap());
|
|
366
|
+
function stageTextures(store, entries) {
|
|
367
|
+
const registered = store.getState().textures;
|
|
368
|
+
let staged = staging.get(store);
|
|
369
|
+
for (const [url, texture] of entries) {
|
|
370
|
+
if (registered.has(url)) continue;
|
|
371
|
+
if (!staged) staging.set(store, staged = /* @__PURE__ */ new Map());
|
|
372
|
+
staged.set(url, texture);
|
|
373
|
+
}
|
|
313
374
|
}
|
|
314
|
-
function
|
|
315
|
-
const
|
|
316
|
-
if (!
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
if (!applied) return;
|
|
320
|
-
for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
|
|
375
|
+
function unstageTextures(store, urls) {
|
|
376
|
+
const staged = staging.get(store);
|
|
377
|
+
if (!staged) return;
|
|
378
|
+
for (const url of urls) staged.delete(url);
|
|
379
|
+
if (staged.size === 0) staging.delete(store);
|
|
321
380
|
}
|
|
322
|
-
function
|
|
323
|
-
const
|
|
324
|
-
const
|
|
325
|
-
if (!
|
|
326
|
-
|
|
381
|
+
function getTextureView(store) {
|
|
382
|
+
const registered = store.getState().textures;
|
|
383
|
+
const staged = staging.get(store);
|
|
384
|
+
if (!staged) return registered;
|
|
385
|
+
const view = new Map(registered);
|
|
386
|
+
for (const [url, texture] of staged) if (!view.has(url)) view.set(url, texture);
|
|
387
|
+
return view;
|
|
327
388
|
}
|
|
328
389
|
|
|
329
|
-
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,
|
|
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 };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { aO as FrameNextCallback } from './fiber.C_MFx7We.js';
|
|
2
|
+
import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
6
|
+
*
|
|
7
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
8
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
9
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
10
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
11
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
12
|
+
*
|
|
13
|
+
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
14
|
+
*
|
|
15
|
+
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
16
|
+
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
17
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Simple priority (backwards compat)
|
|
21
|
+
* useFrame((state, delta) => { ... }, 5)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // With phase-based ordering
|
|
25
|
+
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
29
|
+
* function UI() {
|
|
30
|
+
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
31
|
+
* return <button>...</button>;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
36
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
37
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Scheduler-only access (no callback)
|
|
41
|
+
* const { scheduler } = useFrame()
|
|
42
|
+
* scheduler.pauseJob('some-job-id')
|
|
43
|
+
*
|
|
44
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
45
|
+
*/
|
|
46
|
+
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
47
|
+
|
|
48
|
+
export { useFrame as u };
|
|
@@ -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!");
|
|
@@ -153,8 +229,16 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
153
229
|
const id = options.id ?? reactId;
|
|
154
230
|
const callbackRef = useMutableCallback(callback);
|
|
155
231
|
const isLegacyPriority = typeof priorityOrOptions === "number" && priorityOrOptions > 0;
|
|
232
|
+
const isLegacyOrdering = typeof priorityOrOptions === "number" && priorityOrOptions < 0;
|
|
156
233
|
useIsomorphicLayoutEffect(() => {
|
|
157
234
|
if (!callback) return;
|
|
235
|
+
if (isLegacyOrdering) {
|
|
236
|
+
notifyDepreciated({
|
|
237
|
+
heading: "useFrame numeric priority order is reversed in v10",
|
|
238
|
+
body: "useFrame(callback, number) is deprecated and its ordering direction is reversed from v9: v9 ran lower numbers first, v10 maps the number to { priority } and runs higher numbers first, so a negative priority now runs after default-priority jobs.\n\nUse { before, after } to name the dependency, or { priority } with the v10 direction (higher = earlier).",
|
|
239
|
+
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
240
|
+
});
|
|
241
|
+
}
|
|
158
242
|
if (isInsideCanvas) {
|
|
159
243
|
const state = store.getState();
|
|
160
244
|
const rootId = state.internal.rootId;
|
|
@@ -168,7 +252,7 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
168
252
|
}
|
|
169
253
|
notifyDepreciated({
|
|
170
254
|
heading: "useFrame with numeric priority is deprecated",
|
|
171
|
-
body: 'Using useFrame(callback, number) to control render order is deprecated.\n\nFor custom rendering, use: useFrame(callback, { phase: "render" })\nFor execution order within
|
|
255
|
+
body: 'Using useFrame(callback, number) to control render order is deprecated.\n\nFor custom rendering, use: useFrame(callback, { phase: "render" })\nFor execution order within a phase, use: useFrame(callback, { priority: number }) \u2014 higher runs first, the reverse of v9',
|
|
172
256
|
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
173
257
|
});
|
|
174
258
|
}
|
|
@@ -213,7 +297,7 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
213
297
|
{ id, ...options }
|
|
214
298
|
);
|
|
215
299
|
}
|
|
216
|
-
}, [store, scheduler$1, id, optionsKey, isLegacyPriority, isInsideCanvas]);
|
|
300
|
+
}, [store, scheduler$1, id, optionsKey, isLegacyPriority, isLegacyOrdering, isInsideCanvas]);
|
|
217
301
|
const isPaused = React__namespace.useSyncExternalStore(
|
|
218
302
|
// Subscribe function
|
|
219
303
|
React__namespace.useCallback(
|
|
@@ -291,54 +375,31 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
291
375
|
return controls;
|
|
292
376
|
}
|
|
293
377
|
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (applied.has(extension.name)) return;
|
|
306
|
-
applied.set(extension.name, extension);
|
|
307
|
-
const patch = extension.setup?.(store);
|
|
308
|
-
if (patch) store.setState(patch);
|
|
309
|
-
}
|
|
310
|
-
function registerRootExtension(extension) {
|
|
311
|
-
const registry = getRegistry();
|
|
312
|
-
registry.extensions.set(extension.name, extension);
|
|
313
|
-
for (const store of registry.roots) setupRoot(registry, store, extension);
|
|
314
|
-
return () => {
|
|
315
|
-
if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
function setRenderOverride(store, render) {
|
|
319
|
-
store.getState().internal.renderOverride = render;
|
|
320
|
-
}
|
|
321
|
-
function attachRootExtensions(store) {
|
|
322
|
-
const registry = getRegistry();
|
|
323
|
-
registry.roots.add(store);
|
|
324
|
-
for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
|
|
325
|
-
}
|
|
326
|
-
function current(registry, setUpBy) {
|
|
327
|
-
return registry.extensions.get(setUpBy.name) ?? setUpBy;
|
|
378
|
+
const R3F_STAGED_TEXTURES = Symbol.for("@react-three/fiber.stagedTextures");
|
|
379
|
+
const globalStaging = globalThis;
|
|
380
|
+
const staging = globalStaging[R3F_STAGED_TEXTURES] ?? (globalStaging[R3F_STAGED_TEXTURES] = /* @__PURE__ */ new WeakMap());
|
|
381
|
+
function stageTextures(store, entries) {
|
|
382
|
+
const registered = store.getState().textures;
|
|
383
|
+
let staged = staging.get(store);
|
|
384
|
+
for (const [url, texture] of entries) {
|
|
385
|
+
if (registered.has(url)) continue;
|
|
386
|
+
if (!staged) staging.set(store, staged = /* @__PURE__ */ new Map());
|
|
387
|
+
staged.set(url, texture);
|
|
388
|
+
}
|
|
328
389
|
}
|
|
329
|
-
function
|
|
330
|
-
const
|
|
331
|
-
if (!
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
if (!applied) return;
|
|
335
|
-
for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
|
|
390
|
+
function unstageTextures(store, urls) {
|
|
391
|
+
const staged = staging.get(store);
|
|
392
|
+
if (!staged) return;
|
|
393
|
+
for (const url of urls) staged.delete(url);
|
|
394
|
+
if (staged.size === 0) staging.delete(store);
|
|
336
395
|
}
|
|
337
|
-
function
|
|
338
|
-
const
|
|
339
|
-
const
|
|
340
|
-
if (!
|
|
341
|
-
|
|
396
|
+
function getTextureView(store) {
|
|
397
|
+
const registered = store.getState().textures;
|
|
398
|
+
const staged = staging.get(store);
|
|
399
|
+
if (!staged) return registered;
|
|
400
|
+
const view = new Map(registered);
|
|
401
|
+
for (const [url, texture] of staged) if (!view.has(url)) view.set(url, texture);
|
|
402
|
+
return view;
|
|
342
403
|
}
|
|
343
404
|
|
|
344
405
|
exports.Block = Block;
|
|
@@ -346,13 +407,18 @@ exports.ErrorBoundary = ErrorBoundary;
|
|
|
346
407
|
exports.attachRootExtensions = attachRootExtensions;
|
|
347
408
|
exports.context = context;
|
|
348
409
|
exports.detachRootExtensions = detachRootExtensions;
|
|
410
|
+
exports.getTextureView = getTextureView;
|
|
411
|
+
exports.isDevelopment = isDevelopment;
|
|
349
412
|
exports.notifyAlpha = notifyAlpha;
|
|
350
413
|
exports.notifyDepreciated = notifyDepreciated;
|
|
351
414
|
exports.notifyRootExtensionsHmr = notifyRootExtensionsHmr;
|
|
352
415
|
exports.registerRootExtension = registerRootExtension;
|
|
353
416
|
exports.setRenderOverride = setRenderOverride;
|
|
417
|
+
exports.stageTextures = stageTextures;
|
|
418
|
+
exports.unstageTextures = unstageTextures;
|
|
354
419
|
exports.useBridge = useBridge;
|
|
355
420
|
exports.useFrame = useFrame;
|
|
421
|
+
exports.useGate = useGate;
|
|
356
422
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
357
423
|
exports.useMutableCallback = useMutableCallback;
|
|
358
424
|
exports.useStore = useStore;
|