@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.
- package/android/build.gradle +2 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +12 -48
- package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +64 -0
- package/android/src/main/java/com/bundledrop/BundleDropOtaPrefs.kt +41 -0
- package/ios/BundleDropBridge.m +4 -0
- package/ios/BundleDropLocator.h +11 -0
- package/ios/BundleDropLocator.swift +11 -1
- package/ios/BundleDropModule.swift +10 -0
- package/lib/CLI/cli.js +56 -6
- package/lib/CLI/scripts/aipowered/apply-plan.d.ts +10 -0
- package/lib/CLI/scripts/aipowered/apply-plan.js +50 -0
- package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -0
- package/lib/CLI/scripts/aipowered/backend-client.js +34 -0
- package/lib/CLI/scripts/aipowered/diff-preview.d.ts +7 -0
- package/lib/CLI/scripts/aipowered/diff-preview.js +33 -0
- package/lib/CLI/scripts/aipowered/init-native-config.d.ts +2 -0
- package/lib/CLI/scripts/aipowered/init-native-config.js +131 -0
- package/lib/CLI/scripts/aipowered/scanner.d.ts +5 -0
- package/lib/CLI/scripts/aipowered/scanner.js +349 -0
- package/lib/CLI/scripts/aipowered/types.d.ts +53 -0
- package/lib/CLI/scripts/aipowered/types.js +2 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +8 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +164 -0
- package/lib/CLI/scripts/init-config.js +10 -5
- package/lib/CLI/scripts/init-native-config.js +1 -1
- package/lib/CLI/scripts/post-init.js +7 -18
- package/lib/CLI/scripts/upload-cli.d.ts +2 -0
- package/lib/CLI/scripts/upload-cli.js +53 -25
- package/lib/CLI/utils/ui.d.ts +3 -0
- package/lib/CLI/utils/ui.js +26 -0
- package/lib/api/clientApi.d.ts +2 -1
- package/lib/api/clientApi.js +9 -0
- package/lib/api/types.d.ts +17 -0
- package/lib/context.d.ts +4 -4
- package/lib/context.js +2 -2
- package/lib/fs/bundlePointer.d.ts +2 -0
- package/lib/fs/bundlePointer.js +14 -4
- package/lib/index.d.ts +6 -3
- package/lib/index.js +5 -1
- package/lib/injectImageResolver.js +6 -15
- package/lib/loadConfig.d.ts +4 -4
- package/lib/manager/downloadAndInstall.d.ts +3 -0
- package/lib/manager/downloadAndInstall.js +23 -3
- package/lib/manager/reporting.d.ts +2 -0
- package/lib/manager/reporting.js +25 -0
- package/lib/manager/rollbackState.d.ts +25 -8
- package/lib/manager/rollbackState.js +87 -22
- package/lib/manager/updateCheck.js +15 -1
- package/lib/manager/updateState.d.ts +5 -1
- package/lib/manager/updateState.js +20 -11
- package/lib/native/bundleDropNative.d.ts +1 -0
- package/lib/native/bundleDropNative.js +14 -0
- package/lib/runtime/service.d.ts +28 -0
- package/lib/runtime/service.js +175 -16
- package/lib/scripts/bundle.d.ts +4 -1
- package/lib/scripts/bundle.js +41 -28
- package/lib/scripts/projectRoot.d.ts +1 -0
- package/lib/scripts/projectRoot.js +54 -0
- package/lib/scripts/upload-bundle.d.ts +2 -1
- package/lib/scripts/upload-bundle.js +46 -37
- package/lib/useBundleDrop.d.ts +2 -0
- package/lib/useBundleDrop.js +1 -0
- package/package.json +3 -2
|
@@ -5,7 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.readRollbackState = readState;
|
|
7
7
|
exports.markCandidateActivated = markCandidateActivated;
|
|
8
|
+
exports.reportActiveBundleHealthy = reportActiveBundleHealthy;
|
|
8
9
|
exports.commitActiveBundle = commitActiveBundle;
|
|
10
|
+
exports.isBundleHashFailed = isBundleHashFailed;
|
|
11
|
+
exports.getFailedBundleHashes = getFailedBundleHashes;
|
|
9
12
|
exports.evaluateRollbackOnLaunch = evaluateRollbackOnLaunch;
|
|
10
13
|
exports.rollbackToPreviousIfNeeded = rollbackToPreviousIfNeeded;
|
|
11
14
|
exports.getRollbackPolicy = getRollbackPolicy;
|
|
@@ -15,7 +18,9 @@ const context_1 = require("../context");
|
|
|
15
18
|
const fsUtils_1 = require("../fs/fsUtils");
|
|
16
19
|
const bundlePointer_1 = require("../fs/bundlePointer");
|
|
17
20
|
const bundleInfo_1 = require("../bundleInfo");
|
|
21
|
+
const reporting_1 = require("./reporting");
|
|
18
22
|
const STATE_PATH = `${context_1.BUNDLE_DROP_ROOT}/state.json`;
|
|
23
|
+
const MAX_FAILED_BUNDLES = 20;
|
|
19
24
|
function nowSec() {
|
|
20
25
|
return Math.floor(Date.now() / 1000);
|
|
21
26
|
}
|
|
@@ -40,6 +45,11 @@ async function updateState(partial) {
|
|
|
40
45
|
await writeState(next);
|
|
41
46
|
return next;
|
|
42
47
|
}
|
|
48
|
+
function pruneFailedBundles(failedBundles) {
|
|
49
|
+
return Object.fromEntries(Object.entries(failedBundles)
|
|
50
|
+
.sort(([, left], [, right]) => right.failedAt - left.failedAt)
|
|
51
|
+
.slice(0, MAX_FAILED_BUNDLES));
|
|
52
|
+
}
|
|
43
53
|
async function markCandidateActivated(hash) {
|
|
44
54
|
const previous = await (0, bundlePointer_1.readPreviousBundlePointer)();
|
|
45
55
|
const previousHash = previous?.hash;
|
|
@@ -50,24 +60,68 @@ async function markCandidateActivated(hash) {
|
|
|
50
60
|
candidateActivatedAt: now,
|
|
51
61
|
candidateCommitted: false,
|
|
52
62
|
crashCount: 0,
|
|
53
|
-
crashWindowStartedAt: now,
|
|
54
63
|
lastLaunchAt: now,
|
|
55
64
|
lastGoodHash: previousHash ?? undefined,
|
|
56
65
|
});
|
|
57
66
|
}
|
|
58
|
-
async function
|
|
67
|
+
async function reportActiveBundleHealthy(cached, expectedHash) {
|
|
59
68
|
const current = cached?.currentPointer !== undefined ? cached.currentPointer : await (0, bundlePointer_1.readCurrentBundlePointer)();
|
|
60
69
|
const hash = current?.hash;
|
|
61
70
|
if (!hash)
|
|
62
|
-
return;
|
|
71
|
+
return false;
|
|
72
|
+
if (expectedHash && hash !== expectedHash)
|
|
73
|
+
return false;
|
|
74
|
+
const state = (await readState()) || {};
|
|
75
|
+
const isCandidate = state.candidateHash === hash && state.candidateCommitted !== true;
|
|
76
|
+
if (!isCandidate)
|
|
77
|
+
return false;
|
|
63
78
|
await updateState({
|
|
64
79
|
activeHash: hash,
|
|
65
80
|
candidateHash: hash,
|
|
66
81
|
candidateCommitted: true,
|
|
67
82
|
crashCount: 0,
|
|
68
|
-
crashWindowStartedAt: nowSec(),
|
|
69
83
|
lastGoodHash: hash,
|
|
70
84
|
});
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
async function commitActiveBundle(cached) {
|
|
88
|
+
await reportActiveBundleHealthy(cached);
|
|
89
|
+
}
|
|
90
|
+
async function isBundleHashFailed(hash) {
|
|
91
|
+
if (!hash)
|
|
92
|
+
return false;
|
|
93
|
+
const state = await readState();
|
|
94
|
+
return !!state?.failedBundles?.[hash];
|
|
95
|
+
}
|
|
96
|
+
async function getFailedBundleHashes() {
|
|
97
|
+
const state = await readState();
|
|
98
|
+
return Object.entries(state?.failedBundles || {})
|
|
99
|
+
.sort(([, left], [, right]) => right.failedAt - left.failedAt)
|
|
100
|
+
.slice(0, MAX_FAILED_BUNDLES)
|
|
101
|
+
.map(([hash]) => hash);
|
|
102
|
+
}
|
|
103
|
+
async function buildFailedBundleRecord(hash, reason, state) {
|
|
104
|
+
const [bundleInfo, previous] = await Promise.all([
|
|
105
|
+
(0, bundleInfo_1.readBundleInfo)(),
|
|
106
|
+
(0, bundlePointer_1.readPreviousBundlePointer)(),
|
|
107
|
+
]);
|
|
108
|
+
const record = {
|
|
109
|
+
reason,
|
|
110
|
+
failedAt: nowSec(),
|
|
111
|
+
crashCount: state.crashCount,
|
|
112
|
+
channelName: bundleInfo?.channelName,
|
|
113
|
+
runtimeVersion: bundleInfo?.runtimeVersion,
|
|
114
|
+
previousHash: previous?.hash,
|
|
115
|
+
};
|
|
116
|
+
return record;
|
|
117
|
+
}
|
|
118
|
+
async function recordFailedBundle(hash, record) {
|
|
119
|
+
const state = (await readState()) || {};
|
|
120
|
+
const failedBundles = pruneFailedBundles({
|
|
121
|
+
...(state.failedBundles || {}),
|
|
122
|
+
[hash]: record,
|
|
123
|
+
});
|
|
124
|
+
await updateState({ failedBundles });
|
|
71
125
|
}
|
|
72
126
|
async function evaluateRollbackOnLaunch(policy, cached) {
|
|
73
127
|
const current = cached?.currentPointer !== undefined ? cached.currentPointer : await (0, bundlePointer_1.readCurrentBundlePointer)();
|
|
@@ -75,7 +129,14 @@ async function evaluateRollbackOnLaunch(policy, cached) {
|
|
|
75
129
|
if (!activeHash)
|
|
76
130
|
return { shouldRollback: false };
|
|
77
131
|
const now = nowSec();
|
|
78
|
-
const
|
|
132
|
+
const persistedState = (await readState()) || {};
|
|
133
|
+
const state = cached?.rollbackState !== undefined
|
|
134
|
+
? {
|
|
135
|
+
...persistedState,
|
|
136
|
+
...cached.rollbackState,
|
|
137
|
+
failedBundles: persistedState.failedBundles ?? cached.rollbackState?.failedBundles,
|
|
138
|
+
}
|
|
139
|
+
: persistedState;
|
|
79
140
|
const next = {
|
|
80
141
|
...state,
|
|
81
142
|
activeHash,
|
|
@@ -83,22 +144,13 @@ async function evaluateRollbackOnLaunch(policy, cached) {
|
|
|
83
144
|
};
|
|
84
145
|
const isCandidate = state.candidateHash === activeHash && state.candidateCommitted !== true;
|
|
85
146
|
if (isCandidate) {
|
|
86
|
-
const
|
|
87
|
-
const inWindow = now - windowStart <= policy.crashWindowSec;
|
|
88
|
-
const crashCount = inWindow ? (state.crashCount ?? 0) + 1 : 1;
|
|
147
|
+
const crashCount = (state.crashCount ?? 0) + 1;
|
|
89
148
|
next.crashCount = crashCount;
|
|
90
|
-
next.crashWindowStartedAt = inWindow ? windowStart : now;
|
|
91
149
|
if (policy.maxCrashCount > 0 &&
|
|
92
150
|
crashCount >= policy.maxCrashCount) {
|
|
93
151
|
await writeState(next);
|
|
94
152
|
return { shouldRollback: true, reason: 'crash_loop' };
|
|
95
153
|
}
|
|
96
|
-
if (policy.commitTimeoutSec > 0 &&
|
|
97
|
-
state.candidateActivatedAt &&
|
|
98
|
-
now - state.candidateActivatedAt > policy.commitTimeoutSec) {
|
|
99
|
-
await writeState(next);
|
|
100
|
-
return { shouldRollback: true, reason: 'commit_timeout' };
|
|
101
|
-
}
|
|
102
154
|
}
|
|
103
155
|
await writeState(next);
|
|
104
156
|
return { shouldRollback: false };
|
|
@@ -107,15 +159,29 @@ async function rollbackToPreviousIfNeeded(policy, cached) {
|
|
|
107
159
|
const decision = await evaluateRollbackOnLaunch(policy, cached);
|
|
108
160
|
if (!decision.shouldRollback)
|
|
109
161
|
return { rolledBack: false };
|
|
110
|
-
const
|
|
111
|
-
|
|
162
|
+
const current = cached?.currentPointer !== undefined ? cached.currentPointer : await (0, bundlePointer_1.readCurrentBundlePointer)();
|
|
163
|
+
const failedHash = current?.hash;
|
|
164
|
+
const state = (await readState()) || {};
|
|
165
|
+
if (!failedHash)
|
|
166
|
+
return { rolledBack: false };
|
|
167
|
+
const failedRecord = await buildFailedBundleRecord(failedHash, decision.reason, state);
|
|
168
|
+
await rollbackToPreviousOrNative();
|
|
169
|
+
await recordFailedBundle(failedHash, failedRecord);
|
|
170
|
+
await (0, reporting_1.reportLocalRollback)(failedHash, failedRecord).catch(() => undefined);
|
|
171
|
+
return { rolledBack: true, reason: decision.reason };
|
|
112
172
|
}
|
|
113
173
|
function getRollbackPolicy() {
|
|
114
174
|
return context_1.bundleDropConfig.rollback;
|
|
115
175
|
}
|
|
116
176
|
async function rollbackToPreviousOrNative() {
|
|
117
|
-
const previous = await
|
|
118
|
-
|
|
177
|
+
const [current, previous, state] = await Promise.all([
|
|
178
|
+
(0, bundlePointer_1.readCurrentBundlePointer)(),
|
|
179
|
+
(0, bundlePointer_1.readPreviousBundlePointer)(),
|
|
180
|
+
readState(),
|
|
181
|
+
]);
|
|
182
|
+
const previousIsFailed = previous ? !!state?.failedBundles?.[previous.hash] : false;
|
|
183
|
+
if (previous && previous.hash !== current?.hash && !previousIsFailed) {
|
|
184
|
+
await (0, bundlePointer_1.writeCurrentBundlePointer)({ ...previous, updatedAt: new Date().toISOString() });
|
|
119
185
|
const metadata = await readBundleMetadata(previous.bundlePath);
|
|
120
186
|
await (0, bundleInfo_1.updateBundleInfo)({
|
|
121
187
|
hash: previous.hash,
|
|
@@ -130,12 +196,12 @@ async function rollbackToPreviousOrNative() {
|
|
|
130
196
|
candidateHash: previous.hash,
|
|
131
197
|
candidateCommitted: true,
|
|
132
198
|
crashCount: 0,
|
|
133
|
-
crashWindowStartedAt: nowSec(),
|
|
134
199
|
});
|
|
135
200
|
return { rolledBack: true };
|
|
136
201
|
}
|
|
137
202
|
// No previous OTA bundle exists; fall back to native bundle by clearing the active pointer.
|
|
138
|
-
await (0, bundlePointer_1.
|
|
203
|
+
await (0, bundlePointer_1.deleteCurrentBundlePointer)();
|
|
204
|
+
await (0, bundlePointer_1.deletePreviousBundlePointer)();
|
|
139
205
|
await (0, bundleInfo_1.updateBundleInfo)({
|
|
140
206
|
hash: undefined,
|
|
141
207
|
bundleVersion: undefined,
|
|
@@ -149,7 +215,6 @@ async function rollbackToPreviousOrNative() {
|
|
|
149
215
|
candidateHash: undefined,
|
|
150
216
|
candidateCommitted: true,
|
|
151
217
|
crashCount: 0,
|
|
152
|
-
crashWindowStartedAt: nowSec(),
|
|
153
218
|
});
|
|
154
219
|
return { rolledBack: true, toNative: true };
|
|
155
220
|
}
|
|
@@ -12,6 +12,7 @@ const bundlePointer_1 = require("../fs/bundlePointer");
|
|
|
12
12
|
const installId_1 = require("../fs/installId");
|
|
13
13
|
const userProperties_1 = require("../fs/userProperties");
|
|
14
14
|
const initState_1 = require("../runtime/initState");
|
|
15
|
+
const rollbackState_1 = require("./rollbackState");
|
|
15
16
|
async function getAvailableChannels() {
|
|
16
17
|
const { project } = context_1.config;
|
|
17
18
|
if (!project?.slug) {
|
|
@@ -38,12 +39,13 @@ async function checkForUpdate(channelName = context_2.defaultChannel, onStatusUp
|
|
|
38
39
|
throw new Error('Missing project slug in bundle.drop.config.js');
|
|
39
40
|
}
|
|
40
41
|
onStatusUpdate?.('🔍 Checking for updates...');
|
|
41
|
-
const [local, currentPtr, previousPtr, currentUserProperties, installId] = await Promise.all([
|
|
42
|
+
const [local, currentPtr, previousPtr, currentUserProperties, installId, rejectedHashes] = await Promise.all([
|
|
42
43
|
(0, bundleInfo_1.readBundleInfo)(),
|
|
43
44
|
(0, bundlePointer_1.readCurrentBundlePointer)(),
|
|
44
45
|
(0, bundlePointer_1.readPreviousBundlePointer)(),
|
|
45
46
|
(0, userProperties_1.getCurrentUserProperties)(),
|
|
46
47
|
(0, installId_1.getOrCreateInstallId)(),
|
|
48
|
+
(0, rollbackState_1.getFailedBundleHashes)(),
|
|
47
49
|
]);
|
|
48
50
|
const currentHash = currentPtr?.hash ?? local?.hash ?? null;
|
|
49
51
|
const previousHash = previousPtr?.hash ?? null;
|
|
@@ -56,6 +58,7 @@ async function checkForUpdate(channelName = context_2.defaultChannel, onStatusUp
|
|
|
56
58
|
currentHash,
|
|
57
59
|
currentUserProperties,
|
|
58
60
|
previousHash,
|
|
61
|
+
rejectedHashes,
|
|
59
62
|
currentBundleVersion: local?.bundleVersion ?? null,
|
|
60
63
|
installId,
|
|
61
64
|
});
|
|
@@ -83,6 +86,17 @@ async function checkForUpdate(channelName = context_2.defaultChannel, onStatusUp
|
|
|
83
86
|
return { action: 'ROLLBACK', channelName, reason: decision.reason };
|
|
84
87
|
}
|
|
85
88
|
// INSTALL
|
|
89
|
+
if (await (0, rollbackState_1.isBundleHashFailed)(decision.target.hash)) {
|
|
90
|
+
onStatusUpdate?.('✅ Current bundle retained; latest update previously failed on this device');
|
|
91
|
+
return {
|
|
92
|
+
action: 'NOOP',
|
|
93
|
+
upToDate: false,
|
|
94
|
+
channelName,
|
|
95
|
+
reason: 'BUNDLE_PREVIOUSLY_FAILED',
|
|
96
|
+
skippedFailedBundle: true,
|
|
97
|
+
skippedHash: decision.target.hash,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
86
100
|
onStatusUpdate?.('⬇️ Update available');
|
|
87
101
|
return {
|
|
88
102
|
action: 'INSTALL',
|
|
@@ -7,6 +7,10 @@ export type ApplyUpdateResult = {
|
|
|
7
7
|
status: 'disabled';
|
|
8
8
|
} | {
|
|
9
9
|
status: 'alreadyApplied';
|
|
10
|
+
} | {
|
|
11
|
+
status: 'blocked';
|
|
12
|
+
reason: 'BUNDLE_PREVIOUSLY_FAILED';
|
|
13
|
+
skippedHash?: string;
|
|
10
14
|
};
|
|
11
15
|
export declare const getUpdateState: (cached?: {
|
|
12
16
|
bundleInfo?: BundleInfo | null;
|
|
@@ -20,4 +24,4 @@ export declare const reconcileAppliedBundleOnLaunch: (cached?: {
|
|
|
20
24
|
bundleInfo?: BundleInfo | null;
|
|
21
25
|
bundlePath?: string | null;
|
|
22
26
|
}) => Promise<void>;
|
|
23
|
-
export declare const applyUpdate: (onStatusUpdate?: (status: string) => void) => Promise<ApplyUpdateResult>;
|
|
27
|
+
export declare const applyUpdate: (onStatusUpdate?: (status: string) => void, onBeforeRestart?: () => void) => Promise<ApplyUpdateResult>;
|
|
@@ -5,6 +5,7 @@ const bundleDropNative_1 = require("../native/bundleDropNative");
|
|
|
5
5
|
const bundleInfo_1 = require("../bundleInfo");
|
|
6
6
|
const reporting_1 = require("./reporting");
|
|
7
7
|
const errors_1 = require("../errors");
|
|
8
|
+
const rollbackState_1 = require("./rollbackState");
|
|
8
9
|
const getUpdateState = async (cached) => {
|
|
9
10
|
const info = cached?.bundleInfo !== undefined ? cached.bundleInfo : await (0, bundleInfo_1.readBundleInfo)();
|
|
10
11
|
const path = cached?.bundlePath !== undefined ? cached.bundlePath : await (0, bundleDropNative_1.getDownloadedBundlePathNative)();
|
|
@@ -17,10 +18,12 @@ const getUpdateState = async (cached) => {
|
|
|
17
18
|
exports.getUpdateState = getUpdateState;
|
|
18
19
|
const reconcileAppliedBundleOnLaunch = async (cached) => {
|
|
19
20
|
const state = await (0, exports.getUpdateState)(cached);
|
|
20
|
-
if (!state.info?.pendingApply)
|
|
21
|
-
return;
|
|
22
21
|
if (!state.hasBundle)
|
|
23
22
|
return;
|
|
23
|
+
if (!state.info?.pendingApply) {
|
|
24
|
+
(0, reporting_1.reportInstalledIfReady)(state).catch(() => { });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
24
27
|
await (0, bundleInfo_1.updateBundleInfo)({ pendingApply: false, installedAt: new Date().toISOString() });
|
|
25
28
|
// Fire-and-forget: don't block the startup path for server reporting
|
|
26
29
|
(0, reporting_1.reportInstalledIfReady)({
|
|
@@ -29,7 +32,7 @@ const reconcileAppliedBundleOnLaunch = async (cached) => {
|
|
|
29
32
|
}).catch(() => { });
|
|
30
33
|
};
|
|
31
34
|
exports.reconcileAppliedBundleOnLaunch = reconcileAppliedBundleOnLaunch;
|
|
32
|
-
const applyUpdate = async (onStatusUpdate) => {
|
|
35
|
+
const applyUpdate = async (onStatusUpdate, onBeforeRestart) => {
|
|
33
36
|
try {
|
|
34
37
|
const path = await (0, bundleDropNative_1.getDownloadedBundlePathNative)();
|
|
35
38
|
const info = await (0, bundleInfo_1.readBundleInfo)();
|
|
@@ -41,18 +44,24 @@ const applyUpdate = async (onStatusUpdate) => {
|
|
|
41
44
|
onStatusUpdate?.('ℹ️ Bundle already applied');
|
|
42
45
|
return { status: 'alreadyApplied' };
|
|
43
46
|
}
|
|
47
|
+
if (await (0, rollbackState_1.isBundleHashFailed)(info?.hash)) {
|
|
48
|
+
onStatusUpdate?.('⚠️ Update previously failed on this device');
|
|
49
|
+
return {
|
|
50
|
+
status: 'blocked',
|
|
51
|
+
reason: 'BUNDLE_PREVIOUSLY_FAILED',
|
|
52
|
+
skippedHash: info?.hash,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
44
55
|
onStatusUpdate?.('♻️ Applying downloaded bundle...');
|
|
45
56
|
await (0, bundleInfo_1.updateBundleInfo)({ pendingApply: false, installedAt: new Date().toISOString() });
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
catch (reportError) {
|
|
57
|
+
(0, reporting_1.reportInstalledIfReady)({
|
|
58
|
+
hasBundle: true,
|
|
59
|
+
info: info ? { ...info, pendingApply: false } : info,
|
|
60
|
+
}).catch(reportError => {
|
|
53
61
|
// Telemetry should not block applying the already-downloaded bundle.
|
|
54
62
|
console.warn('⚠️ Failed to report bundle install during apply:', reportError);
|
|
55
|
-
}
|
|
63
|
+
});
|
|
64
|
+
onBeforeRestart?.();
|
|
56
65
|
(0, bundleDropNative_1.restartReactNativeNative)();
|
|
57
66
|
return { status: 'applied' };
|
|
58
67
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDownloadedBundlePathNative = getDownloadedBundlePathNative;
|
|
4
4
|
exports.restartReactNativeNative = restartReactNativeNative;
|
|
5
|
+
exports.setOtaEnabledNative = setOtaEnabledNative;
|
|
5
6
|
const react_native_1 = require("react-native");
|
|
6
7
|
const { BundleDrop } = react_native_1.NativeModules;
|
|
7
8
|
async function getDownloadedBundlePathNative() {
|
|
@@ -20,3 +21,16 @@ async function getDownloadedBundlePathNative() {
|
|
|
20
21
|
function restartReactNativeNative() {
|
|
21
22
|
BundleDrop?.restartReactNative?.();
|
|
22
23
|
}
|
|
24
|
+
async function setOtaEnabledNative(enabled) {
|
|
25
|
+
if (!BundleDrop?.setOtaEnabled)
|
|
26
|
+
return;
|
|
27
|
+
try {
|
|
28
|
+
await BundleDrop.setOtaEnabled(enabled);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
// Best-effort; native may not support this method on older versions.
|
|
32
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
33
|
+
console.debug('BundleDrop.setOtaEnabled failed (best-effort):', e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/lib/runtime/service.d.ts
CHANGED
|
@@ -58,6 +58,10 @@ export declare function downloadAndStage(extraStatusHandler?: StatusHandler): Pr
|
|
|
58
58
|
* Apply a previously staged bundle immediately by restarting the React Native bridge.
|
|
59
59
|
*/
|
|
60
60
|
export declare function applyDownloadedUpdate(extraStatusHandler?: StatusHandler): Promise<ApplyAndRefreshResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Mark the currently running OTA candidate healthy for this device.
|
|
63
|
+
*/
|
|
64
|
+
export declare function reportHealthy(): Promise<void>;
|
|
61
65
|
/**
|
|
62
66
|
* Fetch the list of public channel names available for the configured project.
|
|
63
67
|
*/
|
|
@@ -74,6 +78,30 @@ export declare function installBundleFromListItem(bundle: BundleListItem): Promi
|
|
|
74
78
|
* Read locally stored metadata for the currently downloaded or applied bundle.
|
|
75
79
|
*/
|
|
76
80
|
export declare function getInstalledBundleInfo(): Promise<BundleInfo | null>;
|
|
81
|
+
export type ObservabilityContext = {
|
|
82
|
+
source: 'embedded' | 'ota';
|
|
83
|
+
dist: string;
|
|
84
|
+
tags: {
|
|
85
|
+
bundle_drop_hash: string | null;
|
|
86
|
+
bundle_drop_channel: string | null;
|
|
87
|
+
bundle_drop_version: string | null;
|
|
88
|
+
bundle_drop_runtime_version: string | null;
|
|
89
|
+
bundle_drop_platform: string | null;
|
|
90
|
+
};
|
|
91
|
+
context: BundleInfo | null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Pre-formatted context for error tracking integrations.
|
|
95
|
+
*
|
|
96
|
+
* Returns `dist`, `tags`, and `context` shaped for direct use with
|
|
97
|
+
* Sentry, Bugsnag, Datadog, or any provider. Handles the embedded
|
|
98
|
+
* fallback automatically: when no OTA bundle is active, `source`
|
|
99
|
+
* is `'embedded'` and `dist` is `'embedded'`.
|
|
100
|
+
*
|
|
101
|
+
* If the installed bundle has `pendingApply: true` it is not yet
|
|
102
|
+
* executing, so the context falls back to `'embedded'`.
|
|
103
|
+
*/
|
|
104
|
+
export declare function getObservabilityContext(): Promise<ObservabilityContext>;
|
|
77
105
|
/**
|
|
78
106
|
* Read the current local update state from disk.
|
|
79
107
|
*/
|