Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BridgeJS: @JS Protocol with methods support#456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@krodak
Copy link
Member

@krodakkrodak commentedOct 17, 2025
edited
Loading

Introduction

This PR adds basic support for exporting Swift protocols to JS / TS using BridgeJS plugin.

Overview

BridgeJS now supports exporting Swift protocols as TypeScript interfaces. JavaScript objects implementing these interfaces can be passed to Swift code, where they are automatically wrapped in generated Swift struct that forward method calls and property accesses to the JavaScript implementation.

When you mark a protocol with@JS, BridgeJS generates:

  • A TypeScript interface with the protocol's method signatures and properties
  • A Swift wrapper struct (Any{ProtocolName}) that conforms to the protocol
  • JavaScript bridge code that forwards calls between Swift and JavaScript

Current Limitations

This PR covers support for methods and basic types in parameters and return types, as these types are supported in both Export / Import directions.
Support for properties,Optional and others will be posted in separate PR as changeset is quite large.

Testing

Basic tests with protocol implementation on JS and Swift side used as delegate property of protocol type are added.

Documentation

Added toSources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Protocols.md

kateinoigakukun reacted with hooray emojikateinoigakukun reacted with heart emojikateinoigakukun reacted with rocket emoji
@krodakkrodak self-assigned thisOct 17, 2025
@krodakkrodakforce-pushed thefeat/protocol-support-methods branch 3 times, most recently fromc1d778e toe96d1e8CompareOctober 17, 2025 15:11
[fe09c4b1] Simplify export swift[b42bb7c1] WIP: Simplify protocol method generation[75e1ed37] BridgeJSLink simplification[b1fcc4d0] Cleanup[70aa0332] WIP: Final wrap[2f648eaf] WIP: Protocols simplification[f2f89b33] WIP: Fix for parameters in methods[6026fc1d] WIP: Test protocol methods with parameters
@krodakkrodakforce-pushed thefeat/protocol-support-methods branch frome96d1e8 to7efb593CompareOctober 17, 2025 16:18
Copy link
Member

@kateinoigakukunkateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good to me, thanks!

@kateinoigakukunkateinoigakukun merged commit6310307 intoswiftwasm:mainOct 22, 2025
9 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kateinoigakukunkateinoigakukunkateinoigakukun approved these changes

Assignees

@krodakkrodak

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@krodak@kateinoigakukun

[8]ページ先頭

©2009-2025 Movatter.jp