This is (or should be) a full JavaScript interop package using package:js bindings.
The bindings are generated by machine-reading WebIDL files for types and MDN website for documentation.
Take a look at MediaStream file and check out how nice it got with the awesome MDN documentation.
Sponsor
This package is officially sponsored by Invertase.io
Usage
import 'package:js_bindings/js_bindings.dart';
void main() {
var div = document.createElement('div')
..innerHTML = 'Hello world =]';
document.body!.appendChild(div);
}
Check the example tab for a more complete example.
Promise and Future
JS Promises and Dart Futures are different things.
But this package make them the same! :D
import 'package:js_bindings/js_bindings.dart';
Future<void> main() async {
// you can await like regular future
await window.navigator.mediaDevices.getUserMedia();
// or
window.navigator.mediaDevices.getUserMedia().then((event) {});
}
Enums
Enums like document.visibilityState
are Strings
in JS world,
but here we work with enums instead.
For example document.visibilityState
is of type VisibilityState
, which is a Enum
.
So all of what is specificied in the W3C IDL files as enums are in fact enums in this package.
Variadic args
Dart doesn't have the concept of variadic args as JS, so
we can't make a one to one there. However, we made it that
variadic arguments are multiplied to 3 optional args of same type.
Example: window.console.log(1, 2, 3)
- In this case all arguments are dynamic.
Todo:
For a better JS interop
If you wish for a better JS interop in Dart, please, thumbs up the following issues:
Donation
What about a coffee?
Libraries
- bindings/accelerometer
- Accelerometer
- bindings/all_bindings
- bindings/ambient_light
- Ambient Light Sensor
- bindings/anchors
- WebXR Anchors Module
- bindings/angle_instanced_arrays
- WebGL ANGLE_instanced_arrays Khronos Ratified Extension Specification
- bindings/attribution_reporting_api
- Attribution Reporting
- bindings/audio_output
- Audio Output Devices API
- bindings/autoplay_detection
- Autoplay Policy Detection
- bindings/background_fetch
- Background Fetch
- bindings/background_sync
- Web Background Synchronization
- bindings/badging
- Badging API
- bindings/battery_status
- Battery Status API
- bindings/beacon
- Beacon
- bindings/callbacks
- bindings/capture_handle_identity
- Capture Handle - Bootstrapping Collaboration when Screensharing
- bindings/clipboard_apis
- Clipboard API and events
- bindings/close_watcher
- Close Watcher API
- bindings/compat
- Compatibility Standard
- bindings/compression
- Compression Streams
- bindings/compute_pressure
- Compute Pressure Level 1
- bindings/console
- Console Standard
- bindings/contact_api
- Contact Picker API
- bindings/content_index
- Content Index
- Cookie Store API
- bindings/crash_reporting
- Crash Reporting
- bindings/credential_management_1
- Credential Management Level 1
- bindings/csp3
- Content Security Policy Level 3
- bindings/csp_embedded_enforcement
- Content Security Policy: Embedded Enforcement
- bindings/csp_next
- Scripting Policy
- bindings/css_animation_worklet_1
- CSS Animation Worklet API
- bindings/css_animations_1
- CSS Animations Level 1
- bindings/css_animations_2
- CSS Animations Level 2
- bindings/css_cascade_5
- CSS Cascading and Inheritance Level 5
- bindings/css_conditional_3
- CSS Conditional Rules Module Level 3
- bindings/css_contain_2
- CSS Containment Module Level 2
- bindings/css_contain_3
- CSS Containment Module Level 3
- bindings/css_counter_styles_3
- CSS Counter Styles Level 3
- bindings/css_device_adapt_1
- CSS Device Adaptation Module Level 1
- bindings/css_font_loading_3
- CSS Font Loading Module Level 3
- bindings/css_fonts_4
- CSS Fonts Module Level 4
- bindings/css_highlight_api_1
- CSS Custom Highlight API Module Level 1
- bindings/css_images_4
- CSS Images Module Level 4
- bindings/css_layout_api_1
- CSS Layout API Level 1
- bindings/css_masking_1
- CSS Masking Module Level 1
- CSS Spatial Navigation Level 1
- bindings/css_nesting_1
- CSS Nesting Module
- bindings/css_paint_api_1
- CSS Painting API Level 1
- bindings/css_parser_api
- CSS Parser API
- bindings/css_properties_values_api_1
- CSS Properties and Values API Level 1
- bindings/css_pseudo_4
- CSS Pseudo-Elements Module Level 4
- bindings/css_regions_1
- CSS Regions Module Level 1
- bindings/css_shadow_parts_1
- CSS Shadow Parts
- bindings/css_transitions_1
- CSS Transitions
- bindings/css_transitions_2
- CSS Transitions Level 2
- bindings/css_typed_om_1
- CSS Typed OM Level 1
- bindings/cssom_1
- CSS Object Model (CSSOM)
- bindings/cssom_view_1
- CSSOM View Module
- bindings/custom_state_pseudo_class
- Custom State Pseudo Class
- bindings/datacue
- DataCue API
- bindings/deprecation_reporting
- Deprecation Reporting
- bindings/device_memory_1
- Device Memory
- bindings/device_posture
- Device Posture API
- bindings/digital_goods
- Digital Goods API
- bindings/dom
- DOM Standard
- bindings/dom_parsing
- DOM Parsing and Serialization
- bindings/edit_context
- EditContext API
- bindings/element_timing
- Element Timing API
- bindings/encoding
- Encoding Standard
- bindings/encrypted_media
- Encrypted Media Extensions
- bindings/entries_api
- File and Directory Entries API
- bindings/epub_rs_33
- EPUB Reading Systems 3.3
- bindings/event_timing
- Event Timing API
- bindings/ext_blend_minmax
- WebGL EXT_blend_minmax Khronos Ratified Extension Specification
- bindings/ext_clip_cull_distance
- WebGL EXT_clip_cull_distance Extension Draft Specification
- bindings/ext_color_buffer_float
- WebGL EXT_color_buffer_float Extension Specification
- bindings/ext_color_buffer_half_float
- WebGL EXT_color_buffer_half_float Extension Specification
- bindings/ext_disjoint_timer_query
- WebGL EXT_disjoint_timer_query Extension Specification
- bindings/ext_disjoint_timer_query_webgl2
- WebGL EXT_disjoint_timer_query_webgl2 Extension Specification
- bindings/ext_float_blend
- WebGL EXT_float_blend Extension Specification
- bindings/ext_frag_depth
- WebGL EXT_frag_depth Khronos Ratified Extension Specification
- bindings/ext_shader_texture_lod
- WebGL EXT_shader_texture_lod Khronos Ratified Extension Specification
- bindings/ext_srgb
- WebGL EXT_sRGB Extension Specification
- bindings/ext_texture_compression_bptc
- WebGL EXT_texture_compression_bptc Extension Specification
- bindings/ext_texture_compression_rgtc
- WebGL EXT_texture_compression_rgtc Extension Specification
- bindings/ext_texture_filter_anisotropic
- WebGL EXT_texture_filter_anisotropic Khronos Ratified Extension Specification
- bindings/ext_texture_norm16
- WebGL EXT_texture_norm16 Extension Specification
- bindings/eyedropper_api
- EyeDropper API
- bindings/fedcm
- Federated Credential Management API
- bindings/fetch
- Fetch Standard
- bindings/file_system_access
- File System Access
- bindings/fileapi
- File API
- bindings/filter_effects_1
- Filter Effects Module Level 1
- bindings/font_metrics_api_1
- Font Metrics API Level 1
- bindings/fs
- File System Standard
- bindings/fullscreen
- Fullscreen API Standard
- bindings/gamepad
- Gamepad
- bindings/gamepad_extensions
- Gamepad Extensions
- bindings/generic_sensor
- Generic Sensor API
- bindings/geolocation
- Geolocation API
- bindings/geolocation_sensor
- Geolocation Sensor
- bindings/geometry_1
- Geometry Interfaces Module Level 1
- Get Installed Related Apps API
- bindings/gyroscope
- Gyroscope
- bindings/hr_time_3
- High Resolution Time
- bindings/html
- HTML Standard
- bindings/html_media_capture
- HTML Media Capture
- bindings/idle_detection
- Idle Detection API
- bindings/image_capture
- MediaStream Image Capture
- bindings/image_resource
- Image Resource
- bindings/indexeddb_3
- Indexed Database API 3.0
- bindings/ink_enhancement
- Ink API
- bindings/input_device_capabilities
- Input Device Capabilities
- bindings/input_events_2
- Input Events Level 2
- bindings/intersection_observer
- Intersection Observer
- bindings/intervention_reporting
- Intervention Reporting
- bindings/is_input_pending
- Early detection of input events
- bindings/js_self_profiling
- JS Self-Profiling API
- bindings/json_ld11_api
- JSON-LD 1.1 Processing Algorithms and API
- bindings/json_ld11_framing
- JSON-LD 1.1 Framing
- bindings/keyboard_lock
- Keyboard Lock
- bindings/keyboard_map
- Keyboard Map
- bindings/khr_parallel_shader_compile
- WebGL KHR_parallel_shader_compile Extension Specification
- bindings/largest_contentful_paint
- Largest Contentful Paint
- bindings/layout_instability
- Layout Instability API
- bindings/local_font_access
- Local Font Access API
- bindings/longtasks_1
- Long Tasks API
- bindings/magnetometer
- Magnetometer
- bindings/manifest_incubations
- Manifest Incubations
- bindings/mathml_core
- MathML Core
- bindings/media_capabilities
- Media Capabilities
- bindings/media_playback_quality
- Media Playback Quality
- bindings/media_source_2
- Media Source Extensions™
- bindings/mediacapture_automation
- Media Capture Automation
- bindings/mediacapture_fromelement
- Media Capture from DOM Elements
- bindings/mediacapture_handle_actions
- The Capture-Handle Actions Mechanism
- bindings/mediacapture_region
- Region Capture
- bindings/mediacapture_streams
- Media Capture and Streams
- bindings/mediacapture_transform
- MediaStreamTrack Insertable Media Processing using Streams
- bindings/mediacapture_viewport
- Viewport Capture
- bindings/mediasession
- Media Session Standard
- bindings/mediastream_recording
- MediaStream Recording
- bindings/mst_content_hint
- MediaStreamTrack Content Hints
- Navigation API
- Navigation Timing Level 2
- bindings/netinfo
- Network Information API
- bindings/notifications
- Notifications API Standard
- bindings/oes_draw_buffers_indexed
- WebGL OES_draw_buffers_indexed Extension Specification
- bindings/oes_element_index_uint
- WebGL OES_element_index_uint Khronos Ratified Extension Specification
- bindings/oes_fbo_render_mipmap
- WebGL OES_fbo_render_mipmap Extension Specification
- bindings/oes_standard_derivatives
- WebGL OES_standard_derivatives Khronos Ratified Extension Specification
- bindings/oes_texture_float
- WebGL OES_texture_float Khronos Ratified Extension Specification
- bindings/oes_texture_float_linear
- WebGL OES_texture_float_linear Khronos Ratified Extension Specification
- bindings/oes_texture_half_float
- WebGL OES_texture_half_float Khronos Ratified Extension Specification
- bindings/oes_texture_half_float_linear
- WebGL OES_texture_half_float_linear Khronos Ratified Extension Specification
- bindings/oes_vertex_array_object
- WebGL OES_vertex_array_object Khronos Ratified Extension Specification
- bindings/orientation_event
- DeviceOrientation Event Specification
- bindings/orientation_sensor
- Orientation Sensor
- bindings/ovr_multiview2
- WebGL OVR_multiview2 Extension Specification
- bindings/page_lifecycle
- Page Lifecycle
- bindings/paint_timing
- Paint Timing 1
- bindings/payment_handler
- Payment Handler API
- bindings/payment_request_1_1
- Payment Request API 1.1
- bindings/performance_measure_memory
- Measure Memory API
- bindings/performance_timeline
- Performance Timeline Level 2
- bindings/periodic_background_sync
- Web Periodic Background Synchronization
- bindings/permissions
- Permissions
- bindings/permissions_policy_1
- Permissions Policy
- bindings/permissions_request
- Requesting Permissions
- bindings/permissions_revoke
- Relinquishing Permissions
- bindings/picture_in_picture
- Picture-in-Picture
- bindings/pointerevents3
- Pointer Events
- bindings/pointerlock_2
- Pointer Lock 2.0
- bindings/portals
- Portals
- bindings/prefer_current_tab
- preferCurrentTab
- bindings/prerendering_revamped
- Prerendering Revamped
- bindings/presentation_api
- Presentation API
- bindings/priority_hints
- Priority Hints
- bindings/private_click_measurement
- Private Click Measurement
- bindings/proximity
- Proximity Sensor
- bindings/push_api
- Push API
- bindings/referrer_policy
- Referrer Policy
- bindings/remote_playback
- Remote Playback API
- bindings/reporting_1
- Reporting API
- bindings/requestidlecallback
- requestIdleCallback()
- bindings/resize_observer_1
- Resize Observer
- bindings/resource_timing_2
- Resource Timing Level 2
- bindings/sanitizer_api
- HTML Sanitizer API
- bindings/savedata
- Save Data API
- bindings/scheduling_apis
- Prioritized Task Scheduling
- bindings/screen_capture
- Screen Capture
- bindings/screen_orientation
- The Screen Orientation API
- bindings/screen_wake_lock
- Screen Wake Lock API
- bindings/scroll_animations_1
- Scroll-linked Animations
- bindings/scroll_to_text_fragment
- Text Fragments
- bindings/secure_payment_confirmation
- Secure Payment Confirmation
- bindings/selection_api
- Selection API
- bindings/serial
- Web Serial API
- bindings/server_timing
- Server Timing
- bindings/service_workers
- Service Workers Nightly
- bindings/shape_detection_api
- Accelerated Shape Detection in Images
- bindings/speech_api
- Web Speech API
- bindings/storage
- Storage Standard
- bindings/storage_access
- The Storage Access API
- bindings/streams
- Streams Standard
- bindings/svg2
- Scalable Vector Graphics (SVG) 2
- bindings/svg_animations
- SVG Animations
- bindings/testutils
- Test Utils Standard
- bindings/text_detection_api
- Accelerated Text Detection in Images
- bindings/touch_events
- Touch Events - Level 2
- bindings/trusted_types
- Trusted Types
- bindings/ua_client_hints
- User-Agent Client Hints
- bindings/uievents
- UI Events
- bindings/url
- URL Standard
- bindings/urlpattern
- URLPattern API
- bindings/user_timing
- User Timing Level 3
- bindings/vibration
- Vibration API (Second Edition)
- bindings/video_rvfc
- HTMLVideoElement.requestVideoFrameCallback()
- bindings/virtual_keyboard
- VirtualKeyboard API
- bindings/wai_aria_1_2
- Accessible Rich Internet Applications (WAI-ARIA) 1.3
- bindings/wasm_js_api_2
- WebAssembly JavaScript Interface
- bindings/wasm_web_api_2
- WebAssembly Web API
- bindings/web_animations_1
- Web Animations
- bindings/web_animations_2
- Web Animations Level 2
- bindings/web_bluetooth
- Web Bluetooth
- bindings/web_locks
- Web Locks API
- bindings/web_nfc
- Web NFC
- bindings/web_otp
- WebOTP API
- Web Share API
- bindings/webaudio
- Web Audio API
- bindings/webauthn_3
- Web Authentication: An API for accessing Public Key Credentials - Level
- bindings/webcodecs
- WebCodecs
- bindings/webcrypto_secure_curves
- Secure Curves in the Web Cryptography API
- bindings/webcryptoapi
- Web Cryptography API
- bindings/webdriver2
- WebDriver
- bindings/webgl1
- WebGL Specification
- bindings/webgl2
- WebGL 2.0 Specification
- bindings/webgl_blend_equation_advanced_coherent
- WebGL WEBGL_blend_equation_advanced_coherent Extension Draft Specification
- bindings/webgl_color_buffer_float
- WebGL WEBGL_color_buffer_float Extension Specification
- bindings/webgl_compressed_texture_astc
- WebGL WEBGL_compressed_texture_astc Extension Specification
- bindings/webgl_compressed_texture_etc
- WebGL WEBGL_compressed_texture_etc Extension Specification
- bindings/webgl_compressed_texture_etc1
- WebGL WEBGL_compressed_texture_etc1 Extension Specification
- bindings/webgl_compressed_texture_pvrtc
- WebGL WEBGL_compressed_texture_pvrtc Extension Specification
- bindings/webgl_compressed_texture_s3tc
- WebGL WEBGL_compressed_texture_s3tc Khronos Ratified Extension Specification
- bindings/webgl_compressed_texture_s3tc_srgb
- WebGL WEBGL_compressed_texture_s3tc_srgb Extension Specification
- bindings/webgl_debug_renderer_info
- WebGL WEBGL_debug_renderer_info Khronos Ratified Extension Specification
- bindings/webgl_debug_shaders
- WebGL WEBGL_debug_shaders Khronos Ratified Extension Specification
- bindings/webgl_depth_texture
- WebGL WEBGL_depth_texture Khronos Ratified Extension Specification
- bindings/webgl_draw_buffers
- WebGL WEBGL_draw_buffers Khronos Ratified Extension Specification
- bindings/webgl_draw_instanced_base_vertex_base_instance
- WebGL WEBGL_draw_instanced_base_vertex_base_instance Extension Draft Specification
- bindings/webgl_lose_context
- WebGL WEBGL_lose_context Khronos Ratified Extension Specification
- bindings/webgl_multi_draw
- WebGL WEBGL_multi_draw Extension Specification
- bindings/webgl_multi_draw_instanced_base_vertex_base_instance
- WebGL WEBGL_multi_draw_instanced_base_vertex_base_instance Extension Draft Specification
- bindings/webgpu
- WebGPU
- bindings/webhid
- WebHID API
- bindings/webidl
- Web IDL Standard
- bindings/webmidi
- Web MIDI API
- bindings/webnn
- Web Neural Network API
- bindings/webrtc
- WebRTC 1.0: Real-Time Communication Between Browsers
- bindings/webrtc_encoded_transform
- WebRTC Encoded Transform
- bindings/webrtc_ice
- IceTransport Extensions for WebRTC
- bindings/webrtc_identity
- Identity for WebRTC 1.0
- bindings/webrtc_priority
- WebRTC Priority Control API
- bindings/webrtc_stats
- Identifiers for WebRTC's Statistics API
- bindings/webrtc_svc
- Scalable Video Coding (SVC) Extension for WebRTC
- bindings/websockets
- WebSockets Standard
- bindings/webtransport
- WebTransport
- bindings/webusb
- WebUSB API
- bindings/webvtt1
- WebVTT: The Web Video Text Tracks Format
- bindings/webxr
- WebXR Device API
- bindings/webxr_ar_module_1
- WebXR Augmented Reality Module - Level 1
- bindings/webxr_depth_sensing_1
- WebXR Depth Sensing Module
- bindings/webxr_dom_overlays_1
- WebXR DOM Overlays Module
- bindings/webxr_gamepads_module_1
- WebXR Gamepads Module - Level 1
- bindings/webxr_hand_input_1
- WebXR Hand Input Module - Level 1
- bindings/webxr_hit_test_1
- WebXR Hit Test Module
- bindings/webxr_lighting_estimation_1
- WebXR Lighting Estimation API Level 1
- bindings/webxrlayers_1
- WebXR Layers API Level 1
- bindings/window_controls_overlay
- Window Controls Overlay
- bindings/window_placement
- Multi-Screen Window Placement
- bindings/xhr
- XMLHttpRequest Standard
- js_bindings
- manual
- manual/extensions/document