@react-three/fiber 10.0.0-canary.f75fbf6 → 10.0.0-canary.fbc659b
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 -8
- package/dist/extension.d.cts +4 -4
- package/dist/extension.d.mts +4 -4
- package/dist/extension.d.ts +4 -4
- package/dist/extension.mjs +1 -1
- package/dist/index.cjs +14 -15
- package/dist/index.d.cts +11 -10
- package/dist/index.d.mts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.mjs +4 -5
- package/dist/legacy.cjs +37 -15
- 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 +13 -5
- package/dist/shared/{fiber.BgxhptM_.mjs → fiber.BdIbKbh7.mjs} +2066 -1497
- package/dist/shared/{fiber.B0oukOFO.mjs → fiber.Biz9olEe.mjs} +181 -64
- package/dist/shared/{fiber.BcX0-yko.d.mts → fiber.C6hitYDY.d.cts} +1 -1
- package/dist/shared/{fiber.Dh8K6RJr.d.cts → fiber.C_MFx7We.d.cts} +472 -20
- package/dist/shared/{fiber.Dh8K6RJr.d.mts → fiber.C_MFx7We.d.mts} +472 -20
- package/dist/shared/{fiber.Dh8K6RJr.d.ts → fiber.C_MFx7We.d.ts} +472 -20
- package/dist/shared/{fiber.DH-VJXM_.d.ts → fiber.CtivZ3IY.d.ts} +89 -464
- package/dist/shared/{fiber.cO-9hDzr.d.cts → fiber.CvlK0a1Z.d.mts} +89 -464
- package/dist/shared/{fiber.BgP4izaL.d.cts → fiber.D4fD6H74.d.mts} +1 -1
- package/dist/shared/{fiber.khFlPHPf.cjs → fiber.DfiCufha.cjs} +186 -62
- package/dist/shared/{fiber.AN9kOS0N.d.mts → fiber.VTTQNnlj.d.cts} +89 -464
- package/dist/shared/{fiber.BIhZnMzg.d.ts → fiber.YgTUGbja.d.ts} +1 -1
- package/dist/shared/{fiber.EDf0d92E.cjs → fiber.nDnBf1np.cjs} +2092 -1523
- package/dist/webgpu/index.cjs +13 -13
- package/dist/webgpu/index.d.cts +12 -6
- package/dist/webgpu/index.d.mts +12 -6
- package/dist/webgpu/index.d.ts +12 -6
- package/dist/webgpu/index.mjs +4 -4
- package/package.json +3 -3
- package/dist/chunks/webgl.cjs +0 -27
- package/dist/chunks/webgl.mjs +0 -11
|
@@ -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,160 @@ 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
|
+
}
|
|
148
|
+
|
|
149
|
+
const INTERNAL_LIB_MARKERS = [
|
|
150
|
+
"zustand",
|
|
151
|
+
"setState",
|
|
152
|
+
"Object.assign",
|
|
153
|
+
"@pmndrs/scheduler",
|
|
154
|
+
"Scheduler.tickRoot",
|
|
155
|
+
"Scheduler.stepJob"
|
|
156
|
+
];
|
|
157
|
+
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
158
|
+
if (!stack) return false;
|
|
159
|
+
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
160
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const isAccessorDescriptor = (descriptor) => !!descriptor && (descriptor.get !== void 0 || descriptor.set !== void 0);
|
|
164
|
+
const isAccessor = (object, key) => isAccessorDescriptor(Object.getOwnPropertyDescriptor(object, key));
|
|
165
|
+
function cloneState(...sources) {
|
|
166
|
+
const target = {};
|
|
167
|
+
for (const source of sources) {
|
|
168
|
+
if (source) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
169
|
+
}
|
|
170
|
+
return target;
|
|
171
|
+
}
|
|
172
|
+
function preserveAccessors(rawSet, get) {
|
|
173
|
+
return ((partial, replace) => {
|
|
174
|
+
const previous = get();
|
|
175
|
+
const patch = typeof partial === "function" ? partial(previous) : partial;
|
|
176
|
+
if (replace || !previous || patch == null || Object.is(patch, previous)) {
|
|
177
|
+
return rawSet(patch, replace);
|
|
178
|
+
}
|
|
179
|
+
const next = cloneState(previous);
|
|
180
|
+
const viaSetter = [];
|
|
181
|
+
for (const key of Reflect.ownKeys(patch)) {
|
|
182
|
+
const descriptor = Object.getOwnPropertyDescriptor(patch, key);
|
|
183
|
+
if (!descriptor.enumerable) continue;
|
|
184
|
+
if (isAccessorDescriptor(descriptor)) {
|
|
185
|
+
Object.defineProperty(next, key, descriptor);
|
|
186
|
+
} else if (isAccessor(next, key)) {
|
|
187
|
+
viaSetter.push(key);
|
|
188
|
+
} else {
|
|
189
|
+
Object.defineProperty(next, key, {
|
|
190
|
+
value: descriptor.value,
|
|
191
|
+
writable: true,
|
|
192
|
+
enumerable: true,
|
|
193
|
+
configurable: true
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
for (const key of viaSetter) next[key] = patch[key];
|
|
198
|
+
rawSet(next, true);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const keepAccessors = (initializer) => (rawSet, get, api) => {
|
|
202
|
+
const set = preserveAccessors(rawSet, get);
|
|
203
|
+
api.setState = set;
|
|
204
|
+
return initializer(set, get, api);
|
|
205
|
+
};
|
|
206
|
+
let glNoticeShown = false;
|
|
207
|
+
function defineRendererAccessors(state) {
|
|
208
|
+
Object.defineProperty(state, "gl", {
|
|
209
|
+
get() {
|
|
210
|
+
const renderer = this.internal?.actualRenderer;
|
|
211
|
+
if (!glNoticeShown && renderer && !this.isLegacy) {
|
|
212
|
+
const stack = new Error().stack || "";
|
|
213
|
+
if (!isInternalRendererAccess(stack)) {
|
|
214
|
+
glNoticeShown = true;
|
|
215
|
+
const cleanedStack = stack.split("\n").slice(2).join("\n") || "Stack trace unavailable";
|
|
216
|
+
notifyDepreciated({
|
|
217
|
+
heading: "Accessing state.gl in WebGPU mode",
|
|
218
|
+
body: "Please use state.renderer instead. state.gl is deprecated and will be removed in future versions.\n\nFor backwards compatibility, state.gl currently maps to state.renderer, but this may cause issues with libraries expecting WebGLRenderer.\n\nAccessed from:\n" + cleanedStack
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return renderer;
|
|
223
|
+
},
|
|
224
|
+
set(value) {
|
|
225
|
+
this.internal.actualRenderer = value;
|
|
226
|
+
},
|
|
227
|
+
enumerable: true,
|
|
228
|
+
configurable: true
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(state, "renderer", {
|
|
231
|
+
get() {
|
|
232
|
+
return this.internal?.actualRenderer;
|
|
233
|
+
},
|
|
234
|
+
set(value) {
|
|
235
|
+
this.internal.actualRenderer = value;
|
|
236
|
+
},
|
|
237
|
+
enumerable: true,
|
|
238
|
+
configurable: true
|
|
239
|
+
});
|
|
240
|
+
}
|
|
122
241
|
|
|
123
242
|
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
124
243
|
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React__namespace.createContext(null));
|
|
125
244
|
|
|
245
|
+
const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
|
|
246
|
+
function getRegistry() {
|
|
247
|
+
return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
|
|
248
|
+
extensions: /* @__PURE__ */ new Map(),
|
|
249
|
+
roots: /* @__PURE__ */ new Set(),
|
|
250
|
+
applied: /* @__PURE__ */ new WeakMap()
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function setupRoot(registry, store, extension) {
|
|
254
|
+
let applied = registry.applied.get(store);
|
|
255
|
+
if (!applied) registry.applied.set(store, applied = /* @__PURE__ */ new Map());
|
|
256
|
+
if (applied.has(extension.name)) return;
|
|
257
|
+
applied.set(extension.name, extension);
|
|
258
|
+
const patch = extension.setup?.(store);
|
|
259
|
+
if (patch) store.setState(patch);
|
|
260
|
+
}
|
|
261
|
+
function registerRootExtension(extension) {
|
|
262
|
+
const registry = getRegistry();
|
|
263
|
+
registry.extensions.set(extension.name, extension);
|
|
264
|
+
for (const store of registry.roots) setupRoot(registry, store, extension);
|
|
265
|
+
return () => {
|
|
266
|
+
if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function setRenderOverride(store, render) {
|
|
270
|
+
store.getState().internal.renderOverride = render;
|
|
271
|
+
}
|
|
272
|
+
function attachRootExtensions(store) {
|
|
273
|
+
const registry = getRegistry();
|
|
274
|
+
registry.roots.add(store);
|
|
275
|
+
for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
|
|
276
|
+
}
|
|
277
|
+
function current(registry, setUpBy) {
|
|
278
|
+
return registry.extensions.get(setUpBy.name) ?? setUpBy;
|
|
279
|
+
}
|
|
280
|
+
function detachRootExtensions(store) {
|
|
281
|
+
const registry = getRegistry();
|
|
282
|
+
if (!registry.roots.delete(store)) return;
|
|
283
|
+
const applied = registry.applied.get(store);
|
|
284
|
+
registry.applied.delete(store);
|
|
285
|
+
if (!applied) return;
|
|
286
|
+
for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
|
|
287
|
+
}
|
|
288
|
+
function notifyRootExtensionsHmr(store) {
|
|
289
|
+
const registry = getRegistry();
|
|
290
|
+
const applied = registry.applied.get(store);
|
|
291
|
+
if (!applied) return;
|
|
292
|
+
for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
|
|
293
|
+
}
|
|
294
|
+
|
|
126
295
|
function useStore() {
|
|
127
296
|
const store = React.useContext(context);
|
|
128
297
|
if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
|
|
@@ -149,8 +318,8 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
149
318
|
const options = React__namespace.useMemo(() => {
|
|
150
319
|
return typeof priorityOrOptions === "number" ? { priority: priorityOrOptions } : priorityOrOptions ?? {};
|
|
151
320
|
}, [optionsKey]);
|
|
152
|
-
const
|
|
153
|
-
const id = options.id ??
|
|
321
|
+
const [generatedId] = React__namespace.useState(() => scheduler$1.generateJobId());
|
|
322
|
+
const id = options.id ?? generatedId;
|
|
154
323
|
const callbackRef = useMutableCallback(callback);
|
|
155
324
|
const isLegacyPriority = typeof priorityOrOptions === "number" && priorityOrOptions > 0;
|
|
156
325
|
const isLegacyOrdering = typeof priorityOrOptions === "number" && priorityOrOptions < 0;
|
|
@@ -181,14 +350,12 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
181
350
|
});
|
|
182
351
|
}
|
|
183
352
|
const wrappedCallback = (frameState, delta) => {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
frame: frameState.frame
|
|
191
|
-
};
|
|
353
|
+
const mergedState = cloneState(store.getState());
|
|
354
|
+
mergedState.time = frameState.time;
|
|
355
|
+
mergedState.delta = frameState.delta;
|
|
356
|
+
mergedState.elapsed = frameState.elapsed;
|
|
357
|
+
mergedState.frame = frameState.frame;
|
|
358
|
+
mergedState.overstep = frameState.overstep;
|
|
192
359
|
callbackRef.current?.(mergedState, delta);
|
|
193
360
|
};
|
|
194
361
|
const unregister = scheduler$1.register(wrappedCallback, {
|
|
@@ -326,71 +493,28 @@ function getTextureView(store) {
|
|
|
326
493
|
return view;
|
|
327
494
|
}
|
|
328
495
|
|
|
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
496
|
exports.Block = Block;
|
|
380
497
|
exports.ErrorBoundary = ErrorBoundary;
|
|
381
498
|
exports.attachRootExtensions = attachRootExtensions;
|
|
499
|
+
exports.cloneState = cloneState;
|
|
382
500
|
exports.context = context;
|
|
501
|
+
exports.defineRendererAccessors = defineRendererAccessors;
|
|
383
502
|
exports.detachRootExtensions = detachRootExtensions;
|
|
384
503
|
exports.getTextureView = getTextureView;
|
|
504
|
+
exports.isAccessor = isAccessor;
|
|
505
|
+
exports.isDevelopment = isDevelopment;
|
|
506
|
+
exports.keepAccessors = keepAccessors;
|
|
385
507
|
exports.notifyAlpha = notifyAlpha;
|
|
386
508
|
exports.notifyDepreciated = notifyDepreciated;
|
|
387
509
|
exports.notifyRootExtensionsHmr = notifyRootExtensionsHmr;
|
|
510
|
+
exports.preserveAccessors = preserveAccessors;
|
|
388
511
|
exports.registerRootExtension = registerRootExtension;
|
|
389
512
|
exports.setRenderOverride = setRenderOverride;
|
|
390
513
|
exports.stageTextures = stageTextures;
|
|
391
514
|
exports.unstageTextures = unstageTextures;
|
|
392
515
|
exports.useBridge = useBridge;
|
|
393
516
|
exports.useFrame = useFrame;
|
|
517
|
+
exports.useGate = useGate;
|
|
394
518
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
395
519
|
exports.useMutableCallback = useMutableCallback;
|
|
396
520
|
exports.useStore = useStore;
|