js_interop_utils 1.1.1
js_interop_utils: ^1.1.1 copied to clipboard
A Dart library for seamless interaction with JavaScript using `dart:js_interop`, supporting deep transformations of objects, maps, and arrays.
1.1.1 #
JSArrayOfJSNumberExtension.toListNum/JSArrayExtension.toListOfInt:- Fix: whole numbers beyond the safe integer range (
±(2^53 - 1)) were converted withtoInt(), which caps them on the VM/dart2wasm(e.g.1e20became9223372036854775807).toListNumnow keeps them asdouble, andtoListOfIntskips them.
- Fix: whole numbers beyond the safe integer range (
1.1.0 #
-
sdk: ^3.13.0
-
ObjectExtension:isJSAny,asJSAny,isJSObject,asJSObject,objectDartify:- Reimplemented with
Object?.isA<T>()(Dart 3.12+), removing theis JSxxxchecks andinvalid_runtime_check_with_js_interop_typesignores. - Fix: a non-JS Dart object (e.g. an instance of a Dart class) is no longer reported as a
JSAnywithdart2js. null(ambiguous) is still returned for JS values that are also a DartList/Map/Function(dart2js).
- Reimplemented with
- Added
isJSFunctionandisJSExportedDartFunction. toJSDeep: Fix:TypedData(e.g. aUint8Listinside aMap) is converted to a JS typed array, not to a JSArray.
-
Fix:
Int8List,Uint8ClampedList,Int16List,Uint16List,Int32List,Uint32List,Float32ListandFloat64List.toJSreturned a JSArray: the packageIterable<int>/Iterable<double>toJSextensions shadowed thedart:js_interopones. AddedInt8ListExtension,Uint8ClampedListExtension,Int16ListExtension,Uint16ListExtension,Int32ListExtension,Uint32ListExtension,Float32ListExtensionandFloat64ListExtension(asUint8ListExtensionalready did forUint8List). -
IterableExtension:- Added
toJSIterableDeep: lazyJSIterablecounterpart oftoJSDeep(usesIterable.toJSIterable, Dart 3.12+).
- Added
-
Added
JSIterableExtensionwithtoIterableandtoList.- Works around
JSIterable.toDartIterablefailing for a JS string (Reflect.get called on non-object).
- Works around
-
JSObjectExtension:- Added
prototype(JSObject.getPrototypeOf, Dart 3.13+) andisPlainObject. as<T>():- Fix: with
dart2wasmall interop types are erased to one runtime type, so dispatching onTreturnednullfor valid casts (e.g.JSObject().as<JSObject>()). It now only casts whenTcan't be inspected. - Fix:
as<JSObject>()returnednullwithdart2js. - Added
JSFunctioncheck; removed duplicatedJSInt8Arraybranch and unreachableJSPromisebranch.
- Fix: with
- Added
-
JSArrayExtension:push: usesJSArray.add.- Fix:
toListOfDoublenow returnsList<double>(was aList<int>of only the integer elements). - Fix:
toListOfIntreturned an empty list withdart2wasm(JS numbers are dartified asdouble). It now returns the integer-valued numbers on all platforms.
-
JSArrayOfJSNumberExtension:- Fix:
toListNumthrew for non-integer numbers (e.g.2.5) withdart2js.
- Fix:
-
Tests:
- Added integration tests (
test/js_integration_test.dart) exchanging values with real JS code (JSON, iteration protocols,Set/Map/generators, callbacks,BigInt,Date, typed arrays, prototypes). - Added unit tests for the whole public API (
test/js_interop_utils_api_test.dart).
- Added integration tests (
-
JSObjectUtil: addedprototype(Object.prototype). -
lints: ^6.1.0
-
test: ^1.32.0
-
dependency_validator: ^5.1.0
1.0.11 #
lib/src/js_interop_utils_extensions.dart:- Added nullable iterable extensions for JS interop conversions:
IterableStringNullableExtensionwithtoJSreturningJSArray<JSString?>.IterableNumNullableExtensionwithtoJSreturningJSArray<JSNumber?>.IterableIntNullableExtensionwithtoJSreturningJSArray<JSNumber?>.IterableDoubleNullableExtensionwithtoJSreturningJSArray<JSNumber?>.IterableBoolNullableExtensionwithtoJSreturningJSArray<JSBoolean?>.
- Added nullable iterable extensions for JS interop conversions:
1.0.10 #
IterableExtension,IterableOfIterableExtension,IterableStringExtension,IterableNumExtension,IterableIntExtension,IterableDoubleExtension,IterableBoolExtension:toJSDeep: removed intermediate.toList()call before.toJS.
1.0.9 #
-
ObjectExtension:toJSDeep:- Optimize for
Function: callself.jsify().
- Optimize for
-
test: ^1.26.3
1.0.8 #
-
Added
Uint8ListExtensionwithtoJSmethod forJSUint8Arrayconversion. -
Updated
isJSAnycheck to supportJSTypedArray. -
test: ^1.26.2
1.0.7 #
-
JSArrayExtension:toIterable,toList: avoid return of<dynamic>and avoid issues withdynamicvalues.
-
dependency_validator: ^4.1.3
1.0.6 #
- New
JSDate:DateTimeToJSDateExtension:toJSDate.
1.0.5 #
-
Improve
isJSAnyimplementation forbool,numandString. -
Improve
isJSAnyandasJSAnytests. -
test: ^1.25.15
1.0.4 #
- Improve
isJSAnyandisJSObject.
1.0.3 #
- New
StringExtension:- Added
toDartFix.
- Added
1.0.2 #
-
JSObjectUtil: fixjsKeysmapping name. -
ObjectExtension: addedasJSAny.
1.0.1 #
-
Added extension
Object.isJSAnyandObject.objectDartify(); -
CI: test with
dart2jsanddart2wasm(on Chrome).
1.0.0 #
- Initial version.