Open
Conversation
BridgeJS: support closure types in imported JS APIs
…arget non-Swift/quoted JS property names (`Sources/JavaScriptKit/Macros.swift`). - Plumbed `jsName` through the imported-property IR (`Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift`) and extraction (`Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift`). - Updated TS→Swift generation to no longer drop quoted/invalid TS property names; it now emits Swift-safe identifiers plus `@JSGetter(jsName: ...)` / `@JSSetter(jsName: ...)` as needed (`Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js`). - Updated JS glue + generated `.d.ts` to use bracket property access and quote invalid TS property keys (`Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift`). - Updated snapshots; `swift test --package-path ./Plugins/BridgeJS` now passes (requires `npm ci` at repo root to provide `typescript`).
…erty name is a normal identifier, falling back to bracket access only when needed. - Implementation: `Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift` - Updated snapshots (including `Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.Import.js:215`) - `swift test --package-path ./Plugins/BridgeJS` passes
- Updated macro APIs: `Sources/JavaScriptKit/Macros.swift` - Plumbed `jsName` through the imported skeleton + Swift parser: `Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift`, `Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift` - Updated JS glue + generated `.d.ts` to use the JS names (dot access when possible, bracket access when needed): `Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift` - Updated TS→Swift generator to emit `@JSClass(jsName: ...)` / `@JSFunction(jsName: ...)` when it has to sanitize names: `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js` - Added coverage for a renamed class + quoted method name: `Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/InvalidPropertyNames.d.ts` (snapshots refreshed; `swift test --package-path ./Plugins/BridgeJS` passes)
…ecl`, then again via `visitStructuredType` when the same type showed up in `seenTypes`), which caused the duplicate `_Weird` interface in `InvalidPropertyNames.Import.d.ts`. - Change: `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js` now records emitted class names in `emittedStructuredTypeNames` so the structured-type pass skips them. - Snapshots refreshed; `swift test --package-path ./Plugins/BridgeJS` passes.
…ass`. - Added new import API + XCTest: `Tests/BridgeJSRuntimeTests/bridge-js.d.ts`, `Tests/BridgeJSRuntimeTests/ImportAPITests.swift` - Wired JS-side implementations: `Tests/prelude.mjs` - Regenerated pre-generated files: `./Utilities/bridge-js-generate.sh` (updated `Tests/BridgeJSRuntimeTests/Generated/*`) - Verified: `SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1 make unittest` passes
Add struct-level helpers for copying values out of a backing JS object and raising a new JS object from a Swift struct. This makes it possible to round-trip JSON-style plain objects without manual field mapping, while keeping the default value semantics of exported structs.
BridgeJS: support jsName for imported bindings
* BridgeJS: support UnsafePointer-family types Allow UnsafePointer/UnsafeRawPointer/OpaquePointer as BridgeJS parameter/return and struct field types by lowering them to WASM pointers. Updates codegen/runtime intrinsics and adds coverage in generator snapshots + runtime exports. * Format
BridgeJS: add init(unsafelyCopying:) for @js structs
Add an opt-in from: .global source for @js* import macros so bindings can resolve values from globalThis without routing through the imports object. Teach ts2swift/BridgeJSTool to accept --global <d.ts> inputs (e.g. bridge-js.global.d.ts) so global declarations are separated cleanly, and update generated artifacts + snapshots.
BridgeJS: allow imports from globalThis
* Benchmarks: add optional-return cases and improve runner * Benchmarks: pass iterations without globals * Run ./Utilities/bridge-js-generate.sh --------- Co-authored-by: Krzysztof Rodak <krodak.konta@gmail.com>
BridgeJS: Use let for non-mutated __bjs_self in generated toJSObject()
…ds and optional context (#533)
They are cloned via stack ABI
BridgeJS: Support `@JS` Swift struct types in imported JS signatures
BridgeJS: Align naming for stack based types from "raise" to "lift"
BridgeJS: Fix memory management of SwiftHeapObject
BridgeJS: Fix `Array<@jsclass struct>` support on imported interfaces
…cess BridgeJS: fix namespaced Swift class access in JS codegen
BridgeJS: Fix stack ordering for optional arrays and dictionaries
Now `Optional` conforms to `_BridgedSwiftStackType` whenever `Wrapped`
conforms to `_BridgedSwiftStackType`. This makes generic programming
easier and reduces boilerplate in intrinsics and codegen.
For specialized handling of certain types like associated value enums,
where the presence of a value is encoded as a sentinel case ID (-1),
we implement `bridgeJSStack{Push,Pop}AsOptional` methods, which is on
the witness table of `_BridgedSwiftStackType`.
Also now some of optional types no longer pushes placeholders values for
`nil` cases when pushing in JS and popping in Swift.
…9941ebaf3ac11 BridgeJS: Remove inline array lifting/lowering codegen
BridgeJS: Cover more Array cases in runtime tests
…#679) BridgeJS: Move out default argument tests into a separate suite
…ace-nested classes
…odegen BridgeJS: Fix property codegen using unqualified type name for namespace-nested classes
…classes and structs
…061feae89f16f BridgeJS: Remove `_BridgedSwiftDictionaryStackType` protocol
BridgeJS: Include namespace prefix in ABI names for namespace-nested classes and structs
…9798ee0a74047 BridgeJS: Migrate Dictionary tests to use conventional style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )