Skip to content
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

ios expose constantsController #446 #487

Merged
merged 4 commits into from
Aug 14, 2024

Conversation

cehan-Chloe
Copy link
Collaborator

@cehan-Chloe cehan-Chloe commented Aug 9, 2024

Issue: #446

Test:

  1. add constants controller tests to playerUITests(unit tests)
  2. Use reference-assets plugin TextAsset
    Simulator change(new value "abc" from constants):
    image

TextAsset code change:

struct TextAssetView: View {
    /// The viewModel with decoded data, supplied by `TextAsset`
    @ObservedObject var model: AssetViewModel<TextData>
    @Environment(\.constantsController) var constantsController: ConstantsController?

    @ViewBuilder
    var body: some View {
        VStack {
        if let link = model.data.modifiers?.first(where: { $0.type == "link" })?.metaData?.ref {
            Text(model.data.value.stringValue ?? "").bold().modifier(LinkModifier(link)).accessibility(identifier: model.data.id)
        } else {
            let constantValue: String = constantsController?.getConstants(key: "test", namespace: "test")  ?? "sad"
            Text(constantValue)
        }
        }.onAppear {
            constantsController?.addConstants(data: ["test": "abc"], namespace: "test")
        }
    }
}

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs
📦 Published PR as canary version: 0.8.1--canary.487.16814

Try this version out locally by upgrading relevant packages to 0.8.1--canary.487.16814

Version

Published prerelease version: 0.9.0-next.5

Changelog

Release Notes

Storybook Addon Fixes (#449)

  • Re-adds the ability to render Asset properties as a tab in storybook
  • Re-adds the flow-refresh addon
  • Fixes the dependencies & package layout for the storybook addon
  • Fix dark-mode support

[Hermes] Android integration (#410)

Initial integration with the Hermes JavaScript runtime. This shows a tremendous size improvement over the existing J2V8 integration of ~70% (7.6 MB -> 2.3 MB, architecture dependent).

Opt-in

For now, the default runtime integration provided by the Android Player will still be com.intuit.playerui:j2v8-android, but Hermes can be opted in manually by excluding the J2V8 transitive dependency and including the Hermes artifact:

dependencies {
    // Android Player dependency
    implementation("com.intuit.playerui", "android", PLAYER_VERSION) {
        // J2V8 included for release versions
        exclude(group = "com.intuit.playerui", module = "j2v8-android")
        // Debuggable J2V8 included for canary versions
        exclude(group = "com.intuit.playerui", module = "j2v8-android-debug")
    }
    // Override with Hermes runtime
    implementation("com.intuit.playerui", "hermes-android", PLAYER_VERSION)
}

// Exclude J2V8 transitive dependency for all configurations in this module
configurations { 
    all {
        exclude(group = "com.intuit.playerui", module = "j2v8-android")
        // Debuggable J2V8 included for canary versions
        exclude(group = "com.intuit.playerui", module = "j2v8-android-debug")
    }
}

[!TIP]
If your application includes dependencies that may transitively depend on com.intuit.playerui:android, you would likely need to ensure the default runtime is transitively excluded from those as well, either manually or as a global strategy.

The AndroidPlayer will pick the first runtime it finds on the classpath - you can at least verify which runtime was used for the Player with a new log: Player created using $runtime. But that won't tell you for certain if the other runtimes were successfully excluded. You'll need to examine your APK, or your apps dependency tree, to tell for sure that redundant runtimes aren't unintentionally included.

Most of the setup for this integration is done simply by including the right dependency (and excluding the wrong one), however, the hermes-android integration also relies on the SoLoader for loading the native libraries. All that's needed is to initialize the SoLoader (should be on your classpath with the hermes-android dependency) with an Android Context somewhere before you use the AndroidPlayer, potentially in your activities onCreate:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    SoLoader.init(this, false)
    // ...
}

🚀 Enhancement

🐛 Bug Fix

Authors: 6

@cehan-Chloe cehan-Chloe linked an issue Aug 9, 2024 that may be closed by this pull request
@cehan-Chloe cehan-Chloe marked this pull request as ready for review August 9, 2024 14:53
Copy link

codecov bot commented Aug 9, 2024

Codecov Report

Attention: Patch coverage is 99.22481% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.97%. Comparing base (0c12e2a) to head (08cbaea).
Report is 21 commits behind head on main.

Files Patch % Lines
ios/core/Sources/Player/HeadlessPlayer.swift 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #487      +/-   ##
==========================================
+ Coverage   91.94%   91.97%   +0.03%     
==========================================
  Files         340      341       +1     
  Lines       26838    26967     +129     
  Branches     1946     1946              
==========================================
+ Hits        24675    24803     +128     
- Misses       2149     2150       +1     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cehan-Chloe
Copy link
Collaborator Author

/canary

@cehan-Chloe cehan-Chloe merged commit 1cc6018 into main Aug 14, 2024
11 checks passed
@cehan-Chloe cehan-Chloe deleted the playa9045-ios-expose-constantsController branch August 14, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS: Expose constantsController
3 participants