Skip to content

Tags: swiftwasm/JavaScriptKit

Tags

0.46.2

Toggle 0.46.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
BridgeJS: Workaround `@_extern` inlining issue take 2 (#670)

0.46.1

Toggle 0.46.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request #665 from swiftwasm/fix-swift-class-array

BridgeJS: Fix `Array<@jsclass struct>` support on imported interfaces

0.46.0

Toggle 0.46.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request #656 from PassiveLogic/kr/jsglue-refactor

NFC: BridgeJS: Refactor JSGlueGen with compositional optional handling and helper consolidation

0.45.0

Toggle 0.45.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request #639 from PassiveLogic/kr/bridgejs-skip-unchanged-…

…writes

BridgeJS: Skip writing output files when content is unchanged

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