codex-overleaf-link 1.9.2 → 1.9.3
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/README.md +23 -23
- package/extension/bootstrap/background.js +23 -8
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/bootstrap/popup.html +1 -0
- package/extension/bootstrap/popup.js +5 -1
- package/extension/bootstrap/updateStatus.js +78 -0
- package/extension/src/shared/compatibility.js +1 -1
- package/native-host/src/updateManager.js +64 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<h1>Codex Overleaf Link</h1>
|
|
4
4
|
<p><strong>Empower Overleaf with Codex.</strong></p>
|
|
5
5
|
<p>
|
|
6
|
-
<img src="https://img.shields.io/badge/version-1.9.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-1.9.3-blue" alt="version">
|
|
7
7
|
<img src="https://img.shields.io/badge/platform-macOS%20%2F%20Windows%20%2F%20Linux-lightgrey" alt="platform">
|
|
8
8
|
<img src="https://img.shields.io/badge/chrome-MV3-green" alt="chrome manifest v3">
|
|
9
9
|
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node version">
|
|
@@ -38,14 +38,14 @@ One command installs the managed native host **and** managed extension runtime.
|
|
|
38
38
|
macOS / Linux:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
CODEX_OVERLEAF_REF=v1.9.
|
|
41
|
+
CODEX_OVERLEAF_REF=v1.9.3 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.3/install.sh)"
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Windows PowerShell:
|
|
45
45
|
|
|
46
46
|
```powershell
|
|
47
|
-
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.
|
|
48
|
-
$env:CODEX_OVERLEAF_REF='v1.9.
|
|
47
|
+
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.3/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v1.9.3'
|
|
49
49
|
powershell -ExecutionPolicy Bypass -File install.ps1
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ Then, in the `chrome://extensions` tab the script opened: enable **Developer mod
|
|
|
56
56
|
`npm exec` installs the same managed native host and extension runtime without keeping a source checkout. Use it if you prefer a pinned npm package.
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
59
|
+
npm exec --yes codex-overleaf-link@1.9.3 -- install-managed
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Then, in `chrome://extensions`, enable **Developer mode**, click **Load unpacked**, and select the managed extension path printed by the command. The Release extension zip remains available for explicitly unmanaged/manual installations.
|
|
@@ -86,9 +86,9 @@ npm installs, updates, and uninstalls the coordinated managed extension/native p
|
|
|
86
86
|
|
|
87
87
|
| Action | Command |
|
|
88
88
|
|--------|---------|
|
|
89
|
-
| Install / update | `npm exec --yes codex-overleaf-link@1.9.
|
|
90
|
-
| Diagnose | `npm exec --yes codex-overleaf-link@1.9.
|
|
91
|
-
| Uninstall | `npm exec --yes codex-overleaf-link@1.9.
|
|
89
|
+
| Install / update | `npm exec --yes codex-overleaf-link@1.9.3 -- install-managed` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@1.9.3 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-managed` |
|
|
92
92
|
|
|
93
93
|
Use `--extension-id <chrome-extension-id>` only for a custom/dev unpacked extension id that differs from the official bundled id.
|
|
94
94
|
|
|
@@ -98,13 +98,13 @@ Managed installations discover signed stable updates automatically and apply the
|
|
|
98
98
|
|
|
99
99
|
## GitHub Release Artifacts
|
|
100
100
|
|
|
101
|
-
The v1.9.
|
|
101
|
+
The v1.9.3 GitHub Release contains:
|
|
102
102
|
|
|
103
|
-
- `codex-overleaf-link-extension-v1.9.
|
|
104
|
-
- `codex-overleaf-native-host-v1.9.
|
|
105
|
-
- `codex-overleaf-link-1.9.
|
|
106
|
-
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v1.9.
|
|
107
|
-
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.
|
|
103
|
+
- `codex-overleaf-link-extension-v1.9.3.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v1.9.3.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-1.9.3.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
|
|
106
|
+
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v1.9.3` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.3` when run directly from the release artifact.
|
|
108
108
|
- `uninstall-native-host.mjs`: native host uninstaller that removes the Chrome Native Messaging manifest, bridge executable, and runtime copy.
|
|
109
109
|
- `nativeHostPlatform.js`, `manifest.js`, `runtimeInstaller.js`: helper files required by the loose uninstaller asset.
|
|
110
110
|
- `SHA256SUMS` and `release-manifest.json`: checksum and artifact metadata for release verification.
|
|
@@ -115,7 +115,7 @@ The v1.9.2 GitHub Release contains:
|
|
|
115
115
|
Remove the native host (use `--browser chromium` on Linux Chromium):
|
|
116
116
|
|
|
117
117
|
```bash
|
|
118
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
118
|
+
npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-managed
|
|
119
119
|
```
|
|
120
120
|
|
|
121
121
|
The same command works on Windows PowerShell. If you installed from a manual checkout or source installer, you can also run `npm run uninstall:native` inside the repo, use `node ~/.codex-overleaf/source/scripts/uninstall-native-host.mjs` on macOS / Linux, or use `node $env:LOCALAPPDATA\CodexOverleaf\source\scripts\uninstall-native-host.mjs` on Windows PowerShell.
|
|
@@ -150,13 +150,13 @@ Then remove the extension from `chrome://extensions`. To delete local data: on m
|
|
|
150
150
|
Linux Chromium install or update:
|
|
151
151
|
|
|
152
152
|
```bash
|
|
153
|
-
CODEX_OVERLEAF_REF=v1.9.
|
|
153
|
+
CODEX_OVERLEAF_REF=v1.9.3 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.3/install.sh)" -- --browser chromium
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
Linux Chromium uninstall:
|
|
157
157
|
|
|
158
158
|
```bash
|
|
159
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
159
|
+
npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-managed --browser chromium
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
## Features
|
|
@@ -291,7 +291,7 @@ Composer attachments are turn-scoped Codex context. Limits are 8 attachments per
|
|
|
291
291
|
Re-run any [native host installer](#install), reload the extension in `chrome://extensions`, then refresh the Overleaf tab. This also fixes extension/native version mismatch and native protocol mismatch.
|
|
292
292
|
|
|
293
293
|
```bash
|
|
294
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
294
|
+
npm exec --yes codex-overleaf-link@1.9.3 -- install-managed
|
|
295
295
|
```
|
|
296
296
|
|
|
297
297
|
**The Windows popup or panel shows a Bash recovery command**
|
|
@@ -340,8 +340,8 @@ Use this matrix for release-candidate signoff and compatibility reports. Record
|
|
|
340
340
|
| Browser/channel/version | Google Chrome channel and version. | Google Chrome channel and version. | Google Chrome channel and version. | Chromium channel/package and version. |
|
|
341
341
|
| Install mode | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout; native host installed with `--browser chromium`. |
|
|
342
342
|
| Extension id | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. |
|
|
343
|
-
| Installer/update command | `npm exec --yes codex-overleaf-link@1.9.
|
|
344
|
-
| Uninstall command | `npm exec --yes codex-overleaf-link@1.9.
|
|
343
|
+
| Installer/update command | `npm exec --yes codex-overleaf-link@1.9.3 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.3 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.3 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.3 -- install-managed --browser chromium` |
|
|
344
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-managed --browser chromium` |
|
|
345
345
|
| Manifest/registry path | `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.codex.overleaf.json` | `HKCU\Software\Google\Chrome\NativeMessagingHosts\com.codex.overleaf` -> `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime\com.codex.overleaf.json` | `~/.config/google-chrome/NativeMessagingHosts/com.codex.overleaf.json` | `~/.config/chromium/NativeMessagingHosts/com.codex.overleaf.json` |
|
|
346
346
|
| Bridge/runtime/source path | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `%LOCALAPPDATA%\CodexOverleaf\codex-overleaf-bridge.cmd`; runtime `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime`; source `%LOCALAPPDATA%\CodexOverleaf\source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. |
|
|
347
347
|
| Node/Git/Codex/TeX | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. |
|
|
@@ -377,7 +377,7 @@ Contributions are welcome. Please open an issue before submitting large changes
|
|
|
377
377
|
The recommended v1.9 installation owns one stable unpacked-extension directory and a versioned native-host directory:
|
|
378
378
|
|
|
379
379
|
```bash
|
|
380
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
380
|
+
npm exec --yes codex-overleaf-link@1.9.3 -- install-managed
|
|
381
381
|
```
|
|
382
382
|
|
|
383
383
|
Load the printed extension path once from `chrome://extensions`. Starting with the next signed stable release, Codex Overleaf Link checks GitHub Releases automatically, downloads and verifies the coordinated extension/native-host bundle, waits until every connected Overleaf tab is saved and idle, and then updates both components together. A failed health check restores the previous version automatically.
|
|
@@ -387,11 +387,11 @@ The stable updater ignores drafts and prereleases, performs no telemetry, and ca
|
|
|
387
387
|
The legacy native-only installer remains available for source or unmanaged extension directories:
|
|
388
388
|
|
|
389
389
|
```bash
|
|
390
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
390
|
+
npm exec --yes codex-overleaf-link@1.9.3 -- install-native
|
|
391
391
|
```
|
|
392
392
|
|
|
393
393
|
Legacy native-only installations can be removed with:
|
|
394
394
|
|
|
395
395
|
```bash
|
|
396
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
396
|
+
npm exec --yes codex-overleaf-link@1.9.3 -- uninstall-native
|
|
397
397
|
```
|
|
@@ -16,6 +16,7 @@ let runtimeLoadError = null;
|
|
|
16
16
|
try {
|
|
17
17
|
globalThis.__CODEX_OVERLEAF_RUNTIME_BASE__ = 'runtime';
|
|
18
18
|
importScripts(
|
|
19
|
+
chrome.runtime.getURL('bootstrap/updateStatus.js'),
|
|
19
20
|
chrome.runtime.getURL('runtime/src/shared/compatibility.js'),
|
|
20
21
|
chrome.runtime.getURL('runtime/src/background.js')
|
|
21
22
|
);
|
|
@@ -118,10 +119,13 @@ async function checkAndStage(options = {}) {
|
|
|
118
119
|
if (APPLYING_STATES.has(current.state)) {
|
|
119
120
|
return current;
|
|
120
121
|
}
|
|
122
|
+
if (['staged', 'waiting_for_idle'].includes(current.state) && current.transactionId) {
|
|
123
|
+
return tryApplyStagedUpdate();
|
|
124
|
+
}
|
|
121
125
|
if (!options.manual && Number(current.postponeUntil || 0) > Date.now()) {
|
|
122
126
|
return current;
|
|
123
127
|
}
|
|
124
|
-
await setUpdateState({ ...current, state: 'checking', code: '', message: '' });
|
|
128
|
+
await setUpdateState({ ...current, state: 'checking', blocker: '', blockers: [], code: '', message: '' });
|
|
125
129
|
const checked = await requestInternal({
|
|
126
130
|
method: 'update.check',
|
|
127
131
|
params: {
|
|
@@ -170,7 +174,9 @@ async function checkAndStage(options = {}) {
|
|
|
170
174
|
currentVersion: chrome.runtime.getManifest().version,
|
|
171
175
|
latestVersion: staged.result.targetVersion,
|
|
172
176
|
transactionId: staged.result.transactionId,
|
|
173
|
-
stagedAt: Date.now()
|
|
177
|
+
stagedAt: Date.now(),
|
|
178
|
+
blocker: '',
|
|
179
|
+
blockers: []
|
|
174
180
|
});
|
|
175
181
|
await broadcastUpdateState('staged');
|
|
176
182
|
chrome.alarms.create(IDLE_ALARM, { delayInMinutes: 0.1 });
|
|
@@ -187,20 +193,25 @@ async function tryApplyStagedUpdate() {
|
|
|
187
193
|
}
|
|
188
194
|
const tabs = await chrome.tabs.query({ url: OVERLEAF_MATCHES });
|
|
189
195
|
const probes = await Promise.all(tabs.map(tab => probeTabIdle(tab)));
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
196
|
+
const nativeGate = await requestInternal({ method: 'update.canApply', params: {} }).catch(error => ({
|
|
197
|
+
ok: false,
|
|
198
|
+
error: { code: safeCode(error), message: safeMessage(error) }
|
|
199
|
+
}));
|
|
200
|
+
const blockers = globalThis.CodexOverleafUpdateStatus?.collectBlockers(probes, nativeGate)
|
|
201
|
+
|| ['busy'];
|
|
202
|
+
if (blockers.length) {
|
|
193
203
|
const waiting = await setUpdateState({
|
|
194
204
|
...state,
|
|
195
205
|
state: 'waiting_for_idle',
|
|
196
|
-
blocker:
|
|
206
|
+
blocker: blockers[0],
|
|
207
|
+
blockers
|
|
197
208
|
});
|
|
198
209
|
chrome.alarms.create(IDLE_ALARM, { delayInMinutes: 1 });
|
|
199
210
|
return waiting;
|
|
200
211
|
}
|
|
201
212
|
|
|
202
213
|
await chrome.storage.local.set({ [UPDATE_RELOAD_TABS_KEY]: tabs.map(tab => tab.id).filter(Number.isInteger) });
|
|
203
|
-
await setUpdateState({ ...state, state: 'applying', blocker: '' });
|
|
214
|
+
await setUpdateState({ ...state, state: 'applying', blocker: '', blockers: [] });
|
|
204
215
|
await broadcastUpdateState('applying');
|
|
205
216
|
const applied = await requestInternal({
|
|
206
217
|
method: 'update.apply',
|
|
@@ -353,6 +364,9 @@ async function getUpdateState() {
|
|
|
353
364
|
}
|
|
354
365
|
|
|
355
366
|
async function setUpdateState(next) {
|
|
367
|
+
const blockers = globalThis.CodexOverleafUpdateStatus?.normalizeBlockers(
|
|
368
|
+
Array.isArray(next.blockers) ? next.blockers : (next.blocker ? [next.blocker] : [])
|
|
369
|
+
) || [];
|
|
356
370
|
const value = {
|
|
357
371
|
state: next.state || 'idle',
|
|
358
372
|
managed: next.managed !== false,
|
|
@@ -363,7 +377,8 @@ async function setUpdateState(next) {
|
|
|
363
377
|
stagedAt: Number(next.stagedAt || 0),
|
|
364
378
|
postponeUntil: Number(next.postponeUntil || 0),
|
|
365
379
|
transactionId: next.transactionId || '',
|
|
366
|
-
blocker:
|
|
380
|
+
blocker: blockers[0] || '',
|
|
381
|
+
blockers,
|
|
367
382
|
code: next.code || '',
|
|
368
383
|
message: String(next.message || '').slice(0, 300)
|
|
369
384
|
};
|
|
@@ -5,6 +5,7 @@ const updateVersions = document.getElementById('update-versions');
|
|
|
5
5
|
const updateDetail = document.getElementById('update-detail');
|
|
6
6
|
const checkButton = document.getElementById('check-update');
|
|
7
7
|
const postponeButton = document.getElementById('postpone-update');
|
|
8
|
+
const UpdateStatus = globalThis.CodexOverleafUpdateStatus;
|
|
8
9
|
|
|
9
10
|
checkButton.addEventListener('click', async () => {
|
|
10
11
|
checkButton.disabled = true;
|
|
@@ -33,7 +34,10 @@ async function refreshUpdateState() {
|
|
|
33
34
|
if (state.managed === false) {
|
|
34
35
|
updateDetail.textContent = 'Run install-managed once to enable automatic extension and native-host updates.';
|
|
35
36
|
} else if (state.state === 'waiting_for_idle') {
|
|
36
|
-
|
|
37
|
+
const blockerDetail = UpdateStatus?.formatBlockers(state.blockers || [state.blocker]) || '';
|
|
38
|
+
updateDetail.textContent = blockerDetail
|
|
39
|
+
? `Downloaded and verified. ${blockerDetail}`
|
|
40
|
+
: 'Downloaded and verified. Waiting until every Overleaf tab is saved and idle.';
|
|
37
41
|
} else if (state.state === 'rolled_back') {
|
|
38
42
|
updateDetail.textContent = 'The previous version was restored after a failed health check.';
|
|
39
43
|
} else if (state.state === 'committed') {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
(function initCodexOverleafUpdateStatus(root) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const BLOCKER_MESSAGES = Object.freeze({
|
|
5
|
+
run: 'A Codex run is still active.',
|
|
6
|
+
cancelling: 'A Codex cancellation is still settling.',
|
|
7
|
+
storage: 'Extension state is still being saved.',
|
|
8
|
+
reviewAction: 'An Accept or Undo action is still running.',
|
|
9
|
+
dialog: 'A confirmation dialog is still open.',
|
|
10
|
+
save_state_unverified: 'Overleaf has not confirmed that the document is saved.',
|
|
11
|
+
recent_user_activity: 'Recent editor activity must be idle for 30 seconds.',
|
|
12
|
+
save_state_not_stable: 'The saved state must remain stable for 3 seconds.',
|
|
13
|
+
idle_probe_failed: 'The Overleaf idle check failed.',
|
|
14
|
+
tab_unavailable: 'An Overleaf tab is unavailable.',
|
|
15
|
+
tab_probe_timeout: 'An Overleaf tab did not answer the idle check in time.',
|
|
16
|
+
tab_probe_unavailable: 'Reload an Overleaf tab so the updater can verify that it is idle.',
|
|
17
|
+
tab_not_idle: 'An Overleaf tab is still busy.',
|
|
18
|
+
native_project_locked: 'The native host still holds a project lock.',
|
|
19
|
+
native_run_active: 'The native host is still processing a Codex run.',
|
|
20
|
+
native_gate_unavailable: 'The native host could not report whether it is idle.',
|
|
21
|
+
native_not_idle: 'The native host is still busy.',
|
|
22
|
+
busy: 'An update safety check is still busy.'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
function normalizeBlockers(values = []) {
|
|
26
|
+
const result = [];
|
|
27
|
+
const seen = new Set();
|
|
28
|
+
const visit = value => {
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
value.forEach(visit);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const code = String(value || '').trim();
|
|
34
|
+
if (!code || seen.has(code)) return;
|
|
35
|
+
seen.add(code);
|
|
36
|
+
result.push(code);
|
|
37
|
+
};
|
|
38
|
+
visit(values);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function collectBlockers(probes = [], nativeGate = null) {
|
|
43
|
+
const blockers = [];
|
|
44
|
+
for (const probe of probes || []) {
|
|
45
|
+
if (probe?.idle === true) continue;
|
|
46
|
+
if (Array.isArray(probe?.blockers) && probe.blockers.length) {
|
|
47
|
+
blockers.push(probe.blockers);
|
|
48
|
+
} else {
|
|
49
|
+
blockers.push('tab_not_idle');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!nativeGate?.ok) {
|
|
53
|
+
blockers.push(nativeGate?.error?.code || 'native_gate_unavailable');
|
|
54
|
+
} else if (nativeGate.result?.idle !== true) {
|
|
55
|
+
blockers.push(nativeGate.result?.blockers?.length ? nativeGate.result.blockers : 'native_not_idle');
|
|
56
|
+
}
|
|
57
|
+
return normalizeBlockers(blockers);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function describeBlocker(code) {
|
|
61
|
+
const normalized = String(code || '').trim();
|
|
62
|
+
if (!normalized) return '';
|
|
63
|
+
return BLOCKER_MESSAGES[normalized]
|
|
64
|
+
|| `Update is waiting on: ${normalized.replaceAll('_', ' ')}.`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function formatBlockers(blockers = []) {
|
|
68
|
+
return normalizeBlockers(blockers).map(describeBlocker).filter(Boolean).join(' ');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
root.CodexOverleafUpdateStatus = Object.freeze({
|
|
72
|
+
BLOCKER_MESSAGES,
|
|
73
|
+
collectBlockers,
|
|
74
|
+
describeBlocker,
|
|
75
|
+
formatBlockers,
|
|
76
|
+
normalizeBlockers
|
|
77
|
+
});
|
|
78
|
+
})(typeof window !== 'undefined' ? window : globalThis);
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const MIN_NATIVE_VERSION = '1.0.0';
|
|
13
13
|
const MIN_COMPATIBLE_NATIVE_VERSION = '1.0.0';
|
|
14
14
|
const MIN_COMPATIBLE_EXTENSION_VERSION = '1.0.0';
|
|
15
|
-
const BUILD_TARGET_VERSION = '1.9.
|
|
15
|
+
const BUILD_TARGET_VERSION = '1.9.3';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|
|
@@ -172,6 +172,23 @@ async function stageCandidate(context, options = {}) {
|
|
|
172
172
|
if (!isNewerStableVersion(manifest.version, activeVersion)) {
|
|
173
173
|
throw updateError('update_candidate_stale', 'The staged update is no longer newer than the active version.');
|
|
174
174
|
}
|
|
175
|
+
const existingJournal = readJournal(context);
|
|
176
|
+
if (existingJournal?.state === 'staged' && existingJournal.targetVersion === manifest.version) {
|
|
177
|
+
try {
|
|
178
|
+
verifyStagedPair(existingJournal.payloadRoot, manifest.version);
|
|
179
|
+
return {
|
|
180
|
+
transactionId: existingJournal.id,
|
|
181
|
+
targetVersion: existingJournal.targetVersion,
|
|
182
|
+
state: existingJournal.state,
|
|
183
|
+
reused: true
|
|
184
|
+
};
|
|
185
|
+
} catch (_error) {
|
|
186
|
+
cleanupStage(existingJournal.stageRoot);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (existingJournal && ['applying', 'awaiting_health'].includes(existingJournal.state)) {
|
|
190
|
+
throw updateError('update_transaction_in_progress', 'A managed update transaction is already being applied.');
|
|
191
|
+
}
|
|
175
192
|
const transactionId = crypto.randomUUID();
|
|
176
193
|
const stageRoot = path.join(context.updatesRoot, 'staging-' + transactionId);
|
|
177
194
|
fs.mkdirSync(stageRoot, { recursive: true, mode: 0o700 });
|
|
@@ -202,6 +219,7 @@ async function stageCandidate(context, options = {}) {
|
|
|
202
219
|
updatedAt: new Date().toISOString()
|
|
203
220
|
};
|
|
204
221
|
writeJournal(context, journal);
|
|
222
|
+
cleanupOrphanStageRoots(context.updatesRoot, [stageRoot]);
|
|
205
223
|
return { transactionId, targetVersion: manifest.version, state: journal.state };
|
|
206
224
|
}
|
|
207
225
|
|
|
@@ -247,6 +265,7 @@ function applyStagedUpdate(context, params = {}, options = {}) {
|
|
|
247
265
|
atomicWriteText(path.join(context.nativeRoot, 'previous-version'), journal.sourceVersion + '\n');
|
|
248
266
|
atomicWriteText(path.join(context.nativeRoot, 'active-version'), journal.targetVersion + '\n');
|
|
249
267
|
rewriteManagedManifestVersion(manifestPath, journal.targetVersion);
|
|
268
|
+
syncManagedMarkerVersions(context, journal.targetVersion);
|
|
250
269
|
} catch (error) {
|
|
251
270
|
rollbackFiles(context, { ...journal, previousManifest });
|
|
252
271
|
throw updateError('update_apply_failed', 'Managed update could not be applied atomically.', { cause: error });
|
|
@@ -282,6 +301,7 @@ function confirmUpdate(context, params = {}) {
|
|
|
282
301
|
});
|
|
283
302
|
pruneNativeVersions(context.nativeRoot, new Set([journal.targetVersion, journal.sourceVersion]));
|
|
284
303
|
cleanupStage(journal.stageRoot);
|
|
304
|
+
cleanupOrphanStageRoots(context.updatesRoot);
|
|
285
305
|
return { version: journal.targetVersion, state: 'committed' };
|
|
286
306
|
}
|
|
287
307
|
|
|
@@ -306,6 +326,7 @@ function rollbackUpdate(context, params = {}) {
|
|
|
306
326
|
previousManifest: undefined
|
|
307
327
|
});
|
|
308
328
|
cleanupStage(journal.stageRoot);
|
|
329
|
+
cleanupOrphanStageRoots(context.updatesRoot);
|
|
309
330
|
return { version: journal.sourceVersion, state: 'rolled_back' };
|
|
310
331
|
}
|
|
311
332
|
|
|
@@ -329,6 +350,45 @@ function rollbackFiles(context, journal) {
|
|
|
329
350
|
} else {
|
|
330
351
|
fs.rmSync(path.join(context.nativeRoot, 'previous-version'), { force: true });
|
|
331
352
|
}
|
|
353
|
+
if (parseSemver(journal.sourceVersion)) {
|
|
354
|
+
syncManagedMarkerVersions(context, journal.sourceVersion);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function syncManagedMarkerVersions(context, version) {
|
|
359
|
+
rewriteManagedMarkerVersion(context.extensionRoot, EXTENSION_MARKER, 'extension', version);
|
|
360
|
+
rewriteManagedMarkerVersion(context.nativeRoot, NATIVE_MARKER, 'native', version);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function rewriteManagedMarkerVersion(root, filename, kind, version) {
|
|
364
|
+
const markerPath = path.join(root, filename);
|
|
365
|
+
const marker = readJsonSafe(markerPath, null);
|
|
366
|
+
if (!isManagedMarker(marker, kind)) {
|
|
367
|
+
throw updateError('update_marker_invalid', `The managed ${kind} marker is missing or invalid.`);
|
|
368
|
+
}
|
|
369
|
+
atomicWriteJson(markerPath, {
|
|
370
|
+
...marker,
|
|
371
|
+
version,
|
|
372
|
+
updatedAt: new Date().toISOString()
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function cleanupOrphanStageRoots(updatesRoot, retainedRoots = []) {
|
|
377
|
+
const resolvedRoot = path.resolve(String(updatesRoot || ''));
|
|
378
|
+
if (!resolvedRoot || resolvedRoot === path.parse(resolvedRoot).root) return;
|
|
379
|
+
const retained = new Set((retainedRoots || []).map(value => path.resolve(String(value || ''))));
|
|
380
|
+
let entries;
|
|
381
|
+
try {
|
|
382
|
+
entries = fs.readdirSync(resolvedRoot, { withFileTypes: true });
|
|
383
|
+
} catch (_error) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
for (const entry of entries) {
|
|
387
|
+
if (!entry.isDirectory() || !/^staging-[0-9a-f-]{36}$/i.test(entry.name)) continue;
|
|
388
|
+
const candidate = path.join(resolvedRoot, entry.name);
|
|
389
|
+
if (retained.has(path.resolve(candidate))) continue;
|
|
390
|
+
fs.rmSync(candidate, { recursive: true, force: true });
|
|
391
|
+
}
|
|
332
392
|
}
|
|
333
393
|
|
|
334
394
|
function recoverAndReadStatus(context) {
|
|
@@ -539,10 +599,13 @@ module.exports = {
|
|
|
539
599
|
GITHUB_LATEST_URL,
|
|
540
600
|
applyStagedUpdate,
|
|
541
601
|
checkForUpdate,
|
|
602
|
+
cleanupOrphanStageRoots,
|
|
542
603
|
confirmUpdate,
|
|
543
604
|
getApplyGate,
|
|
544
605
|
getManagedContext,
|
|
545
606
|
handleUpdateRequest,
|
|
546
607
|
isUpdateMethod,
|
|
547
|
-
rollbackUpdate
|
|
608
|
+
rollbackUpdate,
|
|
609
|
+
stageCandidate,
|
|
610
|
+
syncManagedMarkerVersions
|
|
548
611
|
};
|