Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed May 5, 2024
1 parent 642f947 commit 48ed54c
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 92 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*
* @module
*/
export type { Message } from "./types";
export { useWebViewMessage } from "./hooks";
export type { Message } from "./shared/types";
export { useWebViewMessage } from "./native";
4 changes: 2 additions & 2 deletions src/hooks.ts → src/native/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useRef } from "react";
import type WebView from "react-native-webview";
import type { WebViewMessageEvent, WebViewProps } from "react-native-webview";
import { EVENT_KEY } from "./common";
import type { Message } from "./types";
import { EVENT_KEY } from "../shared/constants";
import type { Message } from "../shared/types";

/**
* A hook to subscribe messages from WebView.
Expand Down
144 changes: 72 additions & 72 deletions src/plugin/__snapshots__/index.spec.ts.snap

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/plugin/__snapshots__/metro.spec.ts.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/plugin/html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ROOT_ID } from "../common";
import { ROOT_ID } from "../shared/constants";

export const createContent = (js: string): string => {
// https://github.com/inokawa/react-native-react-bridge/pull/133
Expand Down
2 changes: 1 addition & 1 deletion src/common.js → src/shared/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const EVENT_KEY = "rn-web-bridge";
export const ROOT_ID = "root";
export const ROOT_ID = "rnrb-root";
File renamed without changes.
4 changes: 2 additions & 2 deletions src/web/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EVENT_KEY, ROOT_ID } from "../common";
import type { Message } from "../types";
import { EVENT_KEY, ROOT_ID } from "../shared/constants";
import type { Message } from "../shared/types";

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/web/preact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { useEffect } from "preact/compat";
import { render, ComponentChild } from "preact";
import { listenNativeMessage, emit, getWebViewRootElement } from "./core";
import type { Message } from "../types";
import type { Message } from "../shared/types";

/**
* The entry point of web file
Expand Down
2 changes: 1 addition & 1 deletion src/web/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ReactElement, useEffect } from "react";
import { render } from "react-dom";
import { createRoot } from "react-dom/client";
import { emit, getWebViewRootElement, listenNativeMessage } from "./core";
import type { Message } from "../types";
import type { Message } from "../shared/types";

/**
* The entry point of web file
Expand Down

0 comments on commit 48ed54c

Please sign in to comment.