codex-overleaf-link 1.9.7 → 1.9.8
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 +7 -2
- package/extension/bootstrap/manifest.template.json +3 -1
- package/extension/bootstrap/popup.html +0 -13
- package/extension/bootstrap/update.js +1 -4
- package/extension/runtime-manifest.json +2 -0
- package/extension/src/backgroundUpdateCoordinator.js +51 -5
- package/extension/src/content/settingsPanel.js +12 -0
- package/extension/src/content/updateNotice.js +117 -6
- package/extension/src/popup.js +3 -33
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/i18n.js +6 -0
- 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.8-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.8 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.8/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.8/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v1.9.8'
|
|
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.8 -- 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.8 -- install-managed` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@1.9.8 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@1.9.8 -- 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.8 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.8.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v1.9.8.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-1.9.8.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.8` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.8` 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.7 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.8 -- 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.8 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.8/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.8 -- 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.8 -- 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.8 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.8 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.8 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.8 -- install-managed --browser chromium` |
|
|
344
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@1.9.8 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.8 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.8 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.8 -- 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.8 -- 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.8 -- 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.8 -- uninstall-native
|
|
397
397
|
```
|
|
@@ -6,10 +6,15 @@ const UPDATE_STATE_KEY = 'codex-overleaf-managed-update-state-v1';
|
|
|
6
6
|
const UPDATE_RELOAD_TABS_KEY = 'codex-overleaf-managed-update-tabs-v1';
|
|
7
7
|
const CHECK_ALARM = 'codex-overleaf-stable-update-check';
|
|
8
8
|
const IDLE_ALARM = 'codex-overleaf-staged-update-idle';
|
|
9
|
-
const
|
|
9
|
+
const OVERLEAF_EDITOR_MATCHES = [
|
|
10
10
|
'https://www.overleaf.com/project/*',
|
|
11
11
|
'https://overleaf.com/project/*'
|
|
12
12
|
];
|
|
13
|
+
const OVERLEAF_MATCHES = [
|
|
14
|
+
'https://www.overleaf.com/project',
|
|
15
|
+
'https://overleaf.com/project',
|
|
16
|
+
...OVERLEAF_EDITOR_MATCHES
|
|
17
|
+
];
|
|
13
18
|
const APPLYING_STATES = new Set(['applying', 'awaiting_health', 'rolling_back']);
|
|
14
19
|
|
|
15
20
|
let runtimeLoadError = null;
|
|
@@ -195,7 +200,7 @@ async function tryApplyStagedUpdate() {
|
|
|
195
200
|
if (Number(state.postponeUntil || 0) > Date.now()) {
|
|
196
201
|
return state;
|
|
197
202
|
}
|
|
198
|
-
const tabs = await chrome.tabs.query({ url:
|
|
203
|
+
const tabs = await chrome.tabs.query({ url: OVERLEAF_EDITOR_MATCHES });
|
|
199
204
|
const probes = await Promise.all(tabs.map(tab => probeTabIdle(tab)));
|
|
200
205
|
const nativeGate = await requestInternal({ method: 'update.canApply', params: {} }).catch(error => ({
|
|
201
206
|
ok: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Codex Overleaf Link",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.8",
|
|
5
5
|
"description": "Connect the active Overleaf project to a local Codex bridge.",
|
|
6
6
|
"icons": {
|
|
7
7
|
"16": "assets/icons/icon16.png",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"storage"
|
|
18
18
|
],
|
|
19
19
|
"host_permissions": [
|
|
20
|
+
"https://www.overleaf.com/project",
|
|
21
|
+
"https://overleaf.com/project",
|
|
20
22
|
"https://www.overleaf.com/project/*",
|
|
21
23
|
"https://overleaf.com/project/*"
|
|
22
24
|
],
|
|
@@ -13,18 +13,6 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
<button id="open-panel" data-popup-context>Open panel in Overleaf</button>
|
|
15
15
|
<p id="status" data-popup-context>Use this on an Overleaf project tab.</p>
|
|
16
|
-
<section class="updates" aria-labelledby="updates-title">
|
|
17
|
-
<div class="section-head">
|
|
18
|
-
<strong id="updates-title">Stable updates</strong>
|
|
19
|
-
<span id="update-state" class="update-state">Checking</span>
|
|
20
|
-
</div>
|
|
21
|
-
<p id="update-versions">Current unknown · Latest unknown</p>
|
|
22
|
-
<p id="update-detail" class="muted">Automatic updates apply when Overleaf is saved and idle.</p>
|
|
23
|
-
<div class="update-actions">
|
|
24
|
-
<button id="check-update" class="secondary" type="button">Check now</button>
|
|
25
|
-
<button id="postpone-update" class="quiet" type="button" hidden>Later</button>
|
|
26
|
-
</div>
|
|
27
|
-
</section>
|
|
28
16
|
<div id="native-install" class="install" data-popup-context hidden>
|
|
29
17
|
<strong>Native host attention required</strong>
|
|
30
18
|
<p>Run this command in Terminal, then reload this extension in Chrome.</p>
|
|
@@ -34,6 +22,5 @@
|
|
|
34
22
|
<script src="../runtime/src/shared/compatibility.js"></script>
|
|
35
23
|
<script src="../runtime/src/popup.js"></script>
|
|
36
24
|
<script src="updateStatus.js"></script>
|
|
37
|
-
<script src="popup.js"></script>
|
|
38
25
|
</body>
|
|
39
26
|
</html>
|
|
@@ -176,10 +176,7 @@
|
|
|
176
176
|
if (ACTIVE_PHASES.has(phase)) {
|
|
177
177
|
return [{ id: 'close', label: 'Close window', kind: 'quiet' }];
|
|
178
178
|
}
|
|
179
|
-
return [
|
|
180
|
-
{ id: 'close', label: 'Close', kind: 'quiet' },
|
|
181
|
-
{ id: 'check', label: 'Check latest', kind: 'primary' }
|
|
182
|
-
];
|
|
179
|
+
return [{ id: 'close', label: 'Close', kind: 'quiet' }];
|
|
183
180
|
}
|
|
184
181
|
|
|
185
182
|
function renderActions(phase) {
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
const CHECK_REQUEST_TIMEOUT_MS = 15 * 1000;
|
|
11
11
|
const LEGACY_GUARD = Number.MAX_SAFE_INTEGER;
|
|
12
12
|
const OVERLEAF_MATCHES = [
|
|
13
|
+
'https://www.overleaf.com/project',
|
|
14
|
+
'https://overleaf.com/project',
|
|
13
15
|
'https://www.overleaf.com/project/*',
|
|
14
16
|
'https://overleaf.com/project/*'
|
|
15
17
|
];
|
|
@@ -18,12 +20,14 @@
|
|
|
18
20
|
'codex-overleaf/consent-update-check',
|
|
19
21
|
'codex-overleaf/consent-update-install',
|
|
20
22
|
'codex-overleaf/consent-update-later',
|
|
21
|
-
'codex-overleaf/consent-update-dismiss'
|
|
23
|
+
'codex-overleaf/consent-update-dismiss',
|
|
24
|
+
'codex-overleaf/consent-update-open-center'
|
|
22
25
|
]);
|
|
23
26
|
|
|
24
27
|
const policy = root.CodexOverleafUpdateConsent;
|
|
25
28
|
let nativeBridge = null;
|
|
26
29
|
let initialized = false;
|
|
30
|
+
let updateCenterWindowId = null;
|
|
27
31
|
let policyTail = Promise.resolve();
|
|
28
32
|
|
|
29
33
|
function init(options = {}) {
|
|
@@ -80,6 +84,8 @@
|
|
|
80
84
|
return postponeUpdate();
|
|
81
85
|
case 'codex-overleaf/consent-update-dismiss':
|
|
82
86
|
return dismissCompletedUpdate();
|
|
87
|
+
case 'codex-overleaf/consent-update-open-center':
|
|
88
|
+
return openUpdateCenter(message.action);
|
|
83
89
|
default:
|
|
84
90
|
throw codedError('unknown_update_action', 'Unknown update action.');
|
|
85
91
|
}
|
|
@@ -412,18 +418,58 @@
|
|
|
412
418
|
}
|
|
413
419
|
|
|
414
420
|
function isAllowedSender(sender) {
|
|
415
|
-
if (sender?.id
|
|
416
|
-
if (!sender?.tab) return true;
|
|
421
|
+
if (sender?.id !== chrome.runtime.id) return false;
|
|
417
422
|
try {
|
|
418
|
-
const url = new URL(sender
|
|
423
|
+
const url = new URL(sender?.url || sender?.tab?.url || '');
|
|
424
|
+
const extensionRoot = new URL(chrome.runtime.getURL(''));
|
|
425
|
+
if (url.origin === extensionRoot.origin) {
|
|
426
|
+
return url.pathname === '/bootstrap/popup.html' ||
|
|
427
|
+
url.pathname === '/bootstrap/update.html';
|
|
428
|
+
}
|
|
419
429
|
return url.protocol === 'https:' &&
|
|
420
430
|
(url.hostname === 'www.overleaf.com' || url.hostname === 'overleaf.com') &&
|
|
421
|
-
url.pathname.startsWith('/project/');
|
|
431
|
+
(url.pathname === '/project' || url.pathname.startsWith('/project/'));
|
|
422
432
|
} catch (_error) {
|
|
423
433
|
return false;
|
|
424
434
|
}
|
|
425
435
|
}
|
|
426
436
|
|
|
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
|
+
|
|
427
473
|
function currentVersion() {
|
|
428
474
|
return String(
|
|
429
475
|
root.CodexOverleafCompatibility?.BUILD_TARGET_VERSION ||
|
|
@@ -146,6 +146,18 @@
|
|
|
146
146
|
<p class="codex-set-row-help" data-i18n="languageHelp">Panel display language.</p>
|
|
147
147
|
</div>
|
|
148
148
|
</details>
|
|
149
|
+
<details class="codex-set-group" data-set-group="updates" open>
|
|
150
|
+
<summary class="codex-set-group-head">
|
|
151
|
+
<span class="codex-set-group-title">${codexSetIcon('appearance')}<span data-i18n="softwareUpdatesTitle">Software updates</span></span>
|
|
152
|
+
</summary>
|
|
153
|
+
<div class="codex-set-card" data-update-settings>
|
|
154
|
+
<div class="codex-set-row">
|
|
155
|
+
<p class="codex-set-row-help" data-update-settings-summary data-i18n="softwareUpdatesHelp">Automatically checks signed stable releases for the Extension and Native Host.</p>
|
|
156
|
+
<p class="codex-set-note" data-update-settings-state aria-live="polite" hidden></p>
|
|
157
|
+
<button type="button" class="codex-set-btn" data-check-updates data-i18n="checkForUpdates">Check for updates</button>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</details>
|
|
149
161
|
<details class="codex-set-group" data-set-group="storage" data-storage-card>
|
|
150
162
|
<summary class="codex-set-group-head">
|
|
151
163
|
<span class="codex-set-group-title">${codexSetIcon('database')}<span data-i18n="storageTitle">History & storage</span></span>
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
let completionTimer = null;
|
|
9
9
|
let listenerInstalled = false;
|
|
10
10
|
let getLocale = () => '';
|
|
11
|
+
let settingsRoot = null;
|
|
12
|
+
let settingsActionInFlight = false;
|
|
11
13
|
|
|
12
14
|
function mount(panelLike, options = {}) {
|
|
13
15
|
if (typeof options.getLocale === 'function') {
|
|
@@ -16,10 +18,12 @@
|
|
|
16
18
|
const panel = panelLike?.panelEl || panelLike;
|
|
17
19
|
if (!panel) return;
|
|
18
20
|
if (mountedPanel === panel) {
|
|
21
|
+
bindSettingsControls(panel);
|
|
19
22
|
render();
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
25
|
mountedPanel = panel;
|
|
26
|
+
bindSettingsControls(panel);
|
|
23
27
|
notice?.remove();
|
|
24
28
|
notice = document.createElement('section');
|
|
25
29
|
notice.className = 'codex-update-notice';
|
|
@@ -59,11 +63,13 @@
|
|
|
59
63
|
actionInFlight = true;
|
|
60
64
|
render();
|
|
61
65
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
if (action === 'install' || action === 'retry') {
|
|
67
|
+
await openUpdateCenter(action);
|
|
68
|
+
} else {
|
|
69
|
+
currentView = await request({
|
|
70
|
+
later: 'codex-overleaf/consent-update-later'
|
|
71
|
+
}[action]);
|
|
72
|
+
}
|
|
67
73
|
} catch (error) {
|
|
68
74
|
currentView = {
|
|
69
75
|
...(currentView || {}),
|
|
@@ -93,8 +99,66 @@
|
|
|
93
99
|
return response.result;
|
|
94
100
|
}
|
|
95
101
|
|
|
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
|
+
function bindSettingsControls(panel) {
|
|
116
|
+
settingsRoot = panel;
|
|
117
|
+
const button = panel.querySelector?.('[data-check-updates]');
|
|
118
|
+
if (button && button.dataset.updateSettingsBound !== 'true') {
|
|
119
|
+
button.dataset.updateSettingsBound = 'true';
|
|
120
|
+
button.addEventListener('click', handleSettingsAction);
|
|
121
|
+
}
|
|
122
|
+
renderSettings();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function handleSettingsAction() {
|
|
126
|
+
if (settingsActionInFlight) return;
|
|
127
|
+
settingsActionInFlight = true;
|
|
128
|
+
renderSettings();
|
|
129
|
+
const stateName = currentView?.state?.state || 'idle';
|
|
130
|
+
try {
|
|
131
|
+
if (stateName === 'update_available') {
|
|
132
|
+
await openUpdateCenter('install');
|
|
133
|
+
} 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
|
+
currentView = await request('codex-overleaf/consent-update-check');
|
|
139
|
+
}
|
|
140
|
+
} catch (error) {
|
|
141
|
+
currentView = {
|
|
142
|
+
...(currentView || {}),
|
|
143
|
+
state: {
|
|
144
|
+
...(currentView?.state || {}),
|
|
145
|
+
state: 'failed',
|
|
146
|
+
code: error?.code || 'update_failed',
|
|
147
|
+
message: error?.message || tx('Update check failed.', '更新检查失败。')
|
|
148
|
+
},
|
|
149
|
+
progress: { value: 0, determinate: true, phase: 'failed' },
|
|
150
|
+
showPanel: true
|
|
151
|
+
};
|
|
152
|
+
} finally {
|
|
153
|
+
settingsActionInFlight = false;
|
|
154
|
+
render();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
96
158
|
function render() {
|
|
97
|
-
if (!
|
|
159
|
+
if (!currentView) return;
|
|
160
|
+
renderSettings();
|
|
161
|
+
if (!notice) return;
|
|
98
162
|
clearTimeout(completionTimer);
|
|
99
163
|
if (!currentView.showPanel) {
|
|
100
164
|
notice.hidden = true;
|
|
@@ -157,6 +221,53 @@
|
|
|
157
221
|
}
|
|
158
222
|
}
|
|
159
223
|
|
|
224
|
+
function renderSettings() {
|
|
225
|
+
if (!settingsRoot) return;
|
|
226
|
+
const summary = settingsRoot.querySelector?.('[data-update-settings-summary]');
|
|
227
|
+
const status = settingsRoot.querySelector?.('[data-update-settings-state]');
|
|
228
|
+
const button = settingsRoot.querySelector?.('[data-check-updates]');
|
|
229
|
+
if (!summary || !status || !button) return;
|
|
230
|
+
|
|
231
|
+
const state = currentView?.state || {};
|
|
232
|
+
const stateName = state.state || 'idle';
|
|
233
|
+
const manifestVersion = typeof chrome.runtime.getManifest === 'function'
|
|
234
|
+
? chrome.runtime.getManifest().version
|
|
235
|
+
: '';
|
|
236
|
+
const currentVersion = state.currentVersion || manifestVersion || '';
|
|
237
|
+
const latestVersion = state.latestVersion || '';
|
|
238
|
+
const activeStates = ['downloading', 'staged', 'waiting_for_idle', 'applying', 'awaiting_health'];
|
|
239
|
+
let summaryText = tx(
|
|
240
|
+
`Current v${currentVersion}. Signed stable releases are checked automatically.`,
|
|
241
|
+
`当前版本 v${currentVersion}。系统会自动检查签名稳定版本。`
|
|
242
|
+
);
|
|
243
|
+
let statusText = '';
|
|
244
|
+
let buttonText = tx('Check for updates', '检查更新');
|
|
245
|
+
|
|
246
|
+
if (stateName === 'checking') {
|
|
247
|
+
statusText = tx('Checking the latest stable release…', '正在检查最新稳定版本…');
|
|
248
|
+
buttonText = tx('Checking…', '检查中…');
|
|
249
|
+
} else if (stateName === 'update_available') {
|
|
250
|
+
summaryText = tx(`Stable v${latestVersion} is available.`, `稳定版本 v${latestVersion} 已可用。`);
|
|
251
|
+
statusText = tx('Ready to download and verify.', '已可下载并验证。');
|
|
252
|
+
buttonText = tx('Update now', '立即更新');
|
|
253
|
+
} else if (activeStates.includes(stateName)) {
|
|
254
|
+
statusText = getCopy(state).detail;
|
|
255
|
+
buttonText = tx('View update', '查看更新');
|
|
256
|
+
} else if (stateName === 'failed' || stateName === 'rolled_back') {
|
|
257
|
+
statusText = state.message || getCopy(state).detail;
|
|
258
|
+
buttonText = tx('Retry', '重试');
|
|
259
|
+
} else if (stateName === 'committed') {
|
|
260
|
+
summaryText = tx(`Current v${currentVersion}. Update completed successfully.`, `当前版本 v${currentVersion}。更新已成功完成。`);
|
|
261
|
+
statusText = tx('Both components passed the health check.', '两个组件均已通过健康检查。');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
summary.textContent = summaryText;
|
|
265
|
+
status.textContent = statusText;
|
|
266
|
+
status.hidden = !statusText;
|
|
267
|
+
button.textContent = buttonText;
|
|
268
|
+
button.disabled = settingsActionInFlight || stateName === 'checking';
|
|
269
|
+
}
|
|
270
|
+
|
|
160
271
|
function visibleActions(state) {
|
|
161
272
|
if (actionInFlight) return [];
|
|
162
273
|
if (state === 'update_available') {
|
package/extension/src/popup.js
CHANGED
|
@@ -248,39 +248,9 @@
|
|
|
248
248
|
|
|
249
249
|
function scheduleConsentUpdateUi() {
|
|
250
250
|
const start = () => {
|
|
251
|
-
if (typeof document.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
let actionInFlight = false;
|
|
255
|
-
let currentView = null;
|
|
256
|
-
|
|
257
|
-
section.addEventListener('click', async event => {
|
|
258
|
-
const action = event.target?.closest?.('[data-update-action]')?.dataset?.updateAction;
|
|
259
|
-
if (!action || actionInFlight) return;
|
|
260
|
-
actionInFlight = true;
|
|
261
|
-
renderUpdateSection(section, currentView, { busyAction: action });
|
|
262
|
-
try {
|
|
263
|
-
currentView = await sendConsentAction(action);
|
|
264
|
-
} catch (error) {
|
|
265
|
-
currentView = failedUpdateView(currentView, error);
|
|
266
|
-
} finally {
|
|
267
|
-
actionInFlight = false;
|
|
268
|
-
renderUpdateSection(section, currentView);
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
chrome.runtime.onMessage.addListener(message => {
|
|
273
|
-
if (message?.type !== 'codex-overleaf/consent-update-state') return;
|
|
274
|
-
currentView = message.view;
|
|
275
|
-
if (!actionInFlight) renderUpdateSection(section, currentView);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
sendConsentAction('get')
|
|
279
|
-
.then(view => {
|
|
280
|
-
currentView = view;
|
|
281
|
-
renderUpdateSection(section, view);
|
|
282
|
-
})
|
|
283
|
-
.catch(error => renderUpdateSection(section, failedUpdateView(null, error)));
|
|
251
|
+
if (typeof document.querySelector !== 'function') return;
|
|
252
|
+
document.querySelector('.updates')?.remove();
|
|
253
|
+
document.body?.classList?.remove('consent-update-focus');
|
|
284
254
|
};
|
|
285
255
|
|
|
286
256
|
if (document.readyState === 'loading') {
|
|
@@ -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.8';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|
|
@@ -284,6 +284,9 @@
|
|
|
284
284
|
eventsTruncatedNote: 'Earlier steps of this run were trimmed.',
|
|
285
285
|
newSessionTooltip: 'Start a fresh conversation — the current session\u2019s context will not carry over',
|
|
286
286
|
storageTitle: 'History & storage',
|
|
287
|
+
softwareUpdatesTitle: 'Software updates',
|
|
288
|
+
softwareUpdatesHelp: 'Automatically checks signed stable releases for the Extension and Native Host.',
|
|
289
|
+
checkForUpdates: 'Check for updates',
|
|
287
290
|
storageUsageLoading: 'Calculating usage\u2026',
|
|
288
291
|
storageClearAll: 'Clear all history\u2026',
|
|
289
292
|
storageClearAllHelp: 'Removes every stored session, run and audit record for all projects. Project settings and rules are kept.',
|
|
@@ -756,6 +759,9 @@
|
|
|
756
759
|
eventsTruncatedNote: '本轮更早的步骤已精简。',
|
|
757
760
|
newSessionTooltip: '开启全新对话——当前会话的上下文不会带入',
|
|
758
761
|
storageTitle: '历史与存储',
|
|
762
|
+
softwareUpdatesTitle: '软件更新',
|
|
763
|
+
softwareUpdatesHelp: '自动检查 Extension 与 Native Host 的签名稳定版本。',
|
|
764
|
+
checkForUpdates: '检查更新',
|
|
759
765
|
storageUsageLoading: '正在计算占用…',
|
|
760
766
|
storageClearAll: '清空全部历史…',
|
|
761
767
|
storageClearAllHelp: '删除所有项目已存储的全部会话、运行与审计记录。项目设置与规则会保留。',
|