Skip to content

Tags: swiftwasm/JavaScriptKit

Tags

0.44.1

Toggle 0.44.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
CI: Use debug builds for SwiftSyntax in ./Examples/Embedded (#632)

0.44.0

Toggle 0.44.0's commit message
Documentation tweaks

0.43.1

Toggle 0.43.1's commit message

0.43.0

Toggle 0.43.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
BridgeJS: Add `JSTypedClosure` API (#578)

The new API allows managing JS closures converted from Swift closures
from Swift side. It allows us to get the underlying `JSObject` and
manage its lifetime manually from Swift.

```swift
@js func makeIntToInt() throws(JSException) -> JSTypedClosure<(Int) -> Int> {
    return JSTypedClosure { x in
        return x + 1
    }
}

@JSFunction func takeIntToInt(_ transform: JSTypedClosure<(Int) -> Int>) throws(JSException)

let closure = JSTypedClosure<(Int) -> Int> { x in
    return x * 2
}
defer { closure.release() }
try takeIntToInt(closure)
```

Likewise to `JSClosure`, API users are responsible for "manually" releasing the
closure when it's no longer needed by calling `release()`. After releasing,
the closure becomes unusable and calling it will throw a JS exception
(note that we will not segfault even if the closure is called after releasing).

```swift
let closure = JSTypedClosure<(Int) -> Int> { x in
    return x * 2
}
closure.release()
try closure(10)  // "JSException: Attempted to call a released JSTypedClosure created at <file>:<line>"
```

As a belt-and-suspenders measure, the underlying JS closure is also
registered with a `FinalizationRegistry` to ensure that the Swift closure box
is released when the JS closure is garbage collected, in case the API user
forgets to call `release()`. However, relying on this mechanism is **not recommended**
because the timing of garbage collection is non-deterministic and it's
not guaranteed that it will happen in a timely manner.

----

On the top of the new API, this commit also fixes memory leak issues of
closures exported to JS.

0.42.1

Toggle 0.42.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
BridgeJS: Fix Dictionary bridging after Stack ABI refactor (#594)

0.42.0

Toggle 0.42.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request #590 from swiftwasm/yt/direction-agnostic-stack

[NFC] BridgeJS: Make Stack ABI storage direction agnostic

0.41.0

Toggle 0.41.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request #586 from PassiveLogic/krodak/directory-error

BridgeJS: Skip directories in generate input file processing

0.40.0

Toggle 0.40.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
BridgeJS: Fix macro test suites silently ignoring failures (#559)

* BridgeJS: Fix macro test suites silently ignoring failures

* BridgeJS: Fix macro unit tests and macro implementations to pass tests

0.39.0

Toggle 0.39.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request #524 from swiftwasm/katei/14ce-add-support-for

BridgeJS: support closure types in imported JS APIs

0.38.0

Toggle 0.38.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Documentation: Add JavaScript Interop Cheat Sheet (#491)