-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fabric (New Architecture) codegen support #3487
Fabric (New Architecture) codegen support #3487
Conversation
This reverts commit fc243b0.
@KrzysztofMoch Let me know if I have to fix or implement other things in this PR. |
Yeah, seems like we can't use |
@KrzysztofMoch Map<String, String> headers = new HashMap<>();
ReadableArray propSrcHeadersArray = (src.hasKey(PROP_SRC_HEADERS)) ? src.getArray(PROP_SRC_HEADERS) : null;
if (propSrcHeadersArray != null) {
if (propSrcHeadersArray.size() > 0) {
for (int i = 0; i < propSrcHeadersArray.size(); i++) {
ReadableMap current = propSrcHeadersArray.getMap(i);
String key = current.hasKey("key") ? current.getString("key") : null;
String value = current.hasKey("value") ? current.getString("value") : null;
if (key != null && value != null) {
headers.put(key, value);
}
}
}
} And also we should consider setDRM too. (but approach would be similar) So if you are okay about that code fragment, I will make an additional commit about this issue. |
src/types/video.ts
Outdated
selectedAudioTrack?: SelectedTrack; | ||
selectedTextTrack?: SelectedTrack; | ||
selectedVideoTrack?: SelectedVideoTrack; // android | ||
selectedAudioTrack?: SelectedTrackType; |
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.
I don't undestand why you did this change ...
SelectedTrack is an object representing all possible values to select a track where SelectedTrackType is an enum representing which kind of track selection can be used
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.
Hmm I couldn't fully understand your point.
So you want to use typescript's enum value as selectedAudioTrack's type?
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.
Ah, mate.
I think I just deleted typescript enum types and replaced them from codegen types to recycle codegen types.
Just naming and few types change for codegen types.
I think there would have no problem?
Let me know your opinion.
@freeboub
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 is doc:
selectedAudioTrack
Configure which audio track, if any, is played.
selectedAudioTrack={{
type: Type,
value: Value
}}
SelectedAudioTrack is an object
SelectedAudioTrack.type is the enum you use.
Is that clearer ?
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.
We use https://github.com/react-native-video/react-native-video/pull/3487/files#diff-70773b05560f0897b24b4baa0ed114158fd50e075c0c76de43cc30b90043eb80R75 this type from 'specs/VideoNativeComponent.tsx'
We cannot use typescript's enum type with codegen. It can't be possible.
So I recycled above codegen type for Selected**Track prop types.
I think you want to consider DX for developers by handling type
as enum.
I think it can be possible, but I'm not sure. I will have a try.
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.
@@ -0,0 +1,536 @@ | |||
/* eslint-disable @typescript-eslint/ban-types */ |
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.
Is it mandatory to move this file ?
It makes review harder ... (I think you remove and add instead of git mv)
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.
It's because of handling {}
on codegen.
I wanted to use Readonly but it cannot be possible.
But, I found another issue on OnReceiveAdEventData while I am looking this issue.
OnReceiveAdEventData['data'] type should be handled as array type I guess.
Because codegen cannot parse Record<string, string> type.
I think I just handle that type as just {} and I missed it.
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.
Or, we have to define OnReceiveAdEventData['data'] type as Readonly object if we can define what key and value are expected.
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.
@yungblud I think the point is that instead of deleting and adding a file (using git add
), you should use git mv
to move the file - this keeps the diff between files
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.
@KrzysztofMoch Thanks. That was my mistake.
I will try that!
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.
Hmm, I think I cannot do mv file clearly.
I tried multiple times but it's difficult to show just "mv" on file changes.
And thank you for extracting in smaller PR ! 🙏 |
Thanks my pleasure. |
@yungblud for me its okay 🙌 |
@KrzysztofMoch @freeboub And I would be happy if you guys check again my comments. |
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.
few minor comment.
Regarding to the sample, won't it make sens to merge the new arch with basic sample?
I don't request it now, I am just asking ! I am afraid it will be painful to maintain multiple sample.
android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java
Outdated
Show resolved
Hide resolved
Yeah maybe it would be happier. (if we can) |
src/types/video.ts
Outdated
@@ -80,7 +80,7 @@ export enum SelectedTrackType { | |||
|
|||
export type SelectedTrack = { | |||
type: SelectedTrackType; | |||
value?: string | number; |
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.
Value can be a number in the code ... it is used when we select by index.
Is it problematic for codegen ? I review last commit and it seems working with Int Type !
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.
Ah, all types in src/types/video.ts
are for JS layer's prop types.
The reason I removed number
is I did want to sync with codegen types of SelectedTrack.
Such as this https://github.com/react-native-video/react-native-video/pull/3487/files/d1a858a590339b48d5430fbe8b8769f8f1921bd6#diff-70773b05560f0897b24b4baa0ed114158fd50e075c0c76de43cc30b90043eb80R85
I think Codegen do not allow mixed types.
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.
Maybe we have to change docs content of this types.
I am not sure what is the best option. But codegen do not allow mixed types.
So maybe we have to change docs?
Let me know your opinion @freeboub
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.
ok, I can propose you this change:
- keep current behavior fo external API
- move the value to string only in native bindings (then string To Int in native code)
- do the wrapping in Video.js to convert the int to string
This is the ideal change. but is you really prefer keep it as string only (even in external API), just notice this is a breaking change. (but you need anyway to change the native code)
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.
okay I will have a check.
Thanks for the suggestions!
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.
@freeboub Hey, thanks for the reviewing my PR. |
This PR is OK for me @KrzysztofMoch can you please double check ? |
Okay, will check that |
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.
I have tested both iOS & android in basic example - and it's work perfectly
Now @yungblud you can leave it to use, we will release in our time 😄
Thanks for your effort!
@yungblud I have one question, I guess that with this change we will drop support for older versions of react-native. Do you know maybe what is the older version that we can support?
@KrzysztofMoch Hey, thanks for detailed review of my PR. https://reactnative.dev/blog/2022/03/30/version-068#opting-in-to-the-new-architecture |
I am ready to merge, but there are still conflicts ... |
@freeboub Hello! Conflicts were simple. had no problem. |
@freeboub I merged it to avoid next possible conflicts (if you are not happy with it please revert) |
@KrzysztofMoch I am happy with that :) |
Update the documentation
If you've added new functionality, update the README.md with an entry for your prop or event.
The entry should be inserted in alphabetical order.
Update the changelog
I've completed fully functioning codegen generate.
Provide an example of how to test the change
I've added
yarn codgen
script to package.json, so you guys can test codegen by run that script.Focus the PR on only one area
Describe the changes
src/VideoNativeComponent.ts
tosrc/specs/VideoNativeComponent.ts