@hot-updater/expo 1.1.2 → 1.1.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/expo",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Hot Updater build and config plugin for Expo",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -28,16 +28,16 @@
28
28
  "@babel/core": "7.26.0",
29
29
  "@babel/types": "7.26.0",
30
30
  "uuidv7": "^1.0.2",
31
- "@hot-updater/bare": "1.1.2",
32
- "@hot-updater/cli-tools": "1.1.2",
33
- "@hot-updater/plugin-core": "1.1.2"
31
+ "@hot-updater/bare": "1.1.4",
32
+ "@hot-updater/cli-tools": "1.1.4",
33
+ "@hot-updater/plugin-core": "1.1.4"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^20",
37
37
  "expo": "^50.0.0",
38
38
  "execa": "9.5.2",
39
39
  "vitest": "4.1.4",
40
- "hot-updater": "1.1.2"
40
+ "hot-updater": "1.1.4"
41
41
  },
42
42
  "exports": {
43
43
  ".": {
@@ -111,6 +111,39 @@ function transformAndroidReactHost(contents) {
111
111
  ];
112
112
  return `${prefix}${jsBundleLines.join("\n")}\n${suffix}`;
113
113
  }
114
+ /**
115
+ * Removes every `override fun getJSBundleFile(): String?` block, matching its
116
+ * closing brace by depth so a body with nested blocks (`if`, `else`, `try`)
117
+ * is removed whole.
118
+ */
119
+ function removeKotlinGetJSBundleFile(source) {
120
+ const methodStart = /^\s*override fun getJSBundleFile\(\): String\?\s*\{/gm;
121
+ let result = "";
122
+ let cursor = 0;
123
+ for (const match of source.matchAll(methodStart)) {
124
+ if (match.index < cursor) {
125
+ continue;
126
+ }
127
+ let depth = 1;
128
+ let end = match.index + match[0].length;
129
+ while (end < source.length && depth > 0) {
130
+ if (source[end] === "{") {
131
+ depth += 1;
132
+ }
133
+ else if (source[end] === "}") {
134
+ depth -= 1;
135
+ }
136
+ end += 1;
137
+ }
138
+ if (depth !== 0) {
139
+ // Unbalanced input: leave it for the author instead of cutting it.
140
+ continue;
141
+ }
142
+ result += source.slice(cursor, match.index);
143
+ cursor = end;
144
+ }
145
+ return result + source.slice(cursor);
146
+ }
114
147
  /**
115
148
  * Android: DefaultReactNativeHost pattern (RN 0.81 / Expo 54).
116
149
  * Adds getJSBundleFile() override to the host.
@@ -120,7 +153,6 @@ function transformAndroidDefaultHost(contents) {
120
153
  const kotlinImportAnchor = "import com.facebook.react.ReactApplication";
121
154
  const kotlinReactNativeHostAnchor = "object : DefaultReactNativeHost(this) {";
122
155
  const kotlinMethodCheck = "HotUpdater.getJSBundleFile(applicationContext)";
123
- const kotlinExistingMethodRegex = /^\s*override fun getJSBundleFile\(\): String\?\s*\{[\s\S]*?^\s*\}/gm;
124
156
  const kotlinHermesAnchor = "override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED";
125
157
  const kotlinNewArchAnchor = "override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED";
126
158
  // Check if this is the old pattern with DefaultReactNativeHost
@@ -132,7 +164,7 @@ function transformAndroidDefaultHost(contents) {
132
164
  // 2. Add/Replace getJSBundleFile method if needed
133
165
  if (!result.includes(kotlinMethodCheck)) {
134
166
  // Remove potentially existing (different) override first
135
- result = result.replace(kotlinExistingMethodRegex, "");
167
+ result = removeKotlinGetJSBundleFile(result);
136
168
  const lines = result.split("\n");
137
169
  const findLineIndex = (needle) => {
138
170
  for (let i = 0; i < lines.length; i += 1) {