@fbincon/claude-code-statusline 3.11.0 → 3.12.0
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 +79 -79
- package/candidate.json +247 -196
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js +5 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor-bootstrap.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor-bootstrap.js +41 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor-bootstrap.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor-worker-entry.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor-worker-entry.js +14 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor-worker-entry.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js +9 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/execution-worker-entry.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/execution-worker-entry.js +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/execution-worker-entry.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/execution.d.ts +29 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/execution.js +228 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/execution.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/history.d.ts +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/history.js +150 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/history.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.js +30 -13
- package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition.js +2 -2
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js +11 -6
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/service.d.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js +9 -5
- package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/store.js +6 -6
- package/node_modules/@fbincon/statusline-cli/dist/src/management/store.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js +6 -6
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.js +76 -28
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/bindings.d.ts +17 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/bindings.js +176 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/bindings.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js +11 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/providers.js +26 -8
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/providers.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js +54 -14
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +3 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +36 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +23 -15
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +4 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +4 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/package-manager.ts +164 -291
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/package-validation.ts +10 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-manager.ts +53 -41
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-summary.ts +22 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-validation.ts +11 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +42 -6
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +7 -12722
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/en.ts +2220 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/ja.ts +2220 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/ko.ts +2220 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/zh-CN.ts +2220 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/zh-HK.ts +2220 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/locales/zh-TW.ts +2220 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +21 -14
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/hooks/observe.ts +10 -3
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +4 -4
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +98 -6
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.d.ts +12 -4
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.js +302 -85
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.js +12 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.d.ts +9 -3
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js +74 -26
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-summary.d.ts +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-summary.js +25 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-summary.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.d.ts +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js +13 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.d.ts +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js +15 -3
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +606 -12
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +612 -18
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/management/compatibility.js +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/management/compatibility.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +102 -3
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +102 -3
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +102 -3
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +102 -3
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +102 -3
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +102 -3
- package/node_modules/@fbincon/statusline-platform/dist/src/native.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/native.js +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/native.js.map +1 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/npm.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/npm.js +20 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/npm.js.map +1 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/private-state.d.ts +3 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/private-state.js +53 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/private-state.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/processes.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/processes.js +45 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/processes.js.map +1 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/windows-modes.d.ts +5 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/windows-modes.js +8 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/windows-modes.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/session.d.ts +2 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js +10 -5
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js +4 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,314 +1,187 @@
|
|
|
1
1
|
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
-
import type { PackageStatus, PackageReviewJob, PackageReviewRequest, Operation, ResultFor } from '../generated-contracts.ts';
|
|
2
|
+
import type { PackageStatus, PackageReviewJob, PackageReviewRequest, PackageExecution, PackageCleanupReview, PackageControl, Operation, ResultFor } from '../generated-contracts.ts';
|
|
3
|
+
import type { Editor } from './draft.ts';
|
|
4
|
+
import { closeSourceDraft } from './source-manager.ts';
|
|
3
5
|
import { t, text, renderMessage, type Language, type LocalizedText } from '../i18n/index.ts';
|
|
4
6
|
import { inputKey, inputView, textInput, type TextInput, type TextKey } from './text-input.ts';
|
|
5
7
|
import { wrapText } from '../../ui/text.ts';
|
|
6
8
|
import { BackendError } from '../backend.ts';
|
|
7
|
-
interface Row {
|
|
8
|
-
key: string;
|
|
9
|
-
text: string;
|
|
10
|
-
action?: PackageReviewRequest['action'];
|
|
11
|
-
backup?: string;
|
|
12
|
-
selected?: boolean;
|
|
13
|
-
}
|
|
9
|
+
interface Row { key:string; text:string; action?:PackageReviewRequest['action']; backup?:string; selected?:boolean }
|
|
14
10
|
export interface PackageManager {
|
|
15
|
-
owner:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
selected: string;
|
|
23
|
-
scroll: number;
|
|
24
|
-
rows: Row[];
|
|
25
|
-
capacity: number;
|
|
26
|
-
input: TextInput | null;
|
|
27
|
-
editing: 'prefix' | 'target' | null;
|
|
28
|
-
message: LocalizedText | string | null;
|
|
29
|
-
effect: 'load' | 'start' | 'status' | 'cancel' | 'close' | null;
|
|
30
|
-
action: PackageReviewRequest['action'];
|
|
31
|
-
backup: string | null;
|
|
32
|
-
busy: boolean;
|
|
33
|
-
closed: boolean;
|
|
34
|
-
generation: number;
|
|
11
|
+
owner:string;status:PackageStatus|null;job:PackageReviewJob|null;execution:PackageExecution|null;cleanup:PackageCleanupReview|null;
|
|
12
|
+
prefix:string;target:string;channel:'latest'|'beta'|null;offset:number;selected:string;scroll:number;rows:Row[];capacity:number;
|
|
13
|
+
input:TextInput|null;editing:'prefix'|'target'|'export_path'|null;export_path:string;
|
|
14
|
+
message:LocalizedText|string|null;
|
|
15
|
+
effect:'load'|'start'|'status'|'cancel'|'close'|'execute'|'save-draft'|'discard-draft'|'export-draft'|'reconcile-draft'|'cleanup-review'|'cleanup-apply'|null;
|
|
16
|
+
mode:'status'|'draft'|'execute-confirm'|'cleanup'|'cleanup-confirm';cleanupId:string|null;draftPrepared:boolean;
|
|
17
|
+
action:PackageReviewRequest['action'];backup:string|null;busy:boolean;closed:boolean;generation:number;
|
|
35
18
|
}
|
|
36
|
-
export function packageManager():
|
|
37
|
-
return {
|
|
38
|
-
prefix: '', target: '', channel: null, offset: 0, selected: 'prefix', scroll: 0, rows: [], capacity: 1, input: null, editing: null, message: null,
|
|
39
|
-
effect: 'load', action: 'check', backup: null, busy: false, closed: false, generation: 0 };
|
|
19
|
+
export function packageManager():PackageManager {
|
|
20
|
+
return {owner:'viewer-'+Date.now().toString(36)+'-'+Math.random().toString(36).slice(2),status:null,job:null,execution:null,cleanup:null,prefix:'',target:'',channel:null,offset:0,selected:'prefix',scroll:0,rows:[],capacity:1,input:null,editing:null,export_path:'statusline-before-update.json',message:null,effect:'load',mode:'status',cleanupId:null,draftPrepared:false,action:'check',backup:null,busy:false,closed:false,generation:0};
|
|
40
21
|
}
|
|
41
22
|
export interface PackageBackend {
|
|
42
|
-
request<O extends Operation>(operation:
|
|
23
|
+
request<O extends Operation>(operation:O,payload?:unknown):ResultFor<O>|Promise<ResultFor<O>>;
|
|
24
|
+
control?<O extends Operation>(control:PackageControl,operation:O,payload?:unknown):ResultFor<O>|Promise<ResultFor<O>>;
|
|
43
25
|
}
|
|
44
|
-
|
|
45
|
-
view.
|
|
46
|
-
view.generation++;
|
|
47
|
-
const job = view.job;
|
|
48
|
-
if (job)
|
|
49
|
-
try {
|
|
50
|
-
await backend.request('package_review_cancel', { id: job.id, owner: view.owner });
|
|
51
|
-
}
|
|
52
|
-
catch { /* Worker deadlines still bound a disconnected view. */ }
|
|
26
|
+
function request<O extends Operation>(view:PackageManager,backend:PackageBackend,operation:O,payload:unknown):ResultFor<O>|Promise<ResultFor<O>> {
|
|
27
|
+
return view.execution&&backend.control?backend.control(view.execution.control,operation,payload):backend.request(operation,payload);
|
|
53
28
|
}
|
|
54
|
-
export async function
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if
|
|
72
|
-
|
|
73
|
-
view.message = text('package.ui.cancel_requested');
|
|
74
|
-
view.selected = 'message';
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
view.job = null;
|
|
78
|
-
}
|
|
79
|
-
const status = await backend.request('package_status', { prefix: view.prefix || null, offset: view.offset });
|
|
80
|
-
if (view.closed || generation !== view.generation)
|
|
81
|
-
return;
|
|
82
|
-
if (view.job && status.revision !== view.job.request.expected_revision) {
|
|
83
|
-
view.job = { ...view.job, state: 'failed', review: null, error: 'conflict' };
|
|
84
|
-
view.message = text('package.ui.changed');
|
|
85
|
-
view.selected = 'message';
|
|
86
|
-
}
|
|
87
|
-
view.status = status;
|
|
88
|
-
view.prefix = status.prefix ?? view.prefix;
|
|
89
|
-
}
|
|
90
|
-
else if (effect === 'start') {
|
|
91
|
-
if (!view.status?.prefix)
|
|
92
|
-
throw new BackendError('prefix', text('package.reason_prefix'));
|
|
93
|
-
if (view.job?.state === 'running')
|
|
94
|
-
return;
|
|
95
|
-
const previous = view.job;
|
|
96
|
-
let target = view.action === 'recover-package' ? view.status.pending?.version ?? view.target : view.target || null;
|
|
97
|
-
let integrity: string | null = null;
|
|
98
|
-
if (view.action === 'update' && previous?.state === 'complete' && previous.request.action === 'check' && previous.request.expected_revision === view.status.revision && previous.review &&
|
|
99
|
-
(!target || target === previous.review.target) && (!view.channel || view.channel === previous.review.channel || !!target)) {
|
|
100
|
-
target = previous.review.target;
|
|
101
|
-
integrity = previous.review.integrity;
|
|
102
|
-
}
|
|
103
|
-
const request: PackageReviewRequest = { action: view.action, prefix: view.status.prefix, expected_revision: view.status.revision,
|
|
104
|
-
target: view.action === 'restore-config' ? null : target, channel: !target && ['check', 'update'].includes(view.action) ? view.channel : null,
|
|
105
|
-
backup_id: view.action === 'restore-config' ? view.backup : null, expected_integrity: integrity };
|
|
106
|
-
if (previous) {
|
|
107
|
-
const cancelled = await backend.request('package_review_cancel', { id: previous.id, owner: view.owner });
|
|
108
|
-
if (view.closed || generation !== view.generation)
|
|
109
|
-
return;
|
|
110
|
-
if (cancelled.state !== 'cancelled') {
|
|
111
|
-
view.job = cancelled;
|
|
112
|
-
view.message = text('package.ui.cancel_requested');
|
|
113
|
-
view.selected = 'message';
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
view.job = null;
|
|
117
|
-
}
|
|
118
|
-
const job = await backend.request('package_review_start', { request, owner: view.owner });
|
|
119
|
-
if (view.closed || generation !== view.generation) {
|
|
120
|
-
await backend.request('package_review_cancel', { id: job.id, owner: view.owner });
|
|
121
|
-
return;
|
|
29
|
+
export async function closePackage(view:PackageManager,backend:PackageBackend):Promise<void>{
|
|
30
|
+
view.closed=true;view.generation++;
|
|
31
|
+
if(view.execution)try{await request(view,backend,'package_execute_detach',{id:view.execution.id,owner:view.owner});}catch{/* Detach never cancels an executor. */}
|
|
32
|
+
if(view.job)try{await request(view,backend,'package_review_cancel',{id:view.job.id,owner:view.owner});}catch{/* Review deadlines still bound disconnected views. */}
|
|
33
|
+
}
|
|
34
|
+
function verified(view:PackageManager):boolean {
|
|
35
|
+
const job=view.job,review=job?.review;
|
|
36
|
+
return job?.state==='complete'&&!!review?.compatible&&job.request.action!=='check'&&(review.artifact_verified||job.request.action==='restore-config');
|
|
37
|
+
}
|
|
38
|
+
export async function performPackage(view:PackageManager,backend:PackageBackend,editor?:Editor):Promise<void>{
|
|
39
|
+
const effect=view.effect;if(!effect||view.busy)return;view.effect=null;
|
|
40
|
+
if(effect==='close'){await closePackage(view,backend);return;}
|
|
41
|
+
view.busy=true;const generation=view.generation;
|
|
42
|
+
try{
|
|
43
|
+
if(effect==='load'){
|
|
44
|
+
if(view.job&&view.prefix&&view.job.request.prefix!==view.prefix){
|
|
45
|
+
const cancelled=await request(view,backend,'package_review_cancel',{id:view.job.id,owner:view.owner});
|
|
46
|
+
if(view.closed||generation!==view.generation)return;
|
|
47
|
+
if(cancelled.state!=='cancelled'){view.job=cancelled;view.message=text('package.ui.cancel_requested');view.selected='message';return;}view.job=null;
|
|
122
48
|
}
|
|
123
|
-
|
|
124
|
-
view.
|
|
125
|
-
view.selected
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
view.
|
|
133
|
-
view.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
49
|
+
const status=await request(view,backend,'package_status',{prefix:view.prefix||null,offset:view.offset});
|
|
50
|
+
if(view.closed||generation!==view.generation)return;
|
|
51
|
+
if(view.job&&status.revision!==view.job.request.expected_revision){view.job={...view.job,state:'failed',review:null,error:'conflict'};view.message=text('package.ui.changed');view.selected='message';}
|
|
52
|
+
view.status=status;view.prefix=status.prefix??view.prefix;
|
|
53
|
+
if(status.execution){view.execution=status.execution;if(editor)editor.packageLocked=true;view.selected='execution';}
|
|
54
|
+
}else if(effect==='start'){
|
|
55
|
+
if(!view.status?.prefix)throw new BackendError('prefix',text('package.reason_prefix'));
|
|
56
|
+
if(view.job?.state==='running'||view.execution?.running!==false&&view.execution?.state==='running')return;
|
|
57
|
+
const previous=view.job;
|
|
58
|
+
let target=view.action==='recover-package'?view.status.pending?.version??view.target:view.target||null,integrity:string|null=null;
|
|
59
|
+
if(view.action==='update'&&previous?.state==='complete'&&previous.request.action==='check'&&previous.request.expected_revision===view.status.revision&&previous.review&&(!target||target===previous.review.target)&&(!view.channel||view.channel===previous.review.channel||!!target)){target=previous.review.target;integrity=previous.review.integrity;}
|
|
60
|
+
const reviewRequest:PackageReviewRequest={action:view.action,prefix:view.status.prefix,expected_revision:view.status.revision,target:view.action==='restore-config'?null:target,channel:!target&&['check','update'].includes(view.action)?view.channel:null,backup_id:view.action==='restore-config'?view.backup:null,expected_integrity:integrity};
|
|
61
|
+
if(previous){const cancelled=await request(view,backend,'package_review_cancel',{id:previous.id,owner:view.owner});if(view.closed||generation!==view.generation)return;if(cancelled.state!=='cancelled'){view.job=cancelled;view.message=text('package.ui.cancel_requested');view.selected='message';return;}view.job=null;}
|
|
62
|
+
const job=await request(view,backend,'package_review_start',{request:reviewRequest,owner:view.owner});
|
|
63
|
+
if(view.closed||generation!==view.generation){await request(view,backend,'package_review_cancel',{id:job.id,owner:view.owner});return;}
|
|
64
|
+
view.job=job;view.mode='status';view.draftPrepared=false;view.message=null;view.selected='job';
|
|
65
|
+
}else if(effect==='execute'){
|
|
66
|
+
if(!editor||!verified(view))throw new BackendError('integrity',text('package.reason_integrity'));
|
|
67
|
+
if(editor.saveState!=='idle'){view.mode='draft';view.message=text('editor.save_unknown');return;}
|
|
68
|
+
if(!view.draftPrepared){
|
|
69
|
+
if(!editor.acceptNumeric()){view.message=text('package.ui.draft_required');return;}
|
|
70
|
+
view.mode=editor.modified?'draft':'execute-confirm';view.selected=editor.modified?'draft-cancel':'execute-confirm';return;
|
|
139
71
|
}
|
|
72
|
+
editor.packageLocked=true;
|
|
73
|
+
const execution=await request(view,backend,'package_execute_start',{id:view.job!.id,owner:view.owner});
|
|
74
|
+
view.execution=execution;view.mode='status';view.selected='execution';view.message=text('package.ui.editor_locked');
|
|
75
|
+
await closeSourceDraft(editor,{request:(operation,payload)=>request(view,backend,operation,payload)});
|
|
76
|
+
if(view.closed||generation!==view.generation)await request(view,backend,'package_execute_detach',{id:execution.id,owner:view.owner});
|
|
77
|
+
}else if(effect==='discard-draft'){
|
|
78
|
+
if(!editor||editor.saveState!=='idle')throw new BackendError('configuration_conflict',text('editor.save_locked'));
|
|
79
|
+
editor.replaceDraft(editor.baseline.draft);view.draftPrepared=true;view.mode='execute-confirm';view.selected='execute-confirm';
|
|
80
|
+
}else if(effect==='save-draft'){
|
|
81
|
+
if(!editor||editor.saveState!=='idle')throw new BackendError('configuration_conflict',text('editor.save_locked'));
|
|
82
|
+
if(!editor.acceptNumeric()){view.message=text('package.ui.draft_required');return;}
|
|
83
|
+
const submitted=editor.beginSave();
|
|
84
|
+
try{const saved=await backend.request('apply',{draft:submitted.draft,expected_revision:submitted.revision,...(submitted.target?{target:submitted.target}:{})});editor.committed(saved);}catch(error){editor.saveFailed(error instanceof BackendError?error.code:'');throw error;}
|
|
85
|
+
view.mode='status';view.job=null;view.status=null;view.effect='load';view.message=text('package.ui.review_again');
|
|
86
|
+
}else if(effect==='export-draft'){
|
|
87
|
+
if(!editor||editor.saveState!=='idle')throw new BackendError('configuration_conflict',text('editor.save_locked'));
|
|
88
|
+
await backend.request('export',{draft:editor.draft,path:view.export_path,overwrite:false});view.draftPrepared=true;view.mode='execute-confirm';view.selected='execute-confirm';view.message=text('package.ui.exported');
|
|
89
|
+
}else if(effect==='reconcile-draft'){
|
|
90
|
+
if(!editor?.pendingSave)return;
|
|
91
|
+
const pending=editor.pendingSave;editor.setSaveState('pending');
|
|
92
|
+
try{const current=await backend.request('read',pending.target?{target:pending.target}:{});const result=editor.reconcileSave(current);view.message=text('editor.'+result);view.mode='status';view.job=null;view.status=null;view.effect='load';}catch(error){editor.setSaveState('unknown');throw error;}
|
|
93
|
+
}else if(effect==='cleanup-review'){
|
|
94
|
+
if(!view.prefix)throw new BackendError('prefix',text('package.reason_prefix'));
|
|
95
|
+
view.cleanup=await request(view,backend,'package_cleanup_review',{prefix:view.prefix,offset:view.offset});view.mode='cleanup';view.selected=view.cleanup.rows[0]?'cleanup:'+view.cleanup.rows[0].id:'cleanup-message';
|
|
96
|
+
}else if(effect==='cleanup-apply'){
|
|
97
|
+
view.cleanup=await request(view,backend,'package_cleanup_apply',{prefix:view.prefix,revision:view.cleanup!.revision,ids:[view.cleanupId]});view.mode='cleanup';view.selected='cleanup-message';view.message=text('package.ui.cleaned');
|
|
98
|
+
}else if(effect==='status'&&view.execution){
|
|
99
|
+
view.execution=await request(view,backend,'package_execute_status',{id:view.execution.id});view.selected='execution';
|
|
100
|
+
}else if(view.job){
|
|
101
|
+
const job=await request(view,backend,effect==='cancel'?'package_review_cancel':'package_review_status',{id:view.job.id,owner:view.owner});
|
|
102
|
+
if(view.closed||generation!==view.generation)return;
|
|
103
|
+
const cancelled=effect==='cancel'&&job.state==='cancelled';view.job=cancelled?null:job;view.message=effect==='cancel'?text(cancelled?'package.cancelled':'package.ui.cancel_requested'):null;
|
|
104
|
+
view.selected=effect==='cancel'?'message':job.review?'verification':job.error?'job-error':'job';
|
|
140
105
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if
|
|
144
|
-
|
|
145
|
-
view.selected = 'message';
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
finally {
|
|
149
|
-
if (generation === view.generation)
|
|
150
|
-
view.busy = false;
|
|
151
|
-
}
|
|
106
|
+
}catch(error){
|
|
107
|
+
if(effect==='execute'&&editor&&!view.execution&&error instanceof BackendError&&['arguments','conflict','integrity','identity','busy','development','permission','configuration','journal'].includes(error.code))editor.packageLocked=false;
|
|
108
|
+
if(!view.closed&&generation===view.generation){view.message=error instanceof BackendError&&error.localization?error.localization:text('package.reason_io_error');view.selected='message';}
|
|
109
|
+
}finally{if(generation===view.generation)view.busy=false;}
|
|
152
110
|
}
|
|
153
|
-
export function packageView(view:
|
|
154
|
-
const tr
|
|
155
|
-
const add
|
|
156
|
-
const status
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if
|
|
162
|
-
add('
|
|
163
|
-
|
|
164
|
-
add('
|
|
165
|
-
add('
|
|
166
|
-
|
|
167
|
-
add('
|
|
168
|
-
add('
|
|
169
|
-
status
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
add('previous-page',
|
|
181
|
-
add('next-page', tr('package.ui.next_page'));
|
|
111
|
+
export function packageView(view:PackageManager,language:Language,width:number,height:number):Row[]{
|
|
112
|
+
const tr=(key:string,params:Record<string,unknown>={})=>t('package.ui.'+key,language,params),rows:Row[]=[];
|
|
113
|
+
const add=(key:string,value:string,action?:Row['action'],backup?:string)=>wrapText([value.replace(/[\p{Cc}\p{Cs}]/gu,'')],Math.max(2,width-2)).forEach((line,index)=>rows.push({key:index?key+':'+index:key,text:line,...(action?{action}:{}),...(backup?{backup}:{})}));
|
|
114
|
+
const status=view.status;
|
|
115
|
+
if(view.mode==='draft'){
|
|
116
|
+
add('notice',tr('draft_required'));add('draft-save',tr('draft_save'));add('draft-export',tr('draft_export'));add('draft-discard',tr('draft_discard'));add('draft-cancel',tr('draft_cancel'));add('draft-reconcile',tr('draft_reconcile'));
|
|
117
|
+
}else if(view.mode==='execute-confirm'){
|
|
118
|
+
add('notice',tr('execute_notice'));add('execute-confirm',tr('execute_confirm'));add('draft-cancel',tr('draft_cancel'));
|
|
119
|
+
}else if(view.mode==='cleanup'||view.mode==='cleanup-confirm'){
|
|
120
|
+
add('cleanup-message',tr(view.cleanup?.uncertain?'cleanup_uncertain':'cleanup_notice'));
|
|
121
|
+
if(view.mode==='cleanup-confirm'){add('cleanup-confirm',tr('cleanup_confirm'));add('cleanup-selected',view.cleanupId??'');}
|
|
122
|
+
else for(const row of view.cleanup?.rows??[])add('cleanup:'+row.id,`${row.id} · ${row.version??'—'} · ${tr(row.removable?'cleanup_unused':'cleanup_protected')}${row.reasons.map(reason=>' · '+tr('protect_'+reason)).join('')}`);
|
|
123
|
+
add('previous-page',tr('previous_page'));add('next-page',tr('next_page'));
|
|
124
|
+
}else{
|
|
125
|
+
add('notice',tr('local_notice'));if(status)add('current',tr('current',{value:status.current??t('task.unknown',language)}));
|
|
126
|
+
add('prefix',tr('prefix',{value:view.editing==='prefix'&&view.input?inputView(view.input,Math.max(2,width-12)):view.prefix||t('task.unknown',language)}));
|
|
127
|
+
if(!status)add('loading',t(view.busy?'profiles.loading':'task.unknown',language));
|
|
128
|
+
else{
|
|
129
|
+
add('entry',tr('entry',{value:status.entry??t('task.unknown',language)}));add('config',tr('config',{value:status.config_dir}));add('previous',tr('previous',{value:status.previous??t('task.unknown',language)}));add('observed-channel',tr('channel',{value:status.channel??t('task.unknown',language)}));add('runtime',`Node ${status.node_version} · Claude ${status.host??t('task.unknown',language)}`);
|
|
130
|
+
status.reasons.forEach(reason=>add('reason:'+reason,t('package.reason_'+reason,language,{},reason)));
|
|
131
|
+
if(!view.execution||view.execution.running===false){
|
|
132
|
+
add('target',tr('target',{value:view.editing==='target'&&view.input?inputView(view.input,Math.max(2,width-12)):view.target||tr('default_target')}));add('channel',tr('channel',{value:view.channel??tr('inherit')}));
|
|
133
|
+
for(const action of ['check','update','rollback','recover-package'] as const)add(action,'Enter · '+tr(action),action);
|
|
134
|
+
add('cleanup-review',tr('cleanup_review'));
|
|
135
|
+
}
|
|
136
|
+
if(status.pending)add('pending',tr('pending',{id:status.pending.id,stage:tr('stage_'+status.pending.stage),running:status.pending.running?t('task.value.running',language):t('task.unknown',language)}));
|
|
137
|
+
for(const record of status.history)add('backup:'+record.id,`${record.id} · ${record.version??'—'} · ${tr('stage_'+record.stage)} · ${tr('backup_'+record.backup)}`,record.backup==='verified'?'restore-config':undefined,record.id);
|
|
138
|
+
if(status.total>16){add('previous-page',tr('previous_page'));add('next-page',tr('next_page'));}
|
|
182
139
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (job) {
|
|
186
|
-
add('job', tr('package.ui.job', { id: job.id, state: tr('package.ui.state_' + job.state) }));
|
|
187
|
-
if (job.error)
|
|
188
|
-
add('job-error', t('package.reason_' + job.error, language, {}, job.error));
|
|
189
|
-
if (job.review) {
|
|
190
|
-
const review = job.review;
|
|
191
|
-
add('verification', tr(review.action === 'restore-config' ? 'package.ui.restore_review' : review.artifact_verified ? 'package.ui.verified' : 'package.ui.unverified'));
|
|
192
|
-
add('review-target', `${review.current ?? '—'} → ${review.target ?? '—'}`);
|
|
193
|
-
add('review-config', tr('package.ui.config', { value: review.config_dir }));
|
|
194
|
-
if (review.registry)
|
|
195
|
-
add('registry', review.registry);
|
|
196
|
-
if (review.integrity)
|
|
197
|
-
add('integrity', review.integrity);
|
|
198
|
-
if (review.node_engine)
|
|
199
|
-
add('engine', 'Node ' + review.node_engine);
|
|
200
|
-
review.reasons.forEach(reason => add('review-reason:' + reason, t('package.reason_' + reason, language, {}, reason)));
|
|
201
|
-
review.configuration_conflicts.forEach(file => add('conflict:' + file, file));
|
|
202
|
-
review.files.forEach(file => add('restore:' + file, file));
|
|
140
|
+
if(view.job){const job=view.job;add('job',tr('job',{id:job.id,state:tr('state_'+job.state)}));if(job.error)add('job-error',t('package.reason_'+job.error,language,{},job.error));
|
|
141
|
+
if(job.review){const review=job.review;add('verification',tr(review.action==='restore-config'?'restore_review':review.artifact_verified?'verified':'unverified'));add('review-target',`${review.current??'—'} → ${review.target??'—'}`);add('review-config',tr('config',{value:review.config_dir}));if(review.registry)add('registry',review.registry);if(review.integrity)add('integrity',review.integrity);if(review.node_engine)add('engine','Node '+review.node_engine);review.reasons.forEach(reason=>add('review-reason:'+reason,t('package.reason_'+reason,language,{},reason)));review.configuration_conflicts.forEach(file=>add('conflict:'+file,file));review.files.forEach(file=>add('restore:'+file,file));if(verified(view))add('execute',tr('execute'));}
|
|
203
142
|
}
|
|
143
|
+
if(view.execution){const run=view.execution;add('execution',tr('execution',{id:run.transaction_id??run.id,state:tr('execution_state_'+run.state),stage:t('package.ui.stage_'+run.stage,language,{},run.stage)}));add('execution-results',tr('execution_results',{package:tr(run.results.package===null?'result_na':run.results.package?'result_done':'result_pending'),integration:tr(run.results.integration===null?'result_na':run.results.integration?'result_done':'result_pending'),configuration:tr(run.results.configuration===null?'result_na':run.results.configuration?'result_done':'result_pending')}));add('execution-control',tr('control',{executable:run.control.executable,entry:run.control.args[0]??''}));add('execution-control-help',tr('control_help',{directory:run.control.config_dir}));if(run.error)add('execution-error',t('package.reason_'+run.error,language,{},run.error));add('reload-required',tr('editor_locked'));if(run.state==='complete')add('reopen',tr('reopen'));}
|
|
204
144
|
}
|
|
205
|
-
if
|
|
206
|
-
|
|
207
|
-
let index
|
|
208
|
-
|
|
209
|
-
index = 0;
|
|
210
|
-
view.rows = rows;
|
|
211
|
-
view.selected = rows[index]?.key ?? '';
|
|
212
|
-
view.capacity = Math.max(1, height);
|
|
213
|
-
view.scroll = Math.max(0, Math.min(view.scroll, index, Math.max(0, rows.length - view.capacity)));
|
|
214
|
-
if (index >= view.scroll + view.capacity)
|
|
215
|
-
view.scroll = index - view.capacity + 1;
|
|
216
|
-
return rows.slice(view.scroll, view.scroll + view.capacity).map(row => ({ ...row, text: (row.key === view.selected ? '› ' : ' ') + row.text, selected: row.key === view.selected }));
|
|
145
|
+
if(view.input&&view.editing==='export_path')add('export-path',tr('export_path',{value:inputView(view.input,Math.max(2,width-16))}));
|
|
146
|
+
if(view.message)add('message',renderMessage(view.message,language));
|
|
147
|
+
let index=rows.findIndex(row=>row.key===view.selected);if(index<0)index=0;view.rows=rows;view.selected=rows[index]?.key??'';view.capacity=Math.max(1,height);view.scroll=Math.max(0,Math.min(view.scroll,index,Math.max(0,rows.length-view.capacity)));if(index>=view.scroll+view.capacity)view.scroll=index-view.capacity+1;
|
|
148
|
+
return rows.slice(view.scroll,view.scroll+view.capacity).map(row=>({...row,text:(row.key===view.selected?'› ':' ')+row.text,selected:row.key===view.selected}));
|
|
217
149
|
}
|
|
218
|
-
export function packageKey(view:
|
|
219
|
-
const key
|
|
220
|
-
if
|
|
221
|
-
if
|
|
222
|
-
|
|
223
|
-
view.editing
|
|
224
|
-
return
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const field = view.editing;
|
|
228
|
-
view[field] = view.input.value;
|
|
229
|
-
view.input = null;
|
|
230
|
-
view.editing = null;
|
|
231
|
-
if (field === 'prefix')
|
|
232
|
-
view.status = null;
|
|
233
|
-
if (field === 'target' && view.job) {
|
|
234
|
-
view.effect = 'cancel';
|
|
235
|
-
return 'packages';
|
|
236
|
-
}
|
|
237
|
-
if (field === 'prefix') {
|
|
238
|
-
view.offset = 0;
|
|
239
|
-
view.effect = 'load';
|
|
240
|
-
return 'packages';
|
|
241
|
-
}
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
const result = inputKey(view.input.value, view.input, event, view.editing === 'prefix' ? 4096 : 100);
|
|
245
|
-
view.input = result.state;
|
|
246
|
-
if (result.error)
|
|
247
|
-
view.message = text('input.' + result.error, { limit: view.editing === 'prefix' ? 4096 : 100 });
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
|
-
if (event.text || event.paste || event.meta)
|
|
251
|
-
return null;
|
|
252
|
-
if (cancel || !event.ctrl && key.toLowerCase() === 'q') {
|
|
253
|
-
view.effect = 'close';
|
|
254
|
-
return 'packages';
|
|
255
|
-
}
|
|
256
|
-
if (event.ctrl || view.busy)
|
|
257
|
-
return null;
|
|
258
|
-
if (key.toLowerCase() === 'r') {
|
|
259
|
-
view.effect = view.job ? 'status' : 'load';
|
|
260
|
-
return 'packages';
|
|
261
|
-
}
|
|
262
|
-
if (key.toLowerCase() === 'l') {
|
|
263
|
-
view.effect = 'load';
|
|
264
|
-
return 'packages';
|
|
265
|
-
}
|
|
266
|
-
if (key.toLowerCase() === 'c' && view.job) {
|
|
267
|
-
view.effect = 'cancel';
|
|
268
|
-
return 'packages';
|
|
269
|
-
}
|
|
270
|
-
let index = Math.max(0, view.rows.findIndex(row => row.key === view.selected));
|
|
271
|
-
if (key === 'up')
|
|
272
|
-
index--;
|
|
273
|
-
if (key === 'down')
|
|
274
|
-
index++;
|
|
275
|
-
if (key === 'pageup')
|
|
276
|
-
index -= view.capacity;
|
|
277
|
-
if (key === 'pagedown')
|
|
278
|
-
index += view.capacity;
|
|
279
|
-
if (key === 'home')
|
|
280
|
-
index = 0;
|
|
281
|
-
if (key === 'end')
|
|
282
|
-
index = view.rows.length - 1;
|
|
283
|
-
view.selected = view.rows[Math.max(0, Math.min(index, view.rows.length - 1))]?.key ?? '';
|
|
284
|
-
if (key !== 'enter')
|
|
285
|
-
return null;
|
|
286
|
-
const selectedKey = view.selected.replace(/:\d+$/u, '');
|
|
287
|
-
if (selectedKey === 'prefix' || selectedKey === 'target') {
|
|
288
|
-
view.editing = selectedKey;
|
|
289
|
-
view.input = textInput(view[view.editing]);
|
|
290
|
-
return null;
|
|
291
|
-
}
|
|
292
|
-
if (selectedKey === 'channel') {
|
|
293
|
-
const channels = [null, 'latest', 'beta'] as const;
|
|
294
|
-
view.channel = channels[(channels.indexOf(view.channel) + 1) % 3]!;
|
|
295
|
-
if (view.job) {
|
|
296
|
-
view.effect = 'cancel';
|
|
297
|
-
return 'packages';
|
|
150
|
+
export function packageKey(view:PackageManager,event:TextKey):'packages'|null{
|
|
151
|
+
const key=event.key==='return'?'enter':event.key,cancel=!event.text&&!event.paste&&(key==='escape'||event.ctrl&&key.toLowerCase()==='g');
|
|
152
|
+
if(view.input&&view.editing){
|
|
153
|
+
if(cancel){view.input=null;view.editing=null;return null;}
|
|
154
|
+
if(!event.text&&!event.paste&&key==='enter'){
|
|
155
|
+
const field=view.editing;view[field]=view.input.value;view.input=null;view.editing=null;
|
|
156
|
+
if(field==='export_path'){view.effect='export-draft';return 'packages';}
|
|
157
|
+
if(field==='prefix'){view.status=null;view.offset=0;view.effect='load';return 'packages';}
|
|
158
|
+
if(field==='target'&&view.job){view.effect='cancel';return 'packages';}return null;
|
|
298
159
|
}
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
if (['next-page', 'previous-page'].includes(selectedKey)) {
|
|
302
|
-
view.offset = Math.max(0, Math.min(view.offset + (selectedKey === 'next-page' ? 16 : -16), Math.max(0, Math.floor(((view.status?.total ?? 1) - 1) / 16) * 16)));
|
|
303
|
-
view.effect = 'load';
|
|
304
|
-
return 'packages';
|
|
160
|
+
const result=inputKey(view.input.value,view.input,event,view.editing==='target'?100:4096);view.input=result.state;if(result.error)view.message=text('input.'+result.error,{limit:view.editing==='target'?100:4096});return null;
|
|
305
161
|
}
|
|
306
|
-
|
|
307
|
-
if
|
|
308
|
-
view.
|
|
309
|
-
view.
|
|
310
|
-
view.effect = 'start';
|
|
311
|
-
return 'packages';
|
|
162
|
+
if(event.text||event.paste||event.meta)return null;
|
|
163
|
+
if(cancel||!event.ctrl&&key.toLowerCase()==='q'){
|
|
164
|
+
if(view.mode!=='status'){view.mode='status';view.draftPrepared=false;return null;}
|
|
165
|
+
view.effect='close';return 'packages';
|
|
312
166
|
}
|
|
313
|
-
return null;
|
|
167
|
+
if(event.ctrl||view.busy)return null;
|
|
168
|
+
if(key.toLowerCase()==='r'){view.effect=view.mode==='cleanup'?'cleanup-review':view.execution||view.job?'status':'load';return 'packages';}
|
|
169
|
+
if(key.toLowerCase()==='l'){view.effect='load';return 'packages';}
|
|
170
|
+
if(key.toLowerCase()==='c'&&view.job&&!view.execution){view.effect='cancel';return 'packages';}
|
|
171
|
+
let index=Math.max(0,view.rows.findIndex(row=>row.key===view.selected));if(key==='up')index--;if(key==='down')index++;if(key==='pageup')index-=view.capacity;if(key==='pagedown')index+=view.capacity;if(key==='home')index=0;if(key==='end')index=view.rows.length-1;view.selected=view.rows[Math.max(0,Math.min(index,view.rows.length-1))]?.key??'';
|
|
172
|
+
if(key!=='enter')return null;const selectedKey=view.selected.replace(/:\d+$/u,'');
|
|
173
|
+
if(selectedKey==='draft-cancel'){view.mode='status';view.draftPrepared=false;return null;}
|
|
174
|
+
if(selectedKey==='draft-save'){view.effect='save-draft';return 'packages';}
|
|
175
|
+
if(selectedKey==='draft-reconcile'){view.effect='reconcile-draft';return 'packages';}
|
|
176
|
+
if(selectedKey==='draft-export'){view.editing='export_path';view.input=textInput(view.export_path);return null;}
|
|
177
|
+
if(selectedKey==='draft-discard'){view.effect='discard-draft';return 'packages';}
|
|
178
|
+
if(selectedKey==='execute'){view.draftPrepared=false;view.effect='execute';return 'packages';}
|
|
179
|
+
if(selectedKey==='execute-confirm'){view.draftPrepared=true;view.effect='execute';return 'packages';}
|
|
180
|
+
if(selectedKey==='cleanup-review'){view.offset=0;view.effect='cleanup-review';return 'packages';}
|
|
181
|
+
if(selectedKey==='cleanup-confirm'){view.effect='cleanup-apply';return 'packages';}
|
|
182
|
+
if(selectedKey.startsWith('cleanup:')){const row=view.cleanup?.rows.find(row=>'cleanup:'+row.id===selectedKey);if(row?.removable){view.cleanupId=row.id;view.mode='cleanup-confirm';view.selected='cleanup-confirm';}return null;}
|
|
183
|
+
if((selectedKey==='prefix'||selectedKey==='target')&&!view.execution){view.editing=selectedKey;view.input=textInput(view[selectedKey]);return null;}
|
|
184
|
+
if(selectedKey==='channel'&&!view.execution){const channels=[null,'latest','beta']as const;view.channel=channels[(channels.indexOf(view.channel)+1)%3]!;if(view.job){view.effect='cancel';return 'packages';}return null;}
|
|
185
|
+
if(['next-page','previous-page'].includes(selectedKey)){const total=view.mode==='cleanup'?view.cleanup?.total:view.status?.total;view.offset=Math.max(0,Math.min(view.offset+(selectedKey==='next-page'?16:-16),Math.max(0,Math.floor(((total??1)-1)/16)*16)));view.effect=view.mode==='cleanup'?'cleanup-review':'load';return 'packages';}
|
|
186
|
+
const selected=view.rows.find(row=>row.key===view.selected);if(selected?.action){view.action=selected.action;view.backup=selected.backup??null;view.effect='start';return 'packages';}return null;
|
|
314
187
|
}
|
|
@@ -28,11 +28,20 @@ function review(value: unknown): boolean {
|
|
|
28
28
|
string(value.prefix) && string(value.config_dir) && channel(value.channel) && typeof value.artifact_verified === 'boolean' && typeof value.compatible === 'boolean' &&
|
|
29
29
|
strings(value.reasons) && strings(value.configuration_conflicts) && strings(value.files);
|
|
30
30
|
}
|
|
31
|
+
function execution(value:unknown):boolean {
|
|
32
|
+
return object(value)&&exact(value,['version','id','transaction_id','action','prefix','state','stage','started_at','updated_at','finished_at','error','running','results','control'])&&value.version===1&&string(value.id)&&/^execution-[0-9a-f-]{36}$/u.test(value.id)&&nullable(value.transaction_id)&&['check','update','rollback','recover-package','restore-config'].includes(String(value.action))&&string(value.prefix)&&['running','complete','failed','interrupted'].includes(String(value.state))&&['stage','started_at','updated_at'].every(k=>string(value[k]))&&nullable(value.finished_at)&&nullable(value.error)&&(value.running===null||typeof value.running==='boolean')&&object(value.results)&&exact(value.results,['package','integration','configuration'])&&Object.values(value.results).every(v=>v===null||typeof v==='boolean')&&object(value.control)&&exact(value.control,['executable','args','config_dir'])&&string(value.control.executable)&&string(value.control.config_dir)&&Array.isArray(value.control.args)&&value.control.args.length===1&&value.control.args.every(string);
|
|
33
|
+
}
|
|
34
|
+
function cleanup(value:Record<string,unknown>):boolean {
|
|
35
|
+
return exact(value,['version','revision','prefix','offset','total','uncertain','rows'])&&value.version===1&&string(value.revision)&&/^[a-f0-9]{64}$/u.test(value.revision)&&string(value.prefix)&&Number.isSafeInteger(value.offset)&&Number(value.offset)>=0&&Number.isSafeInteger(value.total)&&Number(value.total)>=0&&typeof value.uncertain==='boolean'&&Array.isArray(value.rows)&&value.rows.length<=16&&value.rows.every(row=>object(row)&&exact(row,['id','removable','reasons','version'])&&string(row.id)&&typeof row.removable==='boolean'&&strings(row.reasons)&&nullable(row.version));
|
|
36
|
+
}
|
|
31
37
|
export function isPackageResult(operation: string, value: unknown): boolean {
|
|
32
38
|
if (!object(value) || value.version !== 1)
|
|
33
39
|
return false;
|
|
40
|
+
if(operation.startsWith('package_execute_'))return execution(value);
|
|
41
|
+
if(operation.startsWith('package_cleanup_'))return cleanup(value);
|
|
34
42
|
if (operation === 'package_status')
|
|
35
|
-
return exact(value, ['version', 'backend_version', 'captured_at', 'revision', 'prefix', 'entry', 'config_dir', 'current', 'previous', 'channel', 'node_version', 'host', 'compatible', 'reasons', 'pending', 'history', 'offset', 'total']) &&
|
|
43
|
+
return exact(value, ['version', ...(Object.hasOwn(value,'execution')?['execution']:[]), 'backend_version', 'captured_at', 'revision', 'prefix', 'entry', 'config_dir', 'current', 'previous', 'channel', 'node_version', 'host', 'compatible', 'reasons', 'pending', 'history', 'offset', 'total']) &&
|
|
44
|
+
(value.execution===undefined||value.execution===null||execution(value.execution))&&
|
|
36
45
|
['backend_version', 'captured_at', 'revision', 'config_dir', 'node_version'].every(key => string(value[key])) && /^[0-9a-f]{64}$/u.test(String(value.revision)) &&
|
|
37
46
|
['prefix', 'entry', 'current', 'previous', 'host'].every(key => nullable(value[key])) && channel(value.channel) && typeof value.compatible === 'boolean' && strings(value.reasons) &&
|
|
38
47
|
(value.pending === null || history(value.pending)) && Array.isArray(value.history) && value.history.length <= 16 && value.history.every(history) &&
|