@gfean/react-native-bundle-drop 0.3.5 → 0.3.7

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.
Files changed (63) hide show
  1. package/android/build.gradle +2 -0
  2. package/android/src/main/java/com/bundledrop/BundleDropModule.kt +12 -48
  3. package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +64 -0
  4. package/android/src/main/java/com/bundledrop/BundleDropOtaPrefs.kt +41 -0
  5. package/ios/BundleDropBridge.m +4 -0
  6. package/ios/BundleDropLocator.h +11 -0
  7. package/ios/BundleDropLocator.swift +11 -1
  8. package/ios/BundleDropModule.swift +10 -0
  9. package/lib/CLI/cli.js +56 -6
  10. package/lib/CLI/scripts/aipowered/apply-plan.d.ts +10 -0
  11. package/lib/CLI/scripts/aipowered/apply-plan.js +50 -0
  12. package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -0
  13. package/lib/CLI/scripts/aipowered/backend-client.js +34 -0
  14. package/lib/CLI/scripts/aipowered/diff-preview.d.ts +7 -0
  15. package/lib/CLI/scripts/aipowered/diff-preview.js +33 -0
  16. package/lib/CLI/scripts/aipowered/init-native-config.d.ts +2 -0
  17. package/lib/CLI/scripts/aipowered/init-native-config.js +131 -0
  18. package/lib/CLI/scripts/aipowered/scanner.d.ts +5 -0
  19. package/lib/CLI/scripts/aipowered/scanner.js +349 -0
  20. package/lib/CLI/scripts/aipowered/types.d.ts +53 -0
  21. package/lib/CLI/scripts/aipowered/types.js +2 -0
  22. package/lib/CLI/scripts/aipowered/validate-plan.d.ts +8 -0
  23. package/lib/CLI/scripts/aipowered/validate-plan.js +164 -0
  24. package/lib/CLI/scripts/init-config.js +10 -5
  25. package/lib/CLI/scripts/init-native-config.js +1 -1
  26. package/lib/CLI/scripts/post-init.js +7 -18
  27. package/lib/CLI/scripts/upload-cli.d.ts +2 -0
  28. package/lib/CLI/scripts/upload-cli.js +53 -25
  29. package/lib/CLI/utils/ui.d.ts +3 -0
  30. package/lib/CLI/utils/ui.js +26 -0
  31. package/lib/api/clientApi.d.ts +2 -1
  32. package/lib/api/clientApi.js +9 -0
  33. package/lib/api/types.d.ts +17 -0
  34. package/lib/context.d.ts +4 -4
  35. package/lib/context.js +2 -2
  36. package/lib/fs/bundlePointer.d.ts +2 -0
  37. package/lib/fs/bundlePointer.js +14 -4
  38. package/lib/index.d.ts +6 -3
  39. package/lib/index.js +5 -1
  40. package/lib/injectImageResolver.js +6 -15
  41. package/lib/loadConfig.d.ts +4 -4
  42. package/lib/manager/downloadAndInstall.d.ts +3 -0
  43. package/lib/manager/downloadAndInstall.js +23 -3
  44. package/lib/manager/reporting.d.ts +2 -0
  45. package/lib/manager/reporting.js +25 -0
  46. package/lib/manager/rollbackState.d.ts +25 -8
  47. package/lib/manager/rollbackState.js +87 -22
  48. package/lib/manager/updateCheck.js +15 -1
  49. package/lib/manager/updateState.d.ts +5 -1
  50. package/lib/manager/updateState.js +20 -11
  51. package/lib/native/bundleDropNative.d.ts +1 -0
  52. package/lib/native/bundleDropNative.js +14 -0
  53. package/lib/runtime/service.d.ts +28 -0
  54. package/lib/runtime/service.js +175 -16
  55. package/lib/scripts/bundle.d.ts +4 -1
  56. package/lib/scripts/bundle.js +41 -28
  57. package/lib/scripts/projectRoot.d.ts +1 -0
  58. package/lib/scripts/projectRoot.js +54 -0
  59. package/lib/scripts/upload-bundle.d.ts +2 -1
  60. package/lib/scripts/upload-bundle.js +46 -37
  61. package/lib/useBundleDrop.d.ts +2 -0
  62. package/lib/useBundleDrop.js +1 -0
  63. package/package.json +3 -2
@@ -171,8 +171,9 @@ async function upload(platform, options) {
171
171
  const bundleCommand = fs.existsSync(compiledBundleScript)
172
172
  ? `node "${compiledBundleScript}"`
173
173
  : `ts-node "${tsBundleScript}"`;
174
+ const sourcemapArg = options.sourcemap ? ' --sourcemap' : '';
174
175
  try {
175
- (0, child_process_1.execSync)(`${bundleCommand} ${platform}`, {
176
+ (0, child_process_1.execSync)(`${bundleCommand} ${platform}${sourcemapArg}`, {
176
177
  stdio: 'inherit',
177
178
  });
178
179
  }
@@ -225,7 +226,7 @@ async function upload(platform, options) {
225
226
  form.append('author', options.author);
226
227
  }
227
228
  form.append('file', fs.createReadStream(zipPath));
228
- ui_1.log.arrow('Uploading bundle to server...');
229
+ const uploadLoader = (0, ui_1.startLoadingStatus)('Uploading bundle to server');
229
230
  try {
230
231
  const res = await axios_1.default.post(`${serverUrl}/bundle/upload`, form, {
231
232
  headers: {
@@ -235,6 +236,9 @@ async function upload(platform, options) {
235
236
  maxContentLength: Infinity,
236
237
  maxBodyLength: Infinity,
237
238
  });
239
+ const sourceMapFile = path.join(outputDir, 'main.jsbundle.map');
240
+ const hasSourceMap = options.sourcemap && fs.existsSync(sourceMapFile);
241
+ const artifactDir = options.artifactDir ? path.resolve(options.artifactDir) : undefined;
238
242
  const result = {
239
243
  platform,
240
244
  appVersion: version ?? null,
@@ -249,21 +253,43 @@ async function upload(platform, options) {
249
253
  releaseNotes: releaseNotes ?? null,
250
254
  author: options.author ?? null,
251
255
  };
256
+ if (artifactDir) {
257
+ try {
258
+ fs.mkdirSync(artifactDir, { recursive: true });
259
+ const bundleFile = path.join(outputDir, 'main.jsbundle');
260
+ if (fs.existsSync(bundleFile)) {
261
+ fs.copyFileSync(bundleFile, path.join(artifactDir, 'main.jsbundle'));
262
+ result.bundlePath = path.join(artifactDir, 'main.jsbundle');
263
+ }
264
+ if (hasSourceMap) {
265
+ fs.copyFileSync(sourceMapFile, path.join(artifactDir, 'main.jsbundle.map'));
266
+ result.sourceMapPath = path.join(artifactDir, 'main.jsbundle.map');
267
+ }
268
+ }
269
+ catch (copyErr) {
270
+ ui_1.log.warn(`Upload succeeded but artifact copy failed: ${copyErr.message}`);
271
+ }
272
+ }
273
+ uploadLoader.stop();
252
274
  ui_1.log.success(`✅ Upload complete`);
253
275
  if (result.bundleVersion != null)
254
276
  ui_1.log.label('Bundle Version', `${result.bundleVersion}`);
255
277
  if (result.bundleVersionLabel)
256
- ui_1.log.label('Bundle Label', result.bundleVersionLabel);
278
+ ui_1.log.label('Bundle Label', `${result.bundleVersionLabel}`);
257
279
  if (result.hash)
258
- ui_1.log.label('Hash', result.hash);
259
- const resultDir = path.join(packageRoot, 'dist');
280
+ ui_1.log.label('Hash', `${result.hash}`);
281
+ const resultDir = artifactDir ?? path.join(packageRoot, 'dist');
260
282
  if (!fs.existsSync(resultDir))
261
283
  fs.mkdirSync(resultDir, { recursive: true });
262
284
  const resultPath = path.join(resultDir, 'bundle-drop-result.json');
263
285
  fs.writeFileSync(resultPath, JSON.stringify(result, null, 2));
264
286
  ui_1.log.label('Result file', resultPath);
287
+ if (artifactDir) {
288
+ ui_1.log.label('Artifact dir', artifactDir);
289
+ }
265
290
  }
266
291
  catch (err) {
292
+ uploadLoader.stop();
267
293
  const raw = err?.response?.data || err.message;
268
294
  if (typeof raw === 'object') {
269
295
  ui_1.log.error(`Upload failed:\n${JSON.stringify(raw, null, 2)}`);
@@ -273,26 +299,28 @@ async function upload(platform, options) {
273
299
  }
274
300
  process.exit(1);
275
301
  }
276
- // Cleanup
277
- console.log();
278
- ui_1.log.arrow('Cleaning up temporary files...');
279
- const cleanupFiles = [
280
- zipPath,
281
- path.join(outputDir, `metadata-${platform}.json`),
282
- path.join(outputDir, 'main.jsbundle'),
283
- ];
284
- const assetsPath = path.join(outputDir, 'assets');
285
- for (const file of cleanupFiles) {
286
- if (fs.existsSync(file)) {
287
- fs.unlinkSync(file);
288
- ui_1.log.label('🧹 Deleted', file);
302
+ finally {
303
+ try {
304
+ const cleanupFiles = [
305
+ zipPath,
306
+ path.join(outputDir, `metadata-${platform}.json`),
307
+ path.join(outputDir, 'main.jsbundle'),
308
+ path.join(outputDir, 'main.jsbundle.map'),
309
+ ];
310
+ const assetsPath = path.join(outputDir, 'assets');
311
+ for (const file of cleanupFiles) {
312
+ if (fs.existsSync(file))
313
+ fs.unlinkSync(file);
314
+ }
315
+ if (fs.existsSync(assetsPath)) {
316
+ fs.rmSync(assetsPath, { recursive: true, force: true });
317
+ }
318
+ console.log();
319
+ ui_1.log.success('🎉 Done! Bundle uploaded and cleaned.');
320
+ console.log();
321
+ }
322
+ catch (cleanupErr) {
323
+ ui_1.log.warn(`Cleanup failed: ${cleanupErr.message}`);
289
324
  }
290
325
  }
291
- if (fs.existsSync(assetsPath)) {
292
- fs.rmSync(assetsPath, { recursive: true, force: true });
293
- ui_1.log.label('🧹 Deleted', assetsPath);
294
- }
295
- console.log();
296
- ui_1.log.success('🎉 Done! Bundle uploaded and cleaned.');
297
- console.log();
298
326
  }
@@ -6,3 +6,6 @@ export declare const log: {
6
6
  arrow: (msg: string) => void;
7
7
  label: (label: string, value: string) => void;
8
8
  };
9
+ export declare function startLoadingStatus(message: string, intervalMs?: number): {
10
+ stop: () => any;
11
+ };
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.log = void 0;
7
+ exports.startLoadingStatus = startLoadingStatus;
7
8
  const chalk_1 = __importDefault(require("chalk"));
8
9
  const figures_1 = __importDefault(require("figures"));
9
10
  exports.log = {
@@ -14,3 +15,28 @@ exports.log = {
14
15
  arrow: (msg) => console.log(chalk_1.default.cyan(figures_1.default.arrowRight), msg),
15
16
  label: (label, value) => console.log(`${chalk_1.default.gray(label)}: ${chalk_1.default.white(value)}`),
16
17
  };
18
+ function startLoadingStatus(message, intervalMs = 300) {
19
+ const frames = ['', '.', '..', '...'];
20
+ let frameIndex = 0;
21
+ let lastLineLength = 0;
22
+ if (!process.stdout.isTTY) {
23
+ exports.log.arrow(`${message}...`);
24
+ return {
25
+ stop: () => undefined,
26
+ };
27
+ }
28
+ const render = () => {
29
+ const line = `${chalk_1.default.cyan(figures_1.default.arrowRight)} ${message}${frames[frameIndex]}`;
30
+ lastLineLength = Math.max(lastLineLength, line.length);
31
+ process.stdout.write(`\r${line}${' '.repeat(Math.max(0, lastLineLength - line.length))}`);
32
+ frameIndex = (frameIndex + 1) % frames.length;
33
+ };
34
+ render();
35
+ const timer = setInterval(render, intervalMs);
36
+ return {
37
+ stop: () => {
38
+ clearInterval(timer);
39
+ process.stdout.write(`\r${' '.repeat(lastLineLength)}\r`);
40
+ },
41
+ };
42
+ }
@@ -1,6 +1,7 @@
1
1
  import type { AxiosResponse } from 'axios';
2
- import { OtaResolveRequest, OtaResolveResponse, PublicChannelsParams, ReportInstalledPayload, BundleListParams, BundleListResponse } from './types';
2
+ import { OtaResolveRequest, OtaResolveResponse, PublicChannelsParams, ReportInstalledPayload, ReportLocalRollbackPayload, BundleListParams, BundleListResponse } from './types';
3
3
  export declare function postOtaResolve(projectSlug: string, payload: OtaResolveRequest): Promise<AxiosResponse<OtaResolveResponse>>;
4
4
  export declare function getPublicChannels(params: PublicChannelsParams): Promise<AxiosResponse<string[]>>;
5
5
  export declare function reportInstalled(projectSlug: string, hash: string, payload: ReportInstalledPayload): Promise<AxiosResponse<void>>;
6
+ export declare function reportLocalRollback(projectSlug: string, hash: string, payload: ReportLocalRollbackPayload): Promise<AxiosResponse<void>>;
6
7
  export declare function getBundleList(projectSlug: string, params: BundleListParams): Promise<AxiosResponse<BundleListResponse>>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.postOtaResolve = postOtaResolve;
4
4
  exports.getPublicChannels = getPublicChannels;
5
5
  exports.reportInstalled = reportInstalled;
6
+ exports.reportLocalRollback = reportLocalRollback;
6
7
  exports.getBundleList = getBundleList;
7
8
  const client_1 = require("./client");
8
9
  function postOtaResolve(projectSlug, payload) {
@@ -24,6 +25,14 @@ function getPublicChannels(params) {
24
25
  }
25
26
  function reportInstalled(projectSlug, hash, payload) {
26
27
  return client_1.apiClient.post(`/projects/${encodeURIComponent(projectSlug)}/bundle/${encodeURIComponent(hash)}/installed`, payload, {
28
+ headers: {
29
+ Accept: 'application/json',
30
+ },
31
+ timeout: 3000,
32
+ });
33
+ }
34
+ function reportLocalRollback(projectSlug, hash, payload) {
35
+ return client_1.apiClient.post(`/projects/${encodeURIComponent(projectSlug)}/bundle/${encodeURIComponent(hash)}/local-rollback-report`, payload, {
27
36
  headers: {
28
37
  Accept: 'application/json',
29
38
  },
@@ -7,6 +7,7 @@ export type OtaResolveRequest = {
7
7
  currentHash?: string | null;
8
8
  currentUserProperties?: UserProperties;
9
9
  previousHash?: string | null;
10
+ rejectedHashes?: string[];
10
11
  currentBundleVersion?: number | null;
11
12
  installId?: string | null;
12
13
  };
@@ -49,6 +50,10 @@ export type UpdateCheckResponse = {
49
50
  channelName?: string;
50
51
  /** Server-side reason for `NOOP` or `ROLLBACK` decisions. */
51
52
  reason?: string;
53
+ /** True when the latest server target was skipped because this install already failed it. */
54
+ skippedFailedBundle?: boolean;
55
+ /** Hash skipped by local failed-bundle quarantine. */
56
+ skippedHash?: string;
52
57
  /** `true` when no compatible bundle exists for the current runtime version. */
53
58
  incompatible?: boolean;
54
59
  /** Runtime version attached to the target bundle or current request. */
@@ -69,6 +74,18 @@ export type ReportInstalledPayload = {
69
74
  environment?: string | null;
70
75
  userProperties?: UserProperties;
71
76
  };
77
+ export type ReportLocalRollbackPayload = {
78
+ reason: string;
79
+ previousHash?: string | null;
80
+ channelName?: string | null;
81
+ platform?: string | null;
82
+ runtimeVersion?: string | null;
83
+ installId?: string | null;
84
+ environment?: string | null;
85
+ userProperties?: UserProperties;
86
+ crashCount?: number | null;
87
+ failedAt?: string | null;
88
+ };
72
89
  /**
73
90
  * Public metadata for a single downloadable bundle returned by the bundle list endpoint.
74
91
  */
package/lib/context.d.ts CHANGED
@@ -31,10 +31,10 @@ export type BundleDropConfig = {
31
31
  rollback: {
32
32
  /** Crash count required before rollback. */
33
33
  maxCrashCount: number;
34
- /** Time window, in seconds, used when counting startup crashes. */
35
- crashWindowSec: number;
36
- /** Time, in seconds, after which a candidate bundle is considered stable. */
37
- commitTimeoutSec: number;
34
+ /** How Bundle Drop marks a newly launched OTA bundle healthy. */
35
+ healthCheckMode: 'auto' | 'manual';
36
+ /** Seconds to wait before automatically marking a candidate healthy in auto mode. */
37
+ healthyAfterSec: number;
38
38
  };
39
39
  };
40
40
  /**
package/lib/context.js CHANGED
@@ -28,7 +28,7 @@ exports.bundleDropConfig = {
28
28
  debugLocal: exports.config.debugLocal ?? false,
29
29
  rollback: {
30
30
  maxCrashCount: exports.config.rollback?.maxCrashCount ?? 3,
31
- crashWindowSec: exports.config.rollback?.crashWindowSec ?? 30,
32
- commitTimeoutSec: exports.config.rollback?.commitTimeoutSec ?? 10,
31
+ healthCheckMode: exports.config.rollback?.healthCheckMode === 'manual' ? 'manual' : 'auto',
32
+ healthyAfterSec: exports.config.rollback?.healthyAfterSec ?? 0,
33
33
  },
34
34
  };
@@ -11,4 +11,6 @@ export declare function setCurrentBundlePointer(bundlePath: string, hash: string
11
11
  setPrevious?: boolean;
12
12
  }): Promise<void>;
13
13
  export declare function rollbackToPreviousPointer(): Promise<BundlePointer | null>;
14
+ export declare function deleteCurrentBundlePointer(): Promise<void>;
15
+ export declare function deletePreviousBundlePointer(): Promise<void>;
14
16
  export declare function clearCurrentBundlePointer(): Promise<void>;
@@ -9,6 +9,8 @@ exports.writeCurrentBundlePointer = writeCurrentBundlePointer;
9
9
  exports.writePreviousBundlePointer = writePreviousBundlePointer;
10
10
  exports.setCurrentBundlePointer = setCurrentBundlePointer;
11
11
  exports.rollbackToPreviousPointer = rollbackToPreviousPointer;
12
+ exports.deleteCurrentBundlePointer = deleteCurrentBundlePointer;
13
+ exports.deletePreviousBundlePointer = deletePreviousBundlePointer;
12
14
  exports.clearCurrentBundlePointer = clearCurrentBundlePointer;
13
15
  const fs_1 = __importDefault(require("../native/fs"));
14
16
  const context_1 = require("../context");
@@ -65,13 +67,21 @@ async function rollbackToPreviousPointer() {
65
67
  await writeCurrentBundlePointer({ ...previous, updatedAt: new Date().toISOString() });
66
68
  return previous;
67
69
  }
70
+ async function deleteCurrentBundlePointer() {
71
+ if (await fs_1.default.exists(CURRENT_POINTER_PATH)) {
72
+ await fs_1.default.unlink(CURRENT_POINTER_PATH);
73
+ }
74
+ }
75
+ async function deletePreviousBundlePointer() {
76
+ if (await fs_1.default.exists(PREVIOUS_POINTER_PATH)) {
77
+ await fs_1.default.unlink(PREVIOUS_POINTER_PATH);
78
+ }
79
+ }
68
80
  async function clearCurrentBundlePointer() {
69
81
  try {
70
- if (await fs_1.default.exists(CURRENT_POINTER_PATH)) {
71
- await fs_1.default.unlink(CURRENT_POINTER_PATH);
72
- }
82
+ await deleteCurrentBundlePointer();
73
83
  }
74
84
  catch {
75
- // ignore
85
+ // Best-effort cleanup for callers that do not need strict rollback semantics.
76
86
  }
77
87
  }
package/lib/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import './bootstrap';
2
- import { getChannelName, initBundleDrop, setChannel } from './runtime/service';
3
- export { getAvailableChannels, checkForUpdate, getInstalledBundleInfo, getAvailableBundles } from './runtime/service';
2
+ import { getChannelName, initBundleDrop, reportHealthy, setChannel } from './runtime/service';
3
+ export { getAvailableChannels, checkForUpdate, getInstalledBundleInfo, getObservabilityContext, getAvailableBundles } from './runtime/service';
4
+ export type { ObservabilityContext } from './runtime/service';
4
5
  export type { AvailableBundlesPage, GetAvailableBundlesOptions } from './manager/updateCheck';
5
- export { downloadUpdate, installBundle, getRuntimeUpdateState as getUpdateState, applyUpdate, setChannel, getChannelName, } from './runtime/service';
6
+ export { downloadUpdate, installBundle, getRuntimeUpdateState as getUpdateState, applyUpdate, setChannel, getChannelName, reportHealthy, } from './runtime/service';
6
7
  export { BundleDropError, isBundleDropError } from './errors';
7
8
  export { getCurrentUserProperties, getUserProperties, setUserProperty, setUserPropery, removeUserProperty, resetUserProperties, } from './fs/userProperties';
8
9
  export type { UserProperties, UserPropertyValue } from './fs/userProperties';
@@ -25,4 +26,6 @@ export declare const BundleDrop: {
25
26
  readonly setChannel: typeof setChannel;
26
27
  /** Read the currently active runtime channel. */
27
28
  readonly getChannelName: typeof getChannelName;
29
+ /** Mark the currently running OTA candidate healthy for this device. */
30
+ readonly reportHealthy: typeof reportHealthy;
28
31
  };
package/lib/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BundleDrop = exports.bundleDropConfig = exports.useBundleDrop = exports.resetUserProperties = exports.removeUserProperty = exports.setUserPropery = exports.setUserProperty = exports.getUserProperties = exports.getCurrentUserProperties = exports.isBundleDropError = exports.BundleDropError = exports.getChannelName = exports.setChannel = exports.applyUpdate = exports.getUpdateState = exports.installBundle = exports.downloadUpdate = exports.getAvailableBundles = exports.getInstalledBundleInfo = exports.checkForUpdate = exports.getAvailableChannels = void 0;
3
+ exports.BundleDrop = exports.bundleDropConfig = exports.useBundleDrop = exports.resetUserProperties = exports.removeUserProperty = exports.setUserPropery = exports.setUserProperty = exports.getUserProperties = exports.getCurrentUserProperties = exports.isBundleDropError = exports.BundleDropError = exports.reportHealthy = exports.getChannelName = exports.setChannel = exports.applyUpdate = exports.getUpdateState = exports.installBundle = exports.downloadUpdate = exports.getAvailableBundles = exports.getObservabilityContext = exports.getInstalledBundleInfo = exports.checkForUpdate = exports.getAvailableChannels = void 0;
4
4
  require("./bootstrap");
5
5
  const service_1 = require("./runtime/service");
6
6
  var service_2 = require("./runtime/service");
7
7
  Object.defineProperty(exports, "getAvailableChannels", { enumerable: true, get: function () { return service_2.getAvailableChannels; } });
8
8
  Object.defineProperty(exports, "checkForUpdate", { enumerable: true, get: function () { return service_2.checkForUpdate; } });
9
9
  Object.defineProperty(exports, "getInstalledBundleInfo", { enumerable: true, get: function () { return service_2.getInstalledBundleInfo; } });
10
+ Object.defineProperty(exports, "getObservabilityContext", { enumerable: true, get: function () { return service_2.getObservabilityContext; } });
10
11
  Object.defineProperty(exports, "getAvailableBundles", { enumerable: true, get: function () { return service_2.getAvailableBundles; } });
11
12
  var service_3 = require("./runtime/service");
12
13
  Object.defineProperty(exports, "downloadUpdate", { enumerable: true, get: function () { return service_3.downloadUpdate; } });
@@ -15,6 +16,7 @@ Object.defineProperty(exports, "getUpdateState", { enumerable: true, get: functi
15
16
  Object.defineProperty(exports, "applyUpdate", { enumerable: true, get: function () { return service_3.applyUpdate; } });
16
17
  Object.defineProperty(exports, "setChannel", { enumerable: true, get: function () { return service_3.setChannel; } });
17
18
  Object.defineProperty(exports, "getChannelName", { enumerable: true, get: function () { return service_3.getChannelName; } });
19
+ Object.defineProperty(exports, "reportHealthy", { enumerable: true, get: function () { return service_3.reportHealthy; } });
18
20
  var errors_1 = require("./errors");
19
21
  Object.defineProperty(exports, "BundleDropError", { enumerable: true, get: function () { return errors_1.BundleDropError; } });
20
22
  Object.defineProperty(exports, "isBundleDropError", { enumerable: true, get: function () { return errors_1.isBundleDropError; } });
@@ -39,4 +41,6 @@ exports.BundleDrop = {
39
41
  setChannel: service_1.setChannel,
40
42
  /** Read the currently active runtime channel. */
41
43
  getChannelName: service_1.getChannelName,
44
+ /** Mark the currently running OTA candidate healthy for this device. */
45
+ reportHealthy: service_1.reportHealthy,
42
46
  };
@@ -37,9 +37,15 @@ function patchImageResolverWithManifest(manifest) {
37
37
  const originalResolve = react_native_1.Image.resolveAssetSource;
38
38
  react_native_1.Image.resolveAssetSource = (source) => {
39
39
  const resolved = originalResolve(source);
40
+ if (typeof source !== 'number' && !source?.__packager_asset) {
41
+ return resolved;
42
+ }
40
43
  const uri = resolved?.uri;
41
44
  if (!uri)
42
45
  return resolved;
46
+ if (/^(https?|data|content):/.test(uri)) {
47
+ return resolved;
48
+ }
43
49
  let cleanedKey = uri;
44
50
  if (uri.startsWith('file://')) {
45
51
  const parts = uri.split('/files/')[1];
@@ -73,21 +79,6 @@ function patchImageResolverWithManifest(manifest) {
73
79
  finalPath = byBase[base];
74
80
  }
75
81
  }
76
- // Fallback: try basename with extension
77
- if (!finalPath) {
78
- const baseWithExt = (cleanedKey.split('/').pop() || '').replace(/^android_asset\//, '');
79
- if (baseWithExt && byKey[baseWithExt]) {
80
- finalPath = byKey[baseWithExt];
81
- }
82
- }
83
- // Last-resort fallback: point to assets/<basename> if nothing is mapped.
84
- if (!finalPath) {
85
- const filename = cleanedKey.split('/').pop();
86
- if (filename) {
87
- const guessed = `assets/${filename}`;
88
- finalPath = guessed;
89
- }
90
- }
91
82
  if (finalPath) {
92
83
  const hasExtension = /\.[a-zA-Z0-9]+$/.test(finalPath);
93
84
  const fullPath = `file://${fs_1.default.DocumentDirectoryPath}/${finalPath}${hasExtension ? '' : (uri.match(/\.[^.]+$/)?.[0] ?? '')}`;
@@ -33,10 +33,10 @@ export type BundleDropProjectConfig = {
33
33
  rollback?: {
34
34
  /** Crash count required before rollback. */
35
35
  maxCrashCount?: number;
36
- /** Time window, in seconds, used when counting startup crashes. */
37
- crashWindowSec?: number;
38
- /** Time, in seconds, after which a candidate bundle is considered stable. */
39
- commitTimeoutSec?: number;
36
+ /** How Bundle Drop marks a newly launched OTA bundle healthy. */
37
+ healthCheckMode?: 'auto' | 'manual';
38
+ /** Seconds to wait before automatically marking a candidate healthy in auto mode. */
39
+ healthyAfterSec?: number;
40
40
  };
41
41
  };
42
42
  export declare function loadConfig(): BundleDropProjectConfig;
@@ -4,6 +4,9 @@ export type DownloadUpdateResult = {
4
4
  hash: string;
5
5
  } | {
6
6
  status: 'upToDate';
7
+ reason?: string;
8
+ skippedFailedBundle?: boolean;
9
+ skippedHash?: string;
7
10
  } | {
8
11
  status: 'disabled';
9
12
  } | {
@@ -38,8 +38,17 @@ async function downloadAndStageUpdate(options, onStatusUpdate) {
38
38
  return { status: 'incompatible' };
39
39
  }
40
40
  if (checkResult.action === 'NOOP') {
41
- statusCb?.('✅ You have the latest version');
42
- return { status: 'upToDate' };
41
+ statusCb?.(checkResult.skippedFailedBundle
42
+ ? '✅ Current bundle retained; requested update previously failed on this device'
43
+ : '✅ You have the latest version');
44
+ return checkResult.skippedFailedBundle
45
+ ? {
46
+ status: 'upToDate',
47
+ reason: checkResult.reason,
48
+ skippedFailedBundle: true,
49
+ skippedHash: checkResult.skippedHash,
50
+ }
51
+ : { status: 'upToDate' };
43
52
  }
44
53
  if (checkResult.action === 'ROLLBACK') {
45
54
  statusCb?.('↩️ Rollback requested');
@@ -63,8 +72,17 @@ async function downloadAndStageUpdate(options, onStatusUpdate) {
63
72
  },
64
73
  });
65
74
  }
66
- statusCb?.('⬇️ Downloading full bundle ZIP!...');
67
75
  const hash = serverHash;
76
+ if (await (0, rollbackState_1.isBundleHashFailed)(hash)) {
77
+ statusCb?.('✅ Current bundle retained; selected update previously failed on this device');
78
+ return {
79
+ status: 'upToDate',
80
+ reason: 'BUNDLE_PREVIOUSLY_FAILED',
81
+ skippedFailedBundle: true,
82
+ skippedHash: hash,
83
+ };
84
+ }
85
+ statusCb?.('⬇️ Downloading full bundle ZIP!...');
68
86
  let installResult;
69
87
  try {
70
88
  installResult = await (0, installFromZip_1.installFromZip)({
@@ -98,6 +116,7 @@ async function downloadAndStageUpdate(options, onStatusUpdate) {
98
116
  }
99
117
  statusCb?.('✅ Update downloaded. Will apply on next launch or when you call applyUpdate().');
100
118
  // Persist installed metadata for future skip logic.
119
+ const previousInfo = await (0, bundleInfo_1.readBundleInfo)();
101
120
  const installedInfo = {
102
121
  bundleVersion: serverBundleVersion ?? metadataFromZip.bundleVersion,
103
122
  version: serverVersion ?? metadataFromZip.version,
@@ -107,6 +126,7 @@ async function downloadAndStageUpdate(options, onStatusUpdate) {
107
126
  installedAt: new Date().toISOString(),
108
127
  pendingApply: true,
109
128
  runtimeVersion: metadataFromZip.runtimeVersion ?? serverRuntimeVersion ?? context_1.runtimeVersion ?? undefined,
129
+ lastInstalledReportedHash: previousInfo?.lastInstalledReportedHash,
110
130
  };
111
131
  await (0, bundleInfo_1.writeBundleInfo)(installedInfo);
112
132
  await (0, bundlePointer_1.setCurrentBundlePointer)(bundlePath, installedHash);
@@ -1,5 +1,7 @@
1
1
  import { BundleInfo } from '../bundleInfo';
2
+ import type { FailedBundleRecord } from './rollbackState';
2
3
  export declare function reportInstalledIfReady(state?: {
3
4
  hasBundle?: boolean;
4
5
  info?: BundleInfo | null;
5
6
  }): Promise<void>;
7
+ export declare function reportLocalRollback(hash: string, record: FailedBundleRecord): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reportInstalledIfReady = reportInstalledIfReady;
4
+ exports.reportLocalRollback = reportLocalRollback;
4
5
  const context_1 = require("../context");
5
6
  const bundleInfo_1 = require("../bundleInfo");
6
7
  const clientApi_1 = require("../api/clientApi");
@@ -48,3 +49,27 @@ async function reportInstalledIfReady(state) {
48
49
  console.warn('⚠️ Failed to report bundle install:', e?.toString?.() || e);
49
50
  }
50
51
  }
52
+ async function reportLocalRollback(hash, record) {
53
+ try {
54
+ const [installId, userProperties] = await Promise.all([
55
+ (0, installId_1.getOrCreateInstallId)(),
56
+ (0, userProperties_1.getCurrentUserProperties)(),
57
+ ]);
58
+ const appEnvironment = (0, initState_1.getBundleDropRuntimeConfig)()?.environment ?? null;
59
+ await (0, clientApi_1.reportLocalRollback)(context_1.config.project.slug, hash, {
60
+ reason: record.reason,
61
+ previousHash: record.previousHash ?? null,
62
+ channelName: record.channelName ?? null,
63
+ platform: context_1.platform,
64
+ installId,
65
+ runtimeVersion: record.runtimeVersion ?? context_1.runtimeVersion ?? null,
66
+ environment: appEnvironment,
67
+ userProperties: Object.keys(userProperties).length > 0 ? userProperties : undefined,
68
+ crashCount: record.crashCount ?? null,
69
+ failedAt: record.failedAt ? new Date(record.failedAt * 1000).toISOString() : null,
70
+ });
71
+ }
72
+ catch (e) {
73
+ console.warn('⚠️ Failed to report local rollback:', e?.toString?.() || e);
74
+ }
75
+ }
@@ -1,8 +1,17 @@
1
1
  import { type BundlePointer } from '../fs/bundlePointer';
2
2
  export type RollbackPolicy = {
3
3
  maxCrashCount?: number;
4
- crashWindowSec?: number;
5
- commitTimeoutSec?: number;
4
+ healthCheckMode?: 'auto' | 'manual';
5
+ healthyAfterSec?: number;
6
+ };
7
+ export type FailedBundleReason = 'crash_loop';
8
+ export type FailedBundleRecord = {
9
+ reason: FailedBundleReason;
10
+ failedAt: number;
11
+ crashCount?: number;
12
+ channelName?: string;
13
+ runtimeVersion?: string;
14
+ previousHash?: string;
6
15
  };
7
16
  export type RollbackState = {
8
17
  activeHash?: string;
@@ -11,28 +20,36 @@ export type RollbackState = {
11
20
  candidateActivatedAt?: number;
12
21
  candidateCommitted?: boolean;
13
22
  crashCount?: number;
14
- crashWindowStartedAt?: number;
15
23
  lastLaunchAt?: number;
24
+ failedBundles?: Record<string, FailedBundleRecord>;
25
+ };
26
+ type RollbackDecision = {
27
+ shouldRollback: false;
28
+ } | {
29
+ shouldRollback: true;
30
+ reason: FailedBundleReason;
16
31
  };
17
32
  declare function readState(): Promise<RollbackState | null>;
18
33
  export { readState as readRollbackState };
19
34
  export declare function markCandidateActivated(hash: string): Promise<void>;
35
+ export declare function reportActiveBundleHealthy(cached?: {
36
+ currentPointer?: BundlePointer | null;
37
+ }, expectedHash?: string): Promise<boolean>;
20
38
  export declare function commitActiveBundle(cached?: {
21
39
  currentPointer?: BundlePointer | null;
22
40
  }): Promise<void>;
41
+ export declare function isBundleHashFailed(hash?: string | null): Promise<boolean>;
42
+ export declare function getFailedBundleHashes(): Promise<string[]>;
23
43
  export declare function evaluateRollbackOnLaunch(policy: Required<RollbackPolicy>, cached?: {
24
44
  currentPointer?: BundlePointer | null;
25
45
  rollbackState?: RollbackState | null;
26
- }): Promise<{
27
- shouldRollback: boolean;
28
- reason?: 'crash_loop' | 'commit_timeout';
29
- }>;
46
+ }): Promise<RollbackDecision>;
30
47
  export declare function rollbackToPreviousIfNeeded(policy: Required<RollbackPolicy>, cached?: {
31
48
  currentPointer?: BundlePointer | null;
32
49
  rollbackState?: RollbackState | null;
33
50
  }): Promise<{
34
51
  rolledBack: boolean;
35
- reason?: 'crash_loop' | 'commit_timeout';
52
+ reason?: FailedBundleReason;
36
53
  }>;
37
54
  export declare function getRollbackPolicy(): Required<RollbackPolicy>;
38
55
  export declare function rollbackToPreviousOrNative(): Promise<{