@hot-updater/react-native 0.36.0 → 0.36.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.
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.HOT_UPDATER_SDK_VERSION = void 0;
7
- const HOT_UPDATER_SDK_VERSION = exports.HOT_UPDATER_SDK_VERSION = "0.36.0";
7
+ const HOT_UPDATER_SDK_VERSION = exports.HOT_UPDATER_SDK_VERSION = "0.36.2";
8
8
  //# sourceMappingURL=sdkVersion.js.map
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
 
3
- export const HOT_UPDATER_SDK_VERSION = "0.36.0";
3
+ export const HOT_UPDATER_SDK_VERSION = "0.36.2";
4
4
  //# sourceMappingURL=sdkVersion.js.map
@@ -1,2 +1,2 @@
1
- export declare const HOT_UPDATER_SDK_VERSION = "0.36.0";
1
+ export declare const HOT_UPDATER_SDK_VERSION = "0.36.2";
2
2
  //# sourceMappingURL=sdkVersion.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const HOT_UPDATER_SDK_VERSION = "0.36.0";
1
+ export declare const HOT_UPDATER_SDK_VERSION = "0.36.2";
2
2
  //# sourceMappingURL=sdkVersion.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/react-native",
3
- "version": "0.36.0",
3
+ "version": "0.36.2",
4
4
  "description": "React Native OTA solution for self-hosted",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/commonjs/index.js",
@@ -131,14 +131,14 @@
131
131
  "react-native-builder-bob": "0.41.0",
132
132
  "@typescript/native": "npm:typescript@^7.0.2",
133
133
  "typescript": "npm:@typescript/typescript6@^6.0.2",
134
- "hot-updater": "0.36.0"
134
+ "hot-updater": "0.36.2"
135
135
  },
136
136
  "dependencies": {
137
137
  "use-sync-external-store": "1.5.0",
138
- "@hot-updater/cli-tools": "0.36.0",
139
- "@hot-updater/core": "0.36.0",
140
- "@hot-updater/js": "0.36.0",
141
- "@hot-updater/plugin-core": "0.36.0"
138
+ "@hot-updater/cli-tools": "0.36.2",
139
+ "@hot-updater/core": "0.36.2",
140
+ "@hot-updater/js": "0.36.2",
141
+ "@hot-updater/plugin-core": "0.36.2"
142
142
  },
143
143
  "scripts": {
144
144
  "build": "node ./scripts/sync-sdk-version.mjs run -- bob build && tsc -p plugin/tsconfig.build.json",
@@ -65,6 +65,20 @@ function transformAndroidReactHost(contents) {
65
65
  return result;
66
66
  }
67
67
  const callContents = result.slice(callStartIndex, closeParenIndex + 1);
68
+ const kotlinLegacyBundlePathRegex = /^([ \t]*)jsBundleFilePath = HotUpdater\.getJSBundleFile\(applicationContext\),[ \t]*\r?$/m;
69
+ const legacyBundlePathMatch = callContents.match(kotlinLegacyBundlePathRegex);
70
+ if (legacyBundlePathMatch) {
71
+ const paramIndent = legacyBundlePathMatch[1];
72
+ const jsBundleLines = [
73
+ `${paramIndent}jsBundleFilePath = if (BuildConfig.DEBUG) {`,
74
+ `${paramIndent} null`,
75
+ `${paramIndent}} else {`,
76
+ `${paramIndent} HotUpdater.getJSBundleFile(applicationContext)`,
77
+ `${paramIndent}},`,
78
+ ];
79
+ const migratedCallContents = callContents.replace(kotlinLegacyBundlePathRegex, jsBundleLines.join("\n"));
80
+ return `${result.slice(0, callStartIndex)}${migratedCallContents}${result.slice(closeParenIndex + 1)}`;
81
+ }
68
82
  if (callContents.includes("jsBundleFilePath")) {
69
83
  return result;
70
84
  }
@@ -102,8 +116,14 @@ function transformAndroidReactHost(contents) {
102
116
  prefix[prevNonWhitespaceIndex] !== "(") {
103
117
  prefix = `${prefix.slice(0, prevNonWhitespaceIndex + 1)},${prefix.slice(prevNonWhitespaceIndex + 1)}`;
104
118
  }
105
- const jsBundleLine = `${paramIndent}jsBundleFilePath = HotUpdater.getJSBundleFile(applicationContext),`;
106
- return `${prefix}${jsBundleLine}\n${suffix}`;
119
+ const jsBundleLines = [
120
+ `${paramIndent}jsBundleFilePath = if (BuildConfig.DEBUG) {`,
121
+ `${paramIndent} null`,
122
+ `${paramIndent}} else {`,
123
+ `${paramIndent} HotUpdater.getJSBundleFile(applicationContext)`,
124
+ `${paramIndent}},`,
125
+ ];
126
+ return `${prefix}${jsBundleLines.join("\n")}\n${suffix}`;
107
127
  }
108
128
  /**
109
129
  * Android: DefaultReactNativeHost pattern (RN 0.81 / Expo 54).
@@ -114,6 +134,7 @@ function transformAndroidDefaultHost(contents) {
114
134
  const kotlinImportAnchor = "import com.facebook.react.ReactApplication";
115
135
  const kotlinReactNativeHostAnchor = "object : DefaultReactNativeHost(this) {";
116
136
  const kotlinMethodCheck = "HotUpdater.getJSBundleFile(applicationContext)";
137
+ const kotlinLegacyMethodRegex = /^([ \t]*)override fun getJSBundleFile\(\): String\? \{[ \t]*\r?\n([ \t]*)return HotUpdater\.getJSBundleFile\(applicationContext\)[ \t]*\r?\n\1\}[ \t]*$/m;
117
138
  const kotlinExistingMethodRegex = /^\s*override fun getJSBundleFile\(\): String\?\s*\{[\s\S]*?^\s*\}/gm;
118
139
  const kotlinHermesAnchor = "override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED";
119
140
  const kotlinNewArchAnchor = "override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED";
@@ -123,6 +144,21 @@ function transformAndroidDefaultHost(contents) {
123
144
  }
124
145
  // 1. Add import if missing
125
146
  let result = addLinesOnce(contents, kotlinImportAnchor, [kotlinImport]);
147
+ const legacyMethodMatch = result.match(kotlinLegacyMethodRegex);
148
+ if (legacyMethodMatch) {
149
+ const methodIndent = legacyMethodMatch[1];
150
+ const bodyIndent = legacyMethodMatch[2];
151
+ const methodLines = [
152
+ `${methodIndent}override fun getJSBundleFile(): String? {`,
153
+ `${bodyIndent}return if (BuildConfig.DEBUG) {`,
154
+ `${bodyIndent} null`,
155
+ `${bodyIndent}} else {`,
156
+ `${bodyIndent} HotUpdater.getJSBundleFile(applicationContext)`,
157
+ `${bodyIndent}}`,
158
+ `${methodIndent}}`,
159
+ ];
160
+ result = result.replace(kotlinLegacyMethodRegex, methodLines.join("\n"));
161
+ }
126
162
  // 2. Add/Replace getJSBundleFile method if needed
127
163
  if (!result.includes(kotlinMethodCheck)) {
128
164
  // Remove potentially existing (different) override first
@@ -159,7 +195,11 @@ function transformAndroidDefaultHost(contents) {
159
195
  const methodLines = [
160
196
  "", // blank line
161
197
  `${indent}override fun getJSBundleFile(): String? {`,
162
- `${bodyIndent}return HotUpdater.getJSBundleFile(applicationContext)`,
198
+ `${bodyIndent}return if (BuildConfig.DEBUG) {`,
199
+ `${bodyIndent} null`,
200
+ `${bodyIndent}} else {`,
201
+ `${bodyIndent} HotUpdater.getJSBundleFile(applicationContext)`,
202
+ `${bodyIndent}}`,
163
203
  `${indent}}`,
164
204
  ];
165
205
  const insertIndex = anchorIndex + 1;
@@ -187,7 +227,11 @@ function transformAndroidDefaultHost(contents) {
187
227
  const bodyIndent = `${indent} `;
188
228
  const methodLines = [
189
229
  `${indent}override fun getJSBundleFile(): String? {`,
190
- `${bodyIndent}return HotUpdater.getJSBundleFile(applicationContext)`,
230
+ `${bodyIndent}return if (BuildConfig.DEBUG) {`,
231
+ `${bodyIndent} null`,
232
+ `${bodyIndent}} else {`,
233
+ `${bodyIndent} HotUpdater.getJSBundleFile(applicationContext)`,
234
+ `${bodyIndent}}`,
191
235
  `${indent}}`,
192
236
  ];
193
237
  lines.splice(hostEndIndex, 0, ...methodLines);
package/src/sdkVersion.ts CHANGED
@@ -1 +1 @@
1
- export const HOT_UPDATER_SDK_VERSION = "0.36.0";
1
+ export const HOT_UPDATER_SDK_VERSION = "0.36.2";