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

feat: publish the package to npm #7

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: package-publish

on: workflow_dispatch

jobs:
package-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install Package
run: yarn
- name: Build
run: yarn prepare
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm whoami && npm publish --access public
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import java.util.List;
import java.util.Map;

public class RNCWebView extends WebView implements LifecycleEventListener {
public class RNCWebView extends WebView implements LifecycleEventListener, RNCWebViewClient.OnLoadingFinishedListener {
protected @Nullable
String injectedJS;
protected @Nullable
Expand Down Expand Up @@ -214,6 +214,7 @@ public void setWebViewClient(WebViewClient client) {
if (client instanceof RNCWebViewClient) {
mRNCWebViewClient = (RNCWebViewClient) client;
mRNCWebViewClient.setProgressChangedFilter(progressChangedFilter);
mRNCWebViewClient.loadingFinishedListener = this;
}
}

Expand Down Expand Up @@ -340,6 +341,10 @@ protected void sendDirectMessage(final String method, WritableMap data) {
mCatalystInstance.callFunction(messagingModuleName, method, params);
}

public void onLoadingFinished() {
onScrollChanged(getScrollX(), getScrollY(), getScrollX(), getScrollY());
}

protected void onScrollChanged(int x, int y, int oldX, int oldY) {
super.onScrollChanged(x, y, oldX, oldY);

Expand Down Expand Up @@ -376,6 +381,10 @@ protected void dispatchEvent(WebView webView, Event event) {

protected void cleanupCallbacksAndDestroy() {
setWebViewClient(null);
if (mRNCWebViewClient != null) {
mRNCWebViewClient.loadingFinishedListener = null;
mRNCWebViewClient = null;
}
destroy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public class RNCWebViewClient extends WebViewClient {

protected boolean mLastLoadFailed = false;
protected RNCWebView.ProgressChangedFilter progressChangedFilter = null;

public static interface OnLoadingFinishedListener {
void onLoadingFinished();
}
public OnLoadingFinishedListener loadingFinishedListener = null;

protected @Nullable String ignoreErrFailedForThisURL = null;
protected @Nullable RNCBasicAuthCredential basicAuthCredential = null;

Expand Down Expand Up @@ -297,6 +303,9 @@ public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail deta
protected void emitFinishEvent(WebView webView, String url) {
int reactTag = RNCWebViewWrapper.getReactTagFromWebView(webView);
UIManagerHelper.getEventDispatcherForReactTag((ReactContext) webView.getContext(), reactTag).dispatchEvent(new TopLoadingFinishEvent(reactTag, createWebViewEvent(webView, url)));
if (loadingFinishedListener != null) {
loadingFinishedListener.onLoadingFinished();
}
}

protected WritableMap createWebViewEvent(WebView webView, String url) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-native-webview",
"name": "@onekeyfe/react-native-webview",
"description": "React Native WebView component for iOS, Android, macOS, and Windows",
"main": "index.js",
"main-internal": "src/index.ts",
Expand Down
Loading