codex-overleaf-link 1.9.8 → 1.9.9
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 +46 -4
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/src/backgroundUpdateCoordinator.js +2 -43
- package/extension/src/content/contentRuntime.js +1 -1
- package/extension/src/content/updateIdle.js +5 -1
- package/extension/src/content/updateNotice.js +38 -36
- 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.9-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.9 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.9/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.9/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v1.9.9'
|
|
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.9 -- 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.9 -- install-managed` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@1.9.9 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@1.9.9 -- 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.9 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.9.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v1.9.9.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-1.9.9.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.9` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.9` 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.8 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.9 -- 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.9 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.9/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.9 -- 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.9 -- 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.9 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- install-managed --browser chromium` |
|
|
344
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.9 -- 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.9 -- 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.9 -- 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.9 -- uninstall-native
|
|
397
397
|
```
|
|
@@ -16,6 +16,13 @@ const OVERLEAF_MATCHES = [
|
|
|
16
16
|
...OVERLEAF_EDITOR_MATCHES
|
|
17
17
|
];
|
|
18
18
|
const APPLYING_STATES = new Set(['applying', 'awaiting_health', 'rolling_back']);
|
|
19
|
+
const FAST_IDLE_RETRY_BLOCKERS = new Set(['recent_user_activity', 'save_state_not_stable']);
|
|
20
|
+
const FAST_IDLE_RETRY_MS = 4000;
|
|
21
|
+
const SLOW_IDLE_RETRY_MS = 15000;
|
|
22
|
+
const IDLE_RETRY_ALARM_MINUTES = 0.5;
|
|
23
|
+
|
|
24
|
+
let idleRetryTimer = null;
|
|
25
|
+
let idleApplyPromise = null;
|
|
19
26
|
|
|
20
27
|
let runtimeLoadError = null;
|
|
21
28
|
try {
|
|
@@ -85,7 +92,7 @@ async function initializeBootstrap() {
|
|
|
85
92
|
chrome.alarms.create(CHECK_ALARM, { delayInMinutes: 0.5, periodInMinutes: 24 * 60 });
|
|
86
93
|
const state = await getUpdateState();
|
|
87
94
|
if (state.state === 'staged' || state.state === 'waiting_for_idle') {
|
|
88
|
-
|
|
95
|
+
scheduleIdleRetry(state.blockers);
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
|
|
@@ -188,13 +195,22 @@ async function checkAndStage(options = {}) {
|
|
|
188
195
|
blockers: []
|
|
189
196
|
});
|
|
190
197
|
await broadcastUpdateState('staged');
|
|
191
|
-
chrome.alarms.create(IDLE_ALARM, { delayInMinutes: 0.1 });
|
|
192
198
|
return tryApplyStagedUpdate();
|
|
193
199
|
}
|
|
194
200
|
|
|
195
|
-
|
|
201
|
+
function tryApplyStagedUpdate() {
|
|
202
|
+
if (idleApplyPromise) return idleApplyPromise;
|
|
203
|
+
idleApplyPromise = tryApplyStagedUpdateCore().finally(() => {
|
|
204
|
+
idleApplyPromise = null;
|
|
205
|
+
});
|
|
206
|
+
return idleApplyPromise;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function tryApplyStagedUpdateCore() {
|
|
210
|
+
cancelIdleRetryTimer();
|
|
196
211
|
const state = await getUpdateState();
|
|
197
212
|
if (!['staged', 'waiting_for_idle'].includes(state.state)) {
|
|
213
|
+
await clearIdleRetry();
|
|
198
214
|
return state;
|
|
199
215
|
}
|
|
200
216
|
if (Number(state.postponeUntil || 0) > Date.now()) {
|
|
@@ -215,10 +231,12 @@ async function tryApplyStagedUpdate() {
|
|
|
215
231
|
blocker: blockers[0],
|
|
216
232
|
blockers
|
|
217
233
|
});
|
|
218
|
-
|
|
234
|
+
await broadcastUpdateState('waiting_for_idle');
|
|
235
|
+
scheduleIdleRetry(blockers);
|
|
219
236
|
return waiting;
|
|
220
237
|
}
|
|
221
238
|
|
|
239
|
+
await clearIdleRetry();
|
|
222
240
|
await chrome.storage.local.set({ [UPDATE_RELOAD_TABS_KEY]: tabs.map(tab => tab.id).filter(Number.isInteger) });
|
|
223
241
|
await setUpdateState({ ...state, state: 'applying', blocker: '', blockers: [] });
|
|
224
242
|
await broadcastUpdateState('applying');
|
|
@@ -234,6 +252,30 @@ async function tryApplyStagedUpdate() {
|
|
|
234
252
|
return { state: 'awaiting_health' };
|
|
235
253
|
}
|
|
236
254
|
|
|
255
|
+
function scheduleIdleRetry(blockers = []) {
|
|
256
|
+
cancelIdleRetryTimer();
|
|
257
|
+
const values = Array.isArray(blockers) ? blockers.filter(Boolean) : [];
|
|
258
|
+
const onlyFastBlockers = values.length > 0 && values.every(value => FAST_IDLE_RETRY_BLOCKERS.has(value));
|
|
259
|
+
const delayMs = onlyFastBlockers ? FAST_IDLE_RETRY_MS : SLOW_IDLE_RETRY_MS;
|
|
260
|
+
idleRetryTimer = setTimeout(() => {
|
|
261
|
+
idleRetryTimer = null;
|
|
262
|
+
tryApplyStagedUpdate().catch(() => {});
|
|
263
|
+
}, delayMs);
|
|
264
|
+
chrome.alarms.create(IDLE_ALARM, { delayInMinutes: IDLE_RETRY_ALARM_MINUTES });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function cancelIdleRetryTimer() {
|
|
268
|
+
if (idleRetryTimer !== null) {
|
|
269
|
+
clearTimeout(idleRetryTimer);
|
|
270
|
+
idleRetryTimer = null;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function clearIdleRetry() {
|
|
275
|
+
cancelIdleRetryTimer();
|
|
276
|
+
await chrome.alarms.clear(IDLE_ALARM).catch(() => {});
|
|
277
|
+
}
|
|
278
|
+
|
|
237
279
|
async function probeTabIdle(tab) {
|
|
238
280
|
if (!Number.isInteger(tab?.id)) {
|
|
239
281
|
return { idle: false, blockers: ['tab_unavailable'] };
|
|
@@ -20,14 +20,12 @@
|
|
|
20
20
|
'codex-overleaf/consent-update-check',
|
|
21
21
|
'codex-overleaf/consent-update-install',
|
|
22
22
|
'codex-overleaf/consent-update-later',
|
|
23
|
-
'codex-overleaf/consent-update-dismiss'
|
|
24
|
-
'codex-overleaf/consent-update-open-center'
|
|
23
|
+
'codex-overleaf/consent-update-dismiss'
|
|
25
24
|
]);
|
|
26
25
|
|
|
27
26
|
const policy = root.CodexOverleafUpdateConsent;
|
|
28
27
|
let nativeBridge = null;
|
|
29
28
|
let initialized = false;
|
|
30
|
-
let updateCenterWindowId = null;
|
|
31
29
|
let policyTail = Promise.resolve();
|
|
32
30
|
|
|
33
31
|
function init(options = {}) {
|
|
@@ -84,8 +82,6 @@
|
|
|
84
82
|
return postponeUpdate();
|
|
85
83
|
case 'codex-overleaf/consent-update-dismiss':
|
|
86
84
|
return dismissCompletedUpdate();
|
|
87
|
-
case 'codex-overleaf/consent-update-open-center':
|
|
88
|
-
return openUpdateCenter(message.action);
|
|
89
85
|
default:
|
|
90
86
|
throw codedError('unknown_update_action', 'Unknown update action.');
|
|
91
87
|
}
|
|
@@ -423,8 +419,7 @@
|
|
|
423
419
|
const url = new URL(sender?.url || sender?.tab?.url || '');
|
|
424
420
|
const extensionRoot = new URL(chrome.runtime.getURL(''));
|
|
425
421
|
if (url.origin === extensionRoot.origin) {
|
|
426
|
-
return url.pathname === '/bootstrap/popup.html'
|
|
427
|
-
url.pathname === '/bootstrap/update.html';
|
|
422
|
+
return url.pathname === '/bootstrap/popup.html';
|
|
428
423
|
}
|
|
429
424
|
return url.protocol === 'https:' &&
|
|
430
425
|
(url.hostname === 'www.overleaf.com' || url.hostname === 'overleaf.com') &&
|
|
@@ -434,42 +429,6 @@
|
|
|
434
429
|
}
|
|
435
430
|
}
|
|
436
431
|
|
|
437
|
-
async function openUpdateCenter(requestedAction = '') {
|
|
438
|
-
const action = String(requestedAction || '');
|
|
439
|
-
if (action && action !== 'install' && action !== 'retry') {
|
|
440
|
-
throw codedError('invalid_update_center_action', 'Unsupported Update Center action.');
|
|
441
|
-
}
|
|
442
|
-
const url = new URL(chrome.runtime.getURL('bootstrap/update.html'));
|
|
443
|
-
if (action) url.searchParams.set('action', action);
|
|
444
|
-
|
|
445
|
-
if (Number.isInteger(updateCenterWindowId)) {
|
|
446
|
-
try {
|
|
447
|
-
const existing = await chrome.windows.get(updateCenterWindowId, { populate: true });
|
|
448
|
-
await chrome.windows.update(updateCenterWindowId, { focused: true });
|
|
449
|
-
const tabId = existing?.tabs?.[0]?.id;
|
|
450
|
-
if (action && Number.isInteger(tabId)) {
|
|
451
|
-
await chrome.tabs.update(tabId, { url: url.href });
|
|
452
|
-
}
|
|
453
|
-
return { opened: true, focused: true, windowId: updateCenterWindowId };
|
|
454
|
-
} catch (_error) {
|
|
455
|
-
updateCenterWindowId = null;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const created = await chrome.windows.create({
|
|
460
|
-
url: url.href,
|
|
461
|
-
type: 'popup',
|
|
462
|
-
width: 420,
|
|
463
|
-
height: 560,
|
|
464
|
-
focused: true
|
|
465
|
-
});
|
|
466
|
-
if (!Number.isInteger(created?.id)) {
|
|
467
|
-
throw codedError('update_center_open_failed', 'Could not open Update Center.');
|
|
468
|
-
}
|
|
469
|
-
updateCenterWindowId = created.id;
|
|
470
|
-
return { opened: true, focused: true, windowId: created.id };
|
|
471
|
-
}
|
|
472
|
-
|
|
473
432
|
function currentVersion() {
|
|
474
433
|
return String(
|
|
475
434
|
root.CodexOverleafCompatibility?.BUILD_TARGET_VERSION ||
|
|
@@ -715,7 +715,7 @@
|
|
|
715
715
|
reviewAction: trackedChangeInFlight.size > 0,
|
|
716
716
|
dialog: Boolean(activePluginConfirmResolve)
|
|
717
717
|
}),
|
|
718
|
-
checkSaved: () => callPageBridge('waitForSaveState', { deadlineMs:
|
|
718
|
+
checkSaved: () => callPageBridge('waitForSaveState', { deadlineMs: 1500, pollIntervalMs: 100, requirePositiveSignal: true }),
|
|
719
719
|
onApplyingChange: applying => { if (panel) panel.dataset.updating = applying ? 'true' : 'false'; },
|
|
720
720
|
showToast: (...args) => showPluginToast(...args),
|
|
721
721
|
getStateMessage: state => ({
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
let stableSavedSince = 0;
|
|
7
7
|
let applying = false;
|
|
8
8
|
const documentRef = options.document || root.document;
|
|
9
|
-
const noteActivity =
|
|
9
|
+
const noteActivity = event => {
|
|
10
|
+
if (event?.target?.closest?.('#codex-overleaf-panel')) return;
|
|
11
|
+
lastUserActivityAt = Date.now();
|
|
12
|
+
stableSavedSince = 0;
|
|
13
|
+
};
|
|
10
14
|
for (const eventName of ['input', 'keydown', 'pointerdown']) {
|
|
11
15
|
documentRef?.addEventListener?.(eventName, noteActivity, true);
|
|
12
16
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
let currentView = null;
|
|
6
6
|
let mountedPanel = null;
|
|
7
7
|
let actionInFlight = false;
|
|
8
|
-
let completionTimer = null;
|
|
9
8
|
let listenerInstalled = false;
|
|
10
9
|
let getLocale = () => '';
|
|
11
10
|
let settingsRoot = null;
|
|
@@ -63,13 +62,12 @@
|
|
|
63
62
|
actionInFlight = true;
|
|
64
63
|
render();
|
|
65
64
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
65
|
+
currentView = await request({
|
|
66
|
+
install: 'codex-overleaf/consent-update-install',
|
|
67
|
+
retry: 'codex-overleaf/consent-update-check',
|
|
68
|
+
later: 'codex-overleaf/consent-update-later',
|
|
69
|
+
dismiss: 'codex-overleaf/consent-update-dismiss'
|
|
70
|
+
}[action]);
|
|
73
71
|
} catch (error) {
|
|
74
72
|
currentView = {
|
|
75
73
|
...(currentView || {}),
|
|
@@ -99,19 +97,6 @@
|
|
|
99
97
|
return response.result;
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
async function openUpdateCenter(action = '') {
|
|
103
|
-
const response = await chrome.runtime.sendMessage({
|
|
104
|
-
type: 'codex-overleaf/consent-update-open-center',
|
|
105
|
-
action
|
|
106
|
-
});
|
|
107
|
-
if (!response?.ok) {
|
|
108
|
-
const error = new Error(response?.error?.message || tx('Could not open Update Center.', '无法打开更新中心。'));
|
|
109
|
-
error.code = response?.error?.code || 'update_center_open_failed';
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
return response.result;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
100
|
function bindSettingsControls(panel) {
|
|
116
101
|
settingsRoot = panel;
|
|
117
102
|
const button = panel.querySelector?.('[data-check-updates]');
|
|
@@ -129,13 +114,13 @@
|
|
|
129
114
|
const stateName = currentView?.state?.state || 'idle';
|
|
130
115
|
try {
|
|
131
116
|
if (stateName === 'update_available') {
|
|
132
|
-
await
|
|
117
|
+
currentView = await request('codex-overleaf/consent-update-install');
|
|
133
118
|
} else if (['failed', 'rolled_back'].includes(stateName)) {
|
|
134
|
-
await openUpdateCenter('retry');
|
|
135
|
-
} else if (['downloading', 'staged', 'waiting_for_idle', 'applying', 'awaiting_health'].includes(stateName)) {
|
|
136
|
-
await openUpdateCenter('');
|
|
137
|
-
} else {
|
|
138
119
|
currentView = await request('codex-overleaf/consent-update-check');
|
|
120
|
+
} else if (!['downloading', 'staged', 'waiting_for_idle', 'applying', 'awaiting_health'].includes(stateName)) {
|
|
121
|
+
currentView = await request('codex-overleaf/consent-update-check');
|
|
122
|
+
} else {
|
|
123
|
+
return;
|
|
139
124
|
}
|
|
140
125
|
} catch (error) {
|
|
141
126
|
currentView = {
|
|
@@ -159,7 +144,6 @@
|
|
|
159
144
|
if (!currentView) return;
|
|
160
145
|
renderSettings();
|
|
161
146
|
if (!notice) return;
|
|
162
|
-
clearTimeout(completionTimer);
|
|
163
147
|
if (!currentView.showPanel) {
|
|
164
148
|
notice.hidden = true;
|
|
165
149
|
notice.replaceChildren();
|
|
@@ -214,11 +198,6 @@
|
|
|
214
198
|
if (focusedAction) {
|
|
215
199
|
notice.querySelector('[data-update-notice-action="' + focusedAction + '"]:not(:disabled)')?.focus();
|
|
216
200
|
}
|
|
217
|
-
if (state.state === 'committed') {
|
|
218
|
-
completionTimer = setTimeout(() => {
|
|
219
|
-
if (notice?.dataset.state === 'committed') notice.hidden = true;
|
|
220
|
-
}, 5000);
|
|
221
|
-
}
|
|
222
201
|
}
|
|
223
202
|
|
|
224
203
|
function renderSettings() {
|
|
@@ -252,7 +231,7 @@
|
|
|
252
231
|
buttonText = tx('Update now', '立即更新');
|
|
253
232
|
} else if (activeStates.includes(stateName)) {
|
|
254
233
|
statusText = getCopy(state).detail;
|
|
255
|
-
buttonText = tx('
|
|
234
|
+
buttonText = tx('Update in progress', '更新进行中');
|
|
256
235
|
} else if (stateName === 'failed' || stateName === 'rolled_back') {
|
|
257
236
|
statusText = state.message || getCopy(state).detail;
|
|
258
237
|
buttonText = tx('Retry', '重试');
|
|
@@ -265,7 +244,7 @@
|
|
|
265
244
|
status.textContent = statusText;
|
|
266
245
|
status.hidden = !statusText;
|
|
267
246
|
button.textContent = buttonText;
|
|
268
|
-
button.disabled = settingsActionInFlight || stateName === 'checking';
|
|
247
|
+
button.disabled = settingsActionInFlight || stateName === 'checking' || activeStates.includes(stateName);
|
|
269
248
|
}
|
|
270
249
|
|
|
271
250
|
function visibleActions(state) {
|
|
@@ -282,12 +261,15 @@
|
|
|
282
261
|
if (['failed', 'rolled_back'].includes(state)) {
|
|
283
262
|
return [{ id: 'retry', label: tx('Retry', '重试'), primary: true }];
|
|
284
263
|
}
|
|
264
|
+
if (state === 'committed') {
|
|
265
|
+
return [{ id: 'dismiss', label: tx('Done', '完成'), primary: true }];
|
|
266
|
+
}
|
|
285
267
|
return [];
|
|
286
268
|
}
|
|
287
269
|
|
|
288
270
|
function getCopy(state) {
|
|
289
271
|
const target = state.latestVersion ? 'v' + state.latestVersion : '';
|
|
290
|
-
const blocker =
|
|
272
|
+
const blocker = blockersCopy(state.blockers?.length ? state.blockers : [state.blocker]);
|
|
291
273
|
return {
|
|
292
274
|
update_available: {
|
|
293
275
|
eyebrow: tx('Update available', '发现新版本'),
|
|
@@ -341,15 +323,35 @@
|
|
|
341
323
|
return {
|
|
342
324
|
unsaved: tx('Overleaf has not confirmed that this document is saved.', 'Overleaf 尚未确认当前文档已保存。'),
|
|
343
325
|
active_run: tx('A Codex task is still running.', 'Codex 任务仍在运行。'),
|
|
326
|
+
run: tx('A Codex task is still running in an Overleaf tab.', '某个 Overleaf 标签页中的 Codex 任务仍在运行。'),
|
|
344
327
|
cancelling: tx('Cancellation is still settling.', '取消操作仍在收尾。'),
|
|
345
328
|
storage_write: tx('Extension state is still being saved.', '扩展状态仍在保存。'),
|
|
329
|
+
storage: tx('Extension state is still being saved.', '扩展状态仍在保存。'),
|
|
346
330
|
review_action: tx('Accept or Undo is still running.', '接受或撤销操作仍在进行。'),
|
|
331
|
+
reviewAction: tx('Accept or Undo is still running.', '接受或撤销操作仍在进行。'),
|
|
347
332
|
dialog_open: tx('A confirmation dialog is open.', '确认对话框仍处于打开状态。'),
|
|
333
|
+
dialog: tx('A confirmation dialog is open.', '确认对话框仍处于打开状态。'),
|
|
334
|
+
recent_user_activity: tx('Waiting briefly after the latest editor activity.', '正在等待最近一次编辑操作稳定下来。'),
|
|
335
|
+
save_state_not_stable: tx('The saved state is being confirmed.', '正在确认稳定的已保存状态。'),
|
|
336
|
+
save_state_unverified: tx('An Overleaf tab has not verified its saved state yet.', '某个 Overleaf 标签页尚未验证已保存状态。'),
|
|
337
|
+
tab_probe_timeout: tx('An Overleaf tab did not answer the safety check. Reload that tab if this persists.', '某个 Overleaf 标签页未响应安全检查;若持续出现,请刷新该标签页。'),
|
|
338
|
+
tab_probe_unavailable: tx('An Overleaf tab needs to be reloaded before it can join the safety check.', '某个 Overleaf 标签页需要刷新后才能参与安全检查。'),
|
|
339
|
+
tab_unavailable: tx('An Overleaf tab is unavailable for the safety check.', '某个 Overleaf 标签页当前无法完成安全检查。'),
|
|
340
|
+
idle_probe_failed: tx('The Overleaf safety check failed. Reload the affected tab and retry.', 'Overleaf 安全检查失败;请刷新受影响的标签页后重试。'),
|
|
348
341
|
native_project_locked: tx('Native Host still holds a project lock.', 'Native Host 仍持有项目锁。'),
|
|
349
|
-
native_run_active: tx('Native Host is still processing a task.', 'Native Host 仍在处理任务。')
|
|
342
|
+
native_run_active: tx('Native Host is still processing a task.', 'Native Host 仍在处理任务。'),
|
|
343
|
+
busy: tx('A component is still busy.', '某个组件仍处于忙碌状态。')
|
|
350
344
|
}[value] || tx('Waiting until every Overleaf tab is saved and idle.', '正在等待所有 Overleaf 标签页完成保存并进入空闲状态。');
|
|
351
345
|
}
|
|
352
346
|
|
|
347
|
+
function blockersCopy(values = []) {
|
|
348
|
+
const messages = [...new Set(values.filter(Boolean).map(blockerCopy))];
|
|
349
|
+
return messages.join(' ') || tx(
|
|
350
|
+
'Waiting until every Overleaf tab is saved and idle.',
|
|
351
|
+
'正在等待所有 Overleaf 标签页完成保存并进入空闲状态。'
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
353
355
|
function tx(english, chinese) {
|
|
354
356
|
const locale = String(getLocale() || document.documentElement?.lang || 'en');
|
|
355
357
|
return /^zh\b/i.test(locale) ? chinese : english;
|
|
@@ -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.9';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|