codex-overleaf-link 1.9.9 → 1.9.11
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 +56 -7
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/src/content/contentRuntime.js +1 -1
- package/extension/src/content/settingsPanel.js +3 -2
- package/extension/src/content/updateIdle.js +1 -1
- package/extension/src/content/updateNotice.js +57 -26
- package/extension/src/pageBridge.js +22 -0
- package/extension/src/shared/compatibility.js +1 -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.11-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.11 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.11/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.11/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v1.9.11'
|
|
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.11 -- 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.11 -- install-managed` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@1.9.11 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@1.9.11 -- 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.11 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.11.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v1.9.11.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-1.9.11.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.11` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.11` 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.9 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.11 -- 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.11 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.11/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.11 -- 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.11 -- 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.11 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.11 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.11 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.11 -- install-managed --browser chromium` |
|
|
344
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@1.9.11 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.11 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.11 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.11 -- 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.11 -- 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.11 -- 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.11 -- uninstall-native
|
|
397
397
|
```
|
|
@@ -20,9 +20,11 @@ const FAST_IDLE_RETRY_BLOCKERS = new Set(['recent_user_activity', 'save_state_no
|
|
|
20
20
|
const FAST_IDLE_RETRY_MS = 4000;
|
|
21
21
|
const SLOW_IDLE_RETRY_MS = 15000;
|
|
22
22
|
const IDLE_RETRY_ALARM_MINUTES = 0.5;
|
|
23
|
+
const RUNTIME_RECOVERY_SETTLE_MS = 250;
|
|
23
24
|
|
|
24
25
|
let idleRetryTimer = null;
|
|
25
26
|
let idleApplyPromise = null;
|
|
27
|
+
let managedRuntimeAssets = null;
|
|
26
28
|
|
|
27
29
|
let runtimeLoadError = null;
|
|
28
30
|
try {
|
|
@@ -103,6 +105,10 @@ async function registerManagedRuntime() {
|
|
|
103
105
|
}
|
|
104
106
|
const manifest = await response.json();
|
|
105
107
|
validateRuntimeManifest(manifest);
|
|
108
|
+
managedRuntimeAssets = {
|
|
109
|
+
js: ['bootstrap/runtimeContext.js', ...manifest.js.map(value => 'runtime/' + value)],
|
|
110
|
+
css: manifest.css.map(value => 'runtime/' + value)
|
|
111
|
+
};
|
|
106
112
|
const registered = await chrome.scripting.getRegisteredContentScripts({ ids: [RUNTIME_SCRIPT_ID] });
|
|
107
113
|
if (registered.length) {
|
|
108
114
|
await chrome.scripting.unregisterContentScripts({ ids: [RUNTIME_SCRIPT_ID] });
|
|
@@ -110,8 +116,8 @@ async function registerManagedRuntime() {
|
|
|
110
116
|
await chrome.scripting.registerContentScripts([{
|
|
111
117
|
id: RUNTIME_SCRIPT_ID,
|
|
112
118
|
matches: manifest.matches,
|
|
113
|
-
js:
|
|
114
|
-
css:
|
|
119
|
+
js: managedRuntimeAssets.js,
|
|
120
|
+
css: managedRuntimeAssets.css,
|
|
115
121
|
runAt: manifest.runAt || 'document_idle',
|
|
116
122
|
persistAcrossSessions: true
|
|
117
123
|
}]);
|
|
@@ -216,8 +222,10 @@ async function tryApplyStagedUpdateCore() {
|
|
|
216
222
|
if (Number(state.postponeUntil || 0) > Date.now()) {
|
|
217
223
|
return state;
|
|
218
224
|
}
|
|
219
|
-
const
|
|
220
|
-
const
|
|
225
|
+
const surfaceTabs = await chrome.tabs.query({ url: OVERLEAF_MATCHES });
|
|
226
|
+
const activeTabs = surfaceTabs.filter(tab => isEditorProjectTab(tab) && !tab.discarded && tab.status !== 'unloaded');
|
|
227
|
+
const refreshTabs = surfaceTabs.filter(tab => !tab.discarded && tab.status !== 'unloaded');
|
|
228
|
+
const probes = await Promise.all(activeTabs.map(tab => probeTabIdle(tab)));
|
|
221
229
|
const nativeGate = await requestInternal({ method: 'update.canApply', params: {} }).catch(error => ({
|
|
222
230
|
ok: false,
|
|
223
231
|
error: { code: safeCode(error), message: safeMessage(error) }
|
|
@@ -237,7 +245,7 @@ async function tryApplyStagedUpdateCore() {
|
|
|
237
245
|
}
|
|
238
246
|
|
|
239
247
|
await clearIdleRetry();
|
|
240
|
-
await chrome.storage.local.set({ [UPDATE_RELOAD_TABS_KEY]:
|
|
248
|
+
await chrome.storage.local.set({ [UPDATE_RELOAD_TABS_KEY]: refreshTabs.map(tab => tab.id).filter(Number.isInteger) });
|
|
241
249
|
await setUpdateState({ ...state, state: 'applying', blocker: '', blockers: [] });
|
|
242
250
|
await broadcastUpdateState('applying');
|
|
243
251
|
const applied = await requestInternal({
|
|
@@ -280,14 +288,55 @@ async function probeTabIdle(tab) {
|
|
|
280
288
|
if (!Number.isInteger(tab?.id)) {
|
|
281
289
|
return { idle: false, blockers: ['tab_unavailable'] };
|
|
282
290
|
}
|
|
291
|
+
if (!isEditorProjectTab(tab)) {
|
|
292
|
+
return { idle: true, saved: true, ignored: true, blockers: [] };
|
|
293
|
+
}
|
|
294
|
+
if (tab.discarded || tab.status === 'unloaded') {
|
|
295
|
+
return { idle: true, saved: true, ignored: true, blockers: [] };
|
|
296
|
+
}
|
|
297
|
+
const firstProbe = await sendTabIdleProbe(tab.id);
|
|
298
|
+
if (firstProbe) return firstProbe;
|
|
299
|
+
if (await injectManagedRuntimeIntoTab(tab.id)) {
|
|
300
|
+
const recoveredProbe = await sendTabIdleProbe(tab.id);
|
|
301
|
+
if (recoveredProbe) return recoveredProbe;
|
|
302
|
+
}
|
|
303
|
+
return { idle: false, blockers: ['tab_probe_unavailable'] };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function isEditorProjectTab(tab) {
|
|
307
|
+
try {
|
|
308
|
+
const url = new URL(tab?.url || '');
|
|
309
|
+
return url.protocol === 'https:' &&
|
|
310
|
+
(url.hostname === 'www.overleaf.com' || url.hostname === 'overleaf.com') &&
|
|
311
|
+
/^\/project\/[^/]+(?:\/|$)/.test(url.pathname);
|
|
312
|
+
} catch (_error) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
async function sendTabIdleProbe(tabId) {
|
|
283
318
|
try {
|
|
284
319
|
return await withTimeout(
|
|
285
|
-
chrome.tabs.sendMessage(
|
|
320
|
+
chrome.tabs.sendMessage(tabId, { type: 'codex-overleaf/update-idle-probe' }),
|
|
286
321
|
3500,
|
|
287
322
|
{ idle: false, blockers: ['tab_probe_timeout'] }
|
|
288
323
|
);
|
|
289
324
|
} catch (_error) {
|
|
290
|
-
return
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async function injectManagedRuntimeIntoTab(tabId) {
|
|
330
|
+
if (!managedRuntimeAssets) return false;
|
|
331
|
+
try {
|
|
332
|
+
if (managedRuntimeAssets.css.length) {
|
|
333
|
+
await chrome.scripting.insertCSS({ target: { tabId }, files: managedRuntimeAssets.css });
|
|
334
|
+
}
|
|
335
|
+
await chrome.scripting.executeScript({ target: { tabId }, files: managedRuntimeAssets.js });
|
|
336
|
+
await new Promise(resolve => setTimeout(resolve, RUNTIME_RECOVERY_SETTLE_MS));
|
|
337
|
+
return true;
|
|
338
|
+
} catch (_error) {
|
|
339
|
+
return false;
|
|
291
340
|
}
|
|
292
341
|
}
|
|
293
342
|
|
|
@@ -715,7 +715,7 @@
|
|
|
715
715
|
reviewAction: trackedChangeInFlight.size > 0,
|
|
716
716
|
dialog: Boolean(activePluginConfirmResolve)
|
|
717
717
|
}),
|
|
718
|
-
checkSaved: () => callPageBridge('waitForSaveState', { deadlineMs: 1500, pollIntervalMs: 100, requirePositiveSignal: true }),
|
|
718
|
+
checkSaved: () => callPageBridge('waitForSaveState', { deadlineMs: 1500, pollIntervalMs: 100, requirePositiveSignal: true, allowQuietEditorFallback: true, quietFallbackMs: 1000 }),
|
|
719
719
|
onApplyingChange: applying => { if (panel) panel.dataset.updating = applying ? 'true' : 'false'; },
|
|
720
720
|
showToast: (...args) => showPluginToast(...args),
|
|
721
721
|
getStateMessage: state => ({
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
history: '<path d="M4.2 3.4h7.6"/><path d="M4.2 8h7.6"/><path d="M4.2 12.6h4.6"/><path d="M2.2 3.4h.1"/><path d="M2.2 8h.1"/><path d="M2.2 12.6h.1"/>',
|
|
11
11
|
lock: '<rect x="3.6" y="7" width="8.8" height="6.2" rx="1.2"/><path d="M5.6 7V5.3a2.4 2.4 0 0 1 4.8 0V7"/><path d="M8 9.6v1.2"/>',
|
|
12
12
|
pen: '<path d="M3.2 12.8 4 9.7l6.6-6.6a1.4 1.4 0 0 1 2 2L6 11.7z"/><path d="m9.6 4.1 2.3 2.3"/>',
|
|
13
|
-
shield: '<path d="M8 2.1 12.4 4v3.5c0 2.9-1.8 5.1-4.4 6.4-2.6-1.3-4.4-3.5-4.4-6.4V4z"/><path d="M6.1 8.1 7.5 9.5 10.2 6.6"/>'
|
|
13
|
+
shield: '<path d="M8 2.1 12.4 4v3.5c0 2.9-1.8 5.1-4.4 6.4-2.6-1.3-4.4-3.5-4.4-6.4V4z"/><path d="M6.1 8.1 7.5 9.5 10.2 6.6"/>',
|
|
14
|
+
software: '<rect x="5.1" y="5.1" width="5.8" height="5.8" rx="1.2"/><path d="M12.9 7.1A5.2 5.2 0 0 0 4.1 4.2"/><path d="M4.1 2.2v2h2"/><path d="M3.1 8.9a5.2 5.2 0 0 0 8.8 2.9"/><path d="M11.9 13.8v-2h-2"/>'
|
|
14
15
|
};
|
|
15
16
|
const safeName = Object.prototype.hasOwnProperty.call(icons, name) ? name : 'appearance';
|
|
16
17
|
return `<span class="codex-icon codex-icon-${safeName}" aria-hidden="true"><svg viewBox="0 0 16 16" focusable="false">${icons[safeName]}</svg></span>`;
|
|
@@ -148,7 +149,7 @@
|
|
|
148
149
|
</details>
|
|
149
150
|
<details class="codex-set-group" data-set-group="updates" open>
|
|
150
151
|
<summary class="codex-set-group-head">
|
|
151
|
-
<span class="codex-set-group-title">${codexSetIcon('
|
|
152
|
+
<span class="codex-set-group-title">${codexSetIcon('software')}<span data-i18n="softwareUpdatesTitle">Software updates</span></span>
|
|
152
153
|
</summary>
|
|
153
154
|
<div class="codex-set-card" data-update-settings>
|
|
154
155
|
<div class="codex-set-row">
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
} catch (_error) {
|
|
42
42
|
saveResult = { ok: false, state: 'unavailable' };
|
|
43
43
|
}
|
|
44
|
-
const saved = saveResult?.ok === true && saveResult?.state
|
|
44
|
+
const saved = saveResult?.ok === true && ['verified_saved', 'verified_quiet'].includes(saveResult?.state);
|
|
45
45
|
if (saved) {
|
|
46
46
|
stableSavedSince = stableSavedSince || Date.now();
|
|
47
47
|
} else {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
let getLocale = () => '';
|
|
10
10
|
let settingsRoot = null;
|
|
11
11
|
let settingsActionInFlight = false;
|
|
12
|
+
const ACTIVE_UPDATE_STATES = new Set(['downloading', 'staged', 'waiting_for_idle', 'applying', 'awaiting_health']);
|
|
12
13
|
|
|
13
14
|
function mount(panelLike, options = {}) {
|
|
14
15
|
if (typeof options.getLocale === 'function') {
|
|
@@ -69,17 +70,10 @@
|
|
|
69
70
|
dismiss: 'codex-overleaf/consent-update-dismiss'
|
|
70
71
|
}[action]);
|
|
71
72
|
} catch (error) {
|
|
72
|
-
currentView = {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
state: 'failed',
|
|
77
|
-
code: error?.code || 'update_failed',
|
|
78
|
-
message: error?.message || tx('Update failed.', '更新失败。')
|
|
79
|
-
},
|
|
80
|
-
progress: { value: 0, determinate: true, phase: 'failed' },
|
|
81
|
-
showPanel: true
|
|
82
|
-
};
|
|
73
|
+
currentView = await reconcileAfterActionError(error, {
|
|
74
|
+
action,
|
|
75
|
+
fallbackMessage: tx('Update failed.', '更新失败。')
|
|
76
|
+
});
|
|
83
77
|
} finally {
|
|
84
78
|
actionInFlight = false;
|
|
85
79
|
render();
|
|
@@ -97,6 +91,49 @@
|
|
|
97
91
|
return response.result;
|
|
98
92
|
}
|
|
99
93
|
|
|
94
|
+
async function reconcileAfterActionError(error, options = {}) {
|
|
95
|
+
if (options.action === 'install' && isRuntimeRestartError(error)) {
|
|
96
|
+
return buildRestartingView();
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const authoritativeView = await request('codex-overleaf/consent-update-get-state');
|
|
100
|
+
if (authoritativeView?.state) return authoritativeView;
|
|
101
|
+
} catch (_stateError) {
|
|
102
|
+
// The local fallback below is used only when the global coordinator is unavailable too.
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
...(currentView || {}),
|
|
106
|
+
state: {
|
|
107
|
+
...(currentView?.state || {}),
|
|
108
|
+
state: 'failed',
|
|
109
|
+
code: error?.code || 'update_failed',
|
|
110
|
+
message: error?.message || options.fallbackMessage || tx('Update failed.', '更新失败。')
|
|
111
|
+
},
|
|
112
|
+
progress: { value: 0, determinate: true, phase: 'failed' },
|
|
113
|
+
showPanel: true
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isRuntimeRestartError(error) {
|
|
118
|
+
return /extension context invalidated|message (?:port|channel) closed|receiving end does not exist|could not establish connection|disconnected port/i.test(
|
|
119
|
+
String(error?.message || error || '')
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function buildRestartingView() {
|
|
124
|
+
return {
|
|
125
|
+
...(currentView || {}),
|
|
126
|
+
state: {
|
|
127
|
+
...(currentView?.state || {}),
|
|
128
|
+
state: 'awaiting_health',
|
|
129
|
+
code: '',
|
|
130
|
+
message: ''
|
|
131
|
+
},
|
|
132
|
+
progress: { value: 90, determinate: false, phase: 'awaiting_health' },
|
|
133
|
+
showPanel: true
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
100
137
|
function bindSettingsControls(panel) {
|
|
101
138
|
settingsRoot = panel;
|
|
102
139
|
const button = panel.querySelector?.('[data-check-updates]');
|
|
@@ -112,28 +149,23 @@
|
|
|
112
149
|
settingsActionInFlight = true;
|
|
113
150
|
renderSettings();
|
|
114
151
|
const stateName = currentView?.state?.state || 'idle';
|
|
152
|
+
let requestedAction = 'check';
|
|
115
153
|
try {
|
|
116
154
|
if (stateName === 'update_available') {
|
|
155
|
+
requestedAction = 'install';
|
|
117
156
|
currentView = await request('codex-overleaf/consent-update-install');
|
|
118
157
|
} else if (['failed', 'rolled_back'].includes(stateName)) {
|
|
119
158
|
currentView = await request('codex-overleaf/consent-update-check');
|
|
120
|
-
} else if (!
|
|
159
|
+
} else if (!ACTIVE_UPDATE_STATES.has(stateName)) {
|
|
121
160
|
currentView = await request('codex-overleaf/consent-update-check');
|
|
122
161
|
} else {
|
|
123
162
|
return;
|
|
124
163
|
}
|
|
125
164
|
} catch (error) {
|
|
126
|
-
currentView = {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
state: 'failed',
|
|
131
|
-
code: error?.code || 'update_failed',
|
|
132
|
-
message: error?.message || tx('Update check failed.', '更新检查失败。')
|
|
133
|
-
},
|
|
134
|
-
progress: { value: 0, determinate: true, phase: 'failed' },
|
|
135
|
-
showPanel: true
|
|
136
|
-
};
|
|
165
|
+
currentView = await reconcileAfterActionError(error, {
|
|
166
|
+
action: requestedAction,
|
|
167
|
+
fallbackMessage: tx('Update check failed.', '更新检查失败。')
|
|
168
|
+
});
|
|
137
169
|
} finally {
|
|
138
170
|
settingsActionInFlight = false;
|
|
139
171
|
render();
|
|
@@ -214,7 +246,6 @@
|
|
|
214
246
|
: '';
|
|
215
247
|
const currentVersion = state.currentVersion || manifestVersion || '';
|
|
216
248
|
const latestVersion = state.latestVersion || '';
|
|
217
|
-
const activeStates = ['downloading', 'staged', 'waiting_for_idle', 'applying', 'awaiting_health'];
|
|
218
249
|
let summaryText = tx(
|
|
219
250
|
`Current v${currentVersion}. Signed stable releases are checked automatically.`,
|
|
220
251
|
`当前版本 v${currentVersion}。系统会自动检查签名稳定版本。`
|
|
@@ -229,7 +260,7 @@
|
|
|
229
260
|
summaryText = tx(`Stable v${latestVersion} is available.`, `稳定版本 v${latestVersion} 已可用。`);
|
|
230
261
|
statusText = tx('Ready to download and verify.', '已可下载并验证。');
|
|
231
262
|
buttonText = tx('Update now', '立即更新');
|
|
232
|
-
} else if (
|
|
263
|
+
} else if (ACTIVE_UPDATE_STATES.has(stateName)) {
|
|
233
264
|
statusText = getCopy(state).detail;
|
|
234
265
|
buttonText = tx('Update in progress', '更新进行中');
|
|
235
266
|
} else if (stateName === 'failed' || stateName === 'rolled_back') {
|
|
@@ -244,7 +275,7 @@
|
|
|
244
275
|
status.textContent = statusText;
|
|
245
276
|
status.hidden = !statusText;
|
|
246
277
|
button.textContent = buttonText;
|
|
247
|
-
button.disabled = settingsActionInFlight || stateName === 'checking' ||
|
|
278
|
+
button.disabled = settingsActionInFlight || stateName === 'checking' || ACTIVE_UPDATE_STATES.has(stateName);
|
|
248
279
|
}
|
|
249
280
|
|
|
250
281
|
function visibleActions(state) {
|
|
@@ -1308,8 +1308,11 @@
|
|
|
1308
1308
|
async function waitForSaveState(params = {}) {
|
|
1309
1309
|
const deadlineMs = Number.isFinite(Number(params.deadlineMs)) ? Number(params.deadlineMs) : 5000;
|
|
1310
1310
|
const pollInterval = Number.isFinite(Number(params.pollIntervalMs)) ? Number(params.pollIntervalMs) : 100;
|
|
1311
|
+
const quietFallbackMs = Number.isFinite(Number(params.quietFallbackMs)) ? Number(params.quietFallbackMs) : 1000;
|
|
1311
1312
|
const deadline = Date.now() + Math.max(0, deadlineMs);
|
|
1312
1313
|
let lastState = { state: 'unknown', reason: 'Overleaf save state has not been checked yet.' };
|
|
1314
|
+
let quietSignature = '';
|
|
1315
|
+
let quietSince = 0;
|
|
1313
1316
|
|
|
1314
1317
|
do {
|
|
1315
1318
|
let current;
|
|
@@ -1332,6 +1335,25 @@
|
|
|
1332
1335
|
reason: current.reason || 'Overleaf save state is unavailable.'
|
|
1333
1336
|
};
|
|
1334
1337
|
}
|
|
1338
|
+
const quietEligible = params.allowQuietEditorFallback === true
|
|
1339
|
+
&& current.state === 'unknown'
|
|
1340
|
+
&& /save indicator was not found/i.test(current.reason || '')
|
|
1341
|
+
&& window.navigator?.onLine !== false
|
|
1342
|
+
&& detectEditor()?.ok === true;
|
|
1343
|
+
if (quietEligible) {
|
|
1344
|
+
const text = String(readActiveEditorText() || '');
|
|
1345
|
+
const signature = `${getActiveFilePath()}:${text.length}:${text.slice(0, 80)}:${text.slice(-80)}`;
|
|
1346
|
+
if (signature === quietSignature && Date.now() - quietSince >= Math.max(0, quietFallbackMs)) {
|
|
1347
|
+
return { ok: true, state: 'verified_quiet', evidence: 'stable_editor_snapshot_without_save_indicator' };
|
|
1348
|
+
}
|
|
1349
|
+
if (signature !== quietSignature) {
|
|
1350
|
+
quietSignature = signature;
|
|
1351
|
+
quietSince = Date.now();
|
|
1352
|
+
}
|
|
1353
|
+
} else {
|
|
1354
|
+
quietSignature = '';
|
|
1355
|
+
quietSince = 0;
|
|
1356
|
+
}
|
|
1335
1357
|
lastState = current;
|
|
1336
1358
|
if (Date.now() >= deadline) {
|
|
1337
1359
|
break;
|
|
@@ -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.11';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|