Expose structuredClone and DOMException globally - #58736
Open
rubennorte wants to merge 2 commits into
Open
rubennorte wants to merge 2 commits into
rubennorte wants to merge 2 commits into
Conversation
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D122331156. |
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 29, 2026
Summary: Install `DOMException` and `structuredClone` lazily during React Native environment setup so they are available without imports, matching their Web API placement. Add Flow and TypeScript global declarations, including the `DOMException` constants exposed by the implementation. Changelog: [General][Added] - Expose `structuredClone` and `DOMException` as global Web APIs Differential Revision: D122331156
rubennorte
force-pushed
the
export-D122331156
branch
from
September 29, 2026 12:12
6958024 to
24a9a17
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 29, 2026
Summary: Install `DOMException` and `structuredClone` lazily during React Native environment setup so they are available without imports, matching their Web API placement. Add Flow and TypeScript global declarations, including the `DOMException` constants exposed by the implementation. Changelog: [General][Added] - Expose `structuredClone` and `DOMException` as global Web APIs Differential Revision: D122331156
rubennorte
force-pushed
the
export-D122331156
branch
from
September 29, 2026 12:35
24a9a17 to
aa6dd17
Compare
Summary: Compare React Native structuredClone behavior with ungap/structured-clone and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe __proto__ data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API. The comparison dependency and benchmark cases were used only to collect the results below and are not shipped with React Native. Before — React Native implementation before this change: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | ------------------------ | ----------------- | ---------------- | ---------------------- | ---------------------- | ------- | | 0 | 'clone a string' | '338.62 ± 0.05%' | '330.00 ± 9.00' | '3014547 ± 0.05%' | '3030303 ± 84962' | 2953184 | | 1 | 'clone a basic array' | '1587.6 ± 10.36%' | '1353.0 ± 19.00' | '734465 ± 0.42%' | '739098 ± 10235' | 638616 | | 2 | 'clone a basic object' | '1344.2 ± 8.81%' | '1172.0 ± 20.00' | '828917 ± 0.33%' | '853242 ± 14813' | 743963 | | 3 | 'clone a complex object' | '3370.6 ± 0.60%' | '3255.0 ± 40.00' | '304183 ± 0.02%' | '307220 ± 3822' | 296680 | After — React Native compared with ungap/structured-clone: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | -------------------------------------- | ----------------- | ----------------- | ---------------------- | ---------------------- | ------- | | 0 | 'React Native: clone a string' | '348.44 ± 0.08%' | '331.00 ± 1.00' | '2927181 ± 0.04%' | '3021148 ± 9155' | 2869970 | | 1 | 'ungap: clone a string' | '2037.4 ± 11.17%' | '1592.0 ± 50.00' | '617833 ± 0.09%' | '628141 ± 19947' | 490832 | | 2 | 'React Native: clone a basic array' | '1460.2 ± 8.39%' | '1282.0 ± 20.00' | '775137 ± 0.42%' | '780031 ± 12362' | 684824 | | 3 | 'ungap: clone a basic array' | '5112.8 ± 0.81%' | '4718.0 ± 111.00' | '205586 ± 0.08%' | '211954 ± 5107' | 195589 | | 4 | 'React Native: clone a basic object' | '1373.8 ± 8.58%' | '1152.0 ± 20.00' | '842837 ± 0.46%' | '868056 ± 15337' | 727910 | | 5 | 'ungap: clone a basic object' | '8853.2 ± 0.76%' | '8253.0 ± 141.00' | '117562 ± 0.05%' | '121168 ± 2106' | 112954 | | 6 | 'React Native: clone a complex object' | '3539.4 ± 0.55%' | '3456.0 ± 50.00' | '288368 ± 0.02%' | '289352 ± 4248' | 282537 | | 7 | 'ungap: clone a complex object' | '21498 ± 0.72%' | '20080 ± 301.00' | '48208 ± 0.09%' | '49801 ± 755' | 46516 | The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios. Changelog: [General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone Differential Revision: D122156629
rubennorte
force-pushed
the
export-D122331156
branch
from
September 29, 2026 15:41
aa6dd17 to
cc7c574
Compare
Summary: Install `DOMException` and `structuredClone` lazily during React Native environment setup so they are available without imports, matching their Web API placement. Add Flow and TypeScript global declarations, including the `DOMException` constants exposed by the implementation. Changelog: [General][Added] - Expose `structuredClone` and `DOMException` as global Web APIs Reviewed By: javache Differential Revision: D122331156
rubennorte
force-pushed
the
export-D122331156
branch
from
September 29, 2026 15:45
cc7c574 to
03a4be0
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Install
DOMExceptionandstructuredClonelazily during React Native environment setup so they are available without imports, matching their Web API placement. Add Flow and TypeScript global declarations, including theDOMExceptionconstants exposed by the implementation.Changelog:
[General][Added] - Expose
structuredCloneandDOMExceptionas global Web APIsReviewed By: javache
Differential Revision: D122331156