Releases: swiftwasm/JavaScriptKit
0.10.1
This is a minor patch release that includes updates to our dependencies and minor documentation tweaks.
Closed issues:
- Do you accept contributions for wrappers over JavaScript objects? (#124)
- Can't read from a file using
JSPromise
(#121) - TypeError when trying to implement a
JSBridgedClass
forWebSocket.send
(#120)
Merged pull requests:
- Update JS dependencies in package-lock.json (#126) via @MaxDesiatov
- Fix typo in method documentation (#125) via @revolter
- Update exported func name to match exported name (#123) via @kateinoigakukun
- Fix incorrect link in
JSDate
documentation (#122) via @revolter
0.10.0
This release contains multiple breaking changes in preparation for enabling async
/await
, when this feature is available in a stable SwiftWasm release. Namely:
JSClosure.init(_ body: @escaping ([JSValue]) -> ())
overload is deprecated to simplify type checking. Its presence requires explicit type signatures at the place of use. It will be removed in a future version of JavaScriptKit.JSClosure
is no longer a subclass ofJSFunction
. These classes are not related enough to keep them in the same class hierarchy. As a result, you can no longer callJSClosure
objects directly from Swift. Call wrapped closures directly instead.- Introduced
JSOneshotClosure
for closures that are going to be called only once. You don't need to manage references to these closures manually, as opposed toJSClosure
. However, they can only be called a single time from the JS side. Subsequent invocation attempts will raise a fatal error on the Swift side. - Removed generic parameters on
JSPromise
, now both success and failure values are always assumed to be ofJSValue
type. This also significantly simplifies type checking and allows callers to fully control type casting if needed.
Closed issues:
- DOMKit? (#21)
Merged pull requests:
- Simplify
JSPromise
API (#115) via @kateinoigakukun - Create
FUNDING.yml
(#117) via @MaxDesiatov - Major API change on
JSClosure
(#113) via @kateinoigakukun - Update
package.json
to lockfileVersion 2 (#114) via @kateinoigakukun - Bump
ini
from 1.3.5 to 1.3.8 in/Example
(#111) via @dependabot[bot] - Update doc comment in
JSTypedArray.swift
(#110) via @MaxDesiatov
0.9.0
This release introduces support for catching JSError
instances in Swift from throwing JavaScript functions. This is possible thanks to the new JSThrowingFunction
and JSThrowingObject
classes. The former can only be called with try
, while the latter will expose all of its member functions as throwing. Use the new throws
property on JSFunction
to convert it to JSThrowingFunction
, and the new throwing
property on JSObject
to convert it to JSThrowingObject
.
Closed issues:
- Support JS errors (#37)
Merged pull requests:
- Update toolchain version swift-wasm-5.3.0-RELEASE (#108) via @kateinoigakukun
- Update ci trigger condition (#104) via @kateinoigakukun
- Fix branch and triple in
compatibility.yml
(#105) via @MaxDesiatov - Check source code compatibility (#103) via @kateinoigakukun
- JS Exception Support (#102) via @kateinoigakukun
- Mention
carton
Docker image and refine wording inREADME.md
(#101) via @MaxDesiatov
0.8.0
This release introduces a few enhancements and deprecations. Namely, JSValueConstructible
and JSValueConvertible
were renamed to ConstructibleFromJSValue
and ConvertibleToJSValue
respectively. The old names are deprecated, and you should move away from using the old names in your code. Additionally, JavaScriptKit now requires the most recent 5.3 and development toolchains, but thanks to this it no longer uses unsafe flags, which prevented building other libraries depending on JavaScriptKit on other platforms.
The main user-visible enhancement is that now force casts are no longer required in client code. That is, we now allow this
let document = JSObject.global.document
let foundDivs = document.getElementsByTagName("div")
in addition to the previously available explicit style with force unwrapping:
let document = JSObject.global.document.object!
let foundDivs = document.getElementsByTagName!("div").object!
Note that the code in the first example is still dynamically typed. The Swift compiler won't warn you if you misspell names of properties or cast them to a wrong type. This feature is purely additive, and is added for convenience. You can still use force unwraps in your code interfacing with JavaScriptKit. If you're interested in a statically-typed DOM API, we recommend having a look at the DOMKit library, which is currently in development.
Lastly, JSError
now conforms to the JSBridgedClass
protocol, which makes it easier to integrate with idiomatic Swift code.
Closed issues:
- Errors building example: undefined symbols (#95)
- Documentation website is broken (#93)
- Rename
JSValueConstructible
andJSValueConvertible
(#87) - Build fails with the unsafe flags error (#6)
Merged pull requests:
- Update example code in
README.md
(#100) via @MaxDesiatov - Update toolchain version, script, and
README.md
(#96) via @MaxDesiatov - [Proposal] Add unsafe convenience methods for JSValue (#98) via @kateinoigakukun
- Remove all unsafe linker flags from Package.swift (#91) via @kateinoigakukun
- Sync package.json and package-lock.json (#90) via @kateinoigakukun
- Rename JSValueConvertible/Constructible/Codable (#88) via @j-f1
- Bump @actions/core from 1.2.2 to 1.2.6 in /ci/perf-tester (#89) via @dependabot[bot]
- Make
JSError
conform toJSBridgedClass
(#86) via @MaxDesiatov
0.7.2
0.7.1
This is a bugfix release that resolves an issue with the JavaScript runtime being unavailable when installed via NPM.
Closed issues:
Merged pull requests:
- Fix runtime files location in
package.json
(#81) via @MaxDesiatov - Run 4 perf tests instead of 2 (#80) via @j-f1
- Specify correct SwiftWasm snapshot in
README.md
(#78) via @MaxDesiatov
0.7.0
This release adds multiple new types bridged from JavaScript, namely JSError
, JSDate
, JSTimer
(which corresponds to setTimeout
/setInterval
calls and manages closure lifetime for you), JSString
and JSPromise
. We now also have documentation published automatically for the main branch.
Closed issues:
TypedArray
improvement? (#52)
Merged pull requests:
- Add a generic
JSPromise
implementation (#62) via @MaxDesiatov - Remove payload2 from value bridging interface (#64) via @kateinoigakukun
- Update Node.js dependencies (#65) via @MaxDesiatov
- Implement
JSString
to reduce bridging overhead (#63) via @kateinoigakukun - Add
JSBridgedType
andJSBridgedClass
(#26) via @j-f1 - Make
JSValue
conform toExpressibleByNilLiteral
(#59) via @j-f1 - Remove
JavaScriptTypedArrayKind
(#58) via @j-f1 - Add doc comments for public APIs (Part 2) (#57) via @kateinoigakukun
- Add doc comments for public APIs (Part 1) (#55) via @kateinoigakukun
- Cleanup invalid test target (#53) via @kateinoigakukun
- Remove deprecated Ref suffix (#51) via @j-f1
- Rename
ref
tojsObject
on JSDate for consistency with JSError (#50) via @MaxDesiatov - Generate and publish documentation with
swift-doc
(#49) via @MaxDesiatov - Add
JSTimer
implementation with tests (#46) via @MaxDesiatov - Add
JSError.stack
, addError
conformance (#48) via @MaxDesiatov - Add
JSDate
implementation with tests (#45) via @MaxDesiatov - Add
JSError
with tests, add JSObject.description (#47) via @MaxDesiatov
0.6.0
This release adds JSTypedArray
generic type, renames JSObjectRef
to JSObject
, and makes JSClosure
memory management more explicit.
Closed issues:
- Support for JS Arrays “holes”, including the test suite (#39)
- BigInt Support (#29)
- Separate namespaces for methods and properties? (#27)
Merged pull requests:
- Add a helper method to copy an array of numbers to a JS TypedArray (#31) via @j-f1
- Resolve small issues (#44) via @kateinoigakukun
- Bump bl from 3.0.0 to 3.0.1 in /IntegrationTests (#42) via @dependabot[bot]
- Bump bl from 3.0.0 to 3.0.1 in /Example (#43) via @dependabot[bot]
- Support Holes in Array (#41) via @kateinoigakukun
- Refine public API (#40) via @kateinoigakukun
- Fix invalid array termination for null and undefined (#38) via @kateinoigakukun
- Add a test helper function (#36) via @j-f1
- Enable Xcode 12 with fresh SwiftWasm 5.3 snapshot (#35) via @MaxDesiatov
- Add void-returning overload to
JSClosure.init
(#34) via @MaxDesiatov - Change
JSClosure.release
todeinit
(#33) via @MaxDesiatov - Clean up the
JSObjectRef
API (#28) via @j-f1 - Remove unused
Tests
directory (#32) via @MaxDesiatov
0.1.0
Update package.json