-
Notifications
You must be signed in to change notification settings - Fork 247
Integrate initial uniffi rust core #1160
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c309757
fix: raise minimum SDK to Flutter 3.38 / Dart 3.10
1egoman 5074c77
style: reformat with dart format for the Dart 3.10 tall style
1egoman b62d54a
feat: wire in the livekit_uniffi Rust core behind a native-only facade
1egoman 850ff4e
Merge remote-tracking branch 'origin/main' into uniffi-rust-core
hiroshihorie 5cbd6d8
Reformat for the Dart 3.10 tall style after main sync
hiroshihorie 691502e
Drop floor-raise changeset and pubspec comment now covered by main
hiroshihorie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| patch type="added" "Wire in the livekit_uniffi Rust core behind a native-only facade, delivered as a bundled cdylib via Native Assets" |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright 2026 LiveKit, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import 'uniffi_io.dart' if (dart.library.js_interop) 'uniffi_web.dart' as impl; | ||
|
|
||
| /// Facade over the Rust core exposed by the `livekit_uniffi` package. | ||
| /// | ||
| /// `livekit_uniffi` reaches Rust through Dart's Native Assets: its build hook | ||
| /// bundles a `cdylib` into the host app and the generated bindings call into it | ||
| /// with `@Native`. None of that exists on the web, where there is no dynamic | ||
| /// library to load, so every entry point here is split native/web through the | ||
| /// same conditional-import pattern the rest of the SDK uses (see | ||
| /// `support/platform.dart`). Web builds must never reach the generated | ||
| /// bindings -- importing them at all would break `dart compile js`/`wasm`. | ||
| /// | ||
| /// Callers get [isAvailable] to branch on, and platform-specific code paths | ||
| /// stay out of the public API surface. | ||
| abstract final class LiveKitUniffi { | ||
| /// Whether the Rust core can be called on this platform. | ||
| /// | ||
| /// False on web. Every other member throws [UnsupportedError] when this is | ||
| /// false, rather than returning a silently wrong value. | ||
| static bool get isAvailable => impl.isAvailable; | ||
|
|
||
| /// Version string reported by the Rust core. | ||
| /// | ||
| /// The simplest possible round trip -- a synchronous, argument-free call | ||
| /// returning a string -- so it doubles as the smoke test that the whole | ||
| /// chain is wired up: build hook resolved the library, `@Native` bound the | ||
| /// symbol, and a value came back across the FFI boundary. | ||
| /// | ||
| /// Throws [UnsupportedError] on web. | ||
| static String get buildVersion => impl.buildVersion(); | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright 2026 LiveKit, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import 'package:livekit_uniffi/livekit_uniffi.dart' as uniffi; | ||
|
|
||
| /// Native implementation of [LiveKitUniffi]. See `uniffi.dart`. | ||
| /// | ||
| /// This is the only file in the SDK that may import the generated bindings: | ||
| /// the conditional import in `uniffi.dart` keeps it out of web builds. | ||
| const bool isAvailable = true; | ||
|
|
||
| String buildVersion() => uniffi.buildVersion(); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright 2026 LiveKit, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| /// Web implementation of [LiveKitUniffi]. See `uniffi.dart`. | ||
| /// | ||
| /// Native Assets bundles a `cdylib`, which the web has no way to load, so the | ||
| /// Rust core is simply absent here. This file deliberately does not import | ||
| /// `package:livekit_uniffi/...` -- doing so would pull `dart:ffi` into a web | ||
| /// compile and fail the build. | ||
| const bool isAvailable = false; | ||
|
|
||
| Never buildVersion() => throw UnsupportedError( | ||
| 'LiveKitUniffi.buildVersion is not available on web: the Rust core is ' | ||
| 'delivered as a native library. Guard calls with ' | ||
| 'LiveKitUniffi.isAvailable.', | ||
| ); |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright 2026 LiveKit, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| @TestOn('vm') | ||
| library; | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| import 'package:livekit_client/src/uniffi/uniffi.dart'; | ||
|
|
||
| void main() { | ||
| // Exercises the whole delivery chain rather than any particular API: the | ||
| // build hook resolved a cdylib for this target, Native Assets bundled it, | ||
| // `@Native` bound the symbol, and a value crossed back from Rust. If the | ||
| // bindgen or the hook regresses, this is what fails first. | ||
| group('livekit_uniffi', () { | ||
| test('is available on native platforms', () { | ||
| expect(LiveKitUniffi.isAvailable, isTrue); | ||
| }); | ||
|
|
||
| test('buildVersion returns the Rust core version', () { | ||
| final version = LiveKitUniffi.buildVersion; | ||
| expect(version, isNotEmpty); | ||
| // The crate stamps its own semver, so assert the shape rather than a | ||
| // literal that would need bumping on every livekit-uniffi release. | ||
| expect(version, matches(RegExp(r'^\d+\.\d+\.\d+'))); | ||
| }); | ||
| }); | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the newly introduced
LiveKitUniffifacade. This allows all these bits of functionality to be turned into noops on web.