Open
Conversation
…ByKey BridgeJS: Remove adhoc `exportedProtocolNameByKey` recording
…2ac569dce3906 BridgeJS: Merge small core files into single Misc.swift
* Add SwiftToSkeleton unified Swift-to-skeleton API Now ExportSwift/ImportTS are not responsible for collecting macro-annotated decls and produce skeletons. * PlayBridgeJS: Update to use SwiftToSkeleton
Utilities/format.swift now looks up `SWIFT_PATH` for the "swift" command location, but PackageToJS's test suites also use this env var to locate the Swift toolchain bin path. To avoid confusion, rename the env var in PackageToJS from `SWIFT_PATH` to `SWIFT_BIN_PATH`.
* BridgeJS: Unify Swift type lookup logic between import/export * BridgeJS: Index known JS types for type lookup
* Implemented TypeScript `enum` → Swift `enum` import for BridgeJS (string-valued enums, plus int-valued as a bonus).
- `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js`: emits Swift `enum Name: String { ... }` (or `: Int`) for TS enums, adds `extension Name: _BridgedSwiftEnumNoPayload {}`, and ensures enum-typed parameters/returns stay typed as the enum (not downgraded to `String`).
- `Plugins/BridgeJS/Sources/BridgeJSCore/ImportSwiftMacros.swift`: resolves referenced Swift enums/typealiases via `TypeDeclResolver` so `FeatureFlag` becomes `.rawValueEnum("FeatureFlag", .string)` in the imported skeleton.
- `Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift`: enables lowering/lifting for `.rawValueEnum` in the `.importTS` context (parameters + returns).
- Added coverage: `Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/StringEnum.d.ts` with new snapshots `Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringEnum.Macros.swift` and `Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringEnum.swift`.
- Verified with `swift test --package-path ./Plugins/BridgeJS --filter ImportTSTests`.
* Added a BridgeJS runtime import test for TS string enums.
- Updated `Tests/BridgeJSRuntimeTests/bridge-js.d.ts` with `FeatureFlag` + `jsRoundTripFeatureFlag`.
- Added JS implementation in `Tests/prelude.mjs`.
- Added XCTest in `Tests/BridgeJSRuntimeTests/ImportAPITests.swift` (`testRoundTripFeatureFlag`).
- Regenerated runtime fixtures under `Tests/BridgeJSRuntimeTests/Generated/` (via `BridgeJSTool generate`).
- Verified runtime: `make unittest SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT+MAIN-wasm32-unknown-wasip1-threads` (passes).
…s in exported APIs by treating `@JSClass` **classes/actors** as `.jsObject` (previously they were misclassified as Swift heap objects, producing JS like `Foo.__construct(...)`). - Fix: `Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift` - Regression test + snapshots: `Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/ImportedTypeInExportedInterface.swift`, `Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.Export.js`, `Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.Export.d.ts`, `Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/ImportedTypeInExportedInterface.swift`, `Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/ImportedTypeInExportedInterface.json` - Verified with `swift test --package-path ./Plugins/BridgeJS`
Enable closure parameter/return types for imported JS interfaces and emit the required closure glue from BridgeJSTool.
…rt-interface BridgeJS: allow exported APIs to use imported @jsclass types
- Updated `@JSClass` macro to emit an error unless it’s attached to a `struct` (`Plugins/BridgeJS/Sources/BridgeJSMacros/JSClassMacro.swift:13`). - Added new diagnostic message `@JSClass can only be applied to structs.` (`Plugins/BridgeJS/Sources/BridgeJSMacros/JSMacroSupport.swift:8`). - Updated macro expansion tests so `class`/`enum`/`actor` usages now produce diagnostics and no generated members/extensions (`Plugins/BridgeJS/Tests/BridgeJSMacrosTests/JSClassMacroTests.swift:147`). - Verified with `swift test --package-path ./Plugins/BridgeJS --filter BridgeJSMacrosTests`.
Add runtime import fixtures and tests for passing Swift closures into JS and receiving JS functions back as Swift closures.
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
NFC: BridgeJS: Remove dead cleanup infrastructure
…g and helper consolidation
…lined layer of indirection
[NFC] BridgeJS: Work around extern inlining by adding an extra non-inlined layer of indirection
TS2Swift: warn on skipped exports
NFC: BridgeJS: Refactor JSGlueGen with compositional optional handling and helper consolidation
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
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 : )