Skip to content

Add TypedArray, UInt8Array in JSI (#56158)#56158

Closed
tsaichien wants to merge 5 commits into
facebook:mainfrom
tsaichien:export-D95245175
Closed

Add TypedArray, UInt8Array in JSI (#56158)#56158
tsaichien wants to merge 5 commits into
facebook:mainfrom
tsaichien:export-D95245175

Conversation

@tsaichien

@tsaichien tsaichien commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Summary:

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:

  • TypedArray: Base class for all typed arrays
  • Uint8Array: Uint8Array type extending TypedArray

New IRuntime APIs:

  • getBuffer(TypedArray): Get underlying ArrayBuffer
  • getByteOffset(TypedArray): Get byte offset property
  • getByteLength(TypedArray): Get byte length property
  • getLength(TypedArray): Get length property
  • createUint8Array(size_t): Create Uint8Array with length
  • createUint8Array(ArrayBuffer, offset, length): Create from
    ArrayBuffer
  • isUint8Array(Object): Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 19, 2026
@meta-codesync

meta-codesync Bot commented Mar 19, 2026

Copy link
Copy Markdown

@tsaichien has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95245175.

@meta-codesync meta-codesync Bot changed the title Add TypedArray, UInt8Array in JSI Add TypedArray, UInt8Array in JSI (#56158) Mar 19, 2026
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 19, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 19, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 19, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 30, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 31, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
tsaichien and others added 4 commits April 14, 2026 11:02
Summary:
After reviewing the feasibility of adding new Runtime functionality, we
realized the current state of `Runtime` makes it hard/inconvenient to
add new basic functionality. It requires creating a new interface (e.g.
`IRuntime2`) to declare the new APIs. Then, everywhere it is needed,
both the original `Runtime` and `IRuntime2` needs to passed in to access
both APIs.

After discussion, we decided to introduce `IRuntime`, which will declare
most of the `Runtime` functionalities. All "protected" APIs, which made
sense before interfaces were introduced, will now be public. The
protected static methods of `Runtime` will remain as is for the Friends
to access.

After we decided to cut "stable" (after incoming JSI improvements), new
functionalities will be added in `IRuntime2` interface. `IRuntime2` will
inherit `IRuntime` to make existing functionality easy to access.

Differential Revision: D89093651
Summary:
Currently, the size of a jsi `Array` is immutable. Once the `Array` is
created, users can only set the element at an existing index, but not
append to it.

This change adds an `Array::push` API to improve ergonomics.

Differential Revision: D82254334
Summary:
Adds `ArrayBuffer::getMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The data referenced
by the `MutableBuffer` will be alive during the entirety of the
`MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Differential Revision: D91264901
Differential Revision: D92993088
tsaichien added a commit to tsaichien/react-native that referenced this pull request Apr 14, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
tsaichien added a commit to tsaichien/react-native that referenced this pull request Apr 14, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
tsaichien added a commit to tsaichien/react-native that referenced this pull request Apr 14, 2026
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
Summary:
Pull Request resolved: facebook#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175
meta-codesync Bot pushed a commit to facebook/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
meta-codesync Bot pushed a commit to facebook/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
@meta-codesync meta-codesync Bot closed this in 572e661 Apr 15, 2026
meta-codesync Bot pushed a commit to facebook/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
@meta-codesync

meta-codesync Bot commented Apr 15, 2026

Copy link
Copy Markdown

This pull request has been merged in 572e661.

@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Apr 15, 2026
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 16, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 16, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
tsaichien added a commit to facebook/hermes that referenced this pull request Apr 16, 2026
Summary:
X-link: facebook/react-native#56158

Add TypedArray and Uint8Array types to JSI with supporting APIs.

New types:
- `TypedArray`: Base class for all typed arrays
- `Uint8Array`: Uint8Array type extending TypedArray

New IRuntime APIs:
- `getBuffer(TypedArray)`: Get underlying ArrayBuffer
- `getByteOffset(TypedArray)`: Get byte offset property
- `getByteLength(TypedArray)`: Get byte length property
- `getLength(TypedArray)`: Get length property
- `createUint8Array(size_t)`: Create Uint8Array with length
- `createUint8Array(ArrayBuffer, offset, length)`: Create from
  ArrayBuffer
- `isUint8Array(Object)`: Check if object is Uint8Array

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D95245175

fbshipit-source-id: 33e7f5d9de42bfcc0b7a57c681fdd73711c2bb13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant