Closed Bug 1804078 Opened 2 years ago Closed 3 months ago

Create non-generated module for shared UniFFI JS code

Categories

(Toolkit :: UniFFI Bindings, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
142 Branch
Tracking Status
firefox142 --- fixed

People

(Reporter: bdk, Assigned: bdk)

References

Details

(Whiteboard: [fxsync-])

Attachments

(1 file)

We should create a JS module for shared UniFFI code. This module should just be static code rather than generated. This provides a few benefits:

  • Reduces runtime size since each generated component can import from it.
  • Makes the code easier to understand since it's regular JS, not JS mixed with template code.
  • We can run the code through a JS linter.

Some things to include in this module:

  • Most/all of the code in Helpers.js including:
    • The FfiConverter base class
    • ArrayBufferDataStream
    • handleRustResult
    • UniFFIError and UniFFIInternalError
  • Some commonly used FfiConverters, especially FfiConverterString
  • UniFFICallbackHandler and UniFFICallbackMethodHandler
Whiteboard: [fxsync-]

This is something I'd love to do for all the UniFFI bindings languages, maybe trying it out on JS could be a first step.

Running ./mach lint revealed a bug: we needed parentheses in the
!(instanceof Uint8Array) check.

Assignee: nobody → bdeankawamura
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 142 Branch
QA Whiteboard: [qa-triage-done-c143/b142]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: