@ohos-ports/react-native-navigation 8.9.0-beta.0 → 8.9.0-beta.1
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/package.json +1 -1
- package/scripts/setup-esm-shim.js +10 -11
package/package.json
CHANGED
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Creates an ESM shim for 'react-native' that bridges CJS named exports
|
|
6
6
|
* from @ohos-ports/react-native to ESM named imports.
|
|
7
|
-
*
|
|
8
|
-
* Background: react-native-navigation uses ESM `import { X } from 'react-native'`
|
|
9
|
-
* but @ohos-ports/react-native is CJS with getter-based lazy exports.
|
|
10
|
-
* Node.js ESM cannot statically resolve named exports from CJS getters,
|
|
11
|
-
* so we create a thin ESM wrapper using createRequire.
|
|
12
7
|
*/
|
|
13
8
|
|
|
14
9
|
const fs = require('fs');
|
|
15
10
|
const path = require('path');
|
|
16
11
|
|
|
12
|
+
// Resolve project root node_modules/react-native
|
|
13
|
+
// __dirname = node_modules/@ohos-ports/react-native-navigation/scripts/
|
|
14
|
+
// ../.. = node_modules/
|
|
17
15
|
const RN_SHIM_DIR = path.join(__dirname, '..', '..', 'react-native');
|
|
18
16
|
|
|
19
17
|
// Check if @ohos-ports/react-native is available
|
|
@@ -21,12 +19,15 @@ let ohosPortsRN;
|
|
|
21
19
|
try {
|
|
22
20
|
ohosPortsRN = require.resolve('@ohos-ports/react-native');
|
|
23
21
|
} catch (e) {
|
|
24
|
-
// @ohos-ports/react-native not installed — skip shim creation
|
|
25
|
-
// User may have regular react-native installed instead
|
|
26
22
|
process.exit(0);
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
//
|
|
25
|
+
// Remove existing react-native directory (might contain original react-native from npm)
|
|
26
|
+
if (fs.existsSync(RN_SHIM_DIR)) {
|
|
27
|
+
fs.rmSync(RN_SHIM_DIR, { recursive: true, force: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Create fresh shim directory
|
|
30
31
|
fs.mkdirSync(RN_SHIM_DIR, { recursive: true });
|
|
31
32
|
|
|
32
33
|
// Write package.json for the shim
|
|
@@ -55,7 +56,6 @@ function safeGet(obj, key) {
|
|
|
55
56
|
try { return obj[key]; } catch(e) { return undefined; }
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
// Dimensions.get('window') fails without RN bridge — provide mock fallback
|
|
59
59
|
const _origDimensions = rn.Dimensions;
|
|
60
60
|
const Dimensions = {
|
|
61
61
|
get: (name) => {
|
|
@@ -86,7 +86,6 @@ export const TurboModuleRegistry = rn.TurboModuleRegistry;
|
|
|
86
86
|
export const View = rn.View;
|
|
87
87
|
export const findNodeHandle = rn.findNodeHandle;
|
|
88
88
|
export const processColor = rn.processColor;
|
|
89
|
-
// These may fail due to Flow syntax in sub-modules — provide safe fallbacks
|
|
90
89
|
export const Button = safeGet(rn, 'Button') || (() => null);
|
|
91
90
|
export const Text = safeGet(rn, 'Text') || (() => null);
|
|
92
91
|
export const requireNativeComponent = safeGet(rn, 'requireNativeComponent') || ((name) => ({ displayName: name }));
|
|
@@ -99,4 +98,4 @@ fs.writeFileSync(
|
|
|
99
98
|
shimContent
|
|
100
99
|
);
|
|
101
100
|
|
|
102
|
-
console.log('@ohos-ports/react-native-navigation: ESM shim for react-native created
|
|
101
|
+
console.log('@ohos-ports/react-native-navigation: ESM shim for react-native created at', path.relative(path.join(__dirname, '..', '..'), RN_SHIM_DIR));
|