forked from Tonnodoubt/N.E.K.O.-RN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-native-web-extended.js
More file actions
42 lines (34 loc) · 1.04 KB
/
react-native-web-extended.js
File metadata and controls
42 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// 这个文件是 react-native-web 的扩展包装器
// 它导出 react-native-web 的所有内容,同时添加缺失的 API
// 导入 react-native-web 的所有内容
const RNWeb = require('react-native-web');
// TurboModuleRegistry 实现(Web 上返回 null)
const TurboModuleRegistry = {
get: (name) => {
console.log(`[Web] TurboModuleRegistry.get("${name}") - returning null`);
return null;
},
getEnforcing: (name) => {
console.log(`[Web] TurboModuleRegistry.getEnforcing("${name}") - returning null`);
return null;
},
};
// NativeModules 空实现
const NativeModules = RNWeb.NativeModules || {};
// 创建导出对象
const exports = {};
// 复制所有 RNWeb 的属性
for (const key in RNWeb) {
if (RNWeb.hasOwnProperty(key)) {
exports[key] = RNWeb[key];
}
}
// 添加我们的扩展
exports.TurboModuleRegistry = TurboModuleRegistry;
exports.NativeModules = NativeModules;
// 如果 RNWeb 有默认导出,保留它
if (RNWeb.default) {
exports.default = RNWeb.default;
}
// 导出
module.exports = exports;