@g9tm/app-diagnostic 0.2.0 → 0.2.1
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/package.json +20 -12
- package/src/bytes.ts +48 -48
- package/src/host.ts +124 -124
- package/src/index.ts +30 -30
- package/src/live/bundle.ts +77 -77
- package/src/live/channel.ts +496 -496
- package/src/live/handlers.ts +426 -426
- package/src/live/models.ts +366 -360
- package/src/live/upload.ts +175 -175
- package/src/recording.ts +176 -176
- package/src/store.ts +39 -39
- package/src/strings.generated.ts +242 -242
- package/src/strings.ts +37 -37
- package/src/tester/archive.ts +83 -83
- package/src/tester/compose.ts +99 -99
- package/src/tester/feed.ts +182 -182
- package/src/tester/gesture.ts +61 -61
- package/src/tester/model.ts +125 -125
- package/src/tester/outbox.ts +131 -131
- package/src/tester/screen.ts +117 -117
- package/src/tester/store.ts +145 -145
- package/src/tester/timeline.ts +98 -98
- package/src/upload.ts +236 -236
- package/src/wire.ts +133 -133
package/src/tester/feed.ts
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
// A tester's report list (G9AppDiagnostic.Maui TesterReportFeedClient + TesterReportsListSheetContentView.Describe): the
|
|
2
|
-
// gateway's list of EVERY tester report (any tester) plus what is still queued on this device, and what each card shows.
|
|
3
|
-
// Same identity as the upload; the gateway answers only a device that has sent a report itself, so a 403 is «not yet»,
|
|
4
|
-
// a plain sentence, never an error.
|
|
5
|
-
import { type DiagnosticFetch, type DiagnosticFiles, type DiagnosticLog, errorText, silentLog, withTimeout } from '../host.ts';
|
|
6
|
-
import { type DeviceHeaderNames, type DeviceIdentity, deviceHeaders, FEED_ROUTE, MANIFEST_ENTRY, NEUTRAL_DEVICE_HEADERS } from '../upload.ts';
|
|
7
|
-
import { isDraft, type TesterReportDraft } from './model.ts';
|
|
8
|
-
|
|
9
|
-
export const TesterReportStates = {
|
|
10
|
-
uploading: 'uploading',
|
|
11
|
-
received: 'received',
|
|
12
|
-
processing: 'processing',
|
|
13
|
-
ready: 'ready',
|
|
14
|
-
filed: 'filed',
|
|
15
|
-
deleted: 'deleted',
|
|
16
|
-
} as const;
|
|
17
|
-
|
|
18
|
-
export const TesterReportOutcomes = {
|
|
19
|
-
jira: 'jira',
|
|
20
|
-
fixedInCode: 'fixed-in-code',
|
|
21
|
-
notABug: 'not-a-bug',
|
|
22
|
-
duplicate: 'duplicate',
|
|
23
|
-
} as const;
|
|
24
|
-
|
|
25
|
-
export interface TesterFeedItem {
|
|
26
|
-
readonly reportId: string;
|
|
27
|
-
readonly code: string;
|
|
28
|
-
readonly title: string;
|
|
29
|
-
readonly username: string;
|
|
30
|
-
readonly platform: string;
|
|
31
|
-
readonly appVersion: string;
|
|
32
|
-
readonly state: string;
|
|
33
|
-
readonly outcome: string;
|
|
34
|
-
readonly jiraKey: string;
|
|
35
|
-
readonly mine: boolean;
|
|
36
|
-
readonly createdAtUtc: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface TesterFeed {
|
|
40
|
-
readonly status: 'loaded' | 'notYet' | 'failed';
|
|
41
|
-
readonly reports: readonly TesterFeedItem[];
|
|
42
|
-
/** The titles of the archives still in this device's outbox (not on the gateway yet, so no code). */
|
|
43
|
-
readonly queued: readonly string[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface TesterFeedOptions {
|
|
47
|
-
readonly files: DiagnosticFiles;
|
|
48
|
-
readonly fetch: DiagnosticFetch;
|
|
49
|
-
readonly gateway: string;
|
|
50
|
-
readonly device: DeviceIdentity;
|
|
51
|
-
readonly headers?: DeviceHeaderNames;
|
|
52
|
-
readonly extraHeaders?: (url: string) => Readonly<Record<string, string>>;
|
|
53
|
-
readonly queued: () => Promise<readonly string[]>;
|
|
54
|
-
readonly timeoutMs?: number;
|
|
55
|
-
readonly log?: DiagnosticLog;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const str = (v: unknown) => (typeof v === 'string' ? v : '');
|
|
59
|
-
|
|
60
|
-
function item(raw: Record<string, unknown>): TesterFeedItem {
|
|
61
|
-
return {
|
|
62
|
-
reportId: str(raw.reportId),
|
|
63
|
-
code: str(raw.code),
|
|
64
|
-
title: str(raw.title),
|
|
65
|
-
username: str(raw.username),
|
|
66
|
-
platform: str(raw.platform),
|
|
67
|
-
appVersion: str(raw.appVersion),
|
|
68
|
-
state: str(raw.state),
|
|
69
|
-
outcome: str(raw.outcome),
|
|
70
|
-
jiraKey: str(raw.jiraKey),
|
|
71
|
-
mine: raw.mine === true,
|
|
72
|
-
createdAtUtc: str(raw.createdAtUtc),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** The manifest inside an archive (null: unreadable — the zip stays queued, never deleted). */
|
|
77
|
-
export async function readManifest(files: DiagnosticFiles, archivePath: string): Promise<TesterReportDraft | null> {
|
|
78
|
-
try {
|
|
79
|
-
const parsed = JSON.parse(await files.zipReadText(archivePath, MANIFEST_ENTRY, 4 * 1024 * 1024)) as unknown;
|
|
80
|
-
return isDraft(parsed) ? parsed : null;
|
|
81
|
-
} catch {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function loadTesterFeed(o: TesterFeedOptions): Promise<TesterFeed> {
|
|
87
|
-
const log = o.log ?? silentLog;
|
|
88
|
-
const queued = await queuedTitles(o).catch(() => [] as string[]);
|
|
89
|
-
try {
|
|
90
|
-
const url = `${o.gateway.replace(/\/+$/, '')}${FEED_ROUTE}`;
|
|
91
|
-
const headers = { ...(o.extraHeaders?.(url) ?? {}), Accept: 'application/json', ...deviceHeaders(o.device, o.headers ?? NEUTRAL_DEVICE_HEADERS) };
|
|
92
|
-
const response = await withTimeout(o.fetch(url, { method: 'GET', headers }), o.timeoutMs ?? 30_000);
|
|
93
|
-
if (response.status === 403) return { status: 'notYet', reports: [], queued };
|
|
94
|
-
const text = await response.text();
|
|
95
|
-
if (response.status < 200 || response.status >= 300) {
|
|
96
|
-
log.log('warn', 'tester', `the report list → HTTP ${response.status}`);
|
|
97
|
-
return { status: 'failed', reports: [], queued };
|
|
98
|
-
}
|
|
99
|
-
const body = JSON.parse(text) as { reports?: unknown };
|
|
100
|
-
const reports = Array.isArray(body.reports) ? body.reports.filter((r): r is Record<string, unknown> => !!r && typeof r === 'object').map(item) : [];
|
|
101
|
-
return { status: 'loaded', reports, queued };
|
|
102
|
-
} catch (error) {
|
|
103
|
-
log.log('warn', 'tester', `the report list could not be loaded: ${errorText(error)}`);
|
|
104
|
-
return { status: 'failed', reports: [], queued };
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function queuedTitles(o: TesterFeedOptions): Promise<string[]> {
|
|
109
|
-
const titles: string[] = [];
|
|
110
|
-
for (const path of await o.queued()) {
|
|
111
|
-
const manifest = await readManifest(o.files, path);
|
|
112
|
-
const name = (path.split('/').pop() ?? path).replace(/\.zip$/, '');
|
|
113
|
-
titles.push(manifest && manifest.title.trim() ? manifest.title : name);
|
|
114
|
-
}
|
|
115
|
-
return titles;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// ── what a card shows ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
119
|
-
|
|
120
|
-
/** Sent → received → reviewed → resolved. */
|
|
121
|
-
export const TRACK_STEPS = 4;
|
|
122
|
-
|
|
123
|
-
export type CardTone = 'warning' | 'info' | 'primary' | 'success' | 'muted';
|
|
124
|
-
|
|
125
|
-
export type CardIcon = 'upload' | 'processing' | 'review' | 'received' | 'filed' | 'done' | 'closed';
|
|
126
|
-
|
|
127
|
-
export interface TesterCard {
|
|
128
|
-
readonly code: string;
|
|
129
|
-
readonly title: string;
|
|
130
|
-
/** A package text key. */
|
|
131
|
-
readonly stateKey: string;
|
|
132
|
-
readonly outcomeKey: string | null;
|
|
133
|
-
readonly tone: CardTone;
|
|
134
|
-
readonly icon: CardIcon;
|
|
135
|
-
/** Steps of the track already walked (0..4). */
|
|
136
|
-
readonly step: number;
|
|
137
|
-
readonly inProgress: boolean;
|
|
138
|
-
readonly jiraKey: string | null;
|
|
139
|
-
readonly createdAtUtc: string | null;
|
|
140
|
-
readonly meta: string;
|
|
141
|
-
readonly mine: boolean;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const OUTCOME_KEY: Readonly<Record<string, string>> = {
|
|
145
|
-
[TesterReportOutcomes.jira]: 'TesterReportOutcomeJiraFormat',
|
|
146
|
-
[TesterReportOutcomes.fixedInCode]: 'TesterReportOutcomeFixedInCode',
|
|
147
|
-
[TesterReportOutcomes.notABug]: 'TesterReportOutcomeNotABug',
|
|
148
|
-
[TesterReportOutcomes.duplicate]: 'TesterReportOutcomeDuplicate',
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
/** The state a tester reads: what became of the report wins over where its processing is. */
|
|
152
|
-
export function describeReport(r: TesterFeedItem): TesterCard {
|
|
153
|
-
const outcomeKey = OUTCOME_KEY[r.outcome] ?? null;
|
|
154
|
-
// « | », not «·»: a Persian face draws a middle dot like a zero beside Persian digits.
|
|
155
|
-
const meta = [r.username, r.platform, r.appVersion ? `${r.appVersion}` : ''].filter((s) => s.trim().length > 0).join(' | ');
|
|
156
|
-
const jiraKey = r.outcome === TesterReportOutcomes.jira && r.jiraKey.trim() ? r.jiraKey : null;
|
|
157
|
-
const base = { code: r.code, title: r.title, outcomeKey, jiraKey, createdAtUtc: r.createdAtUtc || null, meta, mine: r.mine, inProgress: false };
|
|
158
|
-
if (r.state === TesterReportStates.deleted) return { ...base, stateKey: 'TesterReportStateDeleted', tone: 'muted', icon: 'closed', step: TRACK_STEPS };
|
|
159
|
-
if (outcomeKey) return { ...base, stateKey: outcomeKey, outcomeKey: null, tone: 'success', icon: r.outcome === TesterReportOutcomes.jira ? 'filed' : 'done', step: TRACK_STEPS };
|
|
160
|
-
switch (r.state) {
|
|
161
|
-
case TesterReportStates.uploading:
|
|
162
|
-
return { ...base, stateKey: 'TesterReportStateUploading', tone: 'warning', icon: 'upload', step: 1, inProgress: true };
|
|
163
|
-
case TesterReportStates.processing:
|
|
164
|
-
return { ...base, stateKey: 'TesterReportStateProcessing', tone: 'info', icon: 'processing', step: 2, inProgress: true };
|
|
165
|
-
case TesterReportStates.ready:
|
|
166
|
-
return { ...base, stateKey: 'TesterReportStateReady', tone: 'primary', icon: 'review', step: 3 };
|
|
167
|
-
default:
|
|
168
|
-
return { ...base, stateKey: 'TesterReportStateReceived', tone: 'primary', icon: 'received', step: 2 };
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** The four counts across the top: queued · in review · ready · resolved. */
|
|
173
|
-
export function summarize(feed: TesterFeed): { queued: number; review: number; ready: number; done: number } {
|
|
174
|
-
const s = { queued: feed.queued.length, review: 0, ready: 0, done: 0 };
|
|
175
|
-
for (const r of feed.reports) {
|
|
176
|
-
if (r.state === TesterReportStates.deleted || r.outcome) s.done++;
|
|
177
|
-
else if (r.state === TesterReportStates.uploading) s.queued++;
|
|
178
|
-
else if (r.state === TesterReportStates.ready) s.ready++;
|
|
179
|
-
else s.review++;
|
|
180
|
-
}
|
|
181
|
-
return s;
|
|
182
|
-
}
|
|
1
|
+
// A tester's report list (G9AppDiagnostic.Maui TesterReportFeedClient + TesterReportsListSheetContentView.Describe): the
|
|
2
|
+
// gateway's list of EVERY tester report (any tester) plus what is still queued on this device, and what each card shows.
|
|
3
|
+
// Same identity as the upload; the gateway answers only a device that has sent a report itself, so a 403 is «not yet»,
|
|
4
|
+
// a plain sentence, never an error.
|
|
5
|
+
import { type DiagnosticFetch, type DiagnosticFiles, type DiagnosticLog, errorText, silentLog, withTimeout } from '../host.ts';
|
|
6
|
+
import { type DeviceHeaderNames, type DeviceIdentity, deviceHeaders, FEED_ROUTE, MANIFEST_ENTRY, NEUTRAL_DEVICE_HEADERS } from '../upload.ts';
|
|
7
|
+
import { isDraft, type TesterReportDraft } from './model.ts';
|
|
8
|
+
|
|
9
|
+
export const TesterReportStates = {
|
|
10
|
+
uploading: 'uploading',
|
|
11
|
+
received: 'received',
|
|
12
|
+
processing: 'processing',
|
|
13
|
+
ready: 'ready',
|
|
14
|
+
filed: 'filed',
|
|
15
|
+
deleted: 'deleted',
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
export const TesterReportOutcomes = {
|
|
19
|
+
jira: 'jira',
|
|
20
|
+
fixedInCode: 'fixed-in-code',
|
|
21
|
+
notABug: 'not-a-bug',
|
|
22
|
+
duplicate: 'duplicate',
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
export interface TesterFeedItem {
|
|
26
|
+
readonly reportId: string;
|
|
27
|
+
readonly code: string;
|
|
28
|
+
readonly title: string;
|
|
29
|
+
readonly username: string;
|
|
30
|
+
readonly platform: string;
|
|
31
|
+
readonly appVersion: string;
|
|
32
|
+
readonly state: string;
|
|
33
|
+
readonly outcome: string;
|
|
34
|
+
readonly jiraKey: string;
|
|
35
|
+
readonly mine: boolean;
|
|
36
|
+
readonly createdAtUtc: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TesterFeed {
|
|
40
|
+
readonly status: 'loaded' | 'notYet' | 'failed';
|
|
41
|
+
readonly reports: readonly TesterFeedItem[];
|
|
42
|
+
/** The titles of the archives still in this device's outbox (not on the gateway yet, so no code). */
|
|
43
|
+
readonly queued: readonly string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TesterFeedOptions {
|
|
47
|
+
readonly files: DiagnosticFiles;
|
|
48
|
+
readonly fetch: DiagnosticFetch;
|
|
49
|
+
readonly gateway: string;
|
|
50
|
+
readonly device: DeviceIdentity;
|
|
51
|
+
readonly headers?: DeviceHeaderNames;
|
|
52
|
+
readonly extraHeaders?: (url: string) => Readonly<Record<string, string>>;
|
|
53
|
+
readonly queued: () => Promise<readonly string[]>;
|
|
54
|
+
readonly timeoutMs?: number;
|
|
55
|
+
readonly log?: DiagnosticLog;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const str = (v: unknown) => (typeof v === 'string' ? v : '');
|
|
59
|
+
|
|
60
|
+
function item(raw: Record<string, unknown>): TesterFeedItem {
|
|
61
|
+
return {
|
|
62
|
+
reportId: str(raw.reportId),
|
|
63
|
+
code: str(raw.code),
|
|
64
|
+
title: str(raw.title),
|
|
65
|
+
username: str(raw.username),
|
|
66
|
+
platform: str(raw.platform),
|
|
67
|
+
appVersion: str(raw.appVersion),
|
|
68
|
+
state: str(raw.state),
|
|
69
|
+
outcome: str(raw.outcome),
|
|
70
|
+
jiraKey: str(raw.jiraKey),
|
|
71
|
+
mine: raw.mine === true,
|
|
72
|
+
createdAtUtc: str(raw.createdAtUtc),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The manifest inside an archive (null: unreadable — the zip stays queued, never deleted). */
|
|
77
|
+
export async function readManifest(files: DiagnosticFiles, archivePath: string): Promise<TesterReportDraft | null> {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = JSON.parse(await files.zipReadText(archivePath, MANIFEST_ENTRY, 4 * 1024 * 1024)) as unknown;
|
|
80
|
+
return isDraft(parsed) ? parsed : null;
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function loadTesterFeed(o: TesterFeedOptions): Promise<TesterFeed> {
|
|
87
|
+
const log = o.log ?? silentLog;
|
|
88
|
+
const queued = await queuedTitles(o).catch(() => [] as string[]);
|
|
89
|
+
try {
|
|
90
|
+
const url = `${o.gateway.replace(/\/+$/, '')}${FEED_ROUTE}`;
|
|
91
|
+
const headers = { ...(o.extraHeaders?.(url) ?? {}), Accept: 'application/json', ...deviceHeaders(o.device, o.headers ?? NEUTRAL_DEVICE_HEADERS) };
|
|
92
|
+
const response = await withTimeout(o.fetch(url, { method: 'GET', headers }), o.timeoutMs ?? 30_000);
|
|
93
|
+
if (response.status === 403) return { status: 'notYet', reports: [], queued };
|
|
94
|
+
const text = await response.text();
|
|
95
|
+
if (response.status < 200 || response.status >= 300) {
|
|
96
|
+
log.log('warn', 'tester', `the report list → HTTP ${response.status}`);
|
|
97
|
+
return { status: 'failed', reports: [], queued };
|
|
98
|
+
}
|
|
99
|
+
const body = JSON.parse(text) as { reports?: unknown };
|
|
100
|
+
const reports = Array.isArray(body.reports) ? body.reports.filter((r): r is Record<string, unknown> => !!r && typeof r === 'object').map(item) : [];
|
|
101
|
+
return { status: 'loaded', reports, queued };
|
|
102
|
+
} catch (error) {
|
|
103
|
+
log.log('warn', 'tester', `the report list could not be loaded: ${errorText(error)}`);
|
|
104
|
+
return { status: 'failed', reports: [], queued };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function queuedTitles(o: TesterFeedOptions): Promise<string[]> {
|
|
109
|
+
const titles: string[] = [];
|
|
110
|
+
for (const path of await o.queued()) {
|
|
111
|
+
const manifest = await readManifest(o.files, path);
|
|
112
|
+
const name = (path.split('/').pop() ?? path).replace(/\.zip$/, '');
|
|
113
|
+
titles.push(manifest && manifest.title.trim() ? manifest.title : name);
|
|
114
|
+
}
|
|
115
|
+
return titles;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ── what a card shows ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
/** Sent → received → reviewed → resolved. */
|
|
121
|
+
export const TRACK_STEPS = 4;
|
|
122
|
+
|
|
123
|
+
export type CardTone = 'warning' | 'info' | 'primary' | 'success' | 'muted';
|
|
124
|
+
|
|
125
|
+
export type CardIcon = 'upload' | 'processing' | 'review' | 'received' | 'filed' | 'done' | 'closed';
|
|
126
|
+
|
|
127
|
+
export interface TesterCard {
|
|
128
|
+
readonly code: string;
|
|
129
|
+
readonly title: string;
|
|
130
|
+
/** A package text key. */
|
|
131
|
+
readonly stateKey: string;
|
|
132
|
+
readonly outcomeKey: string | null;
|
|
133
|
+
readonly tone: CardTone;
|
|
134
|
+
readonly icon: CardIcon;
|
|
135
|
+
/** Steps of the track already walked (0..4). */
|
|
136
|
+
readonly step: number;
|
|
137
|
+
readonly inProgress: boolean;
|
|
138
|
+
readonly jiraKey: string | null;
|
|
139
|
+
readonly createdAtUtc: string | null;
|
|
140
|
+
readonly meta: string;
|
|
141
|
+
readonly mine: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const OUTCOME_KEY: Readonly<Record<string, string>> = {
|
|
145
|
+
[TesterReportOutcomes.jira]: 'TesterReportOutcomeJiraFormat',
|
|
146
|
+
[TesterReportOutcomes.fixedInCode]: 'TesterReportOutcomeFixedInCode',
|
|
147
|
+
[TesterReportOutcomes.notABug]: 'TesterReportOutcomeNotABug',
|
|
148
|
+
[TesterReportOutcomes.duplicate]: 'TesterReportOutcomeDuplicate',
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** The state a tester reads: what became of the report wins over where its processing is. */
|
|
152
|
+
export function describeReport(r: TesterFeedItem): TesterCard {
|
|
153
|
+
const outcomeKey = OUTCOME_KEY[r.outcome] ?? null;
|
|
154
|
+
// « | », not «·»: a Persian face draws a middle dot like a zero beside Persian digits.
|
|
155
|
+
const meta = [r.username, r.platform, r.appVersion ? `${r.appVersion}` : ''].filter((s) => s.trim().length > 0).join(' | ');
|
|
156
|
+
const jiraKey = r.outcome === TesterReportOutcomes.jira && r.jiraKey.trim() ? r.jiraKey : null;
|
|
157
|
+
const base = { code: r.code, title: r.title, outcomeKey, jiraKey, createdAtUtc: r.createdAtUtc || null, meta, mine: r.mine, inProgress: false };
|
|
158
|
+
if (r.state === TesterReportStates.deleted) return { ...base, stateKey: 'TesterReportStateDeleted', tone: 'muted', icon: 'closed', step: TRACK_STEPS };
|
|
159
|
+
if (outcomeKey) return { ...base, stateKey: outcomeKey, outcomeKey: null, tone: 'success', icon: r.outcome === TesterReportOutcomes.jira ? 'filed' : 'done', step: TRACK_STEPS };
|
|
160
|
+
switch (r.state) {
|
|
161
|
+
case TesterReportStates.uploading:
|
|
162
|
+
return { ...base, stateKey: 'TesterReportStateUploading', tone: 'warning', icon: 'upload', step: 1, inProgress: true };
|
|
163
|
+
case TesterReportStates.processing:
|
|
164
|
+
return { ...base, stateKey: 'TesterReportStateProcessing', tone: 'info', icon: 'processing', step: 2, inProgress: true };
|
|
165
|
+
case TesterReportStates.ready:
|
|
166
|
+
return { ...base, stateKey: 'TesterReportStateReady', tone: 'primary', icon: 'review', step: 3 };
|
|
167
|
+
default:
|
|
168
|
+
return { ...base, stateKey: 'TesterReportStateReceived', tone: 'primary', icon: 'received', step: 2 };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The four counts across the top: queued · in review · ready · resolved. */
|
|
173
|
+
export function summarize(feed: TesterFeed): { queued: number; review: number; ready: number; done: number } {
|
|
174
|
+
const s = { queued: feed.queued.length, review: 0, ready: 0, done: 0 };
|
|
175
|
+
for (const r of feed.reports) {
|
|
176
|
+
if (r.state === TesterReportStates.deleted || r.outcome) s.done++;
|
|
177
|
+
else if (r.state === TesterReportStates.uploading) s.queued++;
|
|
178
|
+
else if (r.state === TesterReportStates.ready) s.ready++;
|
|
179
|
+
else s.review++;
|
|
180
|
+
}
|
|
181
|
+
return s;
|
|
182
|
+
}
|
package/src/tester/gesture.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
// How the tester opens the capture panel (G9AppDiagnostic.Maui TesterGestureMode / TesterGestureService): by default a
|
|
2
|
-
// DOUBLE TAP WITH TWO FINGERS anywhere. The numbers are persisted by apps in the field: never renumber.
|
|
3
|
-
//
|
|
4
|
-
// The recogniser is native and CONSUMES the gesture (the platform package): the second tap cancels the touch for the
|
|
5
|
-
// views under it, so a map never zooms out twice and a list never takes it as a tap. It reports the gesture with its
|
|
6
|
-
// finger count and whether it landed on a surface the app excludes (a map in mode 1); this file decides, for a platform
|
|
7
|
-
// or a test that reports single taps only, whether two of them make one.
|
|
8
|
-
|
|
9
|
-
export const TesterGestureMode = {
|
|
10
|
-
/** Double tap with two fingers, on any screen. */
|
|
11
|
-
TwoFingers: 0,
|
|
12
|
-
/** The same, except on the surfaces the app names (a map, where a two-finger tap zooms out). */
|
|
13
|
-
TwoFingersExceptMap: 1,
|
|
14
|
-
/** Double tap with three fingers: no map conflict, but some phones take a three-finger swipe as a screenshot. */
|
|
15
|
-
ThreeFingers: 2,
|
|
16
|
-
} as const;
|
|
17
|
-
export type TesterGestureMode = (typeof TesterGestureMode)[keyof typeof TesterGestureMode];
|
|
18
|
-
|
|
19
|
-
export const TESTER_GESTURE_MODES: readonly TesterGestureMode[] = [TesterGestureMode.TwoFingers, TesterGestureMode.TwoFingersExceptMap, TesterGestureMode.ThreeFingers];
|
|
20
|
-
|
|
21
|
-
/** Longest gap between the two taps (MAUI MaxGapMs). */
|
|
22
|
-
export const MAX_GAP_MS = 450;
|
|
23
|
-
|
|
24
|
-
export const fingersFor = (mode: TesterGestureMode): number => (mode === TesterGestureMode.ThreeFingers ? 3 : 2);
|
|
25
|
-
|
|
26
|
-
/** A stored mode ("0", 2, garbage) → a mode; anything unknown is the default. */
|
|
27
|
-
export function parseGestureMode(value: unknown): TesterGestureMode {
|
|
28
|
-
const n = Number(value ?? TesterGestureMode.TwoFingers);
|
|
29
|
-
return (TESTER_GESTURE_MODES as readonly number[]).indexOf(n) >= 0 ? (n as TesterGestureMode) : TesterGestureMode.TwoFingers;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** One completed multi-finger tap (x, y: fractions of the window; `excluded`: on a surface the app excludes). */
|
|
33
|
-
export interface TesterTap {
|
|
34
|
-
readonly fingers: number;
|
|
35
|
-
readonly x: number;
|
|
36
|
-
readonly y: number;
|
|
37
|
-
readonly excluded: boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Whether a whole gesture the native recogniser reports counts in this mode. */
|
|
41
|
-
export function gestureCounts(fingers: number, excluded: boolean, mode: TesterGestureMode): boolean {
|
|
42
|
-
if (fingers < fingersFor(mode)) return false;
|
|
43
|
-
return !(mode === TesterGestureMode.TwoFingersExceptMap && excluded);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Pairs single taps into the gesture: true when `tap` is the second of two taps with the same finger count within
|
|
48
|
-
* {@link MAX_GAP_MS}. A third tap starts a new pair; it does not fire again.
|
|
49
|
-
*/
|
|
50
|
-
export function createTapPairer(now: () => number = Date.now): (tap: TesterTap, mode: TesterGestureMode) => boolean {
|
|
51
|
-
let lastMs = Number.NEGATIVE_INFINITY;
|
|
52
|
-
let lastFingers = 0;
|
|
53
|
-
return (tap, mode) => {
|
|
54
|
-
if (!gestureCounts(tap.fingers, tap.excluded, mode)) return false;
|
|
55
|
-
const t = now();
|
|
56
|
-
const fire = lastFingers === tap.fingers && t - lastMs <= MAX_GAP_MS;
|
|
57
|
-
lastMs = fire ? Number.NEGATIVE_INFINITY : t;
|
|
58
|
-
lastFingers = tap.fingers;
|
|
59
|
-
return fire;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
1
|
+
// How the tester opens the capture panel (G9AppDiagnostic.Maui TesterGestureMode / TesterGestureService): by default a
|
|
2
|
+
// DOUBLE TAP WITH TWO FINGERS anywhere. The numbers are persisted by apps in the field: never renumber.
|
|
3
|
+
//
|
|
4
|
+
// The recogniser is native and CONSUMES the gesture (the platform package): the second tap cancels the touch for the
|
|
5
|
+
// views under it, so a map never zooms out twice and a list never takes it as a tap. It reports the gesture with its
|
|
6
|
+
// finger count and whether it landed on a surface the app excludes (a map in mode 1); this file decides, for a platform
|
|
7
|
+
// or a test that reports single taps only, whether two of them make one.
|
|
8
|
+
|
|
9
|
+
export const TesterGestureMode = {
|
|
10
|
+
/** Double tap with two fingers, on any screen. */
|
|
11
|
+
TwoFingers: 0,
|
|
12
|
+
/** The same, except on the surfaces the app names (a map, where a two-finger tap zooms out). */
|
|
13
|
+
TwoFingersExceptMap: 1,
|
|
14
|
+
/** Double tap with three fingers: no map conflict, but some phones take a three-finger swipe as a screenshot. */
|
|
15
|
+
ThreeFingers: 2,
|
|
16
|
+
} as const;
|
|
17
|
+
export type TesterGestureMode = (typeof TesterGestureMode)[keyof typeof TesterGestureMode];
|
|
18
|
+
|
|
19
|
+
export const TESTER_GESTURE_MODES: readonly TesterGestureMode[] = [TesterGestureMode.TwoFingers, TesterGestureMode.TwoFingersExceptMap, TesterGestureMode.ThreeFingers];
|
|
20
|
+
|
|
21
|
+
/** Longest gap between the two taps (MAUI MaxGapMs). */
|
|
22
|
+
export const MAX_GAP_MS = 450;
|
|
23
|
+
|
|
24
|
+
export const fingersFor = (mode: TesterGestureMode): number => (mode === TesterGestureMode.ThreeFingers ? 3 : 2);
|
|
25
|
+
|
|
26
|
+
/** A stored mode ("0", 2, garbage) → a mode; anything unknown is the default. */
|
|
27
|
+
export function parseGestureMode(value: unknown): TesterGestureMode {
|
|
28
|
+
const n = Number(value ?? TesterGestureMode.TwoFingers);
|
|
29
|
+
return (TESTER_GESTURE_MODES as readonly number[]).indexOf(n) >= 0 ? (n as TesterGestureMode) : TesterGestureMode.TwoFingers;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** One completed multi-finger tap (x, y: fractions of the window; `excluded`: on a surface the app excludes). */
|
|
33
|
+
export interface TesterTap {
|
|
34
|
+
readonly fingers: number;
|
|
35
|
+
readonly x: number;
|
|
36
|
+
readonly y: number;
|
|
37
|
+
readonly excluded: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Whether a whole gesture the native recogniser reports counts in this mode. */
|
|
41
|
+
export function gestureCounts(fingers: number, excluded: boolean, mode: TesterGestureMode): boolean {
|
|
42
|
+
if (fingers < fingersFor(mode)) return false;
|
|
43
|
+
return !(mode === TesterGestureMode.TwoFingersExceptMap && excluded);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Pairs single taps into the gesture: true when `tap` is the second of two taps with the same finger count within
|
|
48
|
+
* {@link MAX_GAP_MS}. A third tap starts a new pair; it does not fire again.
|
|
49
|
+
*/
|
|
50
|
+
export function createTapPairer(now: () => number = Date.now): (tap: TesterTap, mode: TesterGestureMode) => boolean {
|
|
51
|
+
let lastMs = Number.NEGATIVE_INFINITY;
|
|
52
|
+
let lastFingers = 0;
|
|
53
|
+
return (tap, mode) => {
|
|
54
|
+
if (!gestureCounts(tap.fingers, tap.excluded, mode)) return false;
|
|
55
|
+
const t = now();
|
|
56
|
+
const fire = lastFingers === tap.fingers && t - lastMs <= MAX_GAP_MS;
|
|
57
|
+
lastMs = fire ? Number.NEGATIVE_INFINITY : t;
|
|
58
|
+
lastFingers = tap.fingers;
|
|
59
|
+
return fire;
|
|
60
|
+
};
|
|
61
|
+
}
|