@vehicle-sil/gui-client 0.2.0-rc.2 → 0.2.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.ja.md +4 -0
- package/README.md +4 -0
- package/dist/index.js +86 -50
- package/package.json +1 -1
- package/types/front-actions.d.ts +6 -5
- package/types/front-types.d.ts +7 -5
- package/types/index.d.ts +1 -1
- package/types/protocol/server.d.ts +4 -2
- package/types/session-state.d.ts +2 -0
- package/types/session.d.ts +8 -8
- package/types/time.d.ts +4 -2
package/README.ja.md
CHANGED
|
@@ -147,6 +147,10 @@ editor.setVisible(true);
|
|
|
147
147
|
| 型 | `TimeState`、`TimeFailure`、`Lateness`、`SendResult`、`NotSentReason` |
|
|
148
148
|
| 定数 | `ANSWER_TIMEOUT_MS` |
|
|
149
149
|
|
|
150
|
+
`front.time` と `client.time` は、把握している実行 ID とサーバーの識別子をコマンドに付けます。実行が切り替わった場合、サーバーはランチャーに送る前にコマンドを拒否します。この指定に対応していないサーバーはリクエストを拒否します。
|
|
151
|
+
|
|
152
|
+
画面は、操作ボタンなどを描画した時点の `RunTarget` を `front.time` に渡せます。その対象が現在の実行と一致しなければ、クライアントが操作を拒否します。
|
|
153
|
+
|
|
150
154
|
### ECU の変数
|
|
151
155
|
|
|
152
156
|
| 種類 | 名前 |
|
package/README.md
CHANGED
|
@@ -147,6 +147,10 @@ The `currentTarget()` method returns the current `{session, instance}` pair, or
|
|
|
147
147
|
| Type | `TimeState`, `TimeFailure`, `Lateness`, `SendResult`, `NotSentReason` |
|
|
148
148
|
| Constant | `ANSWER_TIMEOUT_MS` |
|
|
149
149
|
|
|
150
|
+
Both `front.time` and `client.time` send commands with the known run ID and server instance. If the run is replaced, the server rejects the command before sending it to a launcher. Older servers that do not accept these fields reject the request.
|
|
151
|
+
|
|
152
|
+
A screen can pass the `RunTarget` it captured when rendering a control to `front.time`. The client rejects the action if that target no longer matches the current run.
|
|
153
|
+
|
|
150
154
|
### ECU variable API
|
|
151
155
|
|
|
152
156
|
| Kind | Name |
|
package/dist/index.js
CHANGED
|
@@ -1193,6 +1193,7 @@ var readSessionSummary = (value, path) => {
|
|
|
1193
1193
|
const u = new Unreadable(path);
|
|
1194
1194
|
const time = field(f, path, "time", soft(nullable(object), null, u));
|
|
1195
1195
|
const timePath = `${path}.time`;
|
|
1196
|
+
const stopAt = field(f, path, "stop_at_ms", soft(nullable(integer), void 0, u));
|
|
1196
1197
|
const summary = {
|
|
1197
1198
|
id: field(f, path, "id", integer),
|
|
1198
1199
|
...f["snapshot_rev"] === void 0 ? {} : { snapshot_rev: field(f, path, "snapshot_rev", soft(nullable(integer), null, u)) },
|
|
@@ -1243,6 +1244,7 @@ var readSessionSummary = (value, path) => {
|
|
|
1243
1244
|
)
|
|
1244
1245
|
),
|
|
1245
1246
|
allowed: field(f, path, "allowed", soft(nullable(readServerAllowed), null, u)),
|
|
1247
|
+
...stopAt === void 0 ? {} : { stop_at_ms: stopAt },
|
|
1246
1248
|
check: field(
|
|
1247
1249
|
f,
|
|
1248
1250
|
path,
|
|
@@ -2145,6 +2147,7 @@ function applySummary(session, summary, force = false, controlOnly = false) {
|
|
|
2145
2147
|
const next = staleControl ? session : {
|
|
2146
2148
|
...session,
|
|
2147
2149
|
...incomingRev === null ? {} : { snapshotRev: incomingRev },
|
|
2150
|
+
...summary.stop_at_ms === void 0 ? {} : { stopAtMs: summary.stop_at_ms },
|
|
2148
2151
|
...summary.problem_seq == null ? {} : { problemSeq: Math.max(session.problemSeq ?? 0, summary.problem_seq) },
|
|
2149
2152
|
launcher,
|
|
2150
2153
|
stopRequests: Math.max(session.stopRequests, stopRequestsOf(summary.stop)),
|
|
@@ -2607,6 +2610,9 @@ function blankParticipant(name) {
|
|
|
2607
2610
|
// ../client/src/session.ts
|
|
2608
2611
|
var MAX_NOTICES = 20;
|
|
2609
2612
|
var STALE_EVENTS_NOTICE = "events came with a seq that is not after the last one, and were not shown (the launcher wrote them out of order, or the server sent them again)";
|
|
2613
|
+
function sameRunTarget(left, right) {
|
|
2614
|
+
return left !== null && right !== null && left.session === right.session && left.instance === right.instance;
|
|
2615
|
+
}
|
|
2610
2616
|
var SessionFeed = class {
|
|
2611
2617
|
constructor(connection, onError = rethrowLater) {
|
|
2612
2618
|
this.connection = connection;
|
|
@@ -3003,15 +3009,20 @@ var SessionFeed = class {
|
|
|
3003
3009
|
// ../client/src/time.ts
|
|
3004
3010
|
var ANSWER_TIMEOUT_MS = 5e3;
|
|
3005
3011
|
var TimeControl = class {
|
|
3006
|
-
constructor(session, transport, answerTimeoutMs = ANSWER_TIMEOUT_MS, onError = rethrowLater) {
|
|
3012
|
+
constructor(session, transport, currentTarget, answerTimeoutMs = ANSWER_TIMEOUT_MS, onError = rethrowLater) {
|
|
3007
3013
|
this.session = session;
|
|
3008
3014
|
this.transport = transport;
|
|
3015
|
+
this.currentTarget = currentTarget;
|
|
3009
3016
|
this.answerTimeoutMs = answerTimeoutMs;
|
|
3010
|
-
this.
|
|
3017
|
+
this.awaitingHttp = new Writable(null, Object.is, onError);
|
|
3011
3018
|
this.pending = new Writable(null, Object.is, onError);
|
|
3012
|
-
this.failureValue = new Writable(
|
|
3019
|
+
this.failureValue = new Writable(
|
|
3020
|
+
null,
|
|
3021
|
+
Object.is,
|
|
3022
|
+
onError
|
|
3023
|
+
);
|
|
3013
3024
|
this.state = derived(
|
|
3014
|
-
[session, this.
|
|
3025
|
+
[session, this.awaitingHttp, this.pending, this.failureValue],
|
|
3015
3026
|
() => this.compute(session.get()),
|
|
3016
3027
|
shallowEqual,
|
|
3017
3028
|
onError
|
|
@@ -3019,8 +3030,9 @@ var TimeControl = class {
|
|
|
3019
3030
|
}
|
|
3020
3031
|
session;
|
|
3021
3032
|
transport;
|
|
3033
|
+
currentTarget;
|
|
3022
3034
|
answerTimeoutMs;
|
|
3023
|
-
|
|
3035
|
+
awaitingHttp;
|
|
3024
3036
|
pending;
|
|
3025
3037
|
failureValue;
|
|
3026
3038
|
answerTimer;
|
|
@@ -3051,46 +3063,58 @@ var TimeControl = class {
|
|
|
3051
3063
|
*/
|
|
3052
3064
|
send(command) {
|
|
3053
3065
|
const session = this.session.get();
|
|
3054
|
-
|
|
3066
|
+
const target = this.currentTarget();
|
|
3067
|
+
if (!session || target?.session !== session.id) return { sent: false, reason: "no-session" };
|
|
3055
3068
|
if (this.state.get().sending !== null) return { sent: false, reason: "waiting" };
|
|
3056
3069
|
this.failureValue.set(null);
|
|
3057
3070
|
const pending = {
|
|
3058
3071
|
command: command.command,
|
|
3059
|
-
|
|
3072
|
+
target,
|
|
3060
3073
|
afterSeq: session.lastCommand?.seq ?? -1
|
|
3061
3074
|
};
|
|
3075
|
+
this.awaitingHttp.set(pending);
|
|
3062
3076
|
this.pending.set(pending);
|
|
3063
|
-
this.inFlight.update((n) => n + 1);
|
|
3064
3077
|
clearTimeout(this.answerTimer);
|
|
3065
3078
|
this.answerTimer = setTimeout(() => this.giveUp(pending), this.answerTimeoutMs);
|
|
3066
|
-
this.transport(
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3079
|
+
this.transport(
|
|
3080
|
+
{ method: "POST", path: "api/time", body: { ...command, ...target } },
|
|
3081
|
+
(outcome) => {
|
|
3082
|
+
if (this.awaitingHttp.get() === pending) this.awaitingHttp.set(null);
|
|
3083
|
+
if (outcome.ok || this.pending.get() !== pending) return;
|
|
3084
|
+
clearTimeout(this.answerTimer);
|
|
3085
|
+
this.pending.set(null);
|
|
3086
|
+
if (!sameRunTarget(this.currentTarget(), target)) return;
|
|
3087
|
+
this.failureValue.set({
|
|
3088
|
+
target,
|
|
3089
|
+
report: {
|
|
3090
|
+
kind: "server",
|
|
3091
|
+
message: errorMessage(outcome.error),
|
|
3092
|
+
command: pending.command,
|
|
3093
|
+
session: target.session
|
|
3094
|
+
}
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
);
|
|
3078
3098
|
return { sent: true };
|
|
3079
3099
|
}
|
|
3080
3100
|
/** Stops the wait timer and stops waiting for the answer (when the client closes). */
|
|
3081
3101
|
dispose() {
|
|
3082
3102
|
clearTimeout(this.answerTimer);
|
|
3083
3103
|
this.pending.set(null);
|
|
3104
|
+
this.awaitingHttp.set(null);
|
|
3084
3105
|
}
|
|
3085
3106
|
/** The answer timed out: if no answer has come yet, stop waiting and say so. */
|
|
3086
3107
|
giveUp(pending) {
|
|
3087
3108
|
if (this.pending.get() !== pending || this.state.get().sending === null) return;
|
|
3088
3109
|
this.pending.set(null);
|
|
3089
3110
|
this.failureValue.set({
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3111
|
+
target: pending.target,
|
|
3112
|
+
report: {
|
|
3113
|
+
kind: "no-answer",
|
|
3114
|
+
message: `the launcher did not answer the command (${pending.command}) within ${this.answerTimeoutMs / 1e3} s; it may not read its input. You can send it again.`,
|
|
3115
|
+
command: pending.command,
|
|
3116
|
+
session: pending.target.session
|
|
3117
|
+
}
|
|
3094
3118
|
});
|
|
3095
3119
|
}
|
|
3096
3120
|
compute(session) {
|
|
@@ -3107,10 +3131,11 @@ var TimeControl = class {
|
|
|
3107
3131
|
this.lastLateness = lateness;
|
|
3108
3132
|
const lastCommand = session?.lastCommand ?? null;
|
|
3109
3133
|
const pending = this.pending.get();
|
|
3134
|
+
const target = this.currentTarget();
|
|
3110
3135
|
let sending = null;
|
|
3111
|
-
if (pending) {
|
|
3112
|
-
const answered = !session ||
|
|
3113
|
-
sending = this.
|
|
3136
|
+
if (pending && sameRunTarget(pending.target, target)) {
|
|
3137
|
+
const answered = !session || !session.launcher.running || (session.lastCommand?.seq ?? -1) > pending.afterSeq;
|
|
3138
|
+
sending = this.awaitingHttp.get() === pending || !answered ? pending.command : null;
|
|
3114
3139
|
}
|
|
3115
3140
|
const failure = this.failureValue.get();
|
|
3116
3141
|
return {
|
|
@@ -3120,7 +3145,7 @@ var TimeControl = class {
|
|
|
3120
3145
|
behind: (lateness?.lateSteps ?? 0) > 0,
|
|
3121
3146
|
lastCommand,
|
|
3122
3147
|
sending,
|
|
3123
|
-
failure: failure && failure.
|
|
3148
|
+
failure: failure && sameRunTarget(failure.target, target) ? failure.report : null
|
|
3124
3149
|
};
|
|
3125
3150
|
}
|
|
3126
3151
|
};
|
|
@@ -4499,6 +4524,7 @@ function buildClient(options) {
|
|
|
4499
4524
|
const time = new TimeControl(
|
|
4500
4525
|
session.session,
|
|
4501
4526
|
http,
|
|
4527
|
+
() => session.currentTarget(),
|
|
4502
4528
|
options.answerTimeoutMs ?? ANSWER_TIMEOUT_MS,
|
|
4503
4529
|
onError
|
|
4504
4530
|
);
|
|
@@ -5288,13 +5314,13 @@ var FrontActions = class {
|
|
|
5288
5314
|
);
|
|
5289
5315
|
}
|
|
5290
5316
|
// --- time --------------------------------------------------------------------------------------
|
|
5291
|
-
pause() {
|
|
5292
|
-
return this.time("pause", { command: "pause" }, 0);
|
|
5317
|
+
pause(target) {
|
|
5318
|
+
return this.time("pause", { command: "pause" }, 0, target);
|
|
5293
5319
|
}
|
|
5294
|
-
resume() {
|
|
5295
|
-
return this.time("resume", { command: "resume" }, 0);
|
|
5320
|
+
resume(target) {
|
|
5321
|
+
return this.time("resume", { command: "resume" }, 0, target);
|
|
5296
5322
|
}
|
|
5297
|
-
step(ms) {
|
|
5323
|
+
step(ms, target) {
|
|
5298
5324
|
if (!Number.isFinite(ms) || ms <= 0) {
|
|
5299
5325
|
return this.fail(
|
|
5300
5326
|
new ActionError(
|
|
@@ -5304,9 +5330,9 @@ var FrontActions = class {
|
|
|
5304
5330
|
)
|
|
5305
5331
|
);
|
|
5306
5332
|
}
|
|
5307
|
-
return this.time("step", { command: "step", ms }, ms);
|
|
5333
|
+
return this.time("step", { command: "step", ms }, ms, target);
|
|
5308
5334
|
}
|
|
5309
|
-
setSpeed(value) {
|
|
5335
|
+
setSpeed(value, target) {
|
|
5310
5336
|
if (value !== "max" && !(Number.isFinite(value) && value > 0)) {
|
|
5311
5337
|
return this.fail(
|
|
5312
5338
|
new ActionError(
|
|
@@ -5316,9 +5342,9 @@ var FrontActions = class {
|
|
|
5316
5342
|
)
|
|
5317
5343
|
);
|
|
5318
5344
|
}
|
|
5319
|
-
return this.time("speed", { command: "speed", value }, 0);
|
|
5345
|
+
return this.time("speed", { command: "speed", value }, 0, target);
|
|
5320
5346
|
}
|
|
5321
|
-
runUntil(ms) {
|
|
5347
|
+
runUntil(ms, target) {
|
|
5322
5348
|
if (!Number.isFinite(ms) || ms < 0) {
|
|
5323
5349
|
return this.fail(
|
|
5324
5350
|
new ActionError(
|
|
@@ -5328,26 +5354,32 @@ var FrontActions = class {
|
|
|
5328
5354
|
)
|
|
5329
5355
|
);
|
|
5330
5356
|
}
|
|
5331
|
-
return this.time("run_until", { command: "run_until", at_ms: ms }, ms);
|
|
5357
|
+
return this.time("run_until", { command: "run_until", at_ms: ms }, ms, target);
|
|
5332
5358
|
}
|
|
5333
|
-
time(op, body, amount) {
|
|
5359
|
+
time(op, body, amount, shownTarget) {
|
|
5360
|
+
const target = this.src.low.session.currentTarget();
|
|
5334
5361
|
this.failureValue.set(null);
|
|
5335
5362
|
const snapshot = this.src.snapshot();
|
|
5336
5363
|
const link = linkOf(snapshot);
|
|
5337
5364
|
const own = link === "rejected" || link === "incompatible" ? this.src.controls()[op].reason : this.busyValue.get().has(op) ? { code: "busy", message: `the previous ${op} has not been answered yet: wait for it` } : null;
|
|
5338
5365
|
if (own) return this.fail(new ActionError(own.code, own.message, "refused"));
|
|
5366
|
+
if (shownTarget !== void 0 && !sameRunTarget(shownTarget, target))
|
|
5367
|
+
return this.fail(
|
|
5368
|
+
new ActionError("session-changed", "the displayed run has changed", "refused")
|
|
5369
|
+
);
|
|
5370
|
+
if (!target)
|
|
5371
|
+
return this.fail(new ActionError("not-running", "there is no identified run", "refused"));
|
|
5339
5372
|
const code = this.src.controls()[op === "pause" ? "pause" : "resume"].reason?.code;
|
|
5340
5373
|
if (op === "pause" && code === "paused" || op === "resume" && code === "not-paused") {
|
|
5341
5374
|
return Promise.resolve();
|
|
5342
5375
|
}
|
|
5343
|
-
const session = snapshot.session;
|
|
5344
5376
|
const id = this.nextId++;
|
|
5345
5377
|
return new Promise((resolve, reject) => {
|
|
5346
5378
|
const waiting = {
|
|
5347
5379
|
id,
|
|
5348
5380
|
op,
|
|
5349
5381
|
amount,
|
|
5350
|
-
|
|
5382
|
+
...target,
|
|
5351
5383
|
stage: "sent",
|
|
5352
5384
|
target: 0,
|
|
5353
5385
|
from: 0,
|
|
@@ -5368,9 +5400,12 @@ var FrontActions = class {
|
|
|
5368
5400
|
)
|
|
5369
5401
|
);
|
|
5370
5402
|
}, this.src.answerTimeoutMs);
|
|
5371
|
-
this.src.http(
|
|
5372
|
-
|
|
5373
|
-
|
|
5403
|
+
this.src.http(
|
|
5404
|
+
{ method: "POST", path: "api/time", body: { ...body, id, ...target } },
|
|
5405
|
+
(outcome) => {
|
|
5406
|
+
if (!outcome.ok) this.settle(waiting, actionError(outcome.error));
|
|
5407
|
+
}
|
|
5408
|
+
);
|
|
5374
5409
|
});
|
|
5375
5410
|
}
|
|
5376
5411
|
/** Ends a waiting command: with an error, or (null) as done. A command ended twice is ended once. */
|
|
@@ -5462,8 +5497,9 @@ var FrontActions = class {
|
|
|
5462
5497
|
evaluate() {
|
|
5463
5498
|
if (this.waiting.size === 0) return;
|
|
5464
5499
|
const session = this.src.low.session.session.get();
|
|
5500
|
+
const instance = this.src.low.session.currentInstance();
|
|
5465
5501
|
for (const w of [...this.waiting.values()]) {
|
|
5466
|
-
if (!session || session.id !== w.session || !session.launcher.running || session.result) {
|
|
5502
|
+
if (!session || session.id !== w.session || instance !== w.instance || !session.launcher.running || session.result) {
|
|
5467
5503
|
this.settle(
|
|
5468
5504
|
w,
|
|
5469
5505
|
new ActionError(
|
|
@@ -5932,11 +5968,11 @@ function makeFront(options, onClose) {
|
|
|
5932
5968
|
forceStop: (target) => actions.forceStop(target)
|
|
5933
5969
|
},
|
|
5934
5970
|
time: {
|
|
5935
|
-
pause: () => actions.pause(),
|
|
5936
|
-
resume: () => actions.resume(),
|
|
5937
|
-
step: (ms) => actions.step(ms),
|
|
5938
|
-
setSpeed: (value) => actions.setSpeed(value),
|
|
5939
|
-
runUntil: (ms) => actions.runUntil(ms)
|
|
5971
|
+
pause: (target) => actions.pause(target),
|
|
5972
|
+
resume: (target) => actions.resume(target),
|
|
5973
|
+
step: (ms, target) => actions.step(ms, target),
|
|
5974
|
+
setSpeed: (value, target) => actions.setSpeed(value, target),
|
|
5975
|
+
runUntil: (ms, target) => actions.runUntil(ms, target)
|
|
5940
5976
|
},
|
|
5941
5977
|
variable: (ref) => {
|
|
5942
5978
|
const named = refOf(ref);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vehicle-sil/gui-client",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Client library of the vehicle-sil GUI server: connection, run and time control, ECU variables. No dependencies; browser and Node.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/types/front-actions.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { FrontControls, Intent, OperationName, RunState } from './front-typ
|
|
|
4
4
|
import { ActionError } from './front-types.js';
|
|
5
5
|
import type { Snapshot } from './front-compose.js';
|
|
6
6
|
import type { StopCapture } from './run.js';
|
|
7
|
+
import { type RunTarget } from './session.js';
|
|
7
8
|
import type { CheckResult, ConfigText, SavedConfig } from './protocol.js';
|
|
8
9
|
import { ErrorSink, Readable } from './values.js';
|
|
9
10
|
/** A failed action, kept for `status.problem`. */
|
|
@@ -105,11 +106,11 @@ export declare class FrontActions {
|
|
|
105
106
|
/** Repeated requests for the same run share one operation. */
|
|
106
107
|
private once;
|
|
107
108
|
private guarded;
|
|
108
|
-
pause(): Promise<void>;
|
|
109
|
-
resume(): Promise<void>;
|
|
110
|
-
step(ms: number): Promise<void>;
|
|
111
|
-
setSpeed(value: number | 'max'): Promise<void>;
|
|
112
|
-
runUntil(ms: number): Promise<void>;
|
|
109
|
+
pause(target?: RunTarget | null): Promise<void>;
|
|
110
|
+
resume(target?: RunTarget | null): Promise<void>;
|
|
111
|
+
step(ms: number, target?: RunTarget | null): Promise<void>;
|
|
112
|
+
setSpeed(value: number | 'max', target?: RunTarget | null): Promise<void>;
|
|
113
|
+
runUntil(ms: number, target?: RunTarget | null): Promise<void>;
|
|
113
114
|
private time;
|
|
114
115
|
/** Ends a waiting command: with an error, or (null) as done. A command ended twice is ended once. */
|
|
115
116
|
private settle;
|
package/types/front-types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GuiClient } from './client.js';
|
|
2
|
+
import type { RunTarget } from './session.js';
|
|
2
3
|
import type { CheckResult, ConfigText, SavedConfig, Finding, OutsideState, RunEnd, ScenarioFile, ScenarioStatus, ScenarioStep } from './protocol.js';
|
|
3
4
|
import type { ValueCondition, WriteBlock, WriteStatus } from './variable-state.js';
|
|
4
5
|
import type { VariableRef, VariableValue } from './variables.js';
|
|
@@ -213,13 +214,14 @@ export interface FrontRun {
|
|
|
213
214
|
* Time operations. `pause`, `resume` and `setSpeed` resolve when the launcher has answered; `step` and `runUntil`
|
|
214
215
|
* resolve when time has arrived and the run is paused again (read `clock` after `await`). Another command sent before
|
|
215
216
|
* it arrives (from this page, another page or stdin) rejects it with `interrupted`.
|
|
217
|
+
* Pass the target from the rendered view to refuse the operation if the run changes before dispatch.
|
|
216
218
|
*/
|
|
217
219
|
export interface FrontTime {
|
|
218
|
-
pause(): Promise<void>;
|
|
219
|
-
resume(): Promise<void>;
|
|
220
|
-
step(ms: number): Promise<void>;
|
|
221
|
-
setSpeed(value: number | 'max'): Promise<void>;
|
|
222
|
-
runUntil(ms: number): Promise<void>;
|
|
220
|
+
pause(target?: RunTarget | null): Promise<void>;
|
|
221
|
+
resume(target?: RunTarget | null): Promise<void>;
|
|
222
|
+
step(ms: number, target?: RunTarget | null): Promise<void>;
|
|
223
|
+
setSpeed(value: number | 'max', target?: RunTarget | null): Promise<void>;
|
|
224
|
+
runUntil(ms: number, target?: RunTarget | null): Promise<void>;
|
|
223
225
|
}
|
|
224
226
|
/** What a screen shows for one variable. */
|
|
225
227
|
export interface VariableView {
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { DEFAULT_LIMITS, createClient } from './client.js';
|
|
2
2
|
export type { ClientOptions, GuiClient } from './client.js';
|
|
3
3
|
export type { ClientConnection, CloseInfo, ConnectionState } from './connection.js';
|
|
4
|
-
export type { ClientSession, Notice } from './session.js';
|
|
4
|
+
export type { ClientSession, Notice, RunTarget } from './session.js';
|
|
5
5
|
export type { ClientRun, StopAction } from './run.js';
|
|
6
6
|
export type { ClientTime, Lateness, NotSentReason, SendResult, TimeFailure, TimeState, } from './time.js';
|
|
7
7
|
export { ANSWER_TIMEOUT_MS } from './time.js';
|
|
@@ -355,6 +355,8 @@ export interface SessionSummary {
|
|
|
355
355
|
* that asked for `session_without_check` lack the field and read it as null (the local check result is used as is).
|
|
356
356
|
*/
|
|
357
357
|
check: CheckResult | null;
|
|
358
|
+
/** The checked stop time when the full check was too large to keep. */
|
|
359
|
+
stop_at_ms?: number | null;
|
|
358
360
|
participants: SummaryParticipant[];
|
|
359
361
|
findings: Finding[];
|
|
360
362
|
result: RunResult | null;
|
|
@@ -453,8 +455,8 @@ export interface StopSessionRequestBody extends StopRequestBody {
|
|
|
453
455
|
/** Names of the time commands (the launcher's stdin commands other than stop). */
|
|
454
456
|
export type TimeCommandName = 'pause' | 'resume' | 'step' | 'run_until' | 'speed';
|
|
455
457
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
+
* The command sent in POST api/time. The GUI Client adds the run's session and server instance to the request.
|
|
459
|
+
* The server passes the command to the launcher as one line. The answer arrives as a command event.
|
|
458
460
|
*/
|
|
459
461
|
export type TimeCommand = ({
|
|
460
462
|
command: 'pause';
|
package/types/session-state.d.ts
CHANGED
|
@@ -205,6 +205,8 @@ export interface SessionView {
|
|
|
205
205
|
/** Position of the last known phase received (so an unknown phase never moves the phase backwards). */
|
|
206
206
|
phaseRank: number;
|
|
207
207
|
check: CheckResult | null;
|
|
208
|
+
/** The checked stop time when the full check was too large to keep. */
|
|
209
|
+
stopAtMs?: number | null;
|
|
208
210
|
participants: readonly ParticipantView[];
|
|
209
211
|
/** Log lines (in seq order). */
|
|
210
212
|
logs: readonly LogLine[];
|
package/types/session.d.ts
CHANGED
|
@@ -19,15 +19,18 @@ export interface Notice {
|
|
|
19
19
|
/** How many times the same text arrived. */
|
|
20
20
|
count: number;
|
|
21
21
|
}
|
|
22
|
+
/** Identity of one run across all starts of the server. */
|
|
23
|
+
export interface RunTarget {
|
|
24
|
+
session: number;
|
|
25
|
+
instance: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function sameRunTarget(left: RunTarget | null, right: RunTarget | null): boolean;
|
|
22
28
|
/** Read side of the session copy (GuiClient.session). */
|
|
23
29
|
export interface ClientSession {
|
|
24
30
|
/** The current (or last) session. null while the server has none yet. */
|
|
25
31
|
readonly session: Readable<SessionView | null>;
|
|
26
32
|
/** Identity of the session suitable for a targeted action. */
|
|
27
|
-
currentTarget():
|
|
28
|
-
session: number;
|
|
29
|
-
instance: string;
|
|
30
|
-
} | null;
|
|
33
|
+
currentTarget(): RunTarget | null;
|
|
31
34
|
/** The last authenticated server instance, even when there is no session. */
|
|
32
35
|
currentInstance(): string | null;
|
|
33
36
|
/**
|
|
@@ -140,10 +143,7 @@ export declare class SessionFeed implements ClientSession {
|
|
|
140
143
|
onInstance(listener: (instance: string, current: () => boolean) => void): void;
|
|
141
144
|
/** Instance associated with the current session, or null if its origin is not known. */
|
|
142
145
|
currentInstance(): string | null;
|
|
143
|
-
currentTarget():
|
|
144
|
-
session: number;
|
|
145
|
-
instance: string;
|
|
146
|
-
} | null;
|
|
146
|
+
currentTarget(): RunTarget | null;
|
|
147
147
|
adopt(summary: SessionSummary | null, instance: string, resyncFrom?: string | null): Adoption | null;
|
|
148
148
|
sameRun(adoption: Adoption): boolean;
|
|
149
149
|
isCurrent(revision: number): boolean;
|
package/types/time.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpTransport } from './http.js';
|
|
2
2
|
import { TimeCommand, TimeCommandName } from './protocol.js';
|
|
3
|
+
import { type RunTarget } from './session.js';
|
|
3
4
|
import { CommandView, SessionView, TimeView } from './session-state.js';
|
|
4
5
|
import { ErrorSink, Readable } from './values.js';
|
|
5
6
|
/**
|
|
@@ -98,16 +99,17 @@ export interface ClientTime {
|
|
|
98
99
|
export declare class TimeControl implements ClientTime {
|
|
99
100
|
private readonly session;
|
|
100
101
|
private readonly transport;
|
|
102
|
+
private readonly currentTarget;
|
|
101
103
|
/** How long to wait for an answer (ms). */
|
|
102
104
|
readonly answerTimeoutMs: number;
|
|
103
|
-
private readonly
|
|
105
|
+
private readonly awaitingHttp;
|
|
104
106
|
private readonly pending;
|
|
105
107
|
private readonly failureValue;
|
|
106
108
|
private answerTimer;
|
|
107
109
|
private lastLateness;
|
|
108
110
|
/** Time state. */
|
|
109
111
|
readonly state: Readable<TimeState>;
|
|
110
|
-
constructor(session: Readable<SessionView | null>, transport: HttpTransport,
|
|
112
|
+
constructor(session: Readable<SessionView | null>, transport: HttpTransport, currentTarget: () => RunTarget | null,
|
|
111
113
|
/** How long to wait for an answer (ms). */
|
|
112
114
|
answerTimeoutMs?: number, onError?: ErrorSink);
|
|
113
115
|
pause(): SendResult;
|