forked from react-native-webview/react-native-webview
-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: implement onShouldStartLoadWithRequest and webView turboModule #250
Merged
Merged
Changes from 1 commit
Commits
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 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 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 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 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 @@ | ||
import { UITurboModule } from '@rnoh/react-native-openharmony/ts'; | ||
import { TM } from '@rnoh/react-native-openharmony/generated/ts'; | ||
|
||
export class WebViewTurboModule extends UITurboModule implements TM.RNCWebViewModule.Spec { | ||
private loadCallbackMap : Map<number,()=> void> = new Map(); | ||
|
||
isFileUploadSupported(): Promise<boolean> { | ||
return Promise.resolve(true) | ||
} | ||
|
||
shouldStartLoadWithLockIdentifier(shouldStart: boolean, lockIdentifier: number): void { | ||
if (shouldStart) { | ||
this.callLoadFunction(lockIdentifier) | ||
}else { | ||
this.loadCallbackMap.delete(lockIdentifier) | ||
} | ||
} | ||
|
||
setLoadCallback(tag:number, cb: ()=> void) { | ||
this.loadCallbackMap.set(tag,cb) | ||
} | ||
|
||
callLoadFunction(tag:number){ | ||
this.loadCallbackMap.get(tag)?.() | ||
this.loadCallbackMap.delete(tag) | ||
} | ||
} |
This file contains 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,13 @@ | ||
import type { TurboModule } from 'react-native'; | ||
import { TurboModuleRegistry } from 'react-native'; | ||
import { Double } from 'react-native/Libraries/Types/CodegenTypes'; | ||
|
||
export interface Spec extends TurboModule { | ||
isFileUploadSupported(): Promise<boolean>; | ||
shouldStartLoadWithLockIdentifier( | ||
shouldStart: boolean, | ||
lockIdentifier: Double | ||
): void; | ||
} | ||
|
||
export default TurboModuleRegistry.getEnforcing<Spec>('RNCWebViewModule'); |
This file contains 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
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.
都为空的时候是否需要添加判断
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.
进入加载拦截的回调中都是有url 或者data的,前面加载前已经做了判断处理
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.
this.descriptorWrapper.rawProps.newSource.uri 导致 asset:// 转换失效了
@425765923
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.
如果没有onShouldStartLoadWithRequest使用需求,建议0.2.33版本webview。当前版本onShouldStartLoadWithRequest实现的适用场景比较有限,完整实现需要依赖后续rnoh接口。若目前对该接口有简单需求,也可修改arkts实现代码,将rn拦截逻辑放置与原生端做规避。
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.
👌