rig-review 2.12.0 → 2.13.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/docs/DESIGN.md +82 -71
- package/docs/PANELS.md +20 -12
- package/docs/PARTS_VIEW.md +31 -11
- package/docs/REVIEW_PACKAGE.md +99 -9
- package/docs/STABILITY.md +74 -3
- package/docs/WORKFLOWS.md +40 -12
- package/package.json +2 -1
- package/skills/rig-review/SKILL.md +29 -1
- package/src/build.ts +10 -2
- package/src/cli.ts +14 -12
- package/src/compare-html.ts +22 -24
- package/src/compare-server.ts +1 -1
- package/src/create-pin-gate.ts +3 -0
- package/src/feedback-export.ts +49 -1
- package/src/front.ts +10 -16
- package/src/interview-routes.ts +1 -1
- package/src/job-act.ts +39 -21
- package/src/job-api.ts +102 -11
- package/src/job-contract.ts +44 -4
- package/src/job-front.ts +15 -7
- package/src/job-host.ts +4 -3
- package/src/job-hub.ts +4 -4
- package/src/job-session.ts +5 -2
- package/src/job-source.ts +42 -13
- package/src/joined-project.ts +61 -4
- package/src/open-workspace.ts +12 -12
- package/src/open.ts +17 -9
- package/src/parts-comment.ts +31 -1
- package/src/parts-server.ts +19 -7
- package/src/parts-view.ts +71 -20
- package/src/server.ts +30 -21
- package/src/stage-comment.ts +11 -1
- package/src/stage-parts.ts +18 -10
- package/web/animation-inspection.ts +1 -1
- package/web/bones-panel.ts +1 -3
- package/web/catalog-en.ts +76 -12
- package/web/catalog-ko.ts +76 -12
- package/web/cloth-panel.ts +1 -2
- package/web/compare.css +3 -9
- package/web/compare.html +3 -3
- package/web/compare.ts +69 -64
- package/web/cuts-panel.ts +1 -3
- package/web/density-strip-panel.ts +1 -2
- package/web/i18n.ts +13 -1
- package/web/idle-panel.ts +1 -2
- package/web/index.html +1 -5
- package/web/inspection-persistence.ts +2 -1
- package/web/inspector-blocks.ts +144 -39
- package/web/instance-access.ts +24 -5
- package/web/interview-panel.ts +224 -175
- package/web/job-hub.ts +50 -69
- package/web/job-rig-capture.ts +103 -10
- package/web/job-rig-screen.ts +317 -0
- package/web/job-session.ts +927 -1365
- package/web/main.ts +535 -129
- package/web/mesh-panel.ts +1 -2
- package/web/owner-workspace.ts +88 -109
- package/web/part-selection.ts +47 -6
- package/web/part-thumbnails.ts +20 -6
- package/web/parts-viewport-provider.ts +166 -9
- package/web/physics-panel.ts +1 -2
- package/web/readings-panel.ts +1 -2
- package/web/requirements-panel.ts +1 -3
- package/web/retained-frame-stage.ts +105 -0
- package/web/retarget-panel.ts +2 -3
- package/web/rig-fields-panel.ts +1 -2
- package/web/rig-host.ts +62 -0
- package/web/rig-viewport-provider.ts +63 -16
- package/web/stage-comments.ts +29 -26
- package/web/styles.css +127 -43
- package/web/view-controls.ts +201 -12
- package/web/viewport-controller.ts +97 -26
- package/web/viewport-pair.ts +2 -1
- package/web/workspace-preferences.ts +5 -4
- package/web/workspace-ui.ts +152 -19
- package/src/interview-server.ts +0 -54
- package/web/interview.css +0 -28
- package/web/interview.html +0 -17
- package/web/interview.ts +0 -40
- package/web/job-hub.css +0 -14
- package/web/job-hub.html +0 -5
- package/web/owner-workspace.css +0 -14
- package/web/owner-workspace.html +0 -5
- package/web/parts-flags.ts +0 -48
- package/web/parts-page.ts +0 -217
- package/web/parts.css +0 -116
- package/web/parts.html +0 -15
- package/web/parts.ts +0 -986
- package/web/stage-nav.ts +0 -136
package/web/job-session.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import {mountWorkspaceShell} from './workspace-ui.ts';
|
|
1
2
|
/** Live job window transactions. Every form remains bound to its displayed publication. */
|
|
2
|
-
import { parseControlPart, type ControlPart } from '../src/control.ts';
|
|
3
3
|
import type {
|
|
4
4
|
ActV3,
|
|
5
5
|
DisplayPublicationV3,
|
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
JobCheckpointTable,
|
|
10
10
|
JobInterviewDiagnostics,
|
|
11
11
|
JobResult,
|
|
12
|
-
JobUISubmission,
|
|
13
12
|
PendingAskV3,
|
|
14
13
|
JobPanelComposition,
|
|
15
14
|
PanelComponent,
|
|
@@ -22,17 +21,16 @@ import type {
|
|
|
22
21
|
} from '../src/job-contract.ts';
|
|
23
22
|
import {enCatalog} from './catalog-en.ts';
|
|
24
23
|
import {koCatalog} from './catalog-ko.ts';
|
|
25
|
-
import {t} from './i18n.ts';
|
|
24
|
+
import {t,onLanguageChange} from './i18n.ts';
|
|
25
|
+
import type {InstanceAccess} from './instance-access.ts';
|
|
26
26
|
import {JOB_PLAN_TEXT_FIELDS, parseJobPlanTextProjection, type JobPlanTextProjection} from '../src/job-contract.ts';
|
|
27
27
|
import {JOB_HUB_READY, jobHubMessageMatches, type JobHubBinding} from './job-hub.ts';
|
|
28
|
-
import {recordJobRigDraw, freezeJobRigCapture, copyJobRigViewport, createJobRigSubmission, jobRigPixelPlacement,
|
|
29
|
-
type JobRigDraw, type JobRigDrawState} from './job-rig-capture.ts';
|
|
30
28
|
import {advancePlayback} from './playback-clock.ts';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import
|
|
29
|
+
import {createJobRigScreen, isJobRigScreen, type JobRigScreenPrepared} from './job-rig-screen.ts';
|
|
30
|
+
import type {JobRigPresentation} from './viewport-capture.ts';
|
|
31
|
+
import {labelledControl,createViewControls,inspectionViewSwitch} from './view-controls.ts';
|
|
32
|
+
import {createInterviewForm,interviewPicksRecord,interviewRecords,interviewErrors,type InterviewDisplayQuestion} from './interview-panel.ts';
|
|
33
|
+
import {JOB_COMMENTS_ACT_SCHEMA, JOB_PANEL_COMPOSITION_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, parsePanelComposition} from '../src/job-contract.ts';
|
|
36
34
|
import type {PartsIssue} from '../src/parts-comment.ts';
|
|
37
35
|
|
|
38
36
|
/** Imported runtimes may throw arbitrary prose. Only registered refusal copy reaches the window. */
|
|
@@ -55,7 +53,7 @@ export interface JobWindowTransport {
|
|
|
55
53
|
}
|
|
56
54
|
export interface JobPreparedCommit {
|
|
57
55
|
/** Restore the previous view, including its original forms and route bindings. */
|
|
58
|
-
rollback(): void
|
|
56
|
+
rollback(): void | Promise<void>;
|
|
59
57
|
/** Dispose the old view only after the new displayed nonce is acknowledged. */
|
|
60
58
|
finalize(): void;
|
|
61
59
|
}
|
|
@@ -305,7 +303,7 @@ export function createJobWindow<Prepared>(options: {
|
|
|
305
303
|
error = failure instanceof Error ? failure.message : 'JOB_DISPLAY_MISMATCH';
|
|
306
304
|
}
|
|
307
305
|
finally {
|
|
308
|
-
committed?.rollback();
|
|
306
|
+
await committed?.rollback();
|
|
309
307
|
if (prepared !== undefined)
|
|
310
308
|
adapter.discard(prepared);
|
|
311
309
|
if (revision === intent) {
|
|
@@ -371,7 +369,9 @@ export function createJobWindow<Prepared>(options: {
|
|
|
371
369
|
ask.subject.kind !== 'parts-verdict') throw new Error('JOB_ACT_SOURCE_STALE');
|
|
372
370
|
assertJobAskSource(ask, displayed);
|
|
373
371
|
const previous = ask.act;
|
|
374
|
-
|
|
372
|
+
// An act@6 verdict's note is its one general comment; the signoff resends it.
|
|
373
|
+
const value = (previous?.kind !== 'parts-verdict' ? input.value : previous.schema !== JOB_COMMENTS_ACT_SCHEMA ? previous.value :
|
|
374
|
+
{verdict: previous.value.verdict, words: previous.value.comments.find(comment => !comment.anchor)?.text ?? ''}) as Pick<PartsVerdictValue, 'verdict' | 'words'>;
|
|
375
375
|
const signoff = [...pending.values()].find(item => item.publicationId === publicationId &&
|
|
376
376
|
item.subject.kind === 'signoff' && item.subject.stage === 'parts-review' && item.status === 'pending');
|
|
377
377
|
if (value.verdict === 'approved' && !signoff) throw new Error('JOB_PARTS_SIGNOFF_MISSING');
|
|
@@ -380,7 +380,7 @@ export function createJobWindow<Prepared>(options: {
|
|
|
380
380
|
result = await submit(input);
|
|
381
381
|
if (!result.ok) return result;
|
|
382
382
|
} else {
|
|
383
|
-
if (!previous || previous.kind !== 'parts-verdict' || previous.schema !== JOB_PARTS_VERDICT_ACT_SCHEMA ||
|
|
383
|
+
if (!previous || previous.kind !== 'parts-verdict' || (previous.schema !== JOB_PARTS_VERDICT_ACT_SCHEMA && previous.schema !== JOB_COMMENTS_ACT_SCHEMA) ||
|
|
384
384
|
value.verdict !== 'approved') throw new Error('JOB_ACT_SOURCE_STALE');
|
|
385
385
|
result = {ok: true, value: previous};
|
|
386
386
|
}
|
|
@@ -481,6 +481,7 @@ export function jobPublicationRoutes(display: DisplayPublicationV3, origin: stri
|
|
|
481
481
|
}
|
|
482
482
|
return {
|
|
483
483
|
entry: entry.href,
|
|
484
|
+
jobId: match[1]!,
|
|
484
485
|
api(path: string) {
|
|
485
486
|
if (!/^[A-Za-z0-9][A-Za-z0-9/._-]*$/.test(path) || path.includes('..'))
|
|
486
487
|
throw new Error('JOB_DISPLAY_MISMATCH');
|
|
@@ -688,7 +689,7 @@ type JobInterview = {
|
|
|
688
689
|
})[];
|
|
689
690
|
interview?: JobInterviewDiagnostics | null;
|
|
690
691
|
};
|
|
691
|
-
type JobPartsInventory =
|
|
692
|
+
type JobPartsInventory = import('./parts-viewport-provider.ts').PartsSubjectData;
|
|
692
693
|
interface JobReferenceView {
|
|
693
694
|
id: string;
|
|
694
695
|
label: string;
|
|
@@ -718,7 +719,7 @@ export function jobPartsReviewState(asks: readonly JobWindowAsk[], publicationId
|
|
|
718
719
|
const bound = asks.filter(ask => ask.publicationId === publicationId);
|
|
719
720
|
const verdict = bound.filter(ask => ask.subject.kind === 'parts-verdict').at(-1);
|
|
720
721
|
const act = verdict?.act;
|
|
721
|
-
if (act?.kind !== 'parts-verdict' || act.schema !== JOB_PARTS_VERDICT_ACT_SCHEMA) return 'reviewing';
|
|
722
|
+
if (act?.kind !== 'parts-verdict' || (act.schema !== JOB_PARTS_VERDICT_ACT_SCHEMA && act.schema !== JOB_COMMENTS_ACT_SCHEMA)) return 'reviewing';
|
|
722
723
|
if (act.value.verdict === 'changes-requested') return 'sent';
|
|
723
724
|
const approved = bound.some(ask => ask.subject.kind === 'signoff' && ask.subject.stage === 'parts-review' &&
|
|
724
725
|
ask.act?.kind === 'signoff' && ask.act.value.decision === 'approved');
|
|
@@ -860,7 +861,7 @@ function mediaReady(media: HTMLVideoElement, name: 'loadeddata' | 'seeked', sign
|
|
|
860
861
|
});
|
|
861
862
|
}
|
|
862
863
|
/** Prepare the real published Play model, references and every form dependency off-stage. */
|
|
863
|
-
export async function prepareJobInspection(display: DisplayPublicationV3, signal: AbortSignal): Promise<JobPreparedInspection> {
|
|
864
|
+
export async function prepareJobInspection(display: DisplayPublicationV3, signal: AbortSignal, formsOnly=false): Promise<JobPreparedInspection> {
|
|
864
865
|
const routes = jobPublicationRoutes(display, location.origin);
|
|
865
866
|
const metadata = await jobJson<JobInspectionMetadataV3>(routes.api('review'), signal);
|
|
866
867
|
const publishedSource = display.publication.source;
|
|
@@ -1138,7 +1139,7 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
1138
1139
|
const failed = preloaded.find(result => result.status === 'rejected');
|
|
1139
1140
|
if (failed?.status === 'rejected')
|
|
1140
1141
|
throw failed.reason;
|
|
1141
|
-
if (metadata.manifest?.model) {
|
|
1142
|
+
if (!formsOnly && metadata.manifest?.model) {
|
|
1142
1143
|
const runtime = await import('@rig-c/play');
|
|
1143
1144
|
const modelUrl = routes.asset(metadata.manifest.model);
|
|
1144
1145
|
const modelHash = metadata.reviewedSource!.rig!.sha256;
|
|
@@ -1195,540 +1196,491 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
1195
1196
|
throw error;
|
|
1196
1197
|
}
|
|
1197
1198
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1199
|
+
export type JobForm = {
|
|
1200
|
+
form: HTMLFormElement & {commentWords?:()=>string};
|
|
1201
|
+
fieldset: HTMLFieldSetElement;
|
|
1202
|
+
read: () => UISubmissionV3['value'];
|
|
1203
|
+
submissionId: string;
|
|
1204
|
+
dirty: boolean;
|
|
1205
|
+
submitting: boolean;
|
|
1206
|
+
dispose?():void;
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
type JobFormNode = <Tag extends keyof HTMLElementTagNameMap>(tag: Tag, key?: string) => HTMLElementTagNameMap[Tag];
|
|
1210
|
+
|
|
1211
|
+
/** Existing form and inspection helpers, without a workspace mount. */
|
|
1212
|
+
export function createJobFormHelpers(node: JobFormNode, t: typeof import('./i18n.ts').t) {
|
|
1213
|
+
function inputLabel(key: string, input: HTMLElement): HTMLElement {
|
|
1214
|
+
return labelledControl(node('span', key), input);
|
|
1207
1215
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
const language = new URL(location.href).searchParams.get('lang');
|
|
1217
|
-
if (language === 'en' || language === 'ko')
|
|
1218
|
-
i18n.setLanguagePreference(language);
|
|
1219
|
-
const t = i18n.t;
|
|
1220
|
-
const node = <Tag extends keyof HTMLElementTagNameMap>(tag: Tag, key?: string) => {
|
|
1221
|
-
const value = document.createElement(tag);
|
|
1222
|
-
if (key) {
|
|
1223
|
-
value.dataset.jobText = key;
|
|
1224
|
-
value.textContent = t(key);
|
|
1225
|
-
}
|
|
1226
|
-
return value;
|
|
1227
|
-
};
|
|
1228
|
-
const title = node('h1', 'job.title');
|
|
1229
|
-
const languages = node('select');
|
|
1230
|
-
for (const value of ['en', 'ko']) {
|
|
1231
|
-
const option = node('option');
|
|
1232
|
-
option.value = value;
|
|
1233
|
-
option.textContent = value;
|
|
1234
|
-
languages.append(option);
|
|
1216
|
+
function selectValues(values: readonly string[], labels: readonly string[]): HTMLSelectElement {
|
|
1217
|
+
const select = node('select');
|
|
1218
|
+
values.forEach((value, index) => {
|
|
1219
|
+
const option = node('option', labels[index]);
|
|
1220
|
+
option.value = value;
|
|
1221
|
+
select.append(option);
|
|
1222
|
+
});
|
|
1223
|
+
return select;
|
|
1235
1224
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
};
|
|
1279
|
-
const parseSavedCamera = (raw: unknown): SavedCameraState | null => {
|
|
1280
|
-
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
|
|
1281
|
-
const value = raw as Record<string, unknown>;
|
|
1282
|
-
const cameraCenter = parseSavedPoint(value.cameraCenter);
|
|
1283
|
-
const referenceCenter = parseSavedPoint(value.referenceCenter);
|
|
1284
|
-
if (typeof value.cameraSync !== 'boolean' ||
|
|
1285
|
-
(value.activeCamera !== 'rig' && value.activeCamera !== 'reference') ||
|
|
1286
|
-
typeof value.zoom !== 'number' || !Number.isFinite(value.zoom) || value.zoom < 0.25 || value.zoom > 8 ||
|
|
1287
|
-
typeof value.referenceZoom !== 'number' || !Number.isFinite(value.referenceZoom) || value.referenceZoom < 0.25 || value.referenceZoom > 8 ||
|
|
1288
|
-
cameraCenter === undefined || referenceCenter === undefined) {
|
|
1289
|
-
return null;
|
|
1290
|
-
}
|
|
1291
|
-
return {
|
|
1292
|
-
cameraSync: value.cameraSync,
|
|
1293
|
-
activeCamera: value.activeCamera,
|
|
1294
|
-
zoom: value.zoom,
|
|
1295
|
-
cameraCenter,
|
|
1296
|
-
referenceZoom: value.referenceZoom,
|
|
1297
|
-
referenceCenter,
|
|
1298
|
-
};
|
|
1299
|
-
};
|
|
1300
|
-
const parseSavedPartIdentity = (raw: unknown): ControlPart | null => {
|
|
1301
|
-
try {
|
|
1302
|
-
return parseControlPart(raw);
|
|
1303
|
-
}
|
|
1304
|
-
catch {
|
|
1305
|
-
return null;
|
|
1306
|
-
}
|
|
1307
|
-
};
|
|
1308
|
-
const parseSavedDraftRecord = (raw: unknown): JobRetainedDraft | null => {
|
|
1309
|
-
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
|
|
1310
|
-
const draft = raw as Record<string, unknown>;
|
|
1311
|
-
if (!Array.isArray(draft.forms) || !draft.forms.length ||
|
|
1312
|
-
typeof draft.publicationId !== 'string' || !draft.publicationId ||
|
|
1313
|
-
typeof draft.sourceHash !== 'string' || !draft.sourceHash ||
|
|
1314
|
-
typeof draft.label !== 'string' || !draft.label ||
|
|
1315
|
-
!draft.source || typeof draft.source !== 'object' || Array.isArray(draft.source) ||
|
|
1316
|
-
(draft.source as { sourceHash?: unknown }).sourceHash !== draft.sourceHash) {
|
|
1317
|
-
return null;
|
|
1318
|
-
}
|
|
1319
|
-
const forms = draft.forms.filter((item: unknown): item is { askId: string; value: unknown } =>
|
|
1320
|
-
!!item && typeof item === 'object' && !Array.isArray(item) &&
|
|
1321
|
-
typeof (item as { askId?: unknown }).askId === 'string' && !!(item as { askId: string }).askId);
|
|
1322
|
-
if (!forms.length) return null;
|
|
1323
|
-
return {
|
|
1324
|
-
publicationId: draft.publicationId,
|
|
1325
|
-
sourceHash: draft.sourceHash,
|
|
1326
|
-
source: draft.source as SourceV3,
|
|
1327
|
-
label: draft.label,
|
|
1328
|
-
value: forms.map(item => ({ askId: item.askId, value: item.value })),
|
|
1329
|
-
};
|
|
1330
|
-
};
|
|
1331
|
-
const localWindowKey = 'rig-review-job-window/1:' + access.jobId;
|
|
1332
|
-
let savedWindow: SavedJobWindowState | null = null;
|
|
1333
|
-
try {
|
|
1334
|
-
const parsed = JSON.parse(localStorage.getItem(localWindowKey) ?? 'null');
|
|
1335
|
-
if (parsed && typeof parsed.publicationId === 'string' && typeof parsed.label === 'string' &&
|
|
1336
|
-
typeof parsed.sourceHash === 'string') {
|
|
1337
|
-
savedWindow = parsed as SavedJobWindowState;
|
|
1225
|
+
function textArea(parent: HTMLElement, key: string, name = 'note'): HTMLTextAreaElement {
|
|
1226
|
+
const input = node('textarea');
|
|
1227
|
+
input.name = name;
|
|
1228
|
+
parent.append(inputLabel(key, input));
|
|
1229
|
+
return input;
|
|
1230
|
+
}
|
|
1231
|
+
function imageGallery(images: readonly {name: string; sha256: string; element?: HTMLImageElement;
|
|
1232
|
+
role?: string; duplicate?: boolean}[], titleOnly = false): HTMLElement {
|
|
1233
|
+
const gallery = node('section');
|
|
1234
|
+
gallery.style.display = 'grid';
|
|
1235
|
+
gallery.style.gridAutoFlow = 'column';
|
|
1236
|
+
gallery.style.gridAutoColumns = 'minmax(180px, 1fr)';
|
|
1237
|
+
gallery.style.gap = '16px';
|
|
1238
|
+
gallery.style.overflow = 'auto';
|
|
1239
|
+
gallery.style.minHeight = '0';
|
|
1240
|
+
gallery.style.flex = '1';
|
|
1241
|
+
for (const image of images) {
|
|
1242
|
+
const element = image.element;
|
|
1243
|
+
if (!element) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
1244
|
+
const figure = node('figure');
|
|
1245
|
+
figure.style.margin = '0';
|
|
1246
|
+
figure.style.minWidth = '0';
|
|
1247
|
+
figure.dataset.imageName = image.name;
|
|
1248
|
+
const name = node('h3');
|
|
1249
|
+
name.textContent = image.name;
|
|
1250
|
+
if (titleOnly) name.setAttribute('translate', 'no');
|
|
1251
|
+
name.style.overflowWrap = 'anywhere';
|
|
1252
|
+
const role = image.role ? node('p', 'job.imageRole.' + image.role) : node('p');
|
|
1253
|
+
const hash = node('code');
|
|
1254
|
+
hash.className = 'job-source';
|
|
1255
|
+
hash.style.display = 'block';
|
|
1256
|
+
hash.style.overflowWrap = 'anywhere';
|
|
1257
|
+
if (titleOnly) hash.title = image.sha256;
|
|
1258
|
+
else hash.textContent = image.sha256;
|
|
1259
|
+
element.style.width = '100%';
|
|
1260
|
+
element.style.height = 'auto';
|
|
1261
|
+
element.style.maxHeight = '70vh';
|
|
1262
|
+
element.style.objectFit = 'contain';
|
|
1263
|
+
figure.append(name, role, element, hash);
|
|
1264
|
+
if (image.duplicate)
|
|
1265
|
+
figure.append(node('p', 'job.identicalImages'));
|
|
1266
|
+
gallery.append(figure);
|
|
1338
1267
|
}
|
|
1268
|
+
return gallery;
|
|
1339
1269
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1270
|
+
function planStepText(element: HTMLElement, step: NonNullable<SourceV3['plan']>['steps'][number],
|
|
1271
|
+
projection: JobPlanTextProjection | undefined): void {
|
|
1272
|
+
const row = projection?.status === 'projected' ? projection.steps.find(row => row.id === step.id && row.hash === step.hash) : undefined;
|
|
1273
|
+
const key = row?.does === undefined ? 'job.plan.field.' + (row?.issues.find(issue => issue.field === 'does')?.reason ?? 'absent') : undefined;
|
|
1274
|
+
// Producer identities stay raw; absence keys still follow the job form's own language binding.
|
|
1275
|
+
element.setAttribute('translate', 'no');
|
|
1276
|
+
if (key) element.dataset.jobText = key;
|
|
1277
|
+
else delete element.dataset.jobText;
|
|
1278
|
+
element.textContent = key ? t(key) : row!.does!;
|
|
1279
|
+
}
|
|
1280
|
+
function planTextList(plan: NonNullable<SourceV3['plan']>, projection: JobPlanTextProjection | undefined,
|
|
1281
|
+
selectedId?: string): HTMLElement {
|
|
1282
|
+
const section = node('section');
|
|
1283
|
+
section.className = 'job-plan-text';
|
|
1284
|
+
if (!projection || projection.status === 'unavailable') {
|
|
1285
|
+
section.append(node('p', 'job.plan.noText'));
|
|
1286
|
+
if (projection) section.append(node('p', projection.reason));
|
|
1287
|
+
}
|
|
1288
|
+
const list = node('ol');
|
|
1289
|
+
list.className = 'job-plan-steps';
|
|
1290
|
+
for (const step of plan.steps) {
|
|
1291
|
+
if (selectedId !== undefined && step.id !== selectedId) continue;
|
|
1292
|
+
const item = node('li');
|
|
1293
|
+
item.dataset.jobPlanStep = step.id;
|
|
1294
|
+
const details = node('details');
|
|
1295
|
+
details.open = true;
|
|
1296
|
+
const title = node('summary');
|
|
1297
|
+
planStepText(title, step, projection);
|
|
1298
|
+
title.title = step.id + ' · ' + step.hash;
|
|
1299
|
+
details.append(title);
|
|
1300
|
+
const row = projection?.status === 'projected' ? projection.steps.find(row => row.id === step.id && row.hash === step.hash) : undefined;
|
|
1301
|
+
if (row) {
|
|
1302
|
+
const fields = node('dl');
|
|
1303
|
+
for (const field of JOB_PLAN_TEXT_FIELDS) {
|
|
1304
|
+
if (field === 'does') continue;
|
|
1305
|
+
const term = node('dt', 'job.plan.' + field);
|
|
1306
|
+
const value = node('dd');
|
|
1307
|
+
value.dataset.jobPlanField = field;
|
|
1308
|
+
const issue = row.issues.find(issue => issue.field === field);
|
|
1309
|
+
if (issue) value.append(node('span', 'job.plan.field.' + issue.reason));
|
|
1310
|
+
else if (field === 'rests_on') {
|
|
1311
|
+
const rests = node('ul');
|
|
1312
|
+
for (const text of row.rests_on!) {
|
|
1313
|
+
const rest = node('li'), dependency = plan.steps.find(step => step.id === text);
|
|
1314
|
+
if (dependency) {planStepText(rest, dependency, projection); rest.title = text;}
|
|
1315
|
+
else {rest.textContent = text; rest.setAttribute('translate', 'no');}
|
|
1316
|
+
rests.append(rest);
|
|
1317
|
+
}
|
|
1318
|
+
value.append(rests);
|
|
1319
|
+
} else {value.textContent = row[field]!; value.setAttribute('translate', 'no');}
|
|
1320
|
+
fields.append(term, value);
|
|
1321
|
+
}
|
|
1322
|
+
details.append(fields);
|
|
1350
1323
|
}
|
|
1351
|
-
|
|
1324
|
+
item.append(details); list.append(item);
|
|
1352
1325
|
}
|
|
1326
|
+
list.addEventListener('keydown', event => {
|
|
1327
|
+
const key = event as KeyboardEvent;
|
|
1328
|
+
if (!['ArrowUp', 'ArrowDown'].includes(key.key) || !(key.target instanceof HTMLElement) || key.target.tagName !== 'SUMMARY') return;
|
|
1329
|
+
const summaries = [...list.querySelectorAll<HTMLElement>('summary')];
|
|
1330
|
+
const index = summaries.indexOf(key.target);
|
|
1331
|
+
const next = summaries[index + (key.key === 'ArrowDown' ? 1 : -1)];
|
|
1332
|
+
if (next) {key.preventDefault(); next.focus();}
|
|
1333
|
+
});
|
|
1334
|
+
section.append(list);
|
|
1335
|
+
return section;
|
|
1353
1336
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
let loop = typeof savedWindow?.loop === 'boolean' ? savedWindow.loop : true;
|
|
1365
|
-
let playbackCarry = 0;
|
|
1366
|
-
let rafHandle = 0;
|
|
1367
|
-
let lastFrameTime = 0;
|
|
1368
|
-
let inPlaybackStep = false;
|
|
1369
|
-
let lastRunningSaveMs: number | null = null;
|
|
1370
|
-
let lastSavedWindowJson: string | null = null;
|
|
1371
|
-
let selectedPart = typeof savedWindow?.selectedPart === 'string' ? savedWindow.selectedPart : '';
|
|
1372
|
-
let partMode: 'context' | 'solo' = savedWindow?.partMode === 'solo' ? 'solo' : 'context';
|
|
1373
|
-
let selectedReference = typeof savedWindow?.selectedReference === 'string' ? savedWindow.selectedReference : '';
|
|
1374
|
-
let panel = typeof savedWindow?.panel === 'string' && ['1', '2', '3', '4'].includes(savedWindow.panel)
|
|
1375
|
-
? savedWindow.panel : '3';
|
|
1376
|
-
let restoredPartIdentity: ControlPart | null = parseSavedPartIdentity(savedWindow?.partIdentity);
|
|
1377
|
-
let restoredCamera: SavedCameraState | null = parseSavedCamera(savedWindow?.camera);
|
|
1378
|
-
let compatibilityNotice = Boolean(savedWindow?.compatibilityNotice);
|
|
1379
|
-
type JobForm = {
|
|
1380
|
-
form: HTMLFormElement;
|
|
1381
|
-
fieldset: HTMLFieldSetElement;
|
|
1382
|
-
read: () => UISubmissionV3['value'];
|
|
1383
|
-
submissionId: string;
|
|
1384
|
-
dirty: boolean;
|
|
1385
|
-
submitting: boolean;
|
|
1386
|
-
rigSubmission: ReturnType<typeof createJobRigSubmission>;
|
|
1337
|
+
return {inputLabel, selectValues, textArea, imageGallery, planTextList, planStepText};
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/** The answer builder owns no page shell, transport or draft collection. */
|
|
1341
|
+
export interface JobFormDependencies {
|
|
1342
|
+
node: JobFormNode;
|
|
1343
|
+
translate: typeof import('./i18n.ts').t;
|
|
1344
|
+
helpers: ReturnType<typeof createJobFormHelpers> & {
|
|
1345
|
+
assertJobAskSource: typeof assertJobAskSource;
|
|
1346
|
+
jobCheckpointContext: typeof jobCheckpointContext;
|
|
1387
1347
|
};
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1348
|
+
draftStorage(): Pick<Storage, 'getItem'>;
|
|
1349
|
+
localDraftKey(display: DisplayPublicationV3): string;
|
|
1350
|
+
saveDraft(): void;
|
|
1351
|
+
window: {
|
|
1352
|
+
state(): Pick<JobWindowState, 'receipt' | 'preparing' | 'closed' | 'generation' | 'pending'>;
|
|
1353
|
+
submit(input: UISubmissionV3): Promise<JobResult<ActV3>>;
|
|
1391
1354
|
};
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1355
|
+
access: Pick<JobWindowAccess, 'capability'>;
|
|
1356
|
+
pageId: string;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/** Build the existing answer form with explicit host dependencies. */
|
|
1360
|
+
function formFor(ask: PendingAskV3, prepared: JobPreparedInspection, deps: JobFormDependencies): JobForm {
|
|
1361
|
+
const {node, translate: t, helpers: {textArea, selectValues, imageGallery, planTextList, planStepText, assertJobAskSource, jobCheckpointContext},
|
|
1362
|
+
draftStorage, localDraftKey, saveDraft, window, access, pageId} = deps;
|
|
1363
|
+
if (ask.publicationId !== prepared.display.publication.publicationId)
|
|
1364
|
+
throw new Error('JOB_DISPLAY_MISMATCH');
|
|
1365
|
+
assertJobAskSource(ask, prepared.display);
|
|
1366
|
+
// Rig verdicts belong to the shared screen; unsupported combinations have no job-window form.
|
|
1367
|
+
if (ask.subject.kind === 'review-verdict' && ask.subject.stage === 'rig-review')
|
|
1368
|
+
throw new Error('JOB_ACT_KIND_DISABLED');
|
|
1369
|
+
const form = node('form') as JobForm['form'];
|
|
1370
|
+
form.dataset.jobAsk = ask.askId;
|
|
1371
|
+
form.dataset.jobPublication = ask.publicationId;
|
|
1372
|
+
const fields = node('fieldset');
|
|
1373
|
+
form.append(fields);
|
|
1374
|
+
const source = node('p');
|
|
1375
|
+
source.className = 'job-source';
|
|
1376
|
+
source.textContent = ask.subject.kind === 'review-verdict'
|
|
1377
|
+
? prepared.display.publication.label + ' · ' + ask.source.sourceHash : prepared.display.publication.label;
|
|
1378
|
+
if (ask.subject.kind !== 'review-verdict') {source.title = ask.source.sourceHash; source.setAttribute('translate', 'no');}
|
|
1379
|
+
fields.append(source);
|
|
1380
|
+
const subject = ask.subject;
|
|
1381
|
+
const commentOnly = subject.kind === 'checkpoint' || subject.kind === 'signoff' || subject.kind === 'reopen';
|
|
1382
|
+
const note = commentOnly || subject.kind === 'interview-picks' ? null : textArea(fields, 'interview.note');
|
|
1383
|
+
if(commentOnly)fields.append(node('p','job.commentsFromWorkspace'));
|
|
1384
|
+
let retainedCommentWords='';
|
|
1385
|
+
const commentWords=()=>form.commentWords?.()??retainedCommentWords;
|
|
1386
|
+
let read: () => UISubmissionV3['value'];
|
|
1387
|
+
let submitKey = 'Submit review';
|
|
1388
|
+
let disposeInterview:(()=>void)|undefined;
|
|
1389
|
+
let interviewForm:ReturnType<typeof createInterviewForm>|undefined;
|
|
1390
|
+
if (subject.kind === 'interview-picks') {
|
|
1391
|
+
const question = prepared.interview?.questions.find(item => item.set.id === subject.setId && item.set.question === subject.questionId);
|
|
1392
|
+
if (!question || !question.editable) throw new Error('JOB_ASK_INVALID');
|
|
1393
|
+
if (question.ref.sha256 !== ask.source.optionSet?.sha256) throw new Error('JOB_ACT_SOURCE_STALE');
|
|
1394
|
+
const interviewState = prepared.interview?.interview ?? prepared.display.publication.interview ?? null;
|
|
1395
|
+
const inspectionRecord = interviewState?.records.find(
|
|
1396
|
+
item => item.timeKind === 'inspection' &&
|
|
1397
|
+
item.questionId === subject.questionId &&
|
|
1398
|
+
item.setId === subject.setId &&
|
|
1399
|
+
item.record.endsWith('.pending_options'),
|
|
1400
|
+
);
|
|
1401
|
+
const legacyDiagnostic = inspectionRecord
|
|
1402
|
+
? interviewState?.diagnostics.find(
|
|
1403
|
+
item => item.code === 'INTERVIEW_OPTIONS_SCENE_LEGACY' &&
|
|
1404
|
+
item.record === inspectionRecord.record &&
|
|
1405
|
+
item.at === inspectionRecord.at,
|
|
1406
|
+
)
|
|
1407
|
+
: undefined;
|
|
1408
|
+
if (legacyDiagnostic) {
|
|
1409
|
+
const legacyNotice = node('p', 'INTERVIEW_OPTIONS_SCENE_LEGACY');
|
|
1410
|
+
legacyNotice.dataset.jobInterviewWarning = legacyDiagnostic.code;
|
|
1411
|
+
legacyNotice.dataset.record = legacyDiagnostic.record;
|
|
1412
|
+
fields.prepend(legacyNotice);
|
|
1422
1413
|
}
|
|
1423
|
-
|
|
1424
|
-
return;
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
try {
|
|
1428
|
-
const serialized = JSON.stringify({
|
|
1429
|
-
publicationId: current.display.publication.publicationId,
|
|
1430
|
-
label: current.display.publication.label,
|
|
1431
|
-
sourceHash: current.display.publication.source.sourceHash,
|
|
1432
|
-
previousLabel: state.previousLabel,
|
|
1433
|
-
compatibilityNotice,
|
|
1434
|
-
animation,
|
|
1435
|
-
time,
|
|
1436
|
-
loop,
|
|
1437
|
-
selectedPart,
|
|
1438
|
-
partMode,
|
|
1439
|
-
selectedReference,
|
|
1440
|
-
panel,
|
|
1441
|
-
partIdentity: current.inspection?.value() ?? null,
|
|
1442
|
-
camera: {
|
|
1443
|
-
cameraSync: viewportState.cameraSync,
|
|
1444
|
-
activeCamera: viewportState.activeCamera,
|
|
1445
|
-
zoom: viewportState.zoom,
|
|
1446
|
-
cameraCenter: viewportState.cameraCenter
|
|
1447
|
-
? { x: viewportState.cameraCenter.x, y: viewportState.cameraCenter.y } : null,
|
|
1448
|
-
referenceZoom: viewportState.referenceZoom,
|
|
1449
|
-
referenceCenter: viewportState.referenceCenter
|
|
1450
|
-
? { x: viewportState.referenceCenter.x, y: viewportState.referenceCenter.y } : null,
|
|
1451
|
-
},
|
|
1452
|
-
});
|
|
1453
|
-
if (serialized === lastSavedWindowJson)
|
|
1454
|
-
return;
|
|
1455
|
-
localStorage.setItem(localWindowKey, serialized);
|
|
1456
|
-
lastSavedWindowJson = serialized;
|
|
1457
|
-
}
|
|
1458
|
-
catch { /* Standing state stays in memory when storage is unavailable. */ }
|
|
1459
|
-
}
|
|
1460
|
-
const el = <Element extends HTMLElement = HTMLElement>(id: string): Element => {
|
|
1461
|
-
const element = workspace.querySelector<HTMLElement>('#' + id);
|
|
1462
|
-
if (!element)
|
|
1463
|
-
throw new Error('JOB_WINDOW_ELEMENT_MISSING');
|
|
1464
|
-
return element as Element;
|
|
1465
|
-
};
|
|
1466
|
-
const reference = () => current?.references.find(item => item.id === selectedReference) ?? null;
|
|
1467
|
-
const setText = (id: string, value: string) => { const element = workspace.querySelector('#' + id); if (element)
|
|
1468
|
-
element.textContent = i18n.tr(value); };
|
|
1469
|
-
function redrawOverlay(fresh: boolean): void {
|
|
1470
|
-
const owner = current, overlay = owner ? overlays.get(owner) : undefined;
|
|
1471
|
-
if (!owner || !overlay) return;
|
|
1472
|
-
const root = owner.rigRoot, scale = viewportState.rigScale;
|
|
1473
|
-
const left = parseFloat(root.style.left) || 0, top = parseFloat(root.style.top) || 0;
|
|
1474
|
-
const project = (x: number, y: number) => ({ x: left + x * scale, y: top - y * scale });
|
|
1475
|
-
const bones = (owner.metadata.feedbackCatalog.bones ?? []).map(name => ({ name }));
|
|
1476
|
-
const frame = owner.inspection?.frame('single');
|
|
1477
|
-
const selectedSlot = selectedPart || null;
|
|
1478
|
-
const snap = fresh
|
|
1479
|
-
? overlay.refresh({ player: owner.player, bones, frame, selectedSlot, project, settings: layers })
|
|
1480
|
-
: overlay.redraw({ project, settings: layers });
|
|
1481
|
-
if (!fresh && snap.needsCapture && owner.player) {
|
|
1482
|
-
overlay.refresh({ player: owner.player, bones, frame, selectedSlot, project, settings: layers });
|
|
1414
|
+
interviewForm=createInterviewForm({question,id:'interview-answer-'+ask.askId,node,form,fieldset:fields,source,
|
|
1415
|
+
images:question.images.map(image=>{const visual=prepared.interviewImages.get(image.url);if(!visual)throw new Error('JOB_VISUAL_UNAVAILABLE');return {name:image.name,src:visual.src};}),answered:ask.status==='answered'});
|
|
1416
|
+
disposeInterview=interviewForm.dispose;read=interviewForm.read;
|
|
1417
|
+
submitKey = 'interview.save';
|
|
1483
1418
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
catch (error) {
|
|
1503
|
-
if (current) {
|
|
1504
|
-
drawn.delete(current);
|
|
1505
|
-
current.rigPresentation = undefined;
|
|
1419
|
+
else if (subject.kind === 'checkpoint') {
|
|
1420
|
+
const checkpoint = jobCheckpointContext(ask, prepared.metadata.manifest?.checkpoints ?? []);
|
|
1421
|
+
const heading = node('h3');
|
|
1422
|
+
heading.textContent = checkpoint.title;
|
|
1423
|
+
heading.title = subject.checkpointId;
|
|
1424
|
+
heading.setAttribute('translate', 'no');
|
|
1425
|
+
if (prepared.metadata.manifest?.checkpoints.find(item => item.id === subject.checkpointId)?.title == null)
|
|
1426
|
+
planStepText(heading, checkpoint.step, prepared.metadata.planText);
|
|
1427
|
+
fields.prepend(heading);
|
|
1428
|
+
const guidance = node('p');
|
|
1429
|
+
guidance.textContent = checkpoint.note;
|
|
1430
|
+
guidance.setAttribute('translate', 'no');
|
|
1431
|
+
fields.append(guidance, planTextList(ask.source.plan!, prepared.metadata.planText, checkpoint.step.id));
|
|
1432
|
+
const evidence = prepared.checkpointEvidence?.find(item => item.packet.checkpointId === subject.checkpointId);
|
|
1433
|
+
const declared = ask.source.checkpointEvidence?.find(item => item.checkpointId === subject.checkpointId);
|
|
1434
|
+
if (Boolean(declared) !== Boolean(evidence) || evidence &&
|
|
1435
|
+
(JSON.stringify(evidence.packet) !== JSON.stringify(declared) || evidence.packet.planStepId !== checkpoint.step.id)) {
|
|
1436
|
+
throw new Error('CHECKPOINT_EVIDENCE_INVALID');
|
|
1506
1437
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1438
|
+
if (evidence) {
|
|
1439
|
+
const section = node('section');
|
|
1440
|
+
section.dataset.jobCheckpointEvidence = subject.checkpointId;
|
|
1441
|
+
section.append(node('h4', 'job.checkpointEvidence'));
|
|
1442
|
+
section.append(imageGallery(evidence.packet.tiles.map((tile, index) => ({name: tile.label,
|
|
1443
|
+
sha256: tile.sha256, element: evidence.images[index]?.cloneNode(true) as HTMLImageElement})), true));
|
|
1444
|
+
const tableHost = node('div');
|
|
1445
|
+
tableHost.style.overflow = 'auto';
|
|
1446
|
+
tableHost.style.maxHeight = '50dvh';
|
|
1447
|
+
const table = node('table');
|
|
1448
|
+
table.dataset.jobCheckpointTable = '';
|
|
1449
|
+
const caption = node('caption', 'job.checkpointTable');
|
|
1450
|
+
if (evidence.packet.table.label !== undefined) {
|
|
1451
|
+
delete caption.dataset.jobText;
|
|
1452
|
+
caption.textContent = evidence.packet.table.label;
|
|
1453
|
+
caption.setAttribute('translate', 'no');
|
|
1454
|
+
}
|
|
1455
|
+
const head = node('thead');
|
|
1456
|
+
head.setAttribute('translate', 'no');
|
|
1457
|
+
const columns = node('tr');
|
|
1458
|
+
for (const column of evidence.table.columns) {
|
|
1459
|
+
const cell = node('th');
|
|
1460
|
+
cell.scope = 'col';
|
|
1461
|
+
cell.textContent = column;
|
|
1462
|
+
columns.append(cell);
|
|
1463
|
+
}
|
|
1464
|
+
head.append(columns);
|
|
1465
|
+
const body = node('tbody');
|
|
1466
|
+
body.setAttribute('translate', 'no');
|
|
1467
|
+
for (const row of evidence.table.rows) {
|
|
1468
|
+
const cells = node('tr');
|
|
1469
|
+
for (const value of row) {
|
|
1470
|
+
const cell = node('td');
|
|
1471
|
+
cell.textContent = String(value);
|
|
1472
|
+
cells.append(cell);
|
|
1473
|
+
}
|
|
1474
|
+
body.append(cells);
|
|
1475
|
+
}
|
|
1476
|
+
table.append(caption, head, body);
|
|
1477
|
+
tableHost.append(table);
|
|
1478
|
+
const routes = node('pre');
|
|
1479
|
+
routes.textContent = evidence.packet.routesText;
|
|
1480
|
+
routes.setAttribute('translate', 'no');
|
|
1481
|
+
const recommendation = node('pre');
|
|
1482
|
+
recommendation.textContent = evidence.packet.recommendationText;
|
|
1483
|
+
recommendation.setAttribute('translate', 'no');
|
|
1484
|
+
section.append(tableHost, node('h4', 'job.checkpointRoutes'), routes,
|
|
1485
|
+
node('h4', 'job.checkpointRecommendation'), recommendation);
|
|
1486
|
+
fields.append(section, node('p', 'job.checkpointRouteMapping'));
|
|
1556
1487
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1488
|
+
const outcome = selectValues(['', 'pass', 'fail'], ['Pending', 'Pass', 'job.fail']);
|
|
1489
|
+
outcome.required = true;
|
|
1490
|
+
outcome.name = 'outcome';
|
|
1491
|
+
fields.append(outcome);
|
|
1492
|
+
read = () => ({ checkpointId: subject.checkpointId, outcome: outcome.value as 'pass' | 'fail', words: commentWords() });
|
|
1493
|
+
submitKey = 'job.saveCheckpoint';
|
|
1494
|
+
}
|
|
1495
|
+
else if(subject.kind==='parts-verdict')throw new Error('JOB_PANEL_UNAVAILABLE');
|
|
1496
|
+
else if (subject.kind === 'review-verdict' && (subject.stage === 'image-review' || subject.stage === 'direction-review')) {
|
|
1497
|
+
const verdict = selectValues(['pending', 'approved', 'changes-requested'], ['Pending', 'Approved', 'Changes requested']);
|
|
1498
|
+
verdict.name = 'verdict';
|
|
1499
|
+
fields.append(verdict);
|
|
1500
|
+
const stage = subject.stage;
|
|
1501
|
+
if (stage === 'image-review') {
|
|
1502
|
+
const source = ask.source;
|
|
1503
|
+
if (source.subject !== 'image-set') throw new Error('JOB_ACT_SOURCE_STALE');
|
|
1504
|
+
const imageNotes = source.imageSet.images.map((image, index) => {
|
|
1505
|
+
const group = node('fieldset');
|
|
1506
|
+
const name = node('legend');
|
|
1507
|
+
name.textContent = image.name;
|
|
1508
|
+
group.append(name);
|
|
1509
|
+
fields.append(group);
|
|
1510
|
+
return {name: image.name, input: textArea(group, 'job.imageNote', 'image-note-' + index)};
|
|
1511
|
+
});
|
|
1512
|
+
read = () => {
|
|
1513
|
+
const notes = imageNotes.filter(note => note.input.value !== '')
|
|
1514
|
+
.map(note => ({name: note.name, words: note.input.value}));
|
|
1515
|
+
return {stage, verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: (note?.value ?? ''),
|
|
1516
|
+
...(notes.length ? {imageNotes: notes} : {})};
|
|
1517
|
+
};
|
|
1518
|
+
} else {
|
|
1519
|
+
read = () => ({ stage, verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: (note?.value ?? '') });
|
|
1563
1520
|
}
|
|
1564
|
-
const renderer = player.renderer;
|
|
1565
|
-
const presentation = presentJobRigViewport({pane, root: owner.rigRoot, images: true,
|
|
1566
|
-
canvas: renderer instanceof CanvasRenderer ? renderer.canvas : undefined,
|
|
1567
|
-
backend: renderer instanceof CanvasRenderer ? renderer.backendActive : renderer.meshBackendActive},
|
|
1568
|
-
{camera, posed, assets: owner.assets});
|
|
1569
|
-
pane.append(presentation.canvas);
|
|
1570
|
-
owner.rigPresentation = presentation;
|
|
1571
|
-
pane.dataset.jobRigCanonical = '';
|
|
1572
|
-
drawn.set(owner, recordJobRigDraw(rigDrawState(), ++drawGeneration));
|
|
1573
|
-
} catch {
|
|
1574
|
-
drawn.delete(owner);
|
|
1575
|
-
owner.rigPresentation = undefined;
|
|
1576
1521
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
owner.inspection?.present('single');
|
|
1583
|
-
if (owner === current) redrawOverlay(true);
|
|
1584
|
-
}
|
|
1585
|
-
function syncTransportControls(): void {
|
|
1586
|
-
const playBtn = workspace.querySelector<HTMLButtonElement>('#job-play');
|
|
1587
|
-
if (playBtn) {
|
|
1588
|
-
const clip = current?.assets?.animations.find(item => item.name === animation);
|
|
1589
|
-
playBtn.disabled = !animation || !clip || !(clip.duration > 0) || !current?.player;
|
|
1590
|
-
const key = playing ? 'Pause' : 'Play';
|
|
1591
|
-
playBtn.dataset.jobText = key;
|
|
1592
|
-
playBtn.textContent = t(key);
|
|
1593
|
-
playBtn.setAttribute('aria-pressed', String(playing));
|
|
1522
|
+
else if (subject.kind === 'signoff') {
|
|
1523
|
+
fields.title = subject.stage;
|
|
1524
|
+
if (ask.source.plan) fields.append(planTextList(ask.source.plan, prepared.metadata.planText));
|
|
1525
|
+
read = () => ({ stage: subject.stage, decision: 'approved', words: commentWords() });
|
|
1526
|
+
submitKey = 'job.signoff';
|
|
1594
1527
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1528
|
+
else if (subject.kind === 'reopen') {
|
|
1529
|
+
if (
|
|
1530
|
+
!('record' in ask.source) ||
|
|
1531
|
+
ask.source.subject !== 'plan' ||
|
|
1532
|
+
typeof subject.stage !== 'string' ||
|
|
1533
|
+
!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(subject.stage) ||
|
|
1534
|
+
!ask.source.subjects.some(candidate => candidate.kind === 'reopen' && candidate.stage === subject.stage)
|
|
1535
|
+
) {
|
|
1536
|
+
throw new Error('JOB_ASK_INVALID');
|
|
1537
|
+
}
|
|
1538
|
+
fields.title = subject.stage;
|
|
1539
|
+
read = () => ({ stage: subject.stage, words: commentWords() });
|
|
1540
|
+
submitKey = 'job.reopen';
|
|
1602
1541
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
lastFrameTime = 0;
|
|
1606
|
-
lastRunningSaveMs = null;
|
|
1607
|
-
targetPlayer?.pause();
|
|
1608
|
-
syncTransportControls();
|
|
1609
|
-
saveWindowState();
|
|
1610
|
-
}
|
|
1611
|
-
function presentCurrentFrame(owner: JobPreparedInspection): void {
|
|
1612
|
-
if (!owner.player) return;
|
|
1613
|
-
drawInspection(owner);
|
|
1614
|
-
owner.inspection?.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
1615
|
-
setText('job-part-observation', selectedPart ? JSON.stringify(owner.inspection?.observation(), null, 2) : '');
|
|
1616
|
-
viewport.fitCamera();
|
|
1617
|
-
}
|
|
1618
|
-
function armPlayback(expectedOwner: JobPreparedInspection, expectedPlayer: RigPlayer): void {
|
|
1619
|
-
if (rafHandle) {
|
|
1620
|
-
cancelAnimationFrame(rafHandle);
|
|
1621
|
-
rafHandle = 0;
|
|
1542
|
+
else {
|
|
1543
|
+
throw new Error('JOB_ACT_KIND_DISABLED');
|
|
1622
1544
|
}
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
if
|
|
1632
|
-
if (duration - time <= residue) return String(duration);
|
|
1633
|
-
return String(time);
|
|
1634
|
-
}
|
|
1635
|
-
function stepPlayback(handle: number, expectedOwner: JobPreparedInspection, expectedPlayer: RigPlayer, now: number): void {
|
|
1636
|
-
if (current !== expectedOwner || current?.player !== expectedPlayer) {
|
|
1637
|
-
expectedPlayer.pause();
|
|
1638
|
-
return;
|
|
1639
|
-
}
|
|
1640
|
-
if (handle !== rafHandle) return;
|
|
1641
|
-
rafHandle = 0;
|
|
1642
|
-
const clip = expectedOwner.assets?.animations.find(item => item.name === animation);
|
|
1643
|
-
if (!playing || !hubVisible || !animation || !clip || !(clip.duration > 0)) {
|
|
1644
|
-
stopPlayback(expectedPlayer);
|
|
1645
|
-
return;
|
|
1646
|
-
}
|
|
1647
|
-
const dt = lastFrameTime > 0 ? Math.min(Math.max(0, (now - lastFrameTime) / 1000), 0.1) : 0;
|
|
1648
|
-
lastFrameTime = now;
|
|
1649
|
-
const next = advancePlayback({ time, duration: clip.duration, carry: playbackCarry, elapsed: dt, repeat: loop });
|
|
1650
|
-
for (const step of next.steps) expectedPlayer.advance(step);
|
|
1651
|
-
const activeEntry = expectedPlayer.entry(0);
|
|
1652
|
-
if (!activeEntry || activeEntry.animation !== animation || activeEntry.loop !== loop ||
|
|
1653
|
-
!Number.isFinite(activeEntry.animationTime) || activeEntry.animationTime < 0 ||
|
|
1654
|
-
activeEntry.animationTime > activeEntry.duration) {
|
|
1655
|
-
stopPlayback(expectedPlayer);
|
|
1656
|
-
return;
|
|
1657
|
-
}
|
|
1658
|
-
playbackCarry = next.carry;
|
|
1659
|
-
if (next.ended) {
|
|
1660
|
-
playing = false;
|
|
1661
|
-
playbackCarry = 0;
|
|
1662
|
-
lastFrameTime = 0;
|
|
1663
|
-
expectedPlayer.pause();
|
|
1664
|
-
time = clip.duration;
|
|
1665
|
-
} else {
|
|
1666
|
-
time = activeEntry.animationTime;
|
|
1667
|
-
}
|
|
1668
|
-
const clock = workspace.querySelector<HTMLInputElement>('#job-time');
|
|
1669
|
-
if (clock) clock.value = playbackTimeLabel(clip.duration, activeEntry.trackTime);
|
|
1670
|
-
inPlaybackStep = true;
|
|
1545
|
+
const submit = interviewForm?.submit??node('button', submitKey);
|
|
1546
|
+
submit.type = 'submit';
|
|
1547
|
+
fields.append(submit);
|
|
1548
|
+
const status = interviewForm?.status??node('p');
|
|
1549
|
+
status.setAttribute('role', 'status');
|
|
1550
|
+
form.append(status);
|
|
1551
|
+
const entry: JobForm = { form, fieldset: fields, read, submissionId: crypto.randomUUID(), dirty: false,
|
|
1552
|
+
submitting: false, ...(disposeInterview?{dispose:disposeInterview}:{}) };
|
|
1553
|
+
if(disposeInterview)form.addEventListener('job-form-dispose',disposeInterview);
|
|
1671
1554
|
try {
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1555
|
+
const saved = JSON.parse(draftStorage().getItem(localDraftKey(prepared.display)) ?? 'null');
|
|
1556
|
+
if (saved?.publicationId === prepared.display.publication.publicationId &&
|
|
1557
|
+
saved?.sourceHash === prepared.display.publication.source.sourceHash) {
|
|
1558
|
+
assertJobAskSource({...ask, source: saved.source}, prepared.display);
|
|
1559
|
+
const original = saved.forms?.find((item: {
|
|
1560
|
+
askId: string;
|
|
1561
|
+
}) => item.askId === ask.askId);
|
|
1562
|
+
if(commentOnly&&typeof original?.value?.words==='string'&&original.value.words.length<=10000)retainedCommentWords=original.value.words;
|
|
1563
|
+
for (const input of form.querySelectorAll<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>('input[name],textarea[name],select[name]')) {
|
|
1564
|
+
const restored = original?.controls?.find((item: {
|
|
1565
|
+
name: string;
|
|
1566
|
+
value: string;
|
|
1567
|
+
}) => item.name === input.name);
|
|
1568
|
+
if (restored && typeof restored.value === 'string') {
|
|
1569
|
+
if(input instanceof HTMLInputElement&&input.type==='radio'){
|
|
1570
|
+
input.checked=input.value===restored.value;
|
|
1571
|
+
if(input.checked)input.dispatchEvent(new Event('change'));
|
|
1572
|
+
}else{
|
|
1573
|
+
input.value = restored.value;
|
|
1574
|
+
if (input instanceof HTMLSelectElement)input.dispatchEvent(new Event('change'));
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
entry.dirty = !!original;
|
|
1579
|
+
if(subject.kind==='interview-picks')form.dispatchEvent(new Event('change'));
|
|
1580
|
+
}
|
|
1686
1581
|
}
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
if (!
|
|
1695
|
-
|
|
1696
|
-
});
|
|
1697
|
-
}
|
|
1698
|
-
const referenceSelection = createJobReferenceSelection<JobReferenceView>({
|
|
1699
|
-
current: () => ({owner: current, time}),
|
|
1700
|
-
present(value) {
|
|
1701
|
-
const previous = selectedReference;
|
|
1702
|
-
const camera = structuredClone(viewportState);
|
|
1703
|
-
selectedReference = value.id;
|
|
1582
|
+
catch { /* Invalid or unavailable local drafts grant no submission authority. */ }
|
|
1583
|
+
form.oninput = () => { entry.dirty = true; entry.submissionId = crypto.randomUUID(); saveDraft(); };
|
|
1584
|
+
let attemptedValue:string|undefined;
|
|
1585
|
+
form.onsubmit = async (event) => {
|
|
1586
|
+
event.preventDefault();
|
|
1587
|
+
const state = window.state();
|
|
1588
|
+
const receipt = state.receipt;
|
|
1589
|
+
if (!receipt || state.preparing || state.closed || !access.capability || !form.reportValidity())
|
|
1590
|
+
return;
|
|
1704
1591
|
try {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1592
|
+
const value=read(),key=JSON.stringify(value);
|
|
1593
|
+
if(commentOnly&&attemptedValue!==undefined&&attemptedValue!==key)entry.submissionId=crypto.randomUUID();
|
|
1594
|
+
attemptedValue=key;
|
|
1595
|
+
const input = { kind: subject.kind, publicationId: ask.publicationId,
|
|
1596
|
+
askId: ask.askId, pageId, displayedNonce: receipt.displayedNonce,
|
|
1597
|
+
expectedGeneration: state.generation, submissionId: entry.submissionId, value } as UISubmissionV3;
|
|
1598
|
+
const activeAsk = state.pending.find(item => item.askId === ask.askId);
|
|
1599
|
+
if (!activeAsk) throw new Error('JOB_ASK_INVALID');
|
|
1600
|
+
entry.submitting = true;
|
|
1601
|
+
fields.disabled = true;
|
|
1602
|
+
const frozen = await Promise.resolve(input);
|
|
1603
|
+
if (entry.submissionId !== frozen.submissionId) throw new Error('JOB_STILL_BINDING_MISMATCH');
|
|
1604
|
+
const result = await window.submit(frozen);
|
|
1605
|
+
if (!result.ok)
|
|
1606
|
+
throw new Error(result.error.code);
|
|
1607
|
+
entry.submitting = false;
|
|
1608
|
+
entry.dirty = false;
|
|
1609
|
+
status.dataset.jobText = 'job.saved';
|
|
1610
|
+
status.textContent = t('job.saved');
|
|
1611
|
+
if(subject.kind==='interview-picks'){form.dataset.interviewAnswered='true';form.dispatchEvent(new Event('change'));}
|
|
1612
|
+
saveDraft();
|
|
1715
1613
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1614
|
+
catch (error) {
|
|
1615
|
+
entry.submitting = false;
|
|
1616
|
+
status.dataset.jobText = error instanceof Error && Object.hasOwn(enCatalog, error.message) && Object.hasOwn(koCatalog, error.message)
|
|
1617
|
+
? error.message : 'JOB_ACT_INVALID';
|
|
1618
|
+
status.textContent = jobWindowRefusal(error, 'JOB_ACT_INVALID');
|
|
1619
|
+
fields.disabled = false;
|
|
1620
|
+
}
|
|
1621
|
+
};
|
|
1622
|
+
return entry;
|
|
1623
|
+
}
|
|
1624
|
+
export {formFor};
|
|
1625
|
+
|
|
1626
|
+
// Keep the form dependencies available through the existing preparation seam as well as named exports.
|
|
1627
|
+
prepareJobForms.formFor = formFor;
|
|
1628
|
+
prepareJobForms.helpers = createJobFormHelpers;
|
|
1629
|
+
|
|
1630
|
+
/** The original source-bound draft storage, shared by the legacy and single-screen hosts. */
|
|
1631
|
+
/** Joined inspection uses real API rows and the same answer builder; no job identities or acts are synthesized. */
|
|
1632
|
+
export async function joinedInterviewForms(access:InstanceAccess,present:(forms:readonly HTMLElement[])=>void):Promise<()=>void> {
|
|
1633
|
+
const request=async(path:string,body?:unknown)=>{
|
|
1634
|
+
const response=await fetch(access.route(path),body?{method:'POST',headers:access.headers({'Content-Type':'application/json'}),body:JSON.stringify(body)}:undefined);
|
|
1635
|
+
const value=await response.json();if(!response.ok)throw new Error(value.error);return value;
|
|
1636
|
+
};
|
|
1637
|
+
const data=await request('/api/interview') as {questions:InterviewDisplayQuestion[];diagnostics?:import('../src/interview-project.ts').InterviewDiagnostic[];historical?:import('../src/interview-project.ts').HistoricalInterview[]};
|
|
1638
|
+
const forms=new Map<number,ReturnType<typeof createInterviewForm>>();
|
|
1639
|
+
let selected=Math.max(0,data.questions.findIndex(question=>question.editable&&!question.saved)),disposed=false;
|
|
1640
|
+
const node:JobFormNode=(tag,key)=>{const item=document.createElement(tag);if(key){item.dataset.jobText=key;item.textContent=t(key);}return item;};
|
|
1641
|
+
const show=(index:number)=>{
|
|
1642
|
+
if(disposed)return;selected=index;
|
|
1643
|
+
const question=data.questions[index];
|
|
1644
|
+
if(!question){const empty=node('section');empty.append(node('p','interview.empty'),interviewRecords(data.diagnostics,data.historical));present([empty]);return;}
|
|
1645
|
+
let entry=forms.get(index);
|
|
1646
|
+
if(!entry){
|
|
1647
|
+
entry=createInterviewForm({question,id:'joined-interview-'+question.ref.sha256,node,
|
|
1648
|
+
images:question.images.map(image=>({name:image.name,src:access.route(image.url)})),
|
|
1649
|
+
questions:()=>data.questions.map((item,i)=>({label:item.set.question+' · '+item.set.id+(item.editable?'':' · '+t('interview.history')),answered:forms.get(i)?.form.dataset.interviewAnswered==='true'||Boolean(item.saved||item.answer)})),
|
|
1650
|
+
selected:index,onSelect:show,diagnostics:data.diagnostics,historical:data.historical});
|
|
1651
|
+
const answer=entry;
|
|
1652
|
+
entry.fieldset.disabled=!question.editable||!access.capability;
|
|
1653
|
+
entry.form.onsubmit=async event=>{
|
|
1654
|
+
event.preventDefault();if(!question.editable||!access.capability||entry!.fieldset.disabled||!entry!.form.reportValidity())return;
|
|
1655
|
+
answer.fieldset.disabled=true;
|
|
1656
|
+
try{
|
|
1657
|
+
const value=answer.read(),picks=value.selections.map(selection=>({ask:selection.itemId,option_id:selection.optionId,...(selection.otherText!==null?{other_text:selection.otherText}:{})}));
|
|
1658
|
+
const record=interviewPicksRecord(question.ref,picks,answer.retainedNote,new Date().toISOString());
|
|
1659
|
+
await request('/api/interview/picks',record);
|
|
1660
|
+
question.saved=record;answer.form.dataset.interviewAnswered='true';answer.status.dataset.jobText='interview.saved';answer.status.textContent=t('interview.saved');answer.form.dispatchEvent(new Event('change'));
|
|
1661
|
+
}catch(error){const code=error instanceof Error?error.message.split(':')[0]:'';answer.status.dataset.jobText=interviewErrors[code]??'interview.failed';answer.status.textContent=t(answer.status.dataset.jobText);}
|
|
1662
|
+
finally{answer.fieldset.disabled=!question.editable||!access.capability;}
|
|
1663
|
+
};
|
|
1664
|
+
forms.set(index,entry);
|
|
1665
|
+
}
|
|
1666
|
+
entry.form.dispatchEvent(new Event('change'));present([entry.form]);
|
|
1667
|
+
};
|
|
1668
|
+
const localize=()=>{for(const entry of forms.values())entry.localize();};
|
|
1669
|
+
try{show(selected);}catch(error){for(const entry of forms.values())entry.dispose();throw error;}
|
|
1670
|
+
const off=onLanguageChange(localize);
|
|
1671
|
+
return ()=>{disposed=true;off();for(const entry of forms.values())entry.dispose();forms.clear();};
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
export function createJobFormDrafts(options:{jobId:string;current():JobPreparedInspection|null;forms():ReadonlyMap<string,JobForm>;storage():Pick<Storage,'setItem'>}) {
|
|
1724
1675
|
function localDraftKey(display: DisplayPublicationV3): string {
|
|
1725
|
-
return 'rig-review-job-draft/1:' +
|
|
1676
|
+
return 'rig-review-job-draft/1:' + options.jobId + ':' + display.publication.publicationId + ':' + display.publication.source.sourceHash;
|
|
1726
1677
|
}
|
|
1727
1678
|
function saveDraft(): void {
|
|
1679
|
+
const current=options.current(),forms=options.forms();
|
|
1728
1680
|
if (!current)
|
|
1729
1681
|
return;
|
|
1730
1682
|
try {
|
|
1731
|
-
|
|
1683
|
+
options.storage().setItem(localDraftKey(current.display), JSON.stringify({
|
|
1732
1684
|
publicationId: current.display.publication.publicationId,
|
|
1733
1685
|
sourceHash: current.display.publication.source.sourceHash,
|
|
1734
1686
|
source: current.display.publication.source,
|
|
@@ -1736,620 +1688,443 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1736
1688
|
forms: [...forms].filter(([, item]) => item.dirty).map(([askId, item]) => ({
|
|
1737
1689
|
askId, value: item.read(),
|
|
1738
1690
|
controls: [...item.form.querySelectorAll<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>('input[name],textarea[name],select[name]')]
|
|
1691
|
+
.filter(input=>!(input instanceof HTMLInputElement&&input.type==='radio')||input.checked)
|
|
1739
1692
|
.map(input => ({ name: input.name, value: input.value })),
|
|
1740
1693
|
})),
|
|
1741
1694
|
}));
|
|
1742
1695
|
}
|
|
1743
1696
|
catch { /* The in-memory retained draft remains source-bound. */ }
|
|
1744
1697
|
}
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
figure.append(node('p', 'job.identicalImages'));
|
|
1798
|
-
gallery.append(figure);
|
|
1799
|
-
}
|
|
1800
|
-
return gallery;
|
|
1698
|
+
return {localDraftKey,saveDraft};
|
|
1699
|
+
}
|
|
1700
|
+
prepareJobForms.drafts=createJobFormDrafts;
|
|
1701
|
+
|
|
1702
|
+
/** Host supported publications through the existing transaction/stream modules before mounting any screen. */
|
|
1703
|
+
export async function mountJobScreen(host:HTMLElement):Promise<()=>void> {
|
|
1704
|
+
let storage:Storage|null=null;try{storage=sessionStorage;}catch{/* Keep the capability in memory. */}
|
|
1705
|
+
const access=jobWindowAccess(location.href,storage,href=>history.replaceState(history.state,'',href)),pageId=crypto.randomUUID(),abort=new AbortController();
|
|
1706
|
+
const language=new URL(location.href).searchParams.get('lang');
|
|
1707
|
+
const i18n=await import('./i18n.ts');if(language==='en'||language==='ko')i18n.setLanguagePreference(language);
|
|
1708
|
+
const node=<Tag extends keyof HTMLElementTagNameMap>(tag:Tag,key?:string)=>{const value=document.createElement(tag);if(key){value.dataset.jobText=key;value.textContent=t(key);}return value;};
|
|
1709
|
+
const helpers=createJobFormHelpers(node,t),emptyForms=new Map<string,JobForm>();
|
|
1710
|
+
const modalState=()=>{const prepared=rigScreen.mounted();return prepared?.record??prepared?.modals;};
|
|
1711
|
+
const drafts=createJobFormDrafts({jobId:access.jobId,current:()=>modalState()?.inspection??null,forms:()=>modalState()?.forms??emptyForms,storage:()=>localStorage});
|
|
1712
|
+
const transport=createJobWindowTransport(access);
|
|
1713
|
+
let events:ReturnType<typeof startJobWindowEvents>|undefined,legacyStop:(()=>void)|undefined,stopped=false,fallingBack=false;
|
|
1714
|
+
const dependencies:JobFormDependencies={node,translate:t,helpers:{...helpers,assertJobAskSource,jobCheckpointContext},draftStorage:()=>localStorage,...drafts,access,pageId,
|
|
1715
|
+
window:{state:()=>window.state(),submit:input=>window.submit(input)}};
|
|
1716
|
+
const rigScreen=createJobRigScreen({host,pageId,access,translate:(key,values)=>i18n.t(key,values,'en'),refusal:jobWindowRefusal,formDependencies:dependencies,
|
|
1717
|
+
window:{state:()=>window.state(),submit:input=>window.submit(input)},readPublication:(id,signal)=>transport.readPublication(id,signal),
|
|
1718
|
+
routes:display=>jobPublicationRoutes(display,location.origin),load:async()=>(await import('./main.ts')).mountRigScreen()});
|
|
1719
|
+
let bootstrapNotice:HTMLElement|null=null;
|
|
1720
|
+
const report=(error:unknown,fallback?:string)=>{if(rigScreen.mounted()){rigScreen.report(error,fallback);return;}if(!bootstrapNotice){bootstrapNotice=node('p');bootstrapNotice.setAttribute('role','status');host.append(bootstrapNotice);}bootstrapNotice.textContent=jobWindowRefusal(error,fallback);};
|
|
1721
|
+
const window=createJobWindow<JobRigScreenPrepared|null>({jobId:access.jobId,pageId,transport,adapter:{
|
|
1722
|
+
async prepare(display,signal){const prepared=await rigScreen.prepare(display,signal);if(!prepared&&rigScreen.mounted()){location.reload();return new Promise<never>(()=>{});}return prepared;},
|
|
1723
|
+
captureDraft(){drafts.saveDraft();const forms=modalState()?.forms;const dirty=forms?[...forms].filter(([,entry])=>entry.dirty):[];return dirty.length?dirty.map(([askId,entry])=>({askId,value:entry.read()})):null;},
|
|
1724
|
+
commit:prepared=>prepared?rigScreen.commit(prepared):{rollback(){},finalize(){}},
|
|
1725
|
+
async painted(prepared,signal){if(prepared)await rigScreen.painted(prepared,signal);else{if(stopped||fallingBack||signal.aborted)return;fallingBack=true;abort.abort();window.stop();await events?.done;if(!stopped){const dispose=await mountJobSession(host,true,access);if(stopped)dispose();else legacyStop=dispose;}}},
|
|
1726
|
+
discard:prepared=>{const modal=prepared?.record??prepared?.modals;for(const entry of modal?.forms.values()??[])entry.dispose?.();modal?.inspection.dispose();},
|
|
1727
|
+
changed(state){rigScreen.changed(state);if(state.error&&(!rigScreen.mounted()||rigScreen.mounted()?.record))report(state.error);if(state.receipt&&!state.preparing)events?.displayed();},
|
|
1728
|
+
}});
|
|
1729
|
+
const hub=new URL(location.href).searchParams.get('hub');
|
|
1730
|
+
const binding=()=>({jobId:access.jobId,incarnation:hub!,publicationId:window.state().displayed?.publication.publicationId??null,sourceHash:window.state().displayed?.publication.source.sourceHash??null});
|
|
1731
|
+
const visibility=(event:MessageEvent)=>{if(!hub||!jobHubMessageMatches(event,location.origin,globalThis.parent,binding(),'visibility'))return;events?.visibility(event.data.visible);i18n.setLinkLanguage(null);i18n.setLanguagePreference(event.data.language);};
|
|
1732
|
+
if(hub)globalThis.addEventListener('message',visibility);
|
|
1733
|
+
const localize=i18n.onLanguageChange(()=>{for(const element of host.querySelectorAll<HTMLElement>('[data-job-text]'))element.textContent=t(element.dataset.jobText!);for(const form of host.querySelectorAll('form.interview-answer'))form.dispatchEvent(new Event('job-form-language'));});
|
|
1734
|
+
events=startJobWindowEvents({access,signal:abort.signal,member:!!hub,event:event=>{window.event(event);if(hub)globalThis.parent.postMessage({...binding(),schema:JOB_HUB_READY},location.origin);},refused:error=>report(error,'JOB_STREAM_FAILED')});
|
|
1735
|
+
const stop=()=>{if(stopped)return;stopped=true;drafts.saveDraft();abort.abort();window.stop();const modal=modalState();for(const entry of modal?.forms.values()??[])entry.dispose?.();modal?.inspection.dispose();localize();legacyStop?.();globalThis.removeEventListener('message',visibility);globalThis.removeEventListener('pagehide',stop);};
|
|
1736
|
+
globalThis.addEventListener('pagehide',stop,{once:true});return stop;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
/** Browser mount is explicit so importing transaction helpers never starts an app. */
|
|
1740
|
+
/** `inherited` keeps the capability the one-screen mount already took off the URL (it may live only in memory). */
|
|
1741
|
+
export async function mountJobSession(host: HTMLElement, legacy=false, inherited?: JobWindowAccess): Promise<() => void> {
|
|
1742
|
+
if(!legacy)return mountJobScreen(host);
|
|
1743
|
+
const [{ createViewportController, createViewportState }, { createRigViewportProvider }, { mountViewportPair }, i18n] = await Promise.all([
|
|
1744
|
+
import('./viewport-controller.ts'), import('./rig-viewport-provider.ts'),
|
|
1745
|
+
import('./viewport-pair.ts'), import('./i18n.ts'),
|
|
1746
|
+
]);
|
|
1747
|
+
let storage: Storage | null = null;
|
|
1748
|
+
try {
|
|
1749
|
+
storage = sessionStorage;
|
|
1801
1750
|
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1751
|
+
catch { /* Capability stays in memory. */ }
|
|
1752
|
+
const access = inherited ?? jobWindowAccess(location.href, storage, href => history.replaceState(history.state, '', href));
|
|
1753
|
+
const hubIncarnation = new URL(location.href).searchParams.get('hub');
|
|
1754
|
+
let hubVisible = !hubIncarnation;
|
|
1755
|
+
let events: ReturnType<typeof startJobWindowEvents> | undefined;
|
|
1756
|
+
const pageId = crypto.randomUUID();
|
|
1757
|
+
const transport = createJobWindowTransport(access);
|
|
1758
|
+
const abort = new AbortController();
|
|
1759
|
+
const language = new URL(location.href).searchParams.get('lang');
|
|
1760
|
+
if (language === 'en' || language === 'ko')
|
|
1761
|
+
i18n.setLanguagePreference(language);
|
|
1762
|
+
const t = i18n.t;
|
|
1763
|
+
const node = <Tag extends keyof HTMLElementTagNameMap>(tag: Tag, key?: string) => {
|
|
1764
|
+
const value = document.createElement(tag);
|
|
1765
|
+
if (key) {
|
|
1766
|
+
value.dataset.jobText = key;
|
|
1767
|
+
value.textContent = t(key);
|
|
1768
|
+
}
|
|
1769
|
+
return value;
|
|
1770
|
+
};
|
|
1771
|
+
const formHelpers = prepareJobForms.helpers(node, t);
|
|
1772
|
+
const {inputLabel, imageGallery} = formHelpers;
|
|
1773
|
+
const shell = mountWorkspaceShell({compatibility: 'legacyJobStep5', title: t('job.title')});
|
|
1774
|
+
const {header, title} = shell, languages = shell.language!;
|
|
1775
|
+
languages.value = i18n.getLanguage();
|
|
1776
|
+
languages.setAttribute('aria-label', t('interview.language'));
|
|
1777
|
+
languages.onchange = () => { i18n.setLinkLanguage(null); i18n.setLanguagePreference(languages.value === 'ko' ? 'ko' : 'en'); };
|
|
1778
|
+
const notice = node('p', 'job.waiting');
|
|
1779
|
+
notice.className = 'job-notice';
|
|
1780
|
+
notice.setAttribute('role', 'status');
|
|
1781
|
+
const workspace = node('main');
|
|
1782
|
+
host.classList.add('job-window');
|
|
1783
|
+
host.replaceChildren(header, notice, workspace);
|
|
1784
|
+
let current: JobPreparedInspection | null = null;
|
|
1785
|
+
let currentElement: HTMLElement | null = null;
|
|
1786
|
+
let view = 'compare';
|
|
1787
|
+
type SavedCameraState = Pick<
|
|
1788
|
+
ReturnType<typeof createViewportState>,
|
|
1789
|
+
'cameraSync' | 'activeCamera' | 'zoom' | 'cameraCenter' | 'referenceZoom' | 'referenceCenter'
|
|
1790
|
+
>;
|
|
1791
|
+
type SavedJobWindowState = {
|
|
1792
|
+
publicationId: string;
|
|
1793
|
+
label: string;
|
|
1794
|
+
sourceHash: string;
|
|
1795
|
+
previousLabel: string | null;
|
|
1796
|
+
compatibilityNotice?: boolean;
|
|
1797
|
+
animation?: string;
|
|
1798
|
+
time?: number;
|
|
1799
|
+
loop?: boolean;
|
|
1800
|
+
selectedReference?: string;
|
|
1801
|
+
panel?: string;
|
|
1802
|
+
camera?: unknown;
|
|
1803
|
+
};
|
|
1804
|
+
const parseSavedPoint = (raw: unknown): { x: number; y: number } | null | undefined => {
|
|
1805
|
+
if (raw === null) return null;
|
|
1806
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;
|
|
1807
|
+
const point = raw as Record<string, unknown>;
|
|
1808
|
+
return typeof point.x === 'number' && Number.isFinite(point.x) &&
|
|
1809
|
+
typeof point.y === 'number' && Number.isFinite(point.y)
|
|
1810
|
+
? { x: point.x, y: point.y }
|
|
1811
|
+
: undefined;
|
|
1812
|
+
};
|
|
1813
|
+
const parseSavedCamera = (raw: unknown): SavedCameraState | null => {
|
|
1814
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
|
|
1815
|
+
const value = raw as Record<string, unknown>;
|
|
1816
|
+
const cameraCenter = parseSavedPoint(value.cameraCenter);
|
|
1817
|
+
const referenceCenter = parseSavedPoint(value.referenceCenter);
|
|
1818
|
+
if (typeof value.cameraSync !== 'boolean' ||
|
|
1819
|
+
(value.activeCamera !== 'rig' && value.activeCamera !== 'reference') ||
|
|
1820
|
+
typeof value.zoom !== 'number' || !Number.isFinite(value.zoom) || value.zoom < 0.25 || value.zoom > 8 ||
|
|
1821
|
+
typeof value.referenceZoom !== 'number' || !Number.isFinite(value.referenceZoom) || value.referenceZoom < 0.25 || value.referenceZoom > 8 ||
|
|
1822
|
+
cameraCenter === undefined || referenceCenter === undefined) {
|
|
1823
|
+
return null;
|
|
1824
|
+
}
|
|
1825
|
+
return {
|
|
1826
|
+
cameraSync: value.cameraSync,
|
|
1827
|
+
activeCamera: value.activeCamera,
|
|
1828
|
+
zoom: value.zoom,
|
|
1829
|
+
cameraCenter,
|
|
1830
|
+
referenceZoom: value.referenceZoom,
|
|
1831
|
+
referenceCenter,
|
|
1832
|
+
};
|
|
1833
|
+
};
|
|
1834
|
+
const parseSavedDraftRecord = (raw: unknown): JobRetainedDraft | null => {
|
|
1835
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
|
|
1836
|
+
const draft = raw as Record<string, unknown>;
|
|
1837
|
+
if (!Array.isArray(draft.forms) || !draft.forms.length ||
|
|
1838
|
+
typeof draft.publicationId !== 'string' || !draft.publicationId ||
|
|
1839
|
+
typeof draft.sourceHash !== 'string' || !draft.sourceHash ||
|
|
1840
|
+
typeof draft.label !== 'string' || !draft.label ||
|
|
1841
|
+
!draft.source || typeof draft.source !== 'object' || Array.isArray(draft.source) ||
|
|
1842
|
+
(draft.source as { sourceHash?: unknown }).sourceHash !== draft.sourceHash) {
|
|
1843
|
+
return null;
|
|
1844
|
+
}
|
|
1845
|
+
const forms = draft.forms.filter((item: unknown): item is { askId: string; value: unknown } =>
|
|
1846
|
+
!!item && typeof item === 'object' && !Array.isArray(item) &&
|
|
1847
|
+
typeof (item as { askId?: unknown }).askId === 'string' && !!(item as { askId: string }).askId);
|
|
1848
|
+
if (!forms.length) return null;
|
|
1849
|
+
return {
|
|
1850
|
+
publicationId: draft.publicationId,
|
|
1851
|
+
sourceHash: draft.sourceHash,
|
|
1852
|
+
source: draft.source as SourceV3,
|
|
1853
|
+
label: draft.label,
|
|
1854
|
+
value: forms.map(item => ({ askId: item.askId, value: item.value })),
|
|
1855
|
+
};
|
|
1856
|
+
};
|
|
1857
|
+
const localWindowKey = 'rig-review-job-window/1:' + access.jobId;
|
|
1858
|
+
let savedWindow: SavedJobWindowState | null = null;
|
|
1859
|
+
try {
|
|
1860
|
+
const parsed = JSON.parse(localStorage.getItem(localWindowKey) ?? 'null');
|
|
1861
|
+
if (parsed && typeof parsed.publicationId === 'string' && typeof parsed.label === 'string' &&
|
|
1862
|
+
typeof parsed.sourceHash === 'string') {
|
|
1863
|
+
savedWindow = parsed as SavedJobWindowState;
|
|
1843
1864
|
}
|
|
1844
|
-
list.addEventListener('keydown', event => {
|
|
1845
|
-
const key = event as KeyboardEvent;
|
|
1846
|
-
if (!['ArrowUp', 'ArrowDown'].includes(key.key) || !(key.target instanceof HTMLElement) || key.target.tagName !== 'SUMMARY') return;
|
|
1847
|
-
const summaries = [...list.querySelectorAll<HTMLElement>('summary')];
|
|
1848
|
-
const index = summaries.indexOf(key.target);
|
|
1849
|
-
const next = summaries[index + (key.key === 'ArrowDown' ? 1 : -1)];
|
|
1850
|
-
if (next) {key.preventDefault(); next.focus();}
|
|
1851
|
-
});
|
|
1852
|
-
section.append(list);
|
|
1853
|
-
return section;
|
|
1854
1865
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
source.textContent = prepared.display.publication.label + ' · ' + ask.source.sourceHash;
|
|
1866
|
-
fields.append(source);
|
|
1867
|
-
const note = textArea(fields, 'interview.note');
|
|
1868
|
-
let read: () => UISubmissionV3['value'];
|
|
1869
|
-
let submitKey = 'Submit review';
|
|
1870
|
-
const subject = ask.subject;
|
|
1871
|
-
if (subject.kind === 'interview-picks') {
|
|
1872
|
-
const question = prepared.interview?.questions.find(item => item.set.id === subject.setId && item.set.question === subject.questionId);
|
|
1873
|
-
if (!question || !question.editable) throw new Error('JOB_ASK_INVALID');
|
|
1874
|
-
if (question.ref.sha256 !== ask.source.optionSet?.sha256) throw new Error('JOB_ACT_SOURCE_STALE');
|
|
1875
|
-
const interviewState = prepared.interview?.interview ?? prepared.display.publication.interview ?? null;
|
|
1876
|
-
const inspectionRecord = interviewState?.records.find(
|
|
1877
|
-
item => item.timeKind === 'inspection' &&
|
|
1878
|
-
item.questionId === subject.questionId &&
|
|
1879
|
-
item.setId === subject.setId &&
|
|
1880
|
-
item.record.endsWith('.pending_options'),
|
|
1881
|
-
);
|
|
1882
|
-
const legacyDiagnostic = inspectionRecord
|
|
1883
|
-
? interviewState?.diagnostics.find(
|
|
1884
|
-
item => item.code === 'INTERVIEW_OPTIONS_SCENE_LEGACY' &&
|
|
1885
|
-
item.record === inspectionRecord.record &&
|
|
1886
|
-
item.at === inspectionRecord.at,
|
|
1887
|
-
)
|
|
1888
|
-
: undefined;
|
|
1889
|
-
if (legacyDiagnostic) {
|
|
1890
|
-
const legacyNotice = node('p', 'INTERVIEW_OPTIONS_SCENE_LEGACY');
|
|
1891
|
-
legacyNotice.dataset.jobInterviewWarning = legacyDiagnostic.code;
|
|
1892
|
-
legacyNotice.dataset.record = legacyDiagnostic.record;
|
|
1893
|
-
fields.prepend(legacyNotice);
|
|
1894
|
-
}
|
|
1895
|
-
const heading = node('h3');
|
|
1896
|
-
heading.textContent = question.set.question;
|
|
1897
|
-
fields.prepend(heading);
|
|
1898
|
-
const answers = question.set.asks.map(item => {
|
|
1899
|
-
const group = node('fieldset');
|
|
1900
|
-
const legend = node('legend');
|
|
1901
|
-
legend.textContent = item.prompt;
|
|
1902
|
-
group.append(legend);
|
|
1903
|
-
const pick = node('select');
|
|
1904
|
-
pick.required = true;
|
|
1905
|
-
pick.name = 'choice.' + item.id;
|
|
1906
|
-
const empty = node('option', 'job.choose');
|
|
1907
|
-
empty.value = '';
|
|
1908
|
-
pick.append(empty);
|
|
1909
|
-
for (const choice of item.options) {
|
|
1910
|
-
const option = node('option');
|
|
1911
|
-
option.value = choice.id;
|
|
1912
|
-
option.textContent = choice.label + ' · ' + choice.effect;
|
|
1913
|
-
pick.append(option);
|
|
1914
|
-
}
|
|
1915
|
-
const other = node('textarea');
|
|
1916
|
-
other.hidden = true;
|
|
1917
|
-
other.name = 'other.' + item.id;
|
|
1918
|
-
const warning = node('p');
|
|
1919
|
-
warning.hidden = true;
|
|
1920
|
-
pick.onchange = () => {
|
|
1921
|
-
const choice = item.options.find(option => option.id === pick.value);
|
|
1922
|
-
other.hidden = choice?.kind !== 'other';
|
|
1923
|
-
other.required = choice?.kind === 'other';
|
|
1924
|
-
warning.hidden = choice?.kind === 'value';
|
|
1925
|
-
warning.textContent = t(choice?.kind === 'other' ? 'interview.otherPending' : 'interview.autoPending');
|
|
1926
|
-
};
|
|
1927
|
-
group.append(pick, other, warning);
|
|
1928
|
-
fields.append(group);
|
|
1929
|
-
return { item, pick, other };
|
|
1930
|
-
});
|
|
1931
|
-
for (const image of question.images) {
|
|
1932
|
-
const visual = prepared.interviewImages.get(image.url);
|
|
1933
|
-
if (!visual)
|
|
1934
|
-
throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
1935
|
-
fields.append(visual.cloneNode(true));
|
|
1866
|
+
catch { /* Invalid saved window state falls back to defaults. */ }
|
|
1867
|
+
const initialRetainedDrafts: JobRetainedDraft[] = [];
|
|
1868
|
+
try {
|
|
1869
|
+
const draftPrefix = 'rig-review-job-draft/1:' + access.jobId + ':';
|
|
1870
|
+
for (let index = 0; index < localStorage.length; index++) {
|
|
1871
|
+
const key = localStorage.key(index);
|
|
1872
|
+
if (!key?.startsWith(draftPrefix)) continue;
|
|
1873
|
+
try {
|
|
1874
|
+
const parsedDraft = parseSavedDraftRecord(JSON.parse(localStorage.getItem(key) ?? 'null'));
|
|
1875
|
+
if (parsedDraft) initialRetainedDrafts.push(parsedDraft);
|
|
1936
1876
|
}
|
|
1937
|
-
|
|
1938
|
-
selections: answers.map(({ item, pick, other }) => ({ itemId: item.id, optionId: pick.value,
|
|
1939
|
-
otherText: item.options.find(option => option.id === pick.value)?.kind === 'other' ? other.value : null })), note: note.value });
|
|
1940
|
-
submitKey = 'interview.save';
|
|
1877
|
+
catch { /* Ignore malformed draft entries without dropping sibling drafts. */ }
|
|
1941
1878
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
cell.textContent = String(value);
|
|
1987
|
-
cells.append(cell);
|
|
1988
|
-
}
|
|
1989
|
-
body.append(cells);
|
|
1990
|
-
}
|
|
1991
|
-
table.append(caption, head, body);
|
|
1992
|
-
tableHost.append(table);
|
|
1993
|
-
const routes = node('pre');
|
|
1994
|
-
routes.textContent = evidence.packet.routesText;
|
|
1995
|
-
const recommendation = node('pre');
|
|
1996
|
-
recommendation.textContent = evidence.packet.recommendationText;
|
|
1997
|
-
section.append(tableHost, node('h4', 'job.checkpointRoutes'), routes,
|
|
1998
|
-
node('h4', 'job.checkpointRecommendation'), recommendation);
|
|
1999
|
-
fields.append(section, node('p', 'job.checkpointRouteMapping'));
|
|
1879
|
+
}
|
|
1880
|
+
catch { /* In-memory standing state remains active when storage is unavailable. */ }
|
|
1881
|
+
const previousDisplayed = savedWindow ? {
|
|
1882
|
+
publicationId: savedWindow.publicationId,
|
|
1883
|
+
label: savedWindow.label,
|
|
1884
|
+
previousLabel: typeof savedWindow.previousLabel === 'string' ? savedWindow.previousLabel : null,
|
|
1885
|
+
} : null;
|
|
1886
|
+
let animation = typeof savedWindow?.animation === 'string' ? savedWindow.animation : '';
|
|
1887
|
+
let time = typeof savedWindow?.time === 'number' && Number.isFinite(savedWindow.time) && savedWindow.time >= 0
|
|
1888
|
+
? savedWindow.time : 0;
|
|
1889
|
+
let playing = false;
|
|
1890
|
+
let loop = typeof savedWindow?.loop === 'boolean' ? savedWindow.loop : true;
|
|
1891
|
+
let playbackCarry = 0;
|
|
1892
|
+
let rafHandle = 0;
|
|
1893
|
+
let lastFrameTime = 0;
|
|
1894
|
+
let inPlaybackStep = false;
|
|
1895
|
+
let lastRunningSaveMs: number | null = null;
|
|
1896
|
+
let lastSavedWindowJson: string | null = null;
|
|
1897
|
+
let selectedReference = typeof savedWindow?.selectedReference === 'string' ? savedWindow.selectedReference : '';
|
|
1898
|
+
let panel = typeof savedWindow?.panel === 'string' && ['1', '2', '3', '4'].includes(savedWindow.panel)
|
|
1899
|
+
? savedWindow.panel : '3';
|
|
1900
|
+
let restoredCamera: SavedCameraState | null = parseSavedCamera(savedWindow?.camera);
|
|
1901
|
+
let compatibilityNotice = Boolean(savedWindow?.compatibilityNotice);
|
|
1902
|
+
type PreparedWindow = JobPreparedInspection & {
|
|
1903
|
+
element: HTMLElement;
|
|
1904
|
+
forms: Map<string, JobForm>;
|
|
1905
|
+
};
|
|
1906
|
+
const forms = new Map<string, JobForm>();
|
|
1907
|
+
const viewportState = createViewportState();
|
|
1908
|
+
if (restoredCamera) {
|
|
1909
|
+
Object.assign(viewportState, restoredCamera, { cameraRestoring: false });
|
|
1910
|
+
}
|
|
1911
|
+
function saveWindowState(nowMs?: number): void {
|
|
1912
|
+
if (!current)
|
|
1913
|
+
return;
|
|
1914
|
+
if (inPlaybackStep && nowMs === undefined)
|
|
1915
|
+
return;
|
|
1916
|
+
const state = window.state();
|
|
1917
|
+
if (state.displayed?.publication.publicationId !== current.display.publication.publicationId)
|
|
1918
|
+
return;
|
|
1919
|
+
if (nowMs !== undefined) {
|
|
1920
|
+
if (lastRunningSaveMs === null) {
|
|
1921
|
+
lastRunningSaveMs = nowMs;
|
|
1922
|
+
return;
|
|
2000
1923
|
}
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
fields.append(outcome, note.parentElement!);
|
|
2005
|
-
read = () => ({ checkpointId: subject.checkpointId, outcome: outcome.value as 'pass' | 'fail', words: note.value });
|
|
2006
|
-
submitKey = 'job.saveCheckpoint';
|
|
1924
|
+
if (nowMs - lastRunningSaveMs < 1000)
|
|
1925
|
+
return;
|
|
1926
|
+
lastRunningSaveMs = nowMs;
|
|
2007
1927
|
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
1928
|
+
try {
|
|
1929
|
+
const serialized = JSON.stringify({
|
|
1930
|
+
publicationId: current.display.publication.publicationId,
|
|
1931
|
+
label: current.display.publication.label,
|
|
1932
|
+
sourceHash: current.display.publication.source.sourceHash,
|
|
1933
|
+
previousLabel: state.previousLabel,
|
|
1934
|
+
compatibilityNotice,
|
|
1935
|
+
animation,
|
|
1936
|
+
time,
|
|
1937
|
+
loop,
|
|
1938
|
+
selectedReference,
|
|
1939
|
+
panel,
|
|
1940
|
+
camera: {
|
|
1941
|
+
cameraSync: viewportState.cameraSync,
|
|
1942
|
+
activeCamera: viewportState.activeCamera,
|
|
1943
|
+
zoom: viewportState.zoom,
|
|
1944
|
+
cameraCenter: viewportState.cameraCenter
|
|
1945
|
+
? { x: viewportState.cameraCenter.x, y: viewportState.cameraCenter.y } : null,
|
|
1946
|
+
referenceZoom: viewportState.referenceZoom,
|
|
1947
|
+
referenceCenter: viewportState.referenceCenter
|
|
1948
|
+
? { x: viewportState.referenceCenter.x, y: viewportState.referenceCenter.y } : null,
|
|
1949
|
+
},
|
|
1950
|
+
});
|
|
1951
|
+
if (serialized === lastSavedWindowJson)
|
|
1952
|
+
return;
|
|
1953
|
+
localStorage.setItem(localWindowKey, serialized);
|
|
1954
|
+
lastSavedWindowJson = serialized;
|
|
1955
|
+
}
|
|
1956
|
+
catch { /* Standing state stays in memory when storage is unavailable. */ }
|
|
1957
|
+
}
|
|
1958
|
+
const el = <Element extends HTMLElement = HTMLElement>(id: string): Element => {
|
|
1959
|
+
const element = workspace.querySelector<HTMLElement>('#' + id);
|
|
1960
|
+
if (!element)
|
|
1961
|
+
throw new Error('JOB_WINDOW_ELEMENT_MISSING');
|
|
1962
|
+
return element as Element;
|
|
1963
|
+
};
|
|
1964
|
+
const reference = () => current?.references.find(item => item.id === selectedReference) ?? null;
|
|
1965
|
+
const setText = (id: string, value: string) => { const element = workspace.querySelector('#' + id); if (element)
|
|
1966
|
+
element.textContent = i18n.tr(value); };
|
|
1967
|
+
const provider = createRigViewportProvider({
|
|
1968
|
+
el, player: () => current?.player ?? null, assets: () => current?.assets ?? null,
|
|
1969
|
+
referenceSize: () => reference(), view: () => view, referenceGeneration: () => current?.display.publication.generation ?? 0,
|
|
1970
|
+
parts: () => current?.inspection ?? null, text: setText, fitLabel: 'Fit',
|
|
1971
|
+
message: value => { notice.textContent = jobWindowRefusal(value); }, redrawOverlay: () => {},
|
|
1972
|
+
}, viewportState);
|
|
1973
|
+
const canonicalControls = provider.renderControls;
|
|
1974
|
+
provider.renderControls = controller => {
|
|
1975
|
+
canonicalControls(controller);
|
|
1976
|
+
const fit = el('fit');
|
|
1977
|
+
fit.textContent = t(fit.textContent ?? 'Fit');
|
|
1978
|
+
saveWindowState();
|
|
1979
|
+
};
|
|
1980
|
+
const viewport = createViewportController(provider, viewportState);
|
|
1981
|
+
function drawInspection(owner: JobPreparedInspection): void {
|
|
1982
|
+
owner.player?.draw();
|
|
1983
|
+
owner.inspection?.present('single');
|
|
1984
|
+
}
|
|
1985
|
+
function syncTransportControls(): void {
|
|
1986
|
+
const playBtn = workspace.querySelector<HTMLButtonElement>('#job-play');
|
|
1987
|
+
if (playBtn) {
|
|
1988
|
+
const clip = current?.assets?.animations.find(item => item.name === animation);
|
|
1989
|
+
playBtn.disabled = !animation || !clip || !(clip.duration > 0) || !current?.player;
|
|
1990
|
+
const key = playing ? 'Pause' : 'Play';
|
|
1991
|
+
playBtn.dataset.jobText = key;
|
|
1992
|
+
playBtn.textContent = t(key);
|
|
1993
|
+
playBtn.setAttribute('aria-pressed', String(playing));
|
|
1994
|
+
}
|
|
1995
|
+
const loopInput = workspace.querySelector<HTMLInputElement>('#job-loop');
|
|
1996
|
+
if (loopInput) loopInput.checked = loop;
|
|
1997
|
+
}
|
|
1998
|
+
function stopPlayback(targetPlayer = current?.player): void {
|
|
1999
|
+
if (rafHandle) {
|
|
2000
|
+
cancelAnimationFrame(rafHandle);
|
|
2001
|
+
rafHandle = 0;
|
|
2002
|
+
}
|
|
2003
|
+
playing = false;
|
|
2004
|
+
playbackCarry = 0;
|
|
2005
|
+
lastFrameTime = 0;
|
|
2006
|
+
lastRunningSaveMs = null;
|
|
2007
|
+
targetPlayer?.pause();
|
|
2008
|
+
syncTransportControls();
|
|
2009
|
+
saveWindowState();
|
|
2010
|
+
}
|
|
2011
|
+
function presentCurrentFrame(owner: JobPreparedInspection): void {
|
|
2012
|
+
if (!owner.player) return;
|
|
2013
|
+
drawInspection(owner);
|
|
2014
|
+
viewport.fitCamera();
|
|
2015
|
+
}
|
|
2016
|
+
function armPlayback(expectedOwner: JobPreparedInspection, expectedPlayer: RigPlayer): void {
|
|
2017
|
+
if (rafHandle) {
|
|
2018
|
+
cancelAnimationFrame(rafHandle);
|
|
2019
|
+
rafHandle = 0;
|
|
2016
2020
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
read = () => {
|
|
2034
|
-
const notes = imageNotes.filter(note => note.input.value !== '')
|
|
2035
|
-
.map(note => ({name: note.name, words: note.input.value}));
|
|
2036
|
-
return {stage, verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: note.value,
|
|
2037
|
-
...(notes.length ? {imageNotes: notes} : {})};
|
|
2038
|
-
};
|
|
2039
|
-
} else {
|
|
2040
|
-
read = () => ({ stage, verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: note.value });
|
|
2041
|
-
}
|
|
2021
|
+
const handle = requestAnimationFrame(now => stepPlayback(handle, expectedOwner, expectedPlayer, now));
|
|
2022
|
+
rafHandle = handle;
|
|
2023
|
+
}
|
|
2024
|
+
function playbackTimeLabel(duration: number, trackTime: number): string {
|
|
2025
|
+
// A one-second 1/60 replay leaves six epsilons after modulo. Limit display snapping
|
|
2026
|
+
// to eight duration-scaled epsilons. The public time and captured frame stay raw.
|
|
2027
|
+
if (trackTime < duration) return String(time);
|
|
2028
|
+
const residue = 8 * Number.EPSILON * duration;
|
|
2029
|
+
if (time <= residue) return '0';
|
|
2030
|
+
if (duration - time <= residue) return String(duration);
|
|
2031
|
+
return String(time);
|
|
2032
|
+
}
|
|
2033
|
+
function stepPlayback(handle: number, expectedOwner: JobPreparedInspection, expectedPlayer: RigPlayer, now: number): void {
|
|
2034
|
+
if (current !== expectedOwner || current?.player !== expectedPlayer) {
|
|
2035
|
+
expectedPlayer.pause();
|
|
2036
|
+
return;
|
|
2042
2037
|
}
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
submitKey = 'job.signoff';
|
|
2038
|
+
if (handle !== rafHandle) return;
|
|
2039
|
+
rafHandle = 0;
|
|
2040
|
+
const clip = expectedOwner.assets?.animations.find(item => item.name === animation);
|
|
2041
|
+
if (!playing || !hubVisible || !animation || !clip || !(clip.duration > 0)) {
|
|
2042
|
+
stopPlayback(expectedPlayer);
|
|
2043
|
+
return;
|
|
2050
2044
|
}
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
) {
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
const stage = node('p');
|
|
2062
|
-
stage.textContent = subject.stage;
|
|
2063
|
-
fields.append(stage);
|
|
2064
|
-
read = () => ({ stage: subject.stage, words: note.value });
|
|
2065
|
-
submitKey = 'job.reopen';
|
|
2045
|
+
const dt = lastFrameTime > 0 ? Math.min(Math.max(0, (now - lastFrameTime) / 1000), 0.1) : 0;
|
|
2046
|
+
lastFrameTime = now;
|
|
2047
|
+
const next = advancePlayback({ time, duration: clip.duration, carry: playbackCarry, elapsed: dt, repeat: loop });
|
|
2048
|
+
for (const step of next.steps) expectedPlayer.advance(step);
|
|
2049
|
+
const activeEntry = expectedPlayer.entry(0);
|
|
2050
|
+
if (!activeEntry || activeEntry.animation !== animation || activeEntry.loop !== loop ||
|
|
2051
|
+
!Number.isFinite(activeEntry.animationTime) || activeEntry.animationTime < 0 ||
|
|
2052
|
+
activeEntry.animationTime > activeEntry.duration) {
|
|
2053
|
+
stopPlayback(expectedPlayer);
|
|
2054
|
+
return;
|
|
2066
2055
|
}
|
|
2067
|
-
|
|
2068
|
-
|
|
2056
|
+
playbackCarry = next.carry;
|
|
2057
|
+
if (next.ended) {
|
|
2058
|
+
playing = false;
|
|
2059
|
+
playbackCarry = 0;
|
|
2060
|
+
lastFrameTime = 0;
|
|
2061
|
+
expectedPlayer.pause();
|
|
2062
|
+
time = clip.duration;
|
|
2063
|
+
} else {
|
|
2064
|
+
time = activeEntry.animationTime;
|
|
2069
2065
|
}
|
|
2070
|
-
const
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
const status = node('p');
|
|
2074
|
-
status.setAttribute('role', 'status');
|
|
2075
|
-
form.append(status);
|
|
2076
|
-
const entry: JobForm = { form, fieldset: fields, read, submissionId: crypto.randomUUID(), dirty: false,
|
|
2077
|
-
submitting: false, rigSubmission: createJobRigSubmission() };
|
|
2078
|
-
const signoffSubmissionId = crypto.randomUUID();
|
|
2066
|
+
const clock = workspace.querySelector<HTMLInputElement>('#job-time');
|
|
2067
|
+
if (clock) clock.value = playbackTimeLabel(clip.duration, activeEntry.trackTime);
|
|
2068
|
+
inPlaybackStep = true;
|
|
2079
2069
|
try {
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
saved?.sourceHash === prepared.display.publication.source.sourceHash) {
|
|
2083
|
-
assertJobAskSource({...ask, source: saved.source}, prepared.display);
|
|
2084
|
-
const original = saved.forms?.find((item: {
|
|
2085
|
-
askId: string;
|
|
2086
|
-
}) => item.askId === ask.askId);
|
|
2087
|
-
if (subject.kind === 'parts-verdict') {
|
|
2088
|
-
const panel = partsPanels.get(prepared);
|
|
2089
|
-
if (panel && Array.isArray(original?.value?.issues)) panel.issues = structuredClone(original.value.issues);
|
|
2090
|
-
else if (panel && original?.value?.parts) panel.legacy = original.value;
|
|
2091
|
-
}
|
|
2092
|
-
for (const input of form.querySelectorAll<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>('input[name],textarea[name],select[name]')) {
|
|
2093
|
-
const restored = original?.controls?.find((item: {
|
|
2094
|
-
name: string;
|
|
2095
|
-
value: string;
|
|
2096
|
-
}) => item.name === input.name);
|
|
2097
|
-
if (restored && typeof restored.value === 'string') {
|
|
2098
|
-
input.value = restored.value;
|
|
2099
|
-
if (input instanceof HTMLSelectElement)
|
|
2100
|
-
input.dispatchEvent(new Event('change'));
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
entry.dirty = !!original;
|
|
2104
|
-
}
|
|
2070
|
+
syncTransportControls();
|
|
2071
|
+
presentCurrentFrame(expectedOwner);
|
|
2105
2072
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2073
|
+
finally {
|
|
2074
|
+
inPlaybackStep = false;
|
|
2075
|
+
}
|
|
2076
|
+
if (playing) {
|
|
2077
|
+
saveWindowState(now);
|
|
2078
|
+
} else {
|
|
2079
|
+
lastRunningSaveMs = null;
|
|
2080
|
+
saveWindowState();
|
|
2081
|
+
}
|
|
2082
|
+
if (playing && current === expectedOwner && current.player === expectedPlayer && hubVisible) {
|
|
2083
|
+
armPlayback(expectedOwner, expectedPlayer);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
const referenceSelection = createJobReferenceSelection<JobReferenceView>({
|
|
2087
|
+
current: () => ({owner: current, time}),
|
|
2088
|
+
present(value) {
|
|
2089
|
+
const previous = selectedReference;
|
|
2090
|
+
const camera = structuredClone(viewportState);
|
|
2091
|
+
selectedReference = value.id;
|
|
2114
2092
|
try {
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
if (entry.submissionId !== frozen.submissionId) throw new Error('JOB_STILL_BINDING_MISMATCH');
|
|
2126
|
-
if (subject.kind === 'parts-verdict') window.refresh();
|
|
2127
|
-
const result = subject.kind === 'parts-verdict'
|
|
2128
|
-
? await window.submitParts(frozen, signoffSubmissionId) : await window.submit(frozen);
|
|
2129
|
-
if (!result.ok)
|
|
2130
|
-
throw new Error(result.error.code);
|
|
2131
|
-
entry.submitting = false;
|
|
2132
|
-
entry.dirty = false;
|
|
2133
|
-
entry.rigSubmission.reset();
|
|
2134
|
-
status.dataset.jobText = 'job.saved';
|
|
2135
|
-
status.textContent = t('job.saved');
|
|
2136
|
-
saveDraft();
|
|
2137
|
-
if (subject.kind === 'parts-verdict') window.refresh();
|
|
2138
|
-
}
|
|
2139
|
-
catch (error) {
|
|
2140
|
-
entry.submitting = false;
|
|
2141
|
-
status.dataset.jobText = error instanceof Error && Object.hasOwn(enCatalog, error.message) && Object.hasOwn(koCatalog, error.message)
|
|
2142
|
-
? error.message : 'JOB_ACT_INVALID';
|
|
2143
|
-
status.textContent = jobWindowRefusal(error, 'JOB_ACT_INVALID');
|
|
2144
|
-
fields.disabled = false;
|
|
2145
|
-
if (subject.kind === 'parts-verdict') window.refresh();
|
|
2093
|
+
showReference();
|
|
2094
|
+
el<HTMLSelectElement>('job-reference').value = value.id;
|
|
2095
|
+
viewport.fitCamera();
|
|
2096
|
+
} catch (error) {
|
|
2097
|
+
selectedReference = previous;
|
|
2098
|
+
Object.assign(viewportState, camera);
|
|
2099
|
+
showReference();
|
|
2100
|
+
el<HTMLSelectElement>('job-reference').value = previous;
|
|
2101
|
+
viewport.fitCamera();
|
|
2102
|
+
throw error;
|
|
2146
2103
|
}
|
|
2147
|
-
}
|
|
2148
|
-
|
|
2149
|
-
|
|
2104
|
+
},
|
|
2105
|
+
refused(error) {
|
|
2106
|
+
el<HTMLSelectElement>('job-reference').value = selectedReference;
|
|
2107
|
+
notice.textContent = jobWindowRefusal(error, 'JOB_VISUAL_UNAVAILABLE');
|
|
2108
|
+
},
|
|
2109
|
+
});
|
|
2110
|
+
let unbindNavigation: (() => void) | null = null;
|
|
2111
|
+
let resize: ResizeObserver | null = null;
|
|
2112
|
+
const {localDraftKey,saveDraft}=prepareJobForms.drafts({jobId:access.jobId,current:()=>current,forms:()=>forms,storage:()=>localStorage});
|
|
2150
2113
|
function updateForms(state: JobWindowState): void {
|
|
2151
2114
|
if (!current)
|
|
2152
2115
|
return;
|
|
2153
2116
|
const host = workspace.querySelector<HTMLElement>('[data-job-forms]');
|
|
2154
2117
|
if (!host)
|
|
2155
2118
|
return;
|
|
2156
|
-
const
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
if (partsPanel && ask.subject.kind === 'signoff' && ask.subject.stage === 'parts-review') continue;
|
|
2164
|
-
if (partsPanel && ask.subject.kind === 'parts-verdict' && ask !== activeParts) continue;
|
|
2165
|
-
let entry = forms.get(ask.askId);
|
|
2166
|
-
if (!entry && (ask.status === 'pending' || partsPanel && ask === activeParts)) {
|
|
2167
|
-
try {
|
|
2168
|
-
entry = formFor(ask, current);
|
|
2169
|
-
forms.set(ask.askId, entry);
|
|
2170
|
-
host.append(entry.form);
|
|
2171
|
-
}
|
|
2172
|
-
catch (error) {
|
|
2173
|
-
const refusal = node('p');
|
|
2174
|
-
refusal.textContent = jobWindowRefusal(error, 'JOB_ASK_INVALID');
|
|
2175
|
-
host.append(refusal);
|
|
2176
|
-
}
|
|
2119
|
+
for(const ask of state.pending){
|
|
2120
|
+
if(ask.publicationId!==current.display.publication.publicationId)continue;
|
|
2121
|
+
if(ask.subject.kind!=='review-verdict'||!['image-review','direction-review'].includes(ask.subject.stage))throw new Error('JOB_PANEL_UNAVAILABLE');
|
|
2122
|
+
let entry=forms.get(ask.askId);
|
|
2123
|
+
if(!entry&&ask.status==='pending'){
|
|
2124
|
+
try{entry=prepareJobForms.formFor(ask,current,formDependencies);forms.set(ask.askId,entry);host.append(entry.form);}
|
|
2125
|
+
catch(error){const refusal=node('p');refusal.textContent=jobWindowRefusal(error,'JOB_ASK_INVALID');host.append(refusal);}
|
|
2177
2126
|
}
|
|
2178
|
-
if
|
|
2179
|
-
const partsAsk = partsPanel && ask.subject.kind === 'parts-verdict';
|
|
2180
|
-
entry.fieldset.disabled = entry.submitting || (ask.status !== 'pending' && !(partsAsk && partsState === 'retry-signoff')) ||
|
|
2181
|
-
state.preparing || state.closed || !state.receipt || !access.capability;
|
|
2182
|
-
if (partsAsk) {
|
|
2183
|
-
const button = entry.form.querySelector<HTMLButtonElement>('button[type=submit]')!;
|
|
2184
|
-
const signoff = state.pending.some(item => item.publicationId === ask.publicationId && item.status === 'pending' &&
|
|
2185
|
-
item.subject.kind === 'signoff' && item.subject.stage === 'parts-review');
|
|
2186
|
-
button.dataset.jobText = partsState === 'retry-signoff' ? 'job.partsRetrySignoff' :
|
|
2187
|
-
partsPanel.issues.length ? 'job.partsRequestFixes' : 'job.partsApprove';
|
|
2188
|
-
button.textContent = t(button.dataset.jobText, [partsPanel.issues.length]);
|
|
2189
|
-
button.disabled = !partsPanel.output || !!partsPanel.legacy ||
|
|
2190
|
-
(partsState === 'retry-signoff' || !partsPanel.issues.length) && !signoff;
|
|
2191
|
-
const status = entry.form.querySelector<HTMLElement>('[role=status]')!;
|
|
2192
|
-
if (!partsPanel.output) {
|
|
2193
|
-
status.dataset.jobText = 'JOB_PANEL_OUTPUT_MISSING';
|
|
2194
|
-
status.textContent = t('JOB_PANEL_OUTPUT_MISSING') + ' · ' + ask.subject.kind;
|
|
2195
|
-
} else if (status.dataset.jobText === 'JOB_PANEL_OUTPUT_MISSING') {
|
|
2196
|
-
delete status.dataset.jobText;
|
|
2197
|
-
status.textContent = '';
|
|
2198
|
-
}
|
|
2199
|
-
const words = entry.form.querySelector<HTMLTextAreaElement>('textarea[name=note]');
|
|
2200
|
-
if (words) words.disabled = ask.status !== 'pending';
|
|
2201
|
-
}
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
const hasCheckpointAsk = Boolean(current.player) && state.pending.some(
|
|
2205
|
-
ask => ask.publicationId === current!.display.publication.publicationId &&
|
|
2206
|
-
ask.status === 'pending' && ask.subject.kind === 'checkpoint',
|
|
2207
|
-
);
|
|
2208
|
-
const layerSet = workspace.querySelector<HTMLElement>('#layer-controls');
|
|
2209
|
-
const bgField = workspace.querySelector<HTMLElement>('#job-background-field');
|
|
2210
|
-
const bgSelect = workspace.querySelector<HTMLSelectElement>('#job-background');
|
|
2211
|
-
const hadNonDefaultView = !layers.images || layers.mesh || layers.bones || Boolean(stageBackground);
|
|
2212
|
-
if (!hasCheckpointAsk && hadNonDefaultView) {
|
|
2213
|
-
layers.images = true;
|
|
2214
|
-
layers.mesh = false;
|
|
2215
|
-
layers.bones = false;
|
|
2216
|
-
stageBackground = '';
|
|
2217
|
-
}
|
|
2218
|
-
if (layerSet) {
|
|
2219
|
-
layerSet.hidden = !hasCheckpointAsk;
|
|
2220
|
-
for (const [id, key] of [['layer-images', 'images'], ['layer-mesh', 'mesh'], ['layer-bones', 'bones']] as const) {
|
|
2221
|
-
const box = layerSet.querySelector<HTMLInputElement>('#' + id);
|
|
2222
|
-
if (box) {
|
|
2223
|
-
box.disabled = !hasCheckpointAsk;
|
|
2224
|
-
box.checked = layers[key];
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
describeLayerToggles({ getElementById: id => layerSet.querySelector('#' + id) }, t('No rig supplied'));
|
|
2228
|
-
for (const label of layerSet.querySelectorAll<HTMLElement>('.layer-toggle')) label.title = i18n.tr(label.title);
|
|
2229
|
-
}
|
|
2230
|
-
if (bgField && bgSelect) {
|
|
2231
|
-
bgField.hidden = !hasCheckpointAsk;
|
|
2232
|
-
bgSelect.disabled = !hasCheckpointAsk;
|
|
2233
|
-
bgSelect.value = stageBackground;
|
|
2234
|
-
}
|
|
2235
|
-
if (!hasCheckpointAsk && hadNonDefaultView) {
|
|
2236
|
-
redrawOverlay(true);
|
|
2237
|
-
rememberDraw();
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
async function mountJobParts(prepared: JobPreparedInspection, signal: AbortSignal): Promise<void> {
|
|
2241
|
-
const panel = partsPanels.get(prepared)!;
|
|
2242
|
-
const [{mountPartsWorkspace}, {parsePartsIssue}] = await Promise.all([
|
|
2243
|
-
import('./parts.ts'), import('../src/parts-comment.ts'),
|
|
2244
|
-
]);
|
|
2245
|
-
if (signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
|
|
2246
|
-
const finalized = window.state().pending.filter(ask =>
|
|
2247
|
-
ask.publicationId === prepared.display.publication.publicationId && ask.subject.kind === 'parts-verdict').at(-1)?.act;
|
|
2248
|
-
if (finalized?.kind === 'parts-verdict') {
|
|
2249
|
-
if (finalized.schema === JOB_PARTS_VERDICT_ACT_SCHEMA) panel.issues = [...finalized.value.issues];
|
|
2250
|
-
else panel.legacy = finalized.value;
|
|
2251
|
-
}
|
|
2252
|
-
panel.issues = panel.issues.map(issue => parsePartsIssue(issue, true, false, false));
|
|
2253
|
-
const routes = jobPublicationRoutes(prepared.display, location.origin);
|
|
2254
|
-
const painting = jobPartsPainting(prepared);
|
|
2255
|
-
const lifetime = new AbortController();
|
|
2256
|
-
let rejectPreparation!: (error: unknown) => void;
|
|
2257
|
-
const preparationCancelled = new Promise<never>((_resolve, reject) => {rejectPreparation = reject;});
|
|
2258
|
-
void preparationCancelled.catch(() => {});
|
|
2259
|
-
let mounted: ReturnType<typeof mountPartsWorkspace> | undefined;
|
|
2260
|
-
const cancelPreparation = () => {lifetime.abort(); rejectPreparation(new Error('JOB_PRELOAD_CANCELLED'));};
|
|
2261
|
-
signal.addEventListener('abort', cancelPreparation, {once: true});
|
|
2262
|
-
panel.dispose = () => {
|
|
2263
|
-
signal.removeEventListener('abort', cancelPreparation);
|
|
2264
|
-
lifetime.abort();
|
|
2265
|
-
const instance = mounted;
|
|
2266
|
-
mounted = undefined;
|
|
2267
|
-
instance?.dispose();
|
|
2268
|
-
};
|
|
2269
|
-
const source: PartsSource = {
|
|
2270
|
-
async view() {
|
|
2271
|
-
const view = await jobJson<JobPartsInventory>(routes.api('stage-parts'), lifetime.signal);
|
|
2272
|
-
if (current !== prepared || lifetime.signal.aborted ||
|
|
2273
|
-
view.sourceHash !== prepared.display.publication.source.sourceHash)
|
|
2274
|
-
throw new Error('JOB_ACT_SOURCE_STALE');
|
|
2275
|
-
return {...view, readOnly: false};
|
|
2276
|
-
},
|
|
2277
|
-
async image(index) {
|
|
2278
|
-
const item = prepared.parts?.items.find(item => item.index === index);
|
|
2279
|
-
const image = item && prepared.partImages.get(item.name);
|
|
2280
|
-
if (!image) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
2281
|
-
return image;
|
|
2282
|
-
},
|
|
2283
|
-
async page(index) {
|
|
2284
|
-
const page = prepared.partPages?.get(index);
|
|
2285
|
-
if (!page) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
2286
|
-
return page;
|
|
2287
|
-
},
|
|
2288
|
-
painting: () => painting?.element instanceof HTMLImageElement ? Promise.resolve(painting.element) : null,
|
|
2289
|
-
async crop(issue) {
|
|
2290
|
-
if (current !== prepared || lifetime.signal.aborted) throw new Error('JOB_ACT_SOURCE_STALE');
|
|
2291
|
-
const response = await fetch(routes.api('stage-parts/comment'), {
|
|
2292
|
-
method: 'POST', signal: lifetime.signal, headers: access.headers({'Content-Type': 'application/json'}),
|
|
2293
|
-
body: JSON.stringify(issue),
|
|
2294
|
-
});
|
|
2295
|
-
const value = await response.json();
|
|
2296
|
-
if (!response.ok) throw new Error(value?.error?.code ?? 'PARTS_COMMENT_UNAVAILABLE');
|
|
2297
|
-
if (current !== prepared || lifetime.signal.aborted) throw new Error('JOB_ACT_SOURCE_STALE');
|
|
2298
|
-
return parsePartsIssue(value.comment);
|
|
2299
|
-
},
|
|
2300
|
-
};
|
|
2301
|
-
const host: PartsHost = {
|
|
2302
|
-
initial: () => panel.issues,
|
|
2303
|
-
changed(issues) {
|
|
2304
|
-
if (current !== prepared || lifetime.signal.aborted) return;
|
|
2305
|
-
panel.issues = issues;
|
|
2306
|
-
for (const [askId, entry] of forms) {
|
|
2307
|
-
if (window.state().pending.find(ask => ask.askId === askId)?.subject.kind !== 'parts-verdict') continue;
|
|
2308
|
-
entry.dirty = true;
|
|
2309
|
-
entry.submissionId = crypto.randomUUID();
|
|
2310
|
-
}
|
|
2311
|
-
saveDraft(); window.refresh();
|
|
2312
|
-
},
|
|
2313
|
-
register(output) {
|
|
2314
|
-
if (current !== prepared || lifetime.signal.aborted) return;
|
|
2315
|
-
if (output.kind === 'parts-verdict' && panel.composition.side?.includes('parts.issues')) panel.output = output;
|
|
2316
|
-
window.refresh();
|
|
2317
|
-
},
|
|
2318
|
-
locked() {
|
|
2319
|
-
if (lifetime.signal.aborted || panel.legacy || window.state().closed) return 'sent';
|
|
2320
|
-
if (current !== prepared || [...forms.values()].some(entry => entry.submitting)) return 'sent';
|
|
2321
|
-
const phase = jobPartsReviewState(window.state().pending, prepared.display.publication.publicationId);
|
|
2322
|
-
return phase === 'reviewing' ? 'open' : phase;
|
|
2323
|
-
},
|
|
2324
|
-
};
|
|
2325
|
-
try {
|
|
2326
|
-
mounted = mountPartsWorkspace(panel.slots, source, host, {defaultView: 'assembled'});
|
|
2327
|
-
if (panel.legacy) {
|
|
2328
|
-
const legacy = node('p', 'JOB_PARTS_LEGACY_DRAFT');
|
|
2329
|
-
const rows = node('pre');
|
|
2330
|
-
rows.className = 'job-source';
|
|
2331
|
-
rows.textContent = JSON.stringify(panel.legacy, null, 2);
|
|
2332
|
-
panel.slots.side.append(legacy, rows);
|
|
2333
|
-
}
|
|
2334
|
-
await Promise.race([mounted.ready, preparationCancelled]);
|
|
2335
|
-
panel.slots.toolbar.querySelector<HTMLButtonElement>('#fit')?.click();
|
|
2336
|
-
await new Promise<void>((resolve, reject) => {
|
|
2337
|
-
let frame = 0;
|
|
2338
|
-
const cancelled = () => {
|
|
2339
|
-
signal.removeEventListener('abort', cancelled);
|
|
2340
|
-
cancelAnimationFrame(frame);
|
|
2341
|
-
reject(new Error('JOB_PRELOAD_CANCELLED'));
|
|
2342
|
-
};
|
|
2343
|
-
signal.addEventListener('abort', cancelled, {once: true});
|
|
2344
|
-
frame = requestAnimationFrame(() => {frame = requestAnimationFrame(() => {
|
|
2345
|
-
signal.removeEventListener('abort', cancelled);
|
|
2346
|
-
resolve();
|
|
2347
|
-
});});
|
|
2348
|
-
if (signal.aborted) cancelled();
|
|
2349
|
-
});
|
|
2350
|
-
if (signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
|
|
2351
|
-
} finally {
|
|
2352
|
-
signal.removeEventListener('abort', cancelPreparation);
|
|
2127
|
+
if(entry)entry.fieldset.disabled=entry.submitting||ask.status!=='pending'||state.preparing||state.closed||!state.receipt||!access.capability;
|
|
2353
2128
|
}
|
|
2354
2129
|
}
|
|
2355
2130
|
function build(prepared: JobPreparedInspection): HTMLElement {
|
|
@@ -2368,74 +2143,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2368
2143
|
sourceBinding.textContent = JSON.stringify(prepared.display.publication.source, null, 2);
|
|
2369
2144
|
binding.append(bindingTitle, sourceBinding);
|
|
2370
2145
|
sidebar.append(binding);
|
|
2371
|
-
if (prepared.metadata.capabilities.preRig) {
|
|
2372
|
-
const {composition, invalid} = resolveJobPanels(prepared.metadata, prepared.display.publication.source);
|
|
2373
|
-
root.dataset.jobPartsWorkspace = '';
|
|
2374
|
-
const stage = node('section');
|
|
2375
|
-
stage.className = 'job-stage';
|
|
2376
|
-
const toolbar = node('div');
|
|
2377
|
-
toolbar.className = 'viewbar pv-toolbar';
|
|
2378
|
-
const canvas = node('div');
|
|
2379
|
-
canvas.className = 'job-parts-stage';
|
|
2380
|
-
const left = node('div');
|
|
2381
|
-
const side = node('div');
|
|
2382
|
-
sidebar.prepend(left);
|
|
2383
|
-
const formsHost = node('section');
|
|
2384
|
-
formsHost.className = 'job-forms';
|
|
2385
|
-
formsHost.dataset.jobForms = '';
|
|
2386
|
-
formsHost.append(side);
|
|
2387
|
-
const slots = {left, stage: canvas, toolbar, side};
|
|
2388
|
-
stage.append(toolbar, canvas);
|
|
2389
|
-
root.append(sidebar, stage, formsHost);
|
|
2390
|
-
const components: Record<PanelComponent, PanelSlot | null> = {
|
|
2391
|
-
'parts.list': 'left', 'parts.canvas': 'stage', 'parts.layers': 'toolbar', 'parts.issues': 'side',
|
|
2392
|
-
'act.submit': 'side', 'interview.picks': null, 'plan.body': null, 'rig.playback': null,
|
|
2393
|
-
'scene.composite': null, 'images.set': null,
|
|
2394
|
-
};
|
|
2395
|
-
for (const slot of ['left', 'stage', 'toolbar', 'side'] as const) {
|
|
2396
|
-
const entries = composition[slot] ?? [];
|
|
2397
|
-
slots[slot].hidden = !entries.some(id => components[id] === slot && id !== 'act.submit');
|
|
2398
|
-
for (const id of entries) {
|
|
2399
|
-
if (components[id] === slot) continue;
|
|
2400
|
-
const refusal = node('p');
|
|
2401
|
-
refusal.textContent = t(Object.hasOwn(components, id) ? 'JOB_PANEL_UNAVAILABLE' : 'JOB_PANEL_UNKNOWN', [id]);
|
|
2402
|
-
slots[slot].after(refusal);
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2405
|
-
if (invalid) formsHost.prepend(node('p', 'JOB_PANELS_INVALID'));
|
|
2406
|
-
const history = node('div');
|
|
2407
|
-
history.className = 'job-history';
|
|
2408
|
-
history.dataset.jobHistory = '';
|
|
2409
|
-
formsHost.append(history);
|
|
2410
|
-
const panel = {slots, composition, issues: [] as PartsIssue[], legacy: null, dispose: undefined as (() => void) | undefined};
|
|
2411
|
-
partsPanels.set(prepared, panel);
|
|
2412
|
-
const dispose = prepared.dispose;
|
|
2413
|
-
prepared.dispose = () => {try {panel.dispose?.();} finally {dispose();}};
|
|
2414
|
-
return root;
|
|
2415
|
-
}
|
|
2416
|
-
const parts = node('select');
|
|
2417
|
-
parts.id = 'job-part';
|
|
2418
|
-
parts.disabled = !prepared.metadata.manifest?.model || prepared.metadata.feedbackCatalog.slots === null;
|
|
2419
|
-
const whole = node('option', 'job.wholeRig');
|
|
2420
|
-
whole.value = '';
|
|
2421
|
-
parts.append(whole);
|
|
2422
|
-
for (const slot of prepared.metadata.feedbackCatalog.slots ?? []) {
|
|
2423
|
-
const option = node('option');
|
|
2424
|
-
option.value = slot;
|
|
2425
|
-
option.textContent = slot;
|
|
2426
|
-
parts.append(option);
|
|
2427
|
-
}
|
|
2428
|
-
parts.onchange = () => { selectedPart = parts.value; selectPart(); };
|
|
2429
|
-
sidebar.append(inputLabel('Parts', parts));
|
|
2430
|
-
const solo = node('input');
|
|
2431
|
-
solo.type = 'checkbox';
|
|
2432
|
-
solo.id = 'job-solo';
|
|
2433
|
-
solo.onchange = () => { partMode = solo.checked ? 'solo' : 'context'; selectPart(); };
|
|
2434
|
-
sidebar.append(inputLabel('Solo', solo));
|
|
2435
|
-
const observation = node('pre');
|
|
2436
|
-
observation.id = 'job-part-observation';
|
|
2437
|
-
observation.className = 'job-source';
|
|
2438
|
-
sidebar.append(observation);
|
|
2439
2146
|
const referenceSelect = node('select');
|
|
2440
2147
|
referenceSelect.id = 'job-reference';
|
|
2441
2148
|
for (const reference of prepared.references) {
|
|
@@ -2453,68 +2160,13 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2453
2160
|
stage.className = 'job-stage';
|
|
2454
2161
|
const controls = node('div');
|
|
2455
2162
|
controls.className = 'viewbar';
|
|
2456
|
-
const
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
for (const item of layerShortcuts) {
|
|
2464
|
-
const label = node('label');
|
|
2465
|
-
label.className = 'layer-toggle';
|
|
2466
|
-
const box = node('input');
|
|
2467
|
-
box.id = item.id;
|
|
2468
|
-
box.type = 'checkbox';
|
|
2469
|
-
box.setAttribute('aria-keyshortcuts', item.key.toUpperCase());
|
|
2470
|
-
const keyName = item.id === 'layer-images' ? 'images' : item.id === 'layer-mesh' ? 'mesh' : 'bones';
|
|
2471
|
-
box.checked = layers[keyName];
|
|
2472
|
-
box.disabled = true;
|
|
2473
|
-
box.onchange = () => {
|
|
2474
|
-
layers[keyName] = box.checked;
|
|
2475
|
-
if (current === prepared) {
|
|
2476
|
-
redrawOverlay(true);
|
|
2477
|
-
rememberDraw();
|
|
2478
|
-
}
|
|
2479
|
-
};
|
|
2480
|
-
const kbd = node('kbd');
|
|
2481
|
-
kbd.setAttribute('aria-hidden', 'true');
|
|
2482
|
-
kbd.textContent = item.key.toUpperCase();
|
|
2483
|
-
label.append(box, node('span', item.label), kbd);
|
|
2484
|
-
layerSet.append(label);
|
|
2485
|
-
}
|
|
2486
|
-
describeLayerToggles({ getElementById: id => layerSet.querySelector('#' + id) }, t('No rig supplied'));
|
|
2487
|
-
for (const label of layerSet.querySelectorAll<HTMLElement>('.layer-toggle')) label.title = i18n.tr(label.title);
|
|
2488
|
-
const sentinelKeys = Object.keys(SENTINELS);
|
|
2489
|
-
const bgSelect = selectValues(['', ...sentinelKeys], ['Rig', ...sentinelKeys.map(k => k[0]!.toUpperCase() + k.slice(1))]);
|
|
2490
|
-
bgSelect.id = 'job-background';
|
|
2491
|
-
bgSelect.value = stageBackground;
|
|
2492
|
-
bgSelect.disabled = true;
|
|
2493
|
-
bgSelect.onchange = () => {
|
|
2494
|
-
stageBackground = Object.hasOwn(SENTINELS, bgSelect.value) ? bgSelect.value : '';
|
|
2495
|
-
bgSelect.value = stageBackground;
|
|
2496
|
-
if (current === prepared) {
|
|
2497
|
-
redrawOverlay(false);
|
|
2498
|
-
rememberDraw();
|
|
2499
|
-
}
|
|
2500
|
-
};
|
|
2501
|
-
const bgField = inputLabel('Background', bgSelect);
|
|
2502
|
-
bgField.id = 'job-background-field';
|
|
2503
|
-
bgField.hidden = true;
|
|
2504
|
-
controls.append(layerSet, bgField);
|
|
2505
|
-
for (const [id, key] of [['zoom-in', 'job.zoomIn'], ['zoom-out', 'job.zoomOut'], ['fit', 'Fit']]) {
|
|
2506
|
-
const button = node('button', key);
|
|
2507
|
-
button.id = id!;
|
|
2508
|
-
button.type = 'button';
|
|
2509
|
-
controls.append(button);
|
|
2510
|
-
}
|
|
2511
|
-
const sync = node('input');
|
|
2512
|
-
sync.id = 'camera-sync';
|
|
2513
|
-
sync.type = 'checkbox';
|
|
2514
|
-
controls.append(inputLabel('job.cameraSync', sync));
|
|
2515
|
-
const zoom = node('span');
|
|
2516
|
-
zoom.id = 'zoom-value';
|
|
2517
|
-
controls.append(zoom);
|
|
2163
|
+
const viewControls = createViewControls({layout:'rigStep1', viewSwitch:inspectionViewSwitch(next => {
|
|
2164
|
+
view = next;
|
|
2165
|
+
pair.querySelector<HTMLElement>('#reference-pane')!.hidden = next === 'rig';
|
|
2166
|
+
pair.querySelector<HTMLElement>('#rig-pane')!.hidden = next === 'reference';
|
|
2167
|
+
viewport.fitCamera();
|
|
2168
|
+
})});
|
|
2169
|
+
controls.append(viewControls.syncLabel, viewControls.zoomGroup!);
|
|
2518
2170
|
const pair = node('div');
|
|
2519
2171
|
pair.id = 'stage-layout';
|
|
2520
2172
|
mountViewportPair(pair);
|
|
@@ -2536,14 +2188,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2536
2188
|
rigViewport.addEventListener('pointerdown', () => rigViewport.focus?.());
|
|
2537
2189
|
}
|
|
2538
2190
|
pair.querySelector('#rig-root')!.replaceWith(prepared.rigRoot);
|
|
2539
|
-
const overlayCanvas = pair.querySelector<HTMLCanvasElement>('#rig-overlay');
|
|
2540
|
-
if (overlayCanvas) {
|
|
2541
|
-
overlayCanvas.setAttribute('aria-label', t('Actual rig mesh and bone overlay'));
|
|
2542
|
-
const instance = new RigOverlays({ canvas: overlayCanvas, rigRoot: prepared.rigRoot });
|
|
2543
|
-
overlays.set(prepared, instance);
|
|
2544
|
-
const prevDispose = prepared.dispose;
|
|
2545
|
-
prepared.dispose = () => { try { instance.dispose(); } finally { prevDispose(); } };
|
|
2546
|
-
}
|
|
2547
2191
|
const transport = node('div');
|
|
2548
2192
|
transport.className = 'job-transport';
|
|
2549
2193
|
const clips = node('select');
|
|
@@ -2678,30 +2322,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2678
2322
|
if (child instanceof HTMLElement && child !== identity && child !== binding) child.hidden = true;
|
|
2679
2323
|
}
|
|
2680
2324
|
}
|
|
2681
|
-
else if (source.subject === 'option-set' || source.subject === 'plan') {
|
|
2682
|
-
const summary = node('section');
|
|
2683
|
-
summary.dataset.jobRecord = source.subject;
|
|
2684
|
-
const recordLine = node('p');
|
|
2685
|
-
recordLine.className = 'job-source';
|
|
2686
|
-
recordLine.textContent = source.record.path + ' · ' + source.record.sha256;
|
|
2687
|
-
summary.append(recordLine);
|
|
2688
|
-
if (source.subject === 'option-set') {
|
|
2689
|
-
const optionLine = node('p');
|
|
2690
|
-
optionLine.className = 'job-source';
|
|
2691
|
-
optionLine.textContent = source.selection.questionId + ' · ' + source.optionSet.id + ' · ' + source.optionSetFile.path + ' · ' + source.optionSet.sha256;
|
|
2692
|
-
summary.append(optionLine);
|
|
2693
|
-
}
|
|
2694
|
-
else {
|
|
2695
|
-
root.dataset.jobPlanWorkspace = '';
|
|
2696
|
-
summary.append(identity, binding, planTextList(source.plan, prepared.metadata.planText));
|
|
2697
|
-
}
|
|
2698
|
-
stage.prepend(summary);
|
|
2699
|
-
controls.hidden = pair.hidden = transport.hidden = true;
|
|
2700
|
-
controls.style.display = pair.style.display = transport.style.display = 'none';
|
|
2701
|
-
for (const child of sidebar.children) {
|
|
2702
|
-
if (child instanceof HTMLElement && child !== identity && child !== binding) child.hidden = true;
|
|
2703
|
-
}
|
|
2704
|
-
}
|
|
2705
2325
|
const formsHost = node('section');
|
|
2706
2326
|
formsHost.className = 'job-forms';
|
|
2707
2327
|
formsHost.dataset.jobForms = '';
|
|
@@ -2752,17 +2372,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2752
2372
|
root.append(sidebar, stage, formsHost);
|
|
2753
2373
|
return root;
|
|
2754
2374
|
}
|
|
2755
|
-
function selectPart(): void {
|
|
2756
|
-
if (!current?.inspection)
|
|
2757
|
-
return;
|
|
2758
|
-
drawn.delete(current);
|
|
2759
|
-
current.rigPresentation = undefined;
|
|
2760
|
-
current.inspection.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
2761
|
-
redrawOverlay(true);
|
|
2762
|
-
rememberDraw();
|
|
2763
|
-
setText('job-part-observation', selectedPart ? JSON.stringify(current.inspection.observation(), null, 2) : '');
|
|
2764
|
-
viewport.renderCameraControls();
|
|
2765
|
-
}
|
|
2766
2375
|
function showReference(): void {
|
|
2767
2376
|
const value = reference();
|
|
2768
2377
|
el('reference-content').replaceChildren(...(value ? [value.element] : []));
|
|
@@ -2787,8 +2396,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2787
2396
|
// Setup uses an empty composed track. Animation seek needs a fresh single track.
|
|
2788
2397
|
if (animation && current.player?.composed) current.setupPose(false);
|
|
2789
2398
|
if (current.player) {
|
|
2790
|
-
drawn.delete(current);
|
|
2791
|
-
current.rigPresentation = undefined;
|
|
2792
2399
|
if (animation && (current.player.current !== animation || current.player.entry(0)?.loop !== loop))
|
|
2793
2400
|
current.player.play(animation, { loop });
|
|
2794
2401
|
if (animation) {
|
|
@@ -2807,8 +2414,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2807
2414
|
}
|
|
2808
2415
|
current.player.pause();
|
|
2809
2416
|
drawInspection(current);
|
|
2810
|
-
current.inspection?.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
2811
|
-
setText('job-part-observation', selectedPart ? JSON.stringify(current.inspection?.observation(), null, 2) : '');
|
|
2812
2417
|
}
|
|
2813
2418
|
syncTransportControls();
|
|
2814
2419
|
if (seekReference) {
|
|
@@ -2835,16 +2440,32 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2835
2440
|
function announceHubFrame(): void {
|
|
2836
2441
|
if (hubIncarnation) globalThis.parent.postMessage({...hubBinding(), schema: JOB_HUB_READY}, location.origin);
|
|
2837
2442
|
}
|
|
2443
|
+
// Only publications without a shared-screen host retain this fallback.
|
|
2444
|
+
const formDependencies: JobFormDependencies = {
|
|
2445
|
+
node, translate: t, helpers: {...formHelpers, assertJobAskSource, jobCheckpointContext},
|
|
2446
|
+
draftStorage: () => localStorage, localDraftKey, saveDraft, access, pageId,
|
|
2447
|
+
window: {state: () => window.state(), submit: input => window.submit(input)},
|
|
2448
|
+
};
|
|
2449
|
+
const rigScreen = createJobRigScreen({host, pageId, access, translate: (key, values) => i18n.t(key, values, 'en'), refusal: jobWindowRefusal, formDependencies,
|
|
2450
|
+
readPublication: (id, signal) => transport.readPublication(id, signal),
|
|
2451
|
+
window: {state: () => window.state(), submit: input => window.submit(input)},
|
|
2452
|
+
routes: display => jobPublicationRoutes(display, location.origin), load: async () => (await import('./main.ts')).mountRigScreen()});
|
|
2838
2453
|
const window = createJobWindow({ jobId: access.jobId, pageId, transport,
|
|
2839
2454
|
previousDisplayed, initialRetainedDrafts,
|
|
2840
2455
|
adapter: {
|
|
2841
|
-
async prepare(display, signal): Promise<PreparedWindow> {
|
|
2456
|
+
async prepare(display, signal): Promise<PreparedWindow | JobRigScreenPrepared> {
|
|
2457
|
+
const rig = await rigScreen.prepare(display, signal);
|
|
2458
|
+
if (!rig && rigScreen.mounted()) { location.reload(); return new Promise<never>(() => {}); }
|
|
2459
|
+
if (rig && current) { location.reload(); return new Promise<never>(() => {}); }
|
|
2460
|
+
if (rig) return rig;
|
|
2461
|
+
const source = display.publication.source;
|
|
2462
|
+
if ('record' in source || source.subject !== 'image-set' && !source.direction && (source.model || source.parts))
|
|
2463
|
+
throw new Error('JOB_PANEL_UNAVAILABLE');
|
|
2842
2464
|
const inspection = await prepareJobInspection(display, signal);
|
|
2843
2465
|
try {
|
|
2844
2466
|
const element = build(inspection);
|
|
2845
|
-
const asks = window.state().pending
|
|
2846
|
-
|
|
2847
|
-
const preparedForms = prepareJobForms(display, asks, ask => formFor(ask, inspection));
|
|
2467
|
+
const asks = window.state().pending;
|
|
2468
|
+
const preparedForms = prepareJobForms(display, asks, ask => prepareJobForms.formFor(ask, inspection, formDependencies));
|
|
2848
2469
|
return Object.assign(inspection, { element, forms: preparedForms });
|
|
2849
2470
|
}
|
|
2850
2471
|
catch (error) {
|
|
@@ -2852,13 +2473,13 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2852
2473
|
throw error;
|
|
2853
2474
|
}
|
|
2854
2475
|
},
|
|
2855
|
-
captureDraft() { saveDraft(); const dirty = [...forms].filter(([, item]) => item.dirty); return dirty.length ? dirty.map(([askId, item]) => ({ askId, value: item.read() })) : null; },
|
|
2476
|
+
captureDraft() { if (rigScreen.mounted()) return null; saveDraft(); const dirty = [...forms].filter(([, item]) => item.dirty); return dirty.length ? dirty.map(([askId, item]) => ({ askId, value: item.read() })) : null; },
|
|
2856
2477
|
commit(prepared, display) {
|
|
2478
|
+
if (isJobRigScreen(prepared)) return rigScreen.commit(prepared);
|
|
2857
2479
|
// Pending asks can arrive while assets load. Finish their forms before the visible replacement.
|
|
2858
|
-
const asks = window.state().pending
|
|
2859
|
-
ask.subject.kind === 'signoff' && ask.subject.stage === 'parts-review'));
|
|
2480
|
+
const asks = window.state().pending;
|
|
2860
2481
|
const nextForms = prepareJobForms(display, asks,
|
|
2861
|
-
ask => prepared.forms.get(ask.askId) ?? formFor(ask, prepared));
|
|
2482
|
+
ask => prepared.forms.get(ask.askId) ?? prepareJobForms.formFor(ask, prepared, formDependencies));
|
|
2862
2483
|
const root = prepared.element;
|
|
2863
2484
|
const formHost = root.querySelector<HTMLElement>('[data-job-forms]');
|
|
2864
2485
|
if (!formHost) throw new Error('JOB_WINDOW_ELEMENT_MISSING');
|
|
@@ -2869,9 +2490,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2869
2490
|
const previousElement = currentElement;
|
|
2870
2491
|
const previousForms = new Map(forms);
|
|
2871
2492
|
const restoringCamera = Boolean(previous || restoredCamera);
|
|
2872
|
-
const navigation = { animation, time, loop,
|
|
2873
|
-
layers: { images: layers.images, mesh: layers.mesh, bones: layers.bones }, stageBackground,
|
|
2874
|
-
partIdentity: previous ? (previous.inspection?.value() ?? null) : restoredPartIdentity,
|
|
2493
|
+
const navigation = { animation, time, loop, selectedReference, panel,
|
|
2875
2494
|
camera: structuredClone(viewportState) };
|
|
2876
2495
|
compatibilityNotice = Boolean(!previous &&
|
|
2877
2496
|
savedWindow?.publicationId === display.publication.publicationId &&
|
|
@@ -2881,10 +2500,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2881
2500
|
time = 0;
|
|
2882
2501
|
compatibilityNotice = true;
|
|
2883
2502
|
}
|
|
2884
|
-
if (selectedPart && !(prepared.metadata.feedbackCatalog.slots ?? []).includes(selectedPart)) {
|
|
2885
|
-
selectedPart = '';
|
|
2886
|
-
compatibilityNotice = true;
|
|
2887
|
-
}
|
|
2888
2503
|
if (!prepared.references.some(item => item.id === selectedReference))
|
|
2889
2504
|
selectedReference = prepared.references[0]?.id ?? '';
|
|
2890
2505
|
let nextUnbind: (() => void) | null = null;
|
|
@@ -2898,18 +2513,14 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2898
2513
|
animation = navigation.animation;
|
|
2899
2514
|
time = navigation.time;
|
|
2900
2515
|
loop = navigation.loop;
|
|
2901
|
-
selectedPart = navigation.selectedPart;
|
|
2902
|
-
partMode = navigation.partMode;
|
|
2903
2516
|
selectedReference = navigation.selectedReference;
|
|
2904
2517
|
panel = navigation.panel;
|
|
2905
|
-
Object.assign(layers, navigation.layers);
|
|
2906
|
-
stageBackground = navigation.stageBackground;
|
|
2907
2518
|
forms.clear();
|
|
2908
2519
|
for (const [id, item] of previousForms)
|
|
2909
2520
|
forms.set(id, item);
|
|
2910
2521
|
workspace.replaceChildren(...(previousElement ? [previousElement] : []));
|
|
2911
2522
|
Object.assign(viewportState, navigation.camera);
|
|
2912
|
-
if (current
|
|
2523
|
+
if (current) {
|
|
2913
2524
|
el<HTMLSelectElement>('job-reference').value = selectedReference;
|
|
2914
2525
|
syncTransportControls();
|
|
2915
2526
|
viewport.fitCamera();
|
|
@@ -2921,45 +2532,13 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2921
2532
|
forms.clear();
|
|
2922
2533
|
for (const [id, entry] of nextForms) forms.set(id, entry);
|
|
2923
2534
|
workspace.replaceChildren(root);
|
|
2924
|
-
if (partsPanels.has(prepared)) {
|
|
2925
|
-
updateForms(window.state());
|
|
2926
|
-
return {rollback, finalize() {
|
|
2927
|
-
unbindNavigation?.(); resize?.disconnect();
|
|
2928
|
-
unbindNavigation = null; resize = null;
|
|
2929
|
-
previous?.dispose();
|
|
2930
|
-
title.textContent = display.publication.source.package?.id ?? display.publication.label;
|
|
2931
|
-
}};
|
|
2932
|
-
}
|
|
2933
|
-
el<HTMLSelectElement>('job-part').value = selectedPart;
|
|
2934
|
-
el<HTMLInputElement>('job-solo').checked = partMode === 'solo';
|
|
2935
2535
|
el<HTMLSelectElement>('job-reference').value = selectedReference;
|
|
2936
2536
|
el<HTMLSelectElement>('job-animation').value = animation;
|
|
2937
2537
|
el<HTMLInputElement>('job-loop').checked = loop;
|
|
2938
|
-
layers.images = true;
|
|
2939
|
-
layers.mesh = false;
|
|
2940
|
-
layers.bones = false;
|
|
2941
|
-
stageBackground = '';
|
|
2942
|
-
for (const [id, key] of [['layer-images', 'images'], ['layer-mesh', 'mesh'], ['layer-bones', 'bones']] as const) {
|
|
2943
|
-
el<HTMLInputElement>(id).checked = layers[key];
|
|
2944
|
-
}
|
|
2945
2538
|
el('rig-empty').hidden = !!prepared.player;
|
|
2946
2539
|
Object.assign(viewportState, navigation.camera, { cameraRestoring: restoringCamera });
|
|
2947
2540
|
showReference();
|
|
2948
2541
|
pose(false);
|
|
2949
|
-
if (selectedPart) {
|
|
2950
|
-
try {
|
|
2951
|
-
if (!navigation.partIdentity || navigation.partIdentity.slot !== selectedPart) {
|
|
2952
|
-
throw new Error('PART_IDENTITY_UNAVAILABLE');
|
|
2953
|
-
}
|
|
2954
|
-
prepared.inspection?.assertIdentity(navigation.partIdentity);
|
|
2955
|
-
}
|
|
2956
|
-
catch {
|
|
2957
|
-
selectedPart = '';
|
|
2958
|
-
compatibilityNotice = true;
|
|
2959
|
-
el<HTMLSelectElement>('job-part').value = '';
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
selectPart();
|
|
2963
2542
|
viewportState.cameraRestoring = false;
|
|
2964
2543
|
updateForms(window.state());
|
|
2965
2544
|
showPanel();
|
|
@@ -2969,7 +2548,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2969
2548
|
return {
|
|
2970
2549
|
rollback,
|
|
2971
2550
|
finalize() {
|
|
2972
|
-
restoredPartIdentity = null;
|
|
2973
2551
|
restoredCamera = null;
|
|
2974
2552
|
savedWindow = null;
|
|
2975
2553
|
unbindNavigation?.();
|
|
@@ -2987,10 +2565,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2987
2565
|
}
|
|
2988
2566
|
},
|
|
2989
2567
|
async painted(prepared, signal) {
|
|
2990
|
-
if (
|
|
2991
|
-
await mountJobParts(prepared, signal);
|
|
2992
|
-
return;
|
|
2993
|
-
}
|
|
2568
|
+
if (isJobRigScreen(prepared)) return rigScreen.painted(prepared, signal);
|
|
2994
2569
|
for (const image of prepared.imageSetImages ?? []) {
|
|
2995
2570
|
if (!image.isConnected || !image.complete || !image.naturalWidth || !image.naturalHeight)
|
|
2996
2571
|
throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
@@ -2998,14 +2573,18 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2998
2573
|
await reference()?.seek(time, signal);
|
|
2999
2574
|
if (prepared.player) {
|
|
3000
2575
|
drawInspection(prepared);
|
|
3001
|
-
rememberDraw();
|
|
3002
2576
|
}
|
|
3003
2577
|
await new Promise<void>(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
3004
2578
|
if (signal.aborted)
|
|
3005
2579
|
throw new Error('JOB_PRELOAD_CANCELLED');
|
|
3006
2580
|
},
|
|
3007
|
-
discard(prepared) { prepared.dispose(); },
|
|
2581
|
+
discard(prepared) { if (!isJobRigScreen(prepared)) prepared.dispose(); },
|
|
3008
2582
|
changed(state) {
|
|
2583
|
+
if (rigScreen.mounted()) {
|
|
2584
|
+
rigScreen.changed(state); announceHubFrame();
|
|
2585
|
+
if (state.receipt && !state.preparing) events?.displayed();
|
|
2586
|
+
return;
|
|
2587
|
+
}
|
|
3009
2588
|
notice.dataset.failed = String(!!state.error);
|
|
3010
2589
|
if (state.error)
|
|
3011
2590
|
notice.textContent = state.displayed && state.error !== 'JOB_WINDOW_CLEANUP_FAILED'
|
|
@@ -3014,13 +2593,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
3014
2593
|
notice.textContent = t('job.closed');
|
|
3015
2594
|
else if (state.preparing)
|
|
3016
2595
|
notice.textContent = t('job.preparing');
|
|
3017
|
-
else if (state.displayed && current && partsPanels.has(current)) {
|
|
3018
|
-
const panel = partsPanels.get(current)!;
|
|
3019
|
-
const sending = [...forms.values()].some(entry => entry.submitting);
|
|
3020
|
-
const phase = sending ? 'sending' : jobPartsReviewState(state.pending, state.displayed.publication.publicationId);
|
|
3021
|
-
notice.dataset.jobPartsState = phase;
|
|
3022
|
-
notice.textContent = state.displayed.publication.label + ' · ' + t('job.parts.' + phase, [panel.issues.length]);
|
|
3023
|
-
}
|
|
3024
2596
|
else if (state.displayed) {
|
|
3025
2597
|
delete notice.dataset.jobPartsState;
|
|
3026
2598
|
notice.textContent = state.previousLabel
|
|
@@ -3062,15 +2634,12 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
3062
2634
|
if (state.receipt && !state.preparing) events?.displayed();
|
|
3063
2635
|
},
|
|
3064
2636
|
} });
|
|
3065
|
-
const unbindLayerShortcuts = bindLayerShortcuts(document);
|
|
3066
2637
|
const localize = i18n.onLanguageChange(() => {
|
|
3067
2638
|
for (const element of host.querySelectorAll<HTMLElement>('[data-job-text]'))
|
|
3068
2639
|
element.textContent = t(element.dataset.jobText!);
|
|
3069
2640
|
languages.setAttribute('aria-label', t('interview.language'));
|
|
3070
|
-
if (current
|
|
2641
|
+
if (current) {
|
|
3071
2642
|
workspace.querySelector('#rig-overlay')?.setAttribute('aria-label', t('Actual rig mesh and bone overlay'));
|
|
3072
|
-
describeLayerToggles({ getElementById: id => workspace.querySelector('#' + id) }, t('No rig supplied'));
|
|
3073
|
-
for (const label of workspace.querySelectorAll<HTMLElement>('.layer-toggle')) label.title = i18n.tr(label.title);
|
|
3074
2643
|
viewport.renderCameraControls();
|
|
3075
2644
|
}
|
|
3076
2645
|
window.refresh();
|
|
@@ -3084,11 +2653,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
3084
2653
|
i18n.setLinkLanguage(null); i18n.setLanguagePreference(event.data.language);
|
|
3085
2654
|
}
|
|
3086
2655
|
pauseHiddenHubFrame();
|
|
3087
|
-
if (
|
|
3088
|
-
drawn.delete(current);
|
|
3089
|
-
current.rigPresentation = undefined;
|
|
3090
|
-
}
|
|
3091
|
-
if (hubVisible && current?.player) {drawInspection(current); rememberDraw();}
|
|
2656
|
+
if (hubVisible && current?.player) drawInspection(current);
|
|
3092
2657
|
};
|
|
3093
2658
|
if (hubIncarnation) {globalThis.addEventListener('message', hubVisibility); announceHubFrame();}
|
|
3094
2659
|
events = startJobWindowEvents({access, signal: abort.signal, member: !!hubIncarnation,
|
|
@@ -3100,9 +2665,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
3100
2665
|
resolution?.removeEventListener('change', resolutionChanged);
|
|
3101
2666
|
resolution = globalThis.matchMedia(`(resolution:${globalThis.devicePixelRatio || 1}dppx)`);
|
|
3102
2667
|
resolution.addEventListener('change', resolutionChanged);
|
|
3103
|
-
if (current
|
|
3104
|
-
drawn.delete(current);
|
|
3105
|
-
current.rigPresentation = undefined;
|
|
2668
|
+
if (current) {
|
|
3106
2669
|
viewport.fitCamera();
|
|
3107
2670
|
}
|
|
3108
2671
|
};
|
|
@@ -3117,7 +2680,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
3117
2680
|
abort.abort();
|
|
3118
2681
|
window.stop();
|
|
3119
2682
|
localize();
|
|
3120
|
-
unbindLayerShortcuts();
|
|
3121
2683
|
unbindNavigation?.();
|
|
3122
2684
|
resize?.disconnect();
|
|
3123
2685
|
current?.dispose();
|