Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swiftwasm/JavaScriptKit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.42.1
Choose a base ref
...
head repository: swiftwasm/JavaScriptKit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.43.0
Choose a head ref
  • 4 commits
  • 40 files changed
  • 3 contributors

Commits on Feb 6, 2026

  1. BridgeJS: Generate Swift doc-comment based on JSDoc (#596)

    * Doc comments from .d.ts JSDoc now flow into generated Swift DocC output.
    
    - Added JSDoc parsing (description/@param/@returns) and DocC emission for callable/typed declarations, including classes/interfaces/enums, in `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js`, with guards to only read param/return tags on callable nodes.
    - Added a documented fixture to cover the new behavior and updated the Vitest snapshot (`Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/Documentation.d.ts`, `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/__snapshots__/ts2swift.test.js.snap`).
    
    Tests:
    - `npm test -- -u` (Plugins/BridgeJS/Sources/TS2Swift/JavaScript)
    
    Next steps: optionally run `swift test --package-path ./Plugins/BridgeJS` to keep the Swift-side suite green.
    
    * Added richer WebIDL-derived doc coverage using the bridgejs-development skill: new fixtures model lib.dom-style comments (MDN reference blocks, @param text) and updated Vitest snapshots to show how those JSDoc comments render into DocC. Key files: `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/WebIDLDOMDocs.d.ts`, `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/DOMLike.d.ts`, and the refreshed snapshot in `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/__snapshots__/ts2swift.test.js.snap`. Tests run: `npm test -- -u` (TS2Swift JavaScript).
    
    * Removed the DOM-like fixture and refreshed snapshots to drop its output. Changes: deleted `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/fixtures/DOMLike.d.ts` and updated `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/test/__snapshots__/ts2swift.test.js.snap`.
    
    Tests: `npm test -- -u` (TS2Swift JavaScript).
    kateinoigakukun authored Feb 6, 2026
    Configuration menu
    Copy the full SHA
    bc752fc View commit details
    Browse the repository at this point in the history
  2. BridgeJS: Improve diagnostics and fix-its for macros

    Examples added/covered in this change:
    - @JSFunction: enforce throws(JSException) (missing or wrong type) with note + fix-it ("Declare throws(JSException)").
    - @JSFunction: instance members outside @jsclass emit a clear diagnostic.
    - @JSGetter/@JSSetter: members (instance/static/class) outside @jsclass emit a clear diagnostic.
    - @JSSetter: invalid setter names (e.g. updateFoo) emit a diagnostic and suggest a rename fix-it (e.g. setFoo).
    - @JSSetter: missing value parameter emits a diagnostic and suggests adding a placeholder parameter.
    - @jsclass: using @jsclass on non-struct declarations emits a diagnostic; for "class" also suggests "Change 'class' to 'struct'".
    kateinoigakukun committed Feb 6, 2026
    Configuration menu
    Copy the full SHA
    610b1a6 View commit details
    Browse the repository at this point in the history
  3. Merge pull request #597 from swiftwasm/katei/b443-bridgejs-macros

    BridgeJS: Improve diagnostics and fix-its for macros
    krodak authored Feb 6, 2026
    Configuration menu
    Copy the full SHA
    f68159c View commit details
    Browse the repository at this point in the history
  4. 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.
    kateinoigakukun authored Feb 6, 2026
    Configuration menu
    Copy the full SHA
    8217d06 View commit details
    Browse the repository at this point in the history
Loading