Files
react/packages/shared/forks/ReactFeatureFlags.www.js
Sebastian MarkbågeandGitHub ea05b750a5 Allow Passing Blob/File/MediaSource/MediaStream to src of <img>, <video> and <audio> (#32828)
Behind the `enableSrcObject` flag. This is revisiting a variant of what
was discussed in #11163.

Instead of supporting the [`srcObject`
property](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject)
as a separate name, this adds an overload of `src` to allow objects to
be passed. The DOM needs to add separate properties for the object forms
since you read back but it doesn't make sense for React's write-only API
to do that. Similar to how we'll like add an overload for
`popoverTarget` instead of calling it `popoverTargetElement` and how
`style` accepts an object and it's not `styleObject={{...}}`.

There are a number of reason to revisit this.

- It's just way more convenient to have this built-in and it makes
conceptual sense. We typically support declarative APIs and polyfill
them when necessary.
- RSC supports Blobs and by having it built-in you don't need a Client
Component wrapper to render it where as doing it with effects would
require more complex wrappers. By picking Blobs over base64,
client-navigations can use the more optimized binary encoding in the RSC
protocol.
- The timing aspect of coordinating it with Suspensey images and image
decoding is a bit tricky to get right because if you set it in an effect
it's too late because you've already rendered it.
- SSR gets complicated when done in user space because you have to
handle both branches. Likely with `useSyncExternalStore`.
- By having it built-in we could optimize the payloads shared between
RSC payloads embedded in the HTML and data URLs.

This does not support objects for `<source src>` nor `<img srcset>`.
Those don't really have equivalents in the DOM neither. They're mainly
for picking an option when you don't know programmatically. However, for
this use case you're really better off picking a variant before
generating the blobs.

We may support Response objects in the future too as per
https://github.com/whatwg/fetch/issues/49
2025-04-08 12:11:41 -04:00

123 lines
3.6 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as ExportsType from './ReactFeatureFlags.www';
import typeof * as DynamicFeatureFlags from './ReactFeatureFlags.www-dynamic';
// Re-export dynamic flags from the www version.
const dynamicFeatureFlags: DynamicFeatureFlags = require('ReactFeatureFlags');
export const {
alwaysThrottleRetries,
disableDefaultPropsExceptForClasses,
disableLegacyContextForFunctionComponents,
disableSchedulerTimeoutInWorkLoop,
enableDO_NOT_USE_disableStrictPassiveEffect,
enableHiddenSubtreeInsertionEffectCleanup,
enableInfiniteRenderLoopDetection,
enableNoCloningMemoCache,
enableObjectFiber,
enableRenderableContext,
enableRetryLaneExpiration,
enableSiblingPrerendering,
enableTransitionTracing,
enableTrustedTypesIntegration,
favorSafetyOverHydrationPerf,
renameElementSymbol,
retryLaneExpirationMs,
syncLaneExpirationMs,
transitionLaneExpirationMs,
enableFastAddPropertiesInDiffing,
enableViewTransition,
enableComponentPerformanceTrack,
enableScrollEndPolyfill,
enableFragmentRefs,
} = dynamicFeatureFlags;
// On WWW, __EXPERIMENTAL__ is used for a new modern build.
// It's not used anywhere in production yet.
export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = __PROFILE__;
export const enableProfilerNestedUpdatePhase = __PROFILE__;
export const enableUpdaterTracking = __PROFILE__;
export const enableFabricCompleteRootInCommitPhase = false;
export const enableSuspenseAvoidThisFallback = true;
export const enableCPUSuspense = true;
export const enableUseEffectEventHook = true;
export const enableMoveBefore = false;
export const disableInputAttributeSyncing = false;
export const enableLegacyFBSupport = true;
export const enableYieldingBeforePassive = false;
export const enableThrottledScheduling = false;
export const enableHydrationLaneScheduling = true;
// Logs additional User Timing API marks for use with an experimental profiling tool.
export const enableSchedulingProfiler: boolean =
__PROFILE__ && dynamicFeatureFlags.enableSchedulingProfiler;
export const disableLegacyContext = __EXPERIMENTAL__;
export const enableLegacyCache = true;
export const enableAsyncIterableChildren = false;
export const enableTaint = false;
export const enablePostpone = false;
export const enableHalt = false;
// TODO: www currently relies on this feature. It's disabled in open source.
// Need to remove it.
export const disableCommentsAsDOMContainers = false;
export const enableCreateEventHandleAPI = true;
export const enableScopeAPI = true;
export const enableSuspenseCallback = true;
export const enableLegacyHidden = true;
export const disableTextareaChildren = __EXPERIMENTAL__;
export const enableFizzExternalRuntime = true;
export const passChildrenWhenCloningPersistedNodes = false;
export const enablePersistedModeClonedFlag = false;
export const enableAsyncDebugInfo = false;
export const disableClientCache = true;
export const enableReactTestRendererWarning = false;
export const disableLegacyMode = true;
export const enableShallowPropDiffing = false;
export const enableLazyPublicInstanceInFabric = false;
export const enableGestureTransition = false;
export const enableSuspenseyImages = false;
export const enableSrcObject = false;
export const ownerStackLimit = 1e4;
// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);