@webview-bridge/react-native 1.3.0-nightly.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,34 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.createWebView = void 0;
7
30
  const util_1 = require("../../../shared/util/src");
8
- const react_1 = require("react");
9
- const react_2 = __importDefault(require("react"));
31
+ const react_1 = __importStar(require("react"));
10
32
  const react_native_webview_1 = __importDefault(require("react-native-webview"));
11
33
  const integrations_1 = require("./integrations");
12
34
  const handleRegisterWebMethod_1 = require("./integrations/handleRegisterWebMethod");
@@ -1,3 +1,3 @@
1
- export declare const INJECT_DEBUG = "\n{\n const originalConsoleLog = console.log;\n const originalConsoleError = console.error;\n const originalConsoleWarn = console.warn;\n\n console.log = function() {\n var message = Array.from(arguments).join(' ');\n window.ReactNativeWebView?.postMessage(\n JSON.stringify({ type: \"log\", body: { method: \"log\", args: message } }),\n );\n originalConsoleLog.apply(console, arguments);\n };\n\n console.error = function() {\n var message = Array.from(arguments).join(' ');\n window.ReactNativeWebView?.postMessage(\n JSON.stringify({ type: \"log\", body: { method: \"error\", args: message } }),\n );\n originalConsoleError.apply(console, arguments);\n };\n\n console.warn = function() {\n var message = Array.from(arguments).join(' ');\n window.ReactNativeWebView?.postMessage(\n JSON.stringify({ type: \"log\", body: { method: \"warn\", args: message } }),\n );\n originalConsoleWarn.apply(console, arguments);\n };\n};\n";
1
+ export declare const INJECT_DEBUG = "\n{\n const originalConsoleLog = console.log;\n const originalConsoleError = console.error;\n const originalConsoleWarn = console.warn;\n\n console.log = function() {\n var message = JSON.stringify(Array.from(arguments));\n window.ReactNativeWebView?.postMessage(\n JSON.stringify({ type: \"log\", body: { method: \"log\", args: message } }),\n );\n originalConsoleLog.apply(console, arguments);\n };\n\n console.error = function() {\n var message = JSON.stringify(Array.from(arguments));\n window.ReactNativeWebView?.postMessage(\n JSON.stringify({ type: \"log\", body: { method: \"error\", args: message } }),\n );\n originalConsoleError.apply(console, arguments);\n };\n\n console.warn = function() {\n var message = JSON.stringify(Array.from(arguments));\n window.ReactNativeWebView?.postMessage(\n JSON.stringify({ type: \"log\", body: { method: \"warn\", args: message } }),\n );\n originalConsoleWarn.apply(console, arguments);\n };\n};\n";
2
2
  export type LogType = "log" | "error" | "warn";
3
- export declare const handleLog: (type: LogType, message?: unknown) => void;
3
+ export declare const handleLog: (type: LogType, message: string) => void;
@@ -8,7 +8,7 @@ exports.INJECT_DEBUG = `
8
8
  const originalConsoleWarn = console.warn;
9
9
 
10
10
  console.log = function() {
11
- var message = Array.from(arguments).join(' ');
11
+ var message = JSON.stringify(Array.from(arguments));
12
12
  window.ReactNativeWebView?.postMessage(
13
13
  JSON.stringify({ type: "log", body: { method: "log", args: message } }),
14
14
  );
@@ -16,7 +16,7 @@ exports.INJECT_DEBUG = `
16
16
  };
17
17
 
18
18
  console.error = function() {
19
- var message = Array.from(arguments).join(' ');
19
+ var message = JSON.stringify(Array.from(arguments));
20
20
  window.ReactNativeWebView?.postMessage(
21
21
  JSON.stringify({ type: "log", body: { method: "error", args: message } }),
22
22
  );
@@ -24,7 +24,7 @@ exports.INJECT_DEBUG = `
24
24
  };
25
25
 
26
26
  console.warn = function() {
27
- var message = Array.from(arguments).join(' ');
27
+ var message = JSON.stringify(Array.from(arguments));
28
28
  window.ReactNativeWebView?.postMessage(
29
29
  JSON.stringify({ type: "log", body: { method: "warn", args: message } }),
30
30
  );
@@ -33,17 +33,18 @@ exports.INJECT_DEBUG = `
33
33
  };
34
34
  `;
35
35
  const handleLog = (type, message) => {
36
+ const parsedMessage = JSON.parse(message);
36
37
  switch (type) {
37
38
  case "log": {
38
- console.log("(WebView)", message);
39
+ console.log("(WebView)", parsedMessage);
39
40
  break;
40
41
  }
41
42
  case "error": {
42
- console.error("(WebView)", message);
43
+ console.error("(WebView)", parsedMessage);
43
44
  break;
44
45
  }
45
46
  case "warn": {
46
- console.warn("(WebView)", message);
47
+ console.warn("(WebView)", parsedMessage);
47
48
  break;
48
49
  }
49
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webview-bridge/react-native",
3
- "version": "1.3.0-nightly.0",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "description": "Fully Type-Safe Integration for React Native WebView and Web",
6
6
  "main": "dist/packages/react-native/src/index.js",