@webview-bridge/react-native 1.7.7 → 1.7.8
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.
- package/dist/index.cjs +16 -15
- package/dist/index.js +13 -12
- package/package.json +3 -3
- package/src/createWebView.tsx +3 -2
- package/src/integrations/bridge.ts +44 -34
- package/src/integrations/console.ts +5 -10
package/dist/index.cjs
CHANGED
|
@@ -435,7 +435,7 @@ __export(index_exports, {
|
|
|
435
435
|
});
|
|
436
436
|
module.exports = __toCommonJS(index_exports);
|
|
437
437
|
// src/createWebView.tsx
|
|
438
|
-
var
|
|
438
|
+
var import_utils3 = require("@webview-bridge/utils");
|
|
439
439
|
var import_react = require("react");
|
|
440
440
|
var import_react_native_webview = __toESM(require("react-native-webview"), 1);
|
|
441
441
|
// src/integrations/bridge.ts
|
|
@@ -554,26 +554,26 @@ var handleBridge = /*#__PURE__*/ function() {
|
|
|
554
554
|
};
|
|
555
555
|
}();
|
|
556
556
|
var INJECT_BRIDGE_METHODS = function(bridgeNames) {
|
|
557
|
-
return "\n window.__bridgeMethods__ = ".concat(JSON.stringify(bridgeNames), ";\n");
|
|
557
|
+
return "\n (function() {\n window.__bridgeMethods__ = ".concat(JSON.stringify(bridgeNames), ";\n })();\n");
|
|
558
558
|
};
|
|
559
559
|
var INJECT_BRIDGE_STATE = function(initialState) {
|
|
560
|
-
return "\n window.__bridgeInitialState__ = ".concat(JSON.stringify(initialState), ";\n");
|
|
560
|
+
return "\n (function() {\n window.__bridgeInitialState__ = ".concat(JSON.stringify(initialState), ";\n })();\n");
|
|
561
561
|
};
|
|
562
562
|
var SAFE_NATIVE_EMITTER_EMIT = function(eventName, data) {
|
|
563
563
|
var dataString = JSON.stringify(data);
|
|
564
|
-
return "\
|
|
564
|
+
return "\n (function() {\n if (window.nativeEmitterMap && Object.keys(window.nativeEmitterMap).length > 0) {\n for (const [_, emitter] of Object.entries(window.nativeEmitterMap)) {\n emitter.emit('".concat(eventName, "', ").concat(dataString, ");\n }\n } else if (window.nativeEmitter) {\n // @deprecated This version is not used after 1.7.2\n window.nativeEmitter.emit('").concat(eventName, "', ").concat(dataString, ");\n } else {\n window.nativeBatchedEvents = window.nativeBatchedEvents || [];\n window.nativeBatchedEvents.push(['").concat(eventName, "', ").concat(dataString, "]);\n }\n return true;\n })();\n");
|
|
565
565
|
};
|
|
566
566
|
var SAFE_NATIVE_EMITTER_EMIT_BY_BRIDGE_ID = function(bridgeId, eventName, data) {
|
|
567
567
|
var dataString = JSON.stringify(data);
|
|
568
|
-
return "\
|
|
568
|
+
return "\n (function() {\n if (window.nativeEmitterMap && window.nativeEmitterMap['".concat(bridgeId, "']) {\n window.nativeEmitterMap['").concat(bridgeId, "'].emit('").concat(eventName, "', ").concat(dataString, ");\n } else if (window.nativeEmitter) {\n // @deprecated This version is not used after 1.7.2\n window.nativeEmitter.emit('").concat(eventName, "', ").concat(dataString, ");\n } else {\n window.nativeBatchedEvents = window.nativeBatchedEvents || [];\n window.nativeBatchedEvents.push(['").concat(eventName, "', ").concat(dataString, "]);\n }\n return true;\n })();\n");
|
|
569
569
|
};
|
|
570
570
|
var SAFE_NATIVE_EMITTER_THROW_BY_BRIDGE_ID = function(bridgeId, eventName) {
|
|
571
|
-
return "\
|
|
571
|
+
return "\n (function() {\n if (window.nativeEmitterMap && window.nativeEmitterMap['".concat(bridgeId, "']) {\n window.nativeEmitterMap['").concat(bridgeId, "'].emit('").concat(eventName, "', {}, true);\n } else if (window.nativeEmitter) {\n // @deprecated This version is not used after 1.7.2\n window.nativeEmitter.emit('").concat(eventName, "', {}, true);\n } else {\n window.nativeBatchedEvents = window.nativeBatchedEvents || [];\n window.nativeBatchedEvents.push(['").concat(eventName, "', {}, true]);\n }\n return true;\n })();\n");
|
|
572
572
|
};
|
|
573
573
|
// src/integrations/console.ts
|
|
574
|
-
var
|
|
575
|
-
|
|
576
|
-
|
|
574
|
+
var INJECT_DEBUG = function(uniqueId) {
|
|
575
|
+
return '\n(function() {\n if (window["__bridge_debug_injected_'.concat(uniqueId, '"]) {\n return;\n }\n\n window["__bridge_debug_injected_').concat(uniqueId, '"] = true;\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');
|
|
576
|
+
};
|
|
577
577
|
var handleLog = function(type, message) {
|
|
578
578
|
var _JSON_parse = _to_array(JSON.parse(message)), formatMessage = _JSON_parse[0], parsedMessage = _JSON_parse.slice(1);
|
|
579
579
|
var webviewMark = "(WebView) ";
|
|
@@ -605,7 +605,7 @@ var handleLog = function(type, message) {
|
|
|
605
605
|
}
|
|
606
606
|
};
|
|
607
607
|
// src/integrations/handleRegisterWebMethod.ts
|
|
608
|
-
var
|
|
608
|
+
var import_utils2 = require("@webview-bridge/utils");
|
|
609
609
|
// src/error.ts
|
|
610
610
|
var WebMethodError = /*#__PURE__*/ function(Error1) {
|
|
611
611
|
_inherits(WebMethodError, Error1);
|
|
@@ -630,11 +630,11 @@ var handleRegisterWebMethod = function(emitter, webview, bridgeNames, responseTi
|
|
|
630
630
|
for(_len = _arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
631
631
|
args[_key] = _arguments[_key];
|
|
632
632
|
}
|
|
633
|
-
eventId = (0,
|
|
633
|
+
eventId = (0, import_utils2.createRandomId)();
|
|
634
634
|
return [
|
|
635
635
|
2,
|
|
636
636
|
Promise.race([
|
|
637
|
-
(0,
|
|
637
|
+
(0, import_utils2.createResolver)({
|
|
638
638
|
emitter: emitter,
|
|
639
639
|
methodName: methodName,
|
|
640
640
|
eventId: eventId,
|
|
@@ -643,7 +643,7 @@ var handleRegisterWebMethod = function(emitter, webview, bridgeNames, responseTi
|
|
|
643
643
|
},
|
|
644
644
|
failHandler: new WebMethodError(methodName)
|
|
645
645
|
}),
|
|
646
|
-
(0,
|
|
646
|
+
(0, import_utils2.timeout)(responseTimeout)
|
|
647
647
|
])
|
|
648
648
|
];
|
|
649
649
|
});
|
|
@@ -661,7 +661,8 @@ var createWebView = function(param) {
|
|
|
661
661
|
}
|
|
662
662
|
};
|
|
663
663
|
var webviewRefList = [];
|
|
664
|
-
var emitter = (0,
|
|
664
|
+
var emitter = (0, import_utils3.createEvents)();
|
|
665
|
+
var uniqueId = (0, import_utils3.createRandomId)();
|
|
665
666
|
bridge2.subscribe(function(state) {
|
|
666
667
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
667
668
|
try {
|
|
@@ -876,7 +877,7 @@ var createWebView = function(param) {
|
|
|
876
877
|
"true;"
|
|
877
878
|
].filter(Boolean).join("\n"),
|
|
878
879
|
injectedJavaScript: [
|
|
879
|
-
debug && INJECT_DEBUG,
|
|
880
|
+
debug && INJECT_DEBUG(uniqueId),
|
|
880
881
|
props.injectedJavaScript,
|
|
881
882
|
"true;"
|
|
882
883
|
].filter(Boolean).join("\n")
|
package/dist/index.js
CHANGED
|
@@ -341,7 +341,7 @@ function _ts_generator(thisArg, body) {
|
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
import { createEvents } from "@webview-bridge/utils";
|
|
344
|
+
import { createEvents, createRandomId as createRandomId2 } from "@webview-bridge/utils";
|
|
345
345
|
import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from "react";
|
|
346
346
|
import WebView from "react-native-webview";
|
|
347
347
|
// src/integrations/bridge.ts
|
|
@@ -460,26 +460,26 @@ var handleBridge = /*#__PURE__*/ function() {
|
|
|
460
460
|
};
|
|
461
461
|
}();
|
|
462
462
|
var INJECT_BRIDGE_METHODS = function(bridgeNames) {
|
|
463
|
-
return "\n window.__bridgeMethods__ = ".concat(JSON.stringify(bridgeNames), ";\n");
|
|
463
|
+
return "\n (function() {\n window.__bridgeMethods__ = ".concat(JSON.stringify(bridgeNames), ";\n })();\n");
|
|
464
464
|
};
|
|
465
465
|
var INJECT_BRIDGE_STATE = function(initialState) {
|
|
466
|
-
return "\n window.__bridgeInitialState__ = ".concat(JSON.stringify(initialState), ";\n");
|
|
466
|
+
return "\n (function() {\n window.__bridgeInitialState__ = ".concat(JSON.stringify(initialState), ";\n })();\n");
|
|
467
467
|
};
|
|
468
468
|
var SAFE_NATIVE_EMITTER_EMIT = function(eventName, data) {
|
|
469
469
|
var dataString = JSON.stringify(data);
|
|
470
|
-
return "\
|
|
470
|
+
return "\n (function() {\n if (window.nativeEmitterMap && Object.keys(window.nativeEmitterMap).length > 0) {\n for (const [_, emitter] of Object.entries(window.nativeEmitterMap)) {\n emitter.emit('".concat(eventName, "', ").concat(dataString, ");\n }\n } else if (window.nativeEmitter) {\n // @deprecated This version is not used after 1.7.2\n window.nativeEmitter.emit('").concat(eventName, "', ").concat(dataString, ");\n } else {\n window.nativeBatchedEvents = window.nativeBatchedEvents || [];\n window.nativeBatchedEvents.push(['").concat(eventName, "', ").concat(dataString, "]);\n }\n return true;\n })();\n");
|
|
471
471
|
};
|
|
472
472
|
var SAFE_NATIVE_EMITTER_EMIT_BY_BRIDGE_ID = function(bridgeId, eventName, data) {
|
|
473
473
|
var dataString = JSON.stringify(data);
|
|
474
|
-
return "\
|
|
474
|
+
return "\n (function() {\n if (window.nativeEmitterMap && window.nativeEmitterMap['".concat(bridgeId, "']) {\n window.nativeEmitterMap['").concat(bridgeId, "'].emit('").concat(eventName, "', ").concat(dataString, ");\n } else if (window.nativeEmitter) {\n // @deprecated This version is not used after 1.7.2\n window.nativeEmitter.emit('").concat(eventName, "', ").concat(dataString, ");\n } else {\n window.nativeBatchedEvents = window.nativeBatchedEvents || [];\n window.nativeBatchedEvents.push(['").concat(eventName, "', ").concat(dataString, "]);\n }\n return true;\n })();\n");
|
|
475
475
|
};
|
|
476
476
|
var SAFE_NATIVE_EMITTER_THROW_BY_BRIDGE_ID = function(bridgeId, eventName) {
|
|
477
|
-
return "\
|
|
477
|
+
return "\n (function() {\n if (window.nativeEmitterMap && window.nativeEmitterMap['".concat(bridgeId, "']) {\n window.nativeEmitterMap['").concat(bridgeId, "'].emit('").concat(eventName, "', {}, true);\n } else if (window.nativeEmitter) {\n // @deprecated This version is not used after 1.7.2\n window.nativeEmitter.emit('").concat(eventName, "', {}, true);\n } else {\n window.nativeBatchedEvents = window.nativeBatchedEvents || [];\n window.nativeBatchedEvents.push(['").concat(eventName, "', {}, true]);\n }\n return true;\n })();\n");
|
|
478
478
|
};
|
|
479
479
|
// src/integrations/console.ts
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
480
|
+
var INJECT_DEBUG = function(uniqueId) {
|
|
481
|
+
return '\n(function() {\n if (window["__bridge_debug_injected_'.concat(uniqueId, '"]) {\n return;\n }\n\n window["__bridge_debug_injected_').concat(uniqueId, '"] = true;\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');
|
|
482
|
+
};
|
|
483
483
|
var handleLog = function(type, message) {
|
|
484
484
|
var _JSON_parse = _to_array(JSON.parse(message)), formatMessage = _JSON_parse[0], parsedMessage = _JSON_parse.slice(1);
|
|
485
485
|
var webviewMark = "(WebView) ";
|
|
@@ -511,7 +511,7 @@ var handleLog = function(type, message) {
|
|
|
511
511
|
}
|
|
512
512
|
};
|
|
513
513
|
// src/integrations/handleRegisterWebMethod.ts
|
|
514
|
-
import { createRandomId
|
|
514
|
+
import { createRandomId, createResolver, timeout } from "@webview-bridge/utils";
|
|
515
515
|
// src/error.ts
|
|
516
516
|
var WebMethodError = /*#__PURE__*/ function(Error1) {
|
|
517
517
|
"use strict";
|
|
@@ -537,7 +537,7 @@ var handleRegisterWebMethod = function(emitter, webview, bridgeNames, responseTi
|
|
|
537
537
|
for(_len = _arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
538
538
|
args[_key] = _arguments[_key];
|
|
539
539
|
}
|
|
540
|
-
eventId =
|
|
540
|
+
eventId = createRandomId();
|
|
541
541
|
return [
|
|
542
542
|
2,
|
|
543
543
|
Promise.race([
|
|
@@ -569,6 +569,7 @@ var createWebView = function(param) {
|
|
|
569
569
|
};
|
|
570
570
|
var webviewRefList = [];
|
|
571
571
|
var emitter = createEvents();
|
|
572
|
+
var uniqueId = createRandomId2();
|
|
572
573
|
bridge2.subscribe(function(state) {
|
|
573
574
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
574
575
|
try {
|
|
@@ -783,7 +784,7 @@ var createWebView = function(param) {
|
|
|
783
784
|
"true;"
|
|
784
785
|
].filter(Boolean).join("\n"),
|
|
785
786
|
injectedJavaScript: [
|
|
786
|
-
debug && INJECT_DEBUG,
|
|
787
|
+
debug && INJECT_DEBUG(uniqueId),
|
|
787
788
|
props.injectedJavaScript,
|
|
788
789
|
"true;"
|
|
789
790
|
].filter(Boolean).join("\n")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webview-bridge/react-native",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Fully Type-Safe Integration for React Native WebView and Web",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"react-native-webview": "*"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@webview-bridge/utils": "1.7.
|
|
43
|
-
"@webview-bridge/types": "1.7.
|
|
42
|
+
"@webview-bridge/utils": "1.7.8",
|
|
43
|
+
"@webview-bridge/types": "1.7.8",
|
|
44
44
|
"use-sync-external-store": "^1.2.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
package/src/createWebView.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ParserSchema,
|
|
7
7
|
Primitive,
|
|
8
8
|
} from "@webview-bridge/types";
|
|
9
|
-
import { createEvents } from "@webview-bridge/utils";
|
|
9
|
+
import { createEvents, createRandomId } from "@webview-bridge/utils";
|
|
10
10
|
import type React from "react";
|
|
11
11
|
import {
|
|
12
12
|
forwardRef,
|
|
@@ -133,6 +133,7 @@ export const createWebView = <
|
|
|
133
133
|
|
|
134
134
|
const webviewRefList: React.RefObject<BridgeWebView>[] = [];
|
|
135
135
|
const emitter = createEvents();
|
|
136
|
+
const uniqueId = createRandomId();
|
|
136
137
|
|
|
137
138
|
bridge.subscribe((state) => {
|
|
138
139
|
for (const ref of webviewRefList) {
|
|
@@ -318,7 +319,7 @@ export const createWebView = <
|
|
|
318
319
|
.filter(Boolean)
|
|
319
320
|
.join("\n")}
|
|
320
321
|
injectedJavaScript={[
|
|
321
|
-
debug && INJECT_DEBUG,
|
|
322
|
+
debug && INJECT_DEBUG(uniqueId),
|
|
322
323
|
props.injectedJavaScript,
|
|
323
324
|
"true;",
|
|
324
325
|
]
|
|
@@ -113,30 +113,36 @@ export const handleBridge = async ({
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
export const INJECT_BRIDGE_METHODS = (bridgeNames: string[]) => `
|
|
116
|
-
|
|
116
|
+
(function() {
|
|
117
|
+
window.__bridgeMethods__ = ${JSON.stringify(bridgeNames)};
|
|
118
|
+
})();
|
|
117
119
|
`;
|
|
118
120
|
|
|
119
121
|
export const INJECT_BRIDGE_STATE = (
|
|
120
122
|
initialState: Record<string, Primitive>,
|
|
121
123
|
) => `
|
|
122
|
-
|
|
124
|
+
(function() {
|
|
125
|
+
window.__bridgeInitialState__ = ${JSON.stringify(initialState)};
|
|
126
|
+
})();
|
|
123
127
|
`;
|
|
124
128
|
|
|
125
129
|
export const SAFE_NATIVE_EMITTER_EMIT = (eventName: string, data: unknown) => {
|
|
126
130
|
const dataString = JSON.stringify(data);
|
|
127
131
|
return `
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
132
|
+
(function() {
|
|
133
|
+
if (window.nativeEmitterMap && Object.keys(window.nativeEmitterMap).length > 0) {
|
|
134
|
+
for (const [_, emitter] of Object.entries(window.nativeEmitterMap)) {
|
|
135
|
+
emitter.emit('${eventName}', ${dataString});
|
|
136
|
+
}
|
|
137
|
+
} else if (window.nativeEmitter) {
|
|
138
|
+
// @deprecated This version is not used after 1.7.2
|
|
139
|
+
window.nativeEmitter.emit('${eventName}', ${dataString});
|
|
140
|
+
} else {
|
|
141
|
+
window.nativeBatchedEvents = window.nativeBatchedEvents || [];
|
|
142
|
+
window.nativeBatchedEvents.push(['${eventName}', ${dataString}]);
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
})();
|
|
140
146
|
`;
|
|
141
147
|
};
|
|
142
148
|
|
|
@@ -147,16 +153,18 @@ export const SAFE_NATIVE_EMITTER_EMIT_BY_BRIDGE_ID = (
|
|
|
147
153
|
) => {
|
|
148
154
|
const dataString = JSON.stringify(data);
|
|
149
155
|
return `
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
156
|
+
(function() {
|
|
157
|
+
if (window.nativeEmitterMap && window.nativeEmitterMap['${bridgeId}']) {
|
|
158
|
+
window.nativeEmitterMap['${bridgeId}'].emit('${eventName}', ${dataString});
|
|
159
|
+
} else if (window.nativeEmitter) {
|
|
160
|
+
// @deprecated This version is not used after 1.7.2
|
|
161
|
+
window.nativeEmitter.emit('${eventName}', ${dataString});
|
|
162
|
+
} else {
|
|
163
|
+
window.nativeBatchedEvents = window.nativeBatchedEvents || [];
|
|
164
|
+
window.nativeBatchedEvents.push(['${eventName}', ${dataString}]);
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
})();
|
|
160
168
|
`;
|
|
161
169
|
};
|
|
162
170
|
|
|
@@ -164,14 +172,16 @@ export const SAFE_NATIVE_EMITTER_THROW_BY_BRIDGE_ID = (
|
|
|
164
172
|
bridgeId: string,
|
|
165
173
|
eventName: string,
|
|
166
174
|
) => `
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
175
|
+
(function() {
|
|
176
|
+
if (window.nativeEmitterMap && window.nativeEmitterMap['${bridgeId}']) {
|
|
177
|
+
window.nativeEmitterMap['${bridgeId}'].emit('${eventName}', {}, true);
|
|
178
|
+
} else if (window.nativeEmitter) {
|
|
179
|
+
// @deprecated This version is not used after 1.7.2
|
|
180
|
+
window.nativeEmitter.emit('${eventName}', {}, true);
|
|
181
|
+
} else {
|
|
182
|
+
window.nativeBatchedEvents = window.nativeBatchedEvents || [];
|
|
183
|
+
window.nativeBatchedEvents.push(['${eventName}', {}, true]);
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
})();
|
|
177
187
|
`;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const injectionDetectKey = `__bridge_debug_injected_${createRandomId()}`;
|
|
5
|
-
|
|
6
|
-
export const INJECT_DEBUG = `
|
|
7
|
-
{
|
|
8
|
-
if (window["${injectionDetectKey}"]) {
|
|
1
|
+
export const INJECT_DEBUG = (uniqueId: string) => `
|
|
2
|
+
(function() {
|
|
3
|
+
if (window["__bridge_debug_injected_${uniqueId}"]) {
|
|
9
4
|
return;
|
|
10
5
|
}
|
|
11
6
|
|
|
12
|
-
window["${
|
|
7
|
+
window["__bridge_debug_injected_${uniqueId}"] = true;
|
|
13
8
|
const originalConsoleLog = console.log;
|
|
14
9
|
const originalConsoleError = console.error;
|
|
15
10
|
const originalConsoleWarn = console.warn;
|
|
@@ -37,7 +32,7 @@ export const INJECT_DEBUG = `
|
|
|
37
32
|
);
|
|
38
33
|
originalConsoleWarn.apply(console, arguments);
|
|
39
34
|
};
|
|
40
|
-
};
|
|
35
|
+
})();
|
|
41
36
|
`;
|
|
42
37
|
|
|
43
38
|
export type LogType = "log" | "error" | "warn";
|