rig-review 2.8.0 → 2.10.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/PARTS_VIEW.md +103 -66
- package/docs/REVIEW_PACKAGE.md +143 -9
- package/docs/STABILITY.md +6 -1
- package/package.json +3 -3
- package/src/build.ts +10 -2
- package/src/cli.ts +4 -5
- package/src/correction-handoff.ts +27 -4
- package/src/feedback-export.ts +1 -1
- package/src/front.ts +2 -1
- package/src/handoff.ts +1 -1
- package/src/job-act.ts +43 -23
- package/src/job-api.ts +23 -9
- package/src/job-checkpoint-evidence.ts +113 -0
- package/src/job-cli.ts +6 -2
- package/src/job-contract.ts +110 -13
- package/src/job-front.ts +123 -9
- package/src/job-host.ts +7 -0
- package/src/job-session.ts +73 -8
- package/src/job-source.ts +52 -7
- package/src/manifest.ts +9 -0
- package/src/open-workspace-launch.ts +2 -2
- package/src/open.ts +2 -1
- package/src/parts-comment-crops.ts +126 -31
- package/src/parts-comment.ts +321 -28
- package/src/parts-view.ts +485 -89
- package/src/stage-comment.ts +9 -1
- package/src/stage-parts.ts +5 -1
- package/src/versions.ts +7 -7
- package/web/catalog-en.ts +45 -1
- package/web/catalog-ko.ts +45 -1
- package/web/job-session.ts +682 -134
- package/web/parts-page.ts +217 -0
- package/web/parts-render.ts +26 -19
- package/web/parts-viewport-provider.ts +13 -1
- package/web/parts.css +13 -1
- package/web/parts.html +4 -38
- package/web/parts.ts +649 -267
- package/web/stage-comments.ts +79 -25
- package/web/styles.css +27 -5
- package/web/viewport-controller.ts +13 -4
package/web/job-session.ts
CHANGED
|
@@ -5,10 +5,16 @@ import type {
|
|
|
5
5
|
DisplayPublicationV3,
|
|
6
6
|
EventV3,
|
|
7
7
|
JobDisplayReceipt,
|
|
8
|
+
JobCheckpointEvidence,
|
|
9
|
+
JobCheckpointTable,
|
|
8
10
|
JobInterviewDiagnostics,
|
|
9
11
|
JobResult,
|
|
10
12
|
JobUISubmission,
|
|
11
13
|
PendingAskV3,
|
|
14
|
+
JobPanelComposition,
|
|
15
|
+
PanelComponent,
|
|
16
|
+
PanelSlot,
|
|
17
|
+
PartsVerdictValue,
|
|
12
18
|
PublicationV3,
|
|
13
19
|
RecordSource,
|
|
14
20
|
SourceV3,
|
|
@@ -22,7 +28,11 @@ import {recordJobRigDraw, freezeJobRigCapture, copyJobRigViewport, createJobRigS
|
|
|
22
28
|
type JobRigDraw, type JobRigDrawState} from './job-rig-capture.ts';
|
|
23
29
|
import {advancePlayback} from './playback-clock.ts';
|
|
24
30
|
import {presentJobRigViewport, type JobRigPresentation} from './viewport-capture.ts';
|
|
31
|
+
import {SENTINELS} from './parts-render.ts';
|
|
25
32
|
import {CanvasRenderer} from '@rig-c/play';
|
|
33
|
+
import {JOB_PANEL_COMPOSITION_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, parsePanelComposition} from '../src/job-contract.ts';
|
|
34
|
+
import type {PartsSource, PartsHost} from './parts.ts';
|
|
35
|
+
import type {PartsIssue} from '../src/parts-comment.ts';
|
|
26
36
|
|
|
27
37
|
/** Imported runtimes may throw arbitrary prose. Only registered refusal copy reaches the window. */
|
|
28
38
|
export function jobWindowRefusal(error: unknown, fallback = 'JOB_WINDOW_FAILED'): string {
|
|
@@ -65,6 +75,7 @@ export interface JobRetainedDraft {
|
|
|
65
75
|
readonly label: string;
|
|
66
76
|
readonly value: unknown;
|
|
67
77
|
}
|
|
78
|
+
export type JobWindowAsk = PendingAskV3 & {readonly act?: ActV3};
|
|
68
79
|
export interface JobWindowState {
|
|
69
80
|
readonly generation: number;
|
|
70
81
|
readonly displayed: DisplayPublicationV3 | null;
|
|
@@ -73,7 +84,7 @@ export interface JobWindowState {
|
|
|
73
84
|
readonly closed: boolean;
|
|
74
85
|
readonly error: string | null;
|
|
75
86
|
readonly previousLabel: string | null;
|
|
76
|
-
readonly pending: readonly
|
|
87
|
+
readonly pending: readonly JobWindowAsk[];
|
|
77
88
|
readonly retainedDrafts: readonly JobRetainedDraft[];
|
|
78
89
|
}
|
|
79
90
|
function unwrap<Value>(result: JobResult<Value>): Value {
|
|
@@ -153,7 +164,7 @@ export function createJobWindow<Prepared>(options: {
|
|
|
153
164
|
initialRetainedDrafts?: readonly JobRetainedDraft[];
|
|
154
165
|
}) {
|
|
155
166
|
const { transport, adapter, pageId } = options;
|
|
156
|
-
const pending = new Map<string,
|
|
167
|
+
const pending = new Map<string, JobWindowAsk>();
|
|
157
168
|
const rigAttempts = new WeakSet<UISubmissionV3>();
|
|
158
169
|
const retainedDrafts: JobRetainedDraft[] = [];
|
|
159
170
|
let initialDrafts: readonly JobRetainedDraft[] | null = options.initialRetainedDrafts
|
|
@@ -301,12 +312,13 @@ export function createJobWindow<Prepared>(options: {
|
|
|
301
312
|
void replace(value.publication);
|
|
302
313
|
}
|
|
303
314
|
else if (value.type === 'pending') {
|
|
304
|
-
pending.
|
|
315
|
+
const previous = pending.get(value.ask.askId);
|
|
316
|
+
pending.set(value.ask.askId, previous?.act ? {...value.ask, status: 'answered', act: previous.act} : value.ask);
|
|
305
317
|
}
|
|
306
318
|
else if (value.type === 'act') {
|
|
307
319
|
const ask = pending.get(value.act.askId);
|
|
308
320
|
if (ask)
|
|
309
|
-
pending.set(ask.askId, { ...ask, status: 'answered' });
|
|
321
|
+
pending.set(ask.askId, { ...ask, status: 'answered', act: value.act });
|
|
310
322
|
}
|
|
311
323
|
else if (value.type === 'closed') {
|
|
312
324
|
closed = true;
|
|
@@ -327,10 +339,46 @@ export function createJobWindow<Prepared>(options: {
|
|
|
327
339
|
}
|
|
328
340
|
// The backend authenticates the actual Request and validates the semantic value.
|
|
329
341
|
if (input.capture !== undefined) rigAttempts.add(input);
|
|
330
|
-
|
|
342
|
+
const result = await transport.submit(input);
|
|
343
|
+
if (result.ok && ask) {
|
|
344
|
+
pending.set(ask.askId, {...ask, status: 'answered', act: result.value});
|
|
345
|
+
changed();
|
|
346
|
+
}
|
|
347
|
+
return result;
|
|
348
|
+
}
|
|
349
|
+
async function submitParts(input: UISubmissionV3, signoffSubmissionId: string): Promise<JobResult<ActV3>> {
|
|
350
|
+
const publicationId = input.publicationId;
|
|
351
|
+
const ask = pending.get(input.askId);
|
|
352
|
+
if (!displayed || displayed.publication.publicationId !== publicationId || !ask ||
|
|
353
|
+
ask.subject.kind !== 'parts-verdict') throw new Error('JOB_ACT_SOURCE_STALE');
|
|
354
|
+
assertJobAskSource(ask, displayed);
|
|
355
|
+
const previous = ask.act;
|
|
356
|
+
const value = (previous?.kind === 'parts-verdict' ? previous.value : input.value) as PartsVerdictValue;
|
|
357
|
+
const signoff = [...pending.values()].find(item => item.publicationId === publicationId &&
|
|
358
|
+
item.subject.kind === 'signoff' && item.subject.stage === 'parts-review' && item.status === 'pending');
|
|
359
|
+
if (value.verdict === 'approved' && !signoff) throw new Error('JOB_PARTS_SIGNOFF_MISSING');
|
|
360
|
+
let result: JobResult<ActV3>;
|
|
361
|
+
if (ask.status === 'pending') {
|
|
362
|
+
result = await submit(input);
|
|
363
|
+
if (!result.ok) return result;
|
|
364
|
+
} else {
|
|
365
|
+
if (!previous || previous.kind !== 'parts-verdict' || previous.schema !== JOB_PARTS_VERDICT_ACT_SCHEMA ||
|
|
366
|
+
value.verdict !== 'approved') throw new Error('JOB_ACT_SOURCE_STALE');
|
|
367
|
+
result = {ok: true, value: previous};
|
|
368
|
+
}
|
|
369
|
+
if (value.verdict !== 'approved') return result;
|
|
370
|
+
// Recheck after the first durable write. A replacement never inherits this signoff.
|
|
371
|
+
const latest = state();
|
|
372
|
+
if (latest.displayed?.publication.publicationId !== publicationId || !latest.receipt || !signoff)
|
|
373
|
+
throw new Error('JOB_ACT_SOURCE_STALE');
|
|
374
|
+
assertJobAskSource(signoff, latest.displayed);
|
|
375
|
+
return submit({kind: 'signoff', publicationId, pageId: input.pageId, askId: signoff.askId,
|
|
376
|
+
expectedGeneration: latest.generation, displayedNonce: latest.receipt.displayedNonce,
|
|
377
|
+
submissionId: signoffSubmissionId,
|
|
378
|
+
value: {stage: 'parts-review', decision: 'approved', words: value.words}});
|
|
331
379
|
}
|
|
332
380
|
return {
|
|
333
|
-
event, replace, submit, state, refresh: changed,
|
|
381
|
+
event, replace, submit, submitParts, state, refresh: changed,
|
|
334
382
|
settled: () => queue,
|
|
335
383
|
stop() { stopped = true; ++intent; controller?.abort(); },
|
|
336
384
|
};
|
|
@@ -565,7 +613,12 @@ import type { Checkpoint, ReviewManifest, ReviewedSource } from '../src/manifest
|
|
|
565
613
|
import type { DirectionInspection } from '../src/direction-inspection.ts';
|
|
566
614
|
import type { FeedbackCatalog } from '../src/feedback-validation.ts';
|
|
567
615
|
import type { InterviewQuestion } from '../src/interview-project.ts';
|
|
616
|
+
type JobCheckpointEvidenceMetadata = Omit<JobCheckpointEvidence, 'tiles' | 'table'> & {
|
|
617
|
+
tiles: readonly (JobCheckpointEvidence['tiles'][number] & {url: string})[];
|
|
618
|
+
table: JobCheckpointEvidence['table'] & JobCheckpointTable & {url: string};
|
|
619
|
+
};
|
|
568
620
|
export interface JobInspectionMetadata {
|
|
621
|
+
checkpointEvidence?: readonly JobCheckpointEvidenceMetadata[];
|
|
569
622
|
manifest: ReviewManifest;
|
|
570
623
|
recordSource?: undefined;
|
|
571
624
|
sourceHash: string;
|
|
@@ -585,9 +638,10 @@ export interface JobInspectionMetadata {
|
|
|
585
638
|
preRig?: boolean;
|
|
586
639
|
playback: boolean;
|
|
587
640
|
};
|
|
588
|
-
feedbackCatalog: Pick<FeedbackCatalog, 'slots'
|
|
641
|
+
feedbackCatalog: Pick<FeedbackCatalog, 'slots'> & Partial<Pick<FeedbackCatalog, 'bones'>>;
|
|
589
642
|
}
|
|
590
643
|
export interface JobRecordInspectionMetadata {
|
|
644
|
+
checkpointEvidence?: readonly JobCheckpointEvidenceMetadata[];
|
|
591
645
|
manifest?: undefined;
|
|
592
646
|
recordSource: RecordSource;
|
|
593
647
|
sourceHash: string;
|
|
@@ -602,7 +656,7 @@ export interface JobRecordInspectionMetadata {
|
|
|
602
656
|
preRig?: boolean;
|
|
603
657
|
playback: boolean;
|
|
604
658
|
};
|
|
605
|
-
feedbackCatalog: Pick<FeedbackCatalog, 'slots'
|
|
659
|
+
feedbackCatalog: Pick<FeedbackCatalog, 'slots'> & Partial<Pick<FeedbackCatalog, 'bones'>>;
|
|
606
660
|
}
|
|
607
661
|
export type JobInspectionMetadataV3 = JobInspectionMetadata | JobRecordInspectionMetadata;
|
|
608
662
|
type JobInterview = {
|
|
@@ -614,22 +668,7 @@ type JobInterview = {
|
|
|
614
668
|
})[];
|
|
615
669
|
interview?: JobInterviewDiagnostics | null;
|
|
616
670
|
};
|
|
617
|
-
|
|
618
|
-
sourceHash: string;
|
|
619
|
-
rigSize: [
|
|
620
|
-
number,
|
|
621
|
-
number
|
|
622
|
-
] | null;
|
|
623
|
-
items: {
|
|
624
|
-
name: string;
|
|
625
|
-
index: number;
|
|
626
|
-
x: number;
|
|
627
|
-
y: number;
|
|
628
|
-
w: number;
|
|
629
|
-
h: number;
|
|
630
|
-
imageHash?: string;
|
|
631
|
-
}[];
|
|
632
|
-
}
|
|
671
|
+
type JobPartsInventory = Awaited<ReturnType<PartsSource['view']>>;
|
|
633
672
|
interface JobReferenceView {
|
|
634
673
|
id: string;
|
|
635
674
|
label: string;
|
|
@@ -639,6 +678,43 @@ interface JobReferenceView {
|
|
|
639
678
|
seek(time: number, signal: AbortSignal): Promise<void>;
|
|
640
679
|
}
|
|
641
680
|
|
|
681
|
+
/** Read composition at the host boundary. Unknown IDs remain local to their slot. */
|
|
682
|
+
export function resolveJobPanels(metadata: JobInspectionMetadataV3, source: SourceV3) {
|
|
683
|
+
const parts: JobPanelComposition = {schema: JOB_PANEL_COMPOSITION_SCHEMA, left: ['parts.list'],
|
|
684
|
+
stage: ['parts.canvas'], toolbar: ['parts.layers'], side: ['parts.issues', 'act.submit']};
|
|
685
|
+
const stage: PanelComponent = source.subject === 'image-set' ? 'images.set' :
|
|
686
|
+
isRecordSource(source) ? source.subject === 'plan' ? 'plan.body' : 'interview.picks' :
|
|
687
|
+
source.direction ? 'scene.composite' : 'rig.playback';
|
|
688
|
+
const fallback: JobPanelComposition = metadata.capabilities.preRig ? parts :
|
|
689
|
+
{schema: JOB_PANEL_COMPOSITION_SCHEMA, stage: [stage], side: ['act.submit']};
|
|
690
|
+
const raw: unknown = metadata.manifest?.panels;
|
|
691
|
+
if (raw === undefined) return {composition: fallback, invalid: false};
|
|
692
|
+
try { return {composition: parsePanelComposition(raw), invalid: false}; }
|
|
693
|
+
catch { return {composition: fallback, invalid: true}; }
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** Derived only from finalized asks, including cursor replay after reload. */
|
|
697
|
+
export function jobPartsReviewState(asks: readonly JobWindowAsk[], publicationId: string) {
|
|
698
|
+
const bound = asks.filter(ask => ask.publicationId === publicationId);
|
|
699
|
+
const verdict = bound.filter(ask => ask.subject.kind === 'parts-verdict').at(-1);
|
|
700
|
+
const act = verdict?.act;
|
|
701
|
+
if (act?.kind !== 'parts-verdict' || act.schema !== JOB_PARTS_VERDICT_ACT_SCHEMA) return 'reviewing';
|
|
702
|
+
if (act.value.verdict === 'changes-requested') return 'sent';
|
|
703
|
+
const approved = bound.some(ask => ask.subject.kind === 'signoff' && ask.subject.stage === 'parts-review' &&
|
|
704
|
+
ask.act?.kind === 'signoff' && ask.act.value.decision === 'approved');
|
|
705
|
+
return approved ? 'approved' : 'retry-signoff';
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/** A declared painting identity takes precedence over manifest reference order. */
|
|
709
|
+
export function jobPartsPainting(prepared: Pick<JobPreparedInspection, 'metadata' | 'display' | 'references'>) {
|
|
710
|
+
const declared = prepared.metadata.sourcePainting;
|
|
711
|
+
if (declared) return prepared.references.find(reference => reference.id === declared.id) ?? null;
|
|
712
|
+
const source = prepared.display.publication.source;
|
|
713
|
+
if (isRecordSource(source)) return null;
|
|
714
|
+
const painting = source.parts?.images.find(image => image.role === 'painting');
|
|
715
|
+
return painting ? prepared.references.find(reference => reference.label === painting.role + ' ' + painting.path) ?? null : null;
|
|
716
|
+
}
|
|
717
|
+
|
|
642
718
|
/** A reference stays off-stage until its seek matches the latest inspection time. */
|
|
643
719
|
export function createJobReferenceSelection<Reference extends Pick<JobReferenceView, 'seek'>>(options: {
|
|
644
720
|
current(): {owner: object | null; time: number};
|
|
@@ -686,8 +762,14 @@ export interface JobPreparedInspection {
|
|
|
686
762
|
interview: JobInterview | null;
|
|
687
763
|
parts: JobPartsInventory | null;
|
|
688
764
|
partImages: Map<string, HTMLImageElement>;
|
|
765
|
+
partPages?: Map<number, HTMLImageElement>;
|
|
689
766
|
interviewImages: Map<string, HTMLImageElement>;
|
|
690
767
|
imageSetImages?: readonly HTMLImageElement[];
|
|
768
|
+
checkpointEvidence?: readonly {
|
|
769
|
+
packet: JobCheckpointEvidence;
|
|
770
|
+
table: JobCheckpointTable;
|
|
771
|
+
images: readonly HTMLImageElement[];
|
|
772
|
+
}[];
|
|
691
773
|
references: JobReferenceView[];
|
|
692
774
|
assets: ModelAssets | null;
|
|
693
775
|
player: RigPlayer | null;
|
|
@@ -805,22 +887,40 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
805
887
|
for (const url of objectUrls)
|
|
806
888
|
URL.revokeObjectURL(url);
|
|
807
889
|
};
|
|
808
|
-
async function visualBytes(url: string, hash?: string
|
|
809
|
-
|
|
890
|
+
async function visualBytes(url: string, hash?: string, maximum = 128 * 1024 * 1024,
|
|
891
|
+
hashRefusal = 'JOB_SOURCE_MISMATCH') {
|
|
892
|
+
const bytes = await jobBytes(url, signal, maximum);
|
|
810
893
|
if (hash && await jobDigest(bytes) !== hash)
|
|
811
|
-
throw new Error(
|
|
894
|
+
throw new Error(hashRefusal);
|
|
895
|
+
if (disposed || signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
|
|
812
896
|
return bytes;
|
|
813
897
|
}
|
|
814
|
-
async function image(url: string, hash?: string): Promise<HTMLImageElement> {
|
|
815
|
-
const bytes = await visualBytes(url, hash
|
|
898
|
+
async function image(url: string, hash?: string, evidence = false): Promise<HTMLImageElement> {
|
|
899
|
+
const bytes = await visualBytes(url, hash, evidence ? 8 * 1024 * 1024 : undefined,
|
|
900
|
+
evidence ? 'CHECKPOINT_EVIDENCE_HASH_MISMATCH' : undefined);
|
|
901
|
+
if (disposed || signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
|
|
816
902
|
const blob = URL.createObjectURL(new Blob([bytes.slice().buffer]));
|
|
817
903
|
objectUrls.push(blob);
|
|
818
904
|
const image = new Image();
|
|
819
905
|
image.src = blob;
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
906
|
+
let cancel: () => void = () => {};
|
|
907
|
+
const cancelled = new Promise<never>((_resolve, reject) => {
|
|
908
|
+
cancel = () => reject(new Error('JOB_PRELOAD_CANCELLED'));
|
|
909
|
+
signal.addEventListener('abort', cancel, {once: true});
|
|
910
|
+
if (signal.aborted) cancel();
|
|
911
|
+
});
|
|
912
|
+
try {
|
|
913
|
+
await Promise.race([image.decode().catch(error => {
|
|
914
|
+
if (evidence) throw new Error('CHECKPOINT_EVIDENCE_PNG_INVALID');
|
|
915
|
+
throw error;
|
|
916
|
+
}), cancelled]);
|
|
917
|
+
if (disposed || signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
|
|
918
|
+
if (!image.naturalWidth || !image.naturalHeight)
|
|
919
|
+
throw new Error(evidence ? 'CHECKPOINT_EVIDENCE_PNG_INVALID' : 'JOB_VISUAL_UNAVAILABLE');
|
|
920
|
+
return image;
|
|
921
|
+
} finally {
|
|
922
|
+
signal.removeEventListener('abort', cancel);
|
|
923
|
+
}
|
|
824
924
|
}
|
|
825
925
|
try {
|
|
826
926
|
const interview = metadata.capabilities.interview ? await jobJson<JobInterview>(routes.api('interview'), signal) : null;
|
|
@@ -829,12 +929,57 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
829
929
|
throw new Error('JOB_DISPLAY_MISMATCH');
|
|
830
930
|
}
|
|
831
931
|
const parts = metadata.capabilities.preRig ? await jobJson<JobPartsInventory>(routes.api('stage-parts'), signal) : null;
|
|
932
|
+
if (metadata.sourceHash !== publishedSource.sourceHash || parts && parts.sourceHash !== publishedSource.sourceHash)
|
|
933
|
+
throw new Error('JOB_SOURCE_MISMATCH');
|
|
832
934
|
const references: JobReferenceView[] = [];
|
|
833
935
|
const partImages = new Map<string, HTMLImageElement>();
|
|
834
936
|
const interviewImages = new Map<string, HTMLImageElement>();
|
|
937
|
+
const partPages = new Map<number, HTMLImageElement>();
|
|
835
938
|
const preload: Promise<void>[] = [];
|
|
836
939
|
const imageSetImages: HTMLImageElement[] = [];
|
|
837
940
|
const source = display.publication.source;
|
|
941
|
+
const checkpointEvidence: NonNullable<JobPreparedInspection['checkpointEvidence']>[number][] = [];
|
|
942
|
+
if (Object.hasOwn(metadata, 'checkpointEvidence') !== Object.hasOwn(source, 'checkpointEvidence') ||
|
|
943
|
+
source.checkpointEvidence !== undefined && (!Array.isArray(metadata.checkpointEvidence) ||
|
|
944
|
+
metadata.checkpointEvidence.length !== source.checkpointEvidence.length)) {
|
|
945
|
+
throw new Error('CHECKPOINT_EVIDENCE_INVALID');
|
|
946
|
+
}
|
|
947
|
+
for (const [index, packet] of (source.checkpointEvidence ?? []).entries()) {
|
|
948
|
+
const projection = metadata.checkpointEvidence?.[index];
|
|
949
|
+
const tableUrl = `/api/checkpoint-evidence/${packet.checkpointId}/table`;
|
|
950
|
+
if (!projection?.table || !source.plan?.steps.some(step => step.id === packet.planStepId) ||
|
|
951
|
+
source.subject === 'plan' && !source.subjects.some(subject => subject.kind === 'checkpoint' &&
|
|
952
|
+
subject.checkpointId === packet.checkpointId && packet.planStepId === packet.checkpointId) ||
|
|
953
|
+
sourceSnapshot(projection) !== sourceSnapshot({...packet,
|
|
954
|
+
tiles: packet.tiles.map((tile, tileIndex) => ({...tile,
|
|
955
|
+
url: `/api/checkpoint-evidence/${packet.checkpointId}/tiles/${tileIndex}`})),
|
|
956
|
+
table: {...packet.table, url: tableUrl, schema: projection.table.schema,
|
|
957
|
+
columns: projection.table.columns, rows: projection.table.rows}})) {
|
|
958
|
+
throw new Error('CHECKPOINT_EVIDENCE_INVALID');
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
for (const [index, packet] of (source.checkpointEvidence ?? []).entries()) {
|
|
962
|
+
preload.push((async () => {
|
|
963
|
+
const bytes = await visualBytes(routes.api(`checkpoint-evidence/${packet.checkpointId}/table`),
|
|
964
|
+
packet.table.sha256, 256 * 1024, 'CHECKPOINT_EVIDENCE_HASH_MISMATCH');
|
|
965
|
+
let table: JobCheckpointTable;
|
|
966
|
+
try {
|
|
967
|
+
table = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(bytes));
|
|
968
|
+
const projection = metadata.checkpointEvidence![index]!.table;
|
|
969
|
+
if (sourceSnapshot(table) !== sourceSnapshot({schema: projection.schema,
|
|
970
|
+
columns: projection.columns, rows: projection.rows})) throw new Error();
|
|
971
|
+
} catch {
|
|
972
|
+
throw new Error('CHECKPOINT_EVIDENCE_TABLE_INVALID');
|
|
973
|
+
}
|
|
974
|
+
const images = await Promise.all(packet.tiles.map(async (tile, tileIndex) => {
|
|
975
|
+
const element = await image(routes.api(`checkpoint-evidence/${packet.checkpointId}/tiles/${tileIndex}`),
|
|
976
|
+
tile.sha256, true);
|
|
977
|
+
element.alt = tile.label;
|
|
978
|
+
return element;
|
|
979
|
+
}));
|
|
980
|
+
checkpointEvidence[index] = {packet, table, images};
|
|
981
|
+
})());
|
|
982
|
+
}
|
|
838
983
|
if (source.subject === 'image-set') {
|
|
839
984
|
if (metadata.sourceHash !== source.sourceHash || metadata.manifest?.model)
|
|
840
985
|
throw new Error('JOB_DISPLAY_MISMATCH');
|
|
@@ -850,9 +995,12 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
850
995
|
}
|
|
851
996
|
}
|
|
852
997
|
for (const reference of metadata.manifest?.references ?? []) {
|
|
998
|
+
if (reference.id === metadata.sourcePainting?.id) continue;
|
|
853
999
|
preload.push((async () => {
|
|
854
1000
|
if (reference.type === 'image') {
|
|
855
|
-
const
|
|
1001
|
+
const painting = !isRecordSource(source) ? source.parts?.images.find(entry =>
|
|
1002
|
+
entry.role === 'painting' && reference.label === entry.role + ' ' + entry.path) : null;
|
|
1003
|
+
const element = await image(routes.asset(reference.path), painting?.sha256 ?? metadata.referenceHashes?.[reference.id]);
|
|
856
1004
|
element.alt = reference.label;
|
|
857
1005
|
references.push({ id: reference.id, label: reference.label, element,
|
|
858
1006
|
width: element.naturalWidth, height: element.naturalHeight, seek: async () => { } });
|
|
@@ -957,6 +1105,10 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
957
1105
|
preload.push(image(routes.api('stage-parts/image/' + part.index), part.imageHash)
|
|
958
1106
|
.then(element => { element.alt = part.name; partImages.set(part.name, element); }));
|
|
959
1107
|
}
|
|
1108
|
+
for (const page of parts?.pages ?? []) {
|
|
1109
|
+
preload.push(image(routes.api('stage-parts/page/' + page.index))
|
|
1110
|
+
.then(element => { partPages.set(page.index, element); }));
|
|
1111
|
+
}
|
|
960
1112
|
for (const question of interview?.questions ?? [])
|
|
961
1113
|
for (const asset of question.images) {
|
|
962
1114
|
preload.push(image(routes.instance(asset.url)).then(element => { element.alt = asset.name; interviewImages.set(asset.url, element); }));
|
|
@@ -997,7 +1149,7 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
997
1149
|
};
|
|
998
1150
|
resetToSetup();
|
|
999
1151
|
}
|
|
1000
|
-
if (!isRecordSource(source) && !player && !references.length && !partImages.size && !imageSetImages.length)
|
|
1152
|
+
if (!isRecordSource(source) && !player && !references.length && !partImages.size && !imageSetImages.length && !checkpointEvidence.length)
|
|
1001
1153
|
throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
1002
1154
|
if (signal.aborted)
|
|
1003
1155
|
throw new Error('JOB_PRELOAD_CANCELLED');
|
|
@@ -1005,7 +1157,7 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
1005
1157
|
const order = [metadata.sourcePainting?.id, ...(metadata.manifest?.references.map(reference => reference.id) ?? [])];
|
|
1006
1158
|
references.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
|
|
1007
1159
|
return {
|
|
1008
|
-
display, metadata, interview, parts, partImages, interviewImages, imageSetImages, references, assets, rigRoot,
|
|
1160
|
+
display, metadata, interview, parts, partImages, partPages, interviewImages, imageSetImages, checkpointEvidence, references, assets, rigRoot,
|
|
1009
1161
|
get rigPresentation() { return rigPresentation; },
|
|
1010
1162
|
set rigPresentation(value) {
|
|
1011
1163
|
clearRigPresentation();
|
|
@@ -1024,9 +1176,9 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
1024
1176
|
}
|
|
1025
1177
|
/** Browser mount is explicit so importing transaction helpers never starts an app. */
|
|
1026
1178
|
export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
1027
|
-
const [{ createViewportController, createViewportState }, { createRigViewportProvider }, { mountViewportPair }, i18n] = await Promise.all([
|
|
1179
|
+
const [{ createViewportController, createViewportState }, { createRigViewportProvider }, { mountViewportPair }, { RigOverlays }, { bindLayerShortcuts, describeLayerToggles, layerShortcuts }, i18n] = await Promise.all([
|
|
1028
1180
|
import('./viewport-controller.ts'), import('./rig-viewport-provider.ts'),
|
|
1029
|
-
import('./viewport-pair.ts'), import('./i18n.ts'),
|
|
1181
|
+
import('./viewport-pair.ts'), import('./rig-overlays.ts'), import('./view-controls.ts'), import('./i18n.ts'),
|
|
1030
1182
|
]);
|
|
1031
1183
|
let storage: Storage | null = null;
|
|
1032
1184
|
try {
|
|
@@ -1216,8 +1368,19 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1216
1368
|
element: HTMLElement;
|
|
1217
1369
|
forms: Map<string, JobForm>;
|
|
1218
1370
|
};
|
|
1371
|
+
const partsPanels = new WeakMap<JobPreparedInspection, {
|
|
1372
|
+
slots: {left: HTMLElement; stage: HTMLElement; toolbar: HTMLElement; side: HTMLElement};
|
|
1373
|
+
composition: JobPanelComposition;
|
|
1374
|
+
output?: Parameters<PartsHost['register']>[0];
|
|
1375
|
+
issues: PartsIssue[];
|
|
1376
|
+
legacy: unknown;
|
|
1377
|
+
dispose?: () => void;
|
|
1378
|
+
}>();
|
|
1219
1379
|
const forms = new Map<string, JobForm>();
|
|
1220
1380
|
const drawn = new WeakMap<JobPreparedInspection, JobRigDraw>();
|
|
1381
|
+
const overlays = new WeakMap<JobPreparedInspection, InstanceType<typeof RigOverlays>>();
|
|
1382
|
+
const layers = { images: true, mesh: false, bones: false, meshOpacity: 0.65 };
|
|
1383
|
+
let stageBackground = '';
|
|
1221
1384
|
let drawGeneration = 0;
|
|
1222
1385
|
const viewportState = createViewportState();
|
|
1223
1386
|
if (restoredCamera) {
|
|
@@ -1282,11 +1445,27 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1282
1445
|
const reference = () => current?.references.find(item => item.id === selectedReference) ?? null;
|
|
1283
1446
|
const setText = (id: string, value: string) => { const element = workspace.querySelector('#' + id); if (element)
|
|
1284
1447
|
element.textContent = i18n.tr(value); };
|
|
1448
|
+
function redrawOverlay(fresh: boolean): void {
|
|
1449
|
+
const owner = current, overlay = owner ? overlays.get(owner) : undefined;
|
|
1450
|
+
if (!owner || !overlay) return;
|
|
1451
|
+
const root = owner.rigRoot, scale = viewportState.rigScale;
|
|
1452
|
+
const left = parseFloat(root.style.left) || 0, top = parseFloat(root.style.top) || 0;
|
|
1453
|
+
const project = (x: number, y: number) => ({ x: left + x * scale, y: top - y * scale });
|
|
1454
|
+
const bones = (owner.metadata.feedbackCatalog.bones ?? []).map(name => ({ name }));
|
|
1455
|
+
const frame = owner.inspection?.frame('single');
|
|
1456
|
+
const selectedSlot = selectedPart || null;
|
|
1457
|
+
const snap = fresh
|
|
1458
|
+
? overlay.refresh({ player: owner.player, bones, frame, selectedSlot, project, settings: layers })
|
|
1459
|
+
: overlay.redraw({ project, settings: layers });
|
|
1460
|
+
if (!fresh && snap.needsCapture && owner.player) {
|
|
1461
|
+
overlay.refresh({ player: owner.player, bones, frame, selectedSlot, project, settings: layers });
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1285
1464
|
const provider = createRigViewportProvider({
|
|
1286
1465
|
el, player: () => current?.player ?? null, assets: () => current?.assets ?? null,
|
|
1287
1466
|
referenceSize: () => reference(), view: () => 'compare', referenceGeneration: () => current?.display.publication.generation ?? 0,
|
|
1288
1467
|
parts: () => current?.inspection ?? null, text: setText,
|
|
1289
|
-
message: value => { notice.textContent = jobWindowRefusal(value); }, redrawOverlay:
|
|
1468
|
+
message: value => { notice.textContent = jobWindowRefusal(value); }, redrawOverlay: fresh => redrawOverlay(fresh),
|
|
1290
1469
|
}, viewportState);
|
|
1291
1470
|
const canonicalControls = provider.renderControls;
|
|
1292
1471
|
provider.renderControls = controller => {
|
|
@@ -1335,13 +1514,26 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1335
1514
|
pixels?.width, pixels?.height, canvas?.width, canvas?.height, canvas?.getAttribute('style'),
|
|
1336
1515
|
]),
|
|
1337
1516
|
defaultCamera: plain && camera.zoom === 1 && camera.center.x === frame.center.x && camera.center.y === frame.center.y,
|
|
1338
|
-
wholeRig: !selectedPart && !owner.inspection?.value() && player.slots === null
|
|
1517
|
+
wholeRig: !selectedPart && !owner.inspection?.value() && player.slots === null &&
|
|
1518
|
+
layers.images && !layers.mesh && !layers.bones && !stageBackground,
|
|
1339
1519
|
playing};
|
|
1340
1520
|
}
|
|
1341
1521
|
function rememberDraw(): void {
|
|
1342
1522
|
const owner = current;
|
|
1343
1523
|
if (!owner) return;
|
|
1344
1524
|
try {
|
|
1525
|
+
const pane = el('rig-viewport');
|
|
1526
|
+
const bg = SENTINELS[stageBackground] ?? '';
|
|
1527
|
+
pane.style.backgroundColor = bg;
|
|
1528
|
+
pane.style.backgroundImage = bg ? 'none' : '';
|
|
1529
|
+
if (!layers.images || layers.mesh || layers.bones || bg) {
|
|
1530
|
+
drawn.delete(owner);
|
|
1531
|
+
owner.rigPresentation = undefined;
|
|
1532
|
+
delete pane.dataset.jobRigCanonical;
|
|
1533
|
+
owner.rigRoot.style.visibility = layers.images ? 'visible' : 'hidden';
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
owner.rigRoot.style.visibility = '';
|
|
1345
1537
|
const player = owner.player;
|
|
1346
1538
|
const posed = owner.inspection?.frame('single');
|
|
1347
1539
|
const camera = viewport.numericView().cameras.rig;
|
|
@@ -1349,7 +1541,6 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1349
1541
|
throw new Error('JOB_STILL_CAPTURE_FAILED');
|
|
1350
1542
|
}
|
|
1351
1543
|
const renderer = player.renderer;
|
|
1352
|
-
const pane = el('rig-viewport');
|
|
1353
1544
|
const presentation = presentJobRigViewport({pane, root: owner.rigRoot, images: true,
|
|
1354
1545
|
canvas: renderer instanceof CanvasRenderer ? renderer.canvas : undefined,
|
|
1355
1546
|
backend: renderer instanceof CanvasRenderer ? renderer.backendActive : renderer.meshBackendActive},
|
|
@@ -1368,6 +1559,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1368
1559
|
owner.rigPresentation = undefined;
|
|
1369
1560
|
owner.player?.draw();
|
|
1370
1561
|
owner.inspection?.present('single');
|
|
1562
|
+
if (owner === current) redrawOverlay(true);
|
|
1371
1563
|
}
|
|
1372
1564
|
function syncTransportControls(): void {
|
|
1373
1565
|
const playBtn = workspace.querySelector<HTMLButtonElement>('#job-play');
|
|
@@ -1549,6 +1741,43 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1549
1741
|
parent.append(inputLabel(key, input));
|
|
1550
1742
|
return input;
|
|
1551
1743
|
}
|
|
1744
|
+
function imageGallery(images: readonly {name: string; sha256: string; element?: HTMLImageElement;
|
|
1745
|
+
role?: string; duplicate?: boolean}[]): HTMLElement {
|
|
1746
|
+
const gallery = node('section');
|
|
1747
|
+
gallery.style.display = 'grid';
|
|
1748
|
+
gallery.style.gridAutoFlow = 'column';
|
|
1749
|
+
gallery.style.gridAutoColumns = 'minmax(180px, 1fr)';
|
|
1750
|
+
gallery.style.gap = '16px';
|
|
1751
|
+
gallery.style.overflow = 'auto';
|
|
1752
|
+
gallery.style.minHeight = '0';
|
|
1753
|
+
gallery.style.flex = '1';
|
|
1754
|
+
for (const image of images) {
|
|
1755
|
+
const element = image.element;
|
|
1756
|
+
if (!element) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
1757
|
+
const figure = node('figure');
|
|
1758
|
+
figure.style.margin = '0';
|
|
1759
|
+
figure.style.minWidth = '0';
|
|
1760
|
+
figure.dataset.imageName = image.name;
|
|
1761
|
+
const name = node('h3');
|
|
1762
|
+
name.textContent = image.name;
|
|
1763
|
+
name.style.overflowWrap = 'anywhere';
|
|
1764
|
+
const role = image.role ? node('p', 'job.imageRole.' + image.role) : node('p');
|
|
1765
|
+
const hash = node('code');
|
|
1766
|
+
hash.className = 'job-source';
|
|
1767
|
+
hash.style.display = 'block';
|
|
1768
|
+
hash.style.overflowWrap = 'anywhere';
|
|
1769
|
+
hash.textContent = image.sha256;
|
|
1770
|
+
element.style.width = '100%';
|
|
1771
|
+
element.style.height = 'auto';
|
|
1772
|
+
element.style.maxHeight = '70vh';
|
|
1773
|
+
element.style.objectFit = 'contain';
|
|
1774
|
+
figure.append(name, role, element, hash);
|
|
1775
|
+
if (image.duplicate)
|
|
1776
|
+
figure.append(node('p', 'job.identicalImages'));
|
|
1777
|
+
gallery.append(figure);
|
|
1778
|
+
}
|
|
1779
|
+
return gallery;
|
|
1780
|
+
}
|
|
1552
1781
|
function formFor(ask: PendingAskV3, prepared: JobPreparedInspection): JobForm {
|
|
1553
1782
|
if (ask.publicationId !== prepared.display.publication.publicationId)
|
|
1554
1783
|
throw new Error('JOB_DISPLAY_MISMATCH');
|
|
@@ -1647,6 +1876,57 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1647
1876
|
planStep.className = 'job-source';
|
|
1648
1877
|
planStep.textContent = checkpoint.step.id + ' · ' + checkpoint.step.hash;
|
|
1649
1878
|
fields.append(planStep, guidance);
|
|
1879
|
+
const evidence = prepared.checkpointEvidence?.find(item => item.packet.checkpointId === subject.checkpointId);
|
|
1880
|
+
const declared = ask.source.checkpointEvidence?.find(item => item.checkpointId === subject.checkpointId);
|
|
1881
|
+
if (Boolean(declared) !== Boolean(evidence) || evidence &&
|
|
1882
|
+
(JSON.stringify(evidence.packet) !== JSON.stringify(declared) || evidence.packet.planStepId !== checkpoint.step.id)) {
|
|
1883
|
+
throw new Error('CHECKPOINT_EVIDENCE_INVALID');
|
|
1884
|
+
}
|
|
1885
|
+
if (evidence) {
|
|
1886
|
+
const section = node('section');
|
|
1887
|
+
section.dataset.jobCheckpointEvidence = subject.checkpointId;
|
|
1888
|
+
section.append(node('h4', 'job.checkpointEvidence'));
|
|
1889
|
+
section.append(imageGallery(evidence.packet.tiles.map((tile, index) => ({name: tile.label,
|
|
1890
|
+
sha256: tile.sha256, element: evidence.images[index]?.cloneNode(true) as HTMLImageElement}))));
|
|
1891
|
+
const tableHost = node('div');
|
|
1892
|
+
tableHost.style.overflow = 'auto';
|
|
1893
|
+
tableHost.style.maxHeight = '50dvh';
|
|
1894
|
+
const table = node('table');
|
|
1895
|
+
table.dataset.jobCheckpointTable = '';
|
|
1896
|
+
const caption = node('caption', 'job.checkpointTable');
|
|
1897
|
+
if (evidence.packet.table.label !== undefined) {
|
|
1898
|
+
delete caption.dataset.jobText;
|
|
1899
|
+
caption.textContent = evidence.packet.table.label;
|
|
1900
|
+
}
|
|
1901
|
+
const head = node('thead');
|
|
1902
|
+
const columns = node('tr');
|
|
1903
|
+
for (const column of evidence.table.columns) {
|
|
1904
|
+
const cell = node('th');
|
|
1905
|
+
cell.scope = 'col';
|
|
1906
|
+
cell.textContent = column;
|
|
1907
|
+
columns.append(cell);
|
|
1908
|
+
}
|
|
1909
|
+
head.append(columns);
|
|
1910
|
+
const body = node('tbody');
|
|
1911
|
+
for (const row of evidence.table.rows) {
|
|
1912
|
+
const cells = node('tr');
|
|
1913
|
+
for (const value of row) {
|
|
1914
|
+
const cell = node('td');
|
|
1915
|
+
cell.textContent = String(value);
|
|
1916
|
+
cells.append(cell);
|
|
1917
|
+
}
|
|
1918
|
+
body.append(cells);
|
|
1919
|
+
}
|
|
1920
|
+
table.append(caption, head, body);
|
|
1921
|
+
tableHost.append(table);
|
|
1922
|
+
const routes = node('pre');
|
|
1923
|
+
routes.textContent = evidence.packet.routesText;
|
|
1924
|
+
const recommendation = node('pre');
|
|
1925
|
+
recommendation.textContent = evidence.packet.recommendationText;
|
|
1926
|
+
section.append(tableHost, node('h4', 'job.checkpointRoutes'), routes,
|
|
1927
|
+
node('h4', 'job.checkpointRecommendation'), recommendation);
|
|
1928
|
+
fields.append(section, node('p', 'job.checkpointRouteMapping'));
|
|
1929
|
+
}
|
|
1650
1930
|
const outcome = selectValues(['', 'pass', 'fail'], ['Pending', 'Pass', 'job.fail']);
|
|
1651
1931
|
outcome.required = true;
|
|
1652
1932
|
outcome.name = 'outcome';
|
|
@@ -1655,32 +1935,13 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1655
1935
|
submitKey = 'job.saveCheckpoint';
|
|
1656
1936
|
}
|
|
1657
1937
|
else if (subject.kind === 'parts-verdict') {
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
const legend = node('legend');
|
|
1666
|
-
legend.textContent = part.name;
|
|
1667
|
-
group.append(legend);
|
|
1668
|
-
const partOutcome = selectValues(['pending', 'clean', 'flagged'], ['Pending', 'Clean', 'Flagged']);
|
|
1669
|
-
const meshOutcome = selectValues(['pending', 'clean', 'flagged'], ['Pending', 'Clean', 'Flagged']);
|
|
1670
|
-
partOutcome.name = 'parts.' + part.name + '.outcome';
|
|
1671
|
-
meshOutcome.name = 'mesh.' + part.name + '.outcome';
|
|
1672
|
-
group.append(inputLabel('Parts', partOutcome));
|
|
1673
|
-
const partNote = textArea(group, 'Note', 'parts.' + part.name + '.note');
|
|
1674
|
-
group.append(inputLabel('Mesh', meshOutcome));
|
|
1675
|
-
const meshNote = textArea(group, 'Note', 'mesh.' + part.name + '.note');
|
|
1676
|
-
fields.append(group);
|
|
1677
|
-
return { partId: part.name, partOutcome, meshOutcome, partNote, meshNote };
|
|
1678
|
-
});
|
|
1679
|
-
read = () => ({ verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: note.value,
|
|
1680
|
-
parts: parts.map(part => ({ partId: part.partId,
|
|
1681
|
-
part: { outcome: part.partOutcome.value as 'pending' | 'clean' | 'flagged', note: part.partNote.value },
|
|
1682
|
-
mesh: { outcome: part.meshOutcome.value as 'pending' | 'clean' | 'flagged', note: part.meshNote.value } })) });
|
|
1683
|
-
submitKey = 'job.savePartsVerdict';
|
|
1938
|
+
read = () => {
|
|
1939
|
+
const panel = partsPanels.get(prepared);
|
|
1940
|
+
if (panel?.legacy) throw new Error('JOB_PARTS_LEGACY_DRAFT');
|
|
1941
|
+
if (!panel?.output) throw new Error('JOB_PANEL_OUTPUT_MISSING');
|
|
1942
|
+
return {...panel.output.value(), words: note.value};
|
|
1943
|
+
};
|
|
1944
|
+
submitKey = 'job.partsApprove';
|
|
1684
1945
|
}
|
|
1685
1946
|
else if (subject.kind === 'review-verdict') {
|
|
1686
1947
|
const verdict = selectValues(['pending', 'approved', 'changes-requested'], ['Pending', 'Approved', 'Changes requested']);
|
|
@@ -1742,13 +2003,20 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1742
2003
|
form.append(status);
|
|
1743
2004
|
const entry: JobForm = { form, fieldset: fields, read, submissionId: crypto.randomUUID(), dirty: false,
|
|
1744
2005
|
submitting: false, rigSubmission: createJobRigSubmission() };
|
|
2006
|
+
const signoffSubmissionId = crypto.randomUUID();
|
|
1745
2007
|
try {
|
|
1746
2008
|
const saved = JSON.parse(localStorage.getItem(localDraftKey(prepared.display)) ?? 'null');
|
|
1747
2009
|
if (saved?.publicationId === prepared.display.publication.publicationId &&
|
|
1748
2010
|
saved?.sourceHash === prepared.display.publication.source.sourceHash) {
|
|
2011
|
+
assertJobAskSource({...ask, source: saved.source}, prepared.display);
|
|
1749
2012
|
const original = saved.forms?.find((item: {
|
|
1750
2013
|
askId: string;
|
|
1751
2014
|
}) => item.askId === ask.askId);
|
|
2015
|
+
if (subject.kind === 'parts-verdict') {
|
|
2016
|
+
const panel = partsPanels.get(prepared);
|
|
2017
|
+
if (panel && Array.isArray(original?.value?.issues)) panel.issues = structuredClone(original.value.issues);
|
|
2018
|
+
else if (panel && original?.value?.parts) panel.legacy = original.value;
|
|
2019
|
+
}
|
|
1752
2020
|
for (const input of form.querySelectorAll<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>('input[name],textarea[name],select[name]')) {
|
|
1753
2021
|
const restored = original?.controls?.find((item: {
|
|
1754
2022
|
name: string;
|
|
@@ -1783,7 +2051,9 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1783
2051
|
fields.disabled = true;
|
|
1784
2052
|
const frozen = await pending;
|
|
1785
2053
|
if (entry.submissionId !== frozen.submissionId) throw new Error('JOB_STILL_BINDING_MISMATCH');
|
|
1786
|
-
|
|
2054
|
+
if (subject.kind === 'parts-verdict') window.refresh();
|
|
2055
|
+
const result = subject.kind === 'parts-verdict'
|
|
2056
|
+
? await window.submitParts(frozen, signoffSubmissionId) : await window.submit(frozen);
|
|
1787
2057
|
if (!result.ok)
|
|
1788
2058
|
throw new Error(result.error.code);
|
|
1789
2059
|
entry.submitting = false;
|
|
@@ -1792,6 +2062,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1792
2062
|
status.dataset.jobText = 'job.saved';
|
|
1793
2063
|
status.textContent = t('job.saved');
|
|
1794
2064
|
saveDraft();
|
|
2065
|
+
if (subject.kind === 'parts-verdict') window.refresh();
|
|
1795
2066
|
}
|
|
1796
2067
|
catch (error) {
|
|
1797
2068
|
entry.submitting = false;
|
|
@@ -1799,6 +2070,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1799
2070
|
? error.message : 'JOB_ACT_INVALID';
|
|
1800
2071
|
status.textContent = jobWindowRefusal(error, 'JOB_ACT_INVALID');
|
|
1801
2072
|
fields.disabled = false;
|
|
2073
|
+
if (subject.kind === 'parts-verdict') window.refresh();
|
|
1802
2074
|
}
|
|
1803
2075
|
};
|
|
1804
2076
|
return entry;
|
|
@@ -1809,11 +2081,17 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1809
2081
|
const host = workspace.querySelector<HTMLElement>('[data-job-forms]');
|
|
1810
2082
|
if (!host)
|
|
1811
2083
|
return;
|
|
2084
|
+
const partsPanel = partsPanels.get(current);
|
|
2085
|
+
const partsState = jobPartsReviewState(state.pending, current.display.publication.publicationId);
|
|
2086
|
+
const activeParts = state.pending.filter(ask => ask.publicationId === current!.display.publication.publicationId &&
|
|
2087
|
+
ask.subject.kind === 'parts-verdict').at(-1);
|
|
1812
2088
|
for (const ask of state.pending) {
|
|
1813
2089
|
if (ask.publicationId !== current.display.publication.publicationId)
|
|
1814
2090
|
continue;
|
|
2091
|
+
if (partsPanel && ask.subject.kind === 'signoff' && ask.subject.stage === 'parts-review') continue;
|
|
2092
|
+
if (partsPanel && ask.subject.kind === 'parts-verdict' && ask !== activeParts) continue;
|
|
1815
2093
|
let entry = forms.get(ask.askId);
|
|
1816
|
-
if (!entry && ask.status === 'pending') {
|
|
2094
|
+
if (!entry && (ask.status === 'pending' || partsPanel && ask === activeParts)) {
|
|
1817
2095
|
try {
|
|
1818
2096
|
entry = formFor(ask, current);
|
|
1819
2097
|
forms.set(ask.askId, entry);
|
|
@@ -1825,8 +2103,181 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1825
2103
|
host.append(refusal);
|
|
1826
2104
|
}
|
|
1827
2105
|
}
|
|
1828
|
-
if (entry)
|
|
1829
|
-
|
|
2106
|
+
if (entry) {
|
|
2107
|
+
const partsAsk = partsPanel && ask.subject.kind === 'parts-verdict';
|
|
2108
|
+
entry.fieldset.disabled = entry.submitting || (ask.status !== 'pending' && !(partsAsk && partsState === 'retry-signoff')) ||
|
|
2109
|
+
state.preparing || state.closed || !state.receipt || !access.capability;
|
|
2110
|
+
if (partsAsk) {
|
|
2111
|
+
const button = entry.form.querySelector<HTMLButtonElement>('button[type=submit]')!;
|
|
2112
|
+
const signoff = state.pending.some(item => item.publicationId === ask.publicationId && item.status === 'pending' &&
|
|
2113
|
+
item.subject.kind === 'signoff' && item.subject.stage === 'parts-review');
|
|
2114
|
+
button.dataset.jobText = partsState === 'retry-signoff' ? 'job.partsRetrySignoff' :
|
|
2115
|
+
partsPanel.issues.length ? 'job.partsRequestFixes' : 'job.partsApprove';
|
|
2116
|
+
button.textContent = t(button.dataset.jobText, [partsPanel.issues.length]);
|
|
2117
|
+
button.disabled = !partsPanel.output || !!partsPanel.legacy ||
|
|
2118
|
+
(partsState === 'retry-signoff' || !partsPanel.issues.length) && !signoff;
|
|
2119
|
+
const status = entry.form.querySelector<HTMLElement>('[role=status]')!;
|
|
2120
|
+
if (!partsPanel.output) {
|
|
2121
|
+
status.dataset.jobText = 'JOB_PANEL_OUTPUT_MISSING';
|
|
2122
|
+
status.textContent = t('JOB_PANEL_OUTPUT_MISSING') + ' · ' + ask.subject.kind;
|
|
2123
|
+
} else if (status.dataset.jobText === 'JOB_PANEL_OUTPUT_MISSING') {
|
|
2124
|
+
delete status.dataset.jobText;
|
|
2125
|
+
status.textContent = '';
|
|
2126
|
+
}
|
|
2127
|
+
const words = entry.form.querySelector<HTMLTextAreaElement>('textarea[name=note]');
|
|
2128
|
+
if (words) words.disabled = ask.status !== 'pending';
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
const hasCheckpointAsk = Boolean(current.player) && state.pending.some(
|
|
2133
|
+
ask => ask.publicationId === current!.display.publication.publicationId &&
|
|
2134
|
+
ask.status === 'pending' && ask.subject.kind === 'checkpoint',
|
|
2135
|
+
);
|
|
2136
|
+
const layerSet = workspace.querySelector<HTMLElement>('#layer-controls');
|
|
2137
|
+
const bgField = workspace.querySelector<HTMLElement>('#job-background-field');
|
|
2138
|
+
const bgSelect = workspace.querySelector<HTMLSelectElement>('#job-background');
|
|
2139
|
+
const hadNonDefaultView = !layers.images || layers.mesh || layers.bones || Boolean(stageBackground);
|
|
2140
|
+
if (!hasCheckpointAsk && hadNonDefaultView) {
|
|
2141
|
+
layers.images = true;
|
|
2142
|
+
layers.mesh = false;
|
|
2143
|
+
layers.bones = false;
|
|
2144
|
+
stageBackground = '';
|
|
2145
|
+
}
|
|
2146
|
+
if (layerSet) {
|
|
2147
|
+
layerSet.hidden = !hasCheckpointAsk;
|
|
2148
|
+
for (const [id, key] of [['layer-images', 'images'], ['layer-mesh', 'mesh'], ['layer-bones', 'bones']] as const) {
|
|
2149
|
+
const box = layerSet.querySelector<HTMLInputElement>('#' + id);
|
|
2150
|
+
if (box) {
|
|
2151
|
+
box.disabled = !hasCheckpointAsk;
|
|
2152
|
+
box.checked = layers[key];
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
describeLayerToggles({ getElementById: id => layerSet.querySelector('#' + id) }, t('No rig supplied'));
|
|
2156
|
+
for (const label of layerSet.querySelectorAll<HTMLElement>('.layer-toggle')) label.title = i18n.tr(label.title);
|
|
2157
|
+
}
|
|
2158
|
+
if (bgField && bgSelect) {
|
|
2159
|
+
bgField.hidden = !hasCheckpointAsk;
|
|
2160
|
+
bgSelect.disabled = !hasCheckpointAsk;
|
|
2161
|
+
bgSelect.value = stageBackground;
|
|
2162
|
+
}
|
|
2163
|
+
if (!hasCheckpointAsk && hadNonDefaultView) {
|
|
2164
|
+
redrawOverlay(true);
|
|
2165
|
+
rememberDraw();
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
async function mountJobParts(prepared: JobPreparedInspection, signal: AbortSignal): Promise<void> {
|
|
2169
|
+
const panel = partsPanels.get(prepared)!;
|
|
2170
|
+
const [{mountPartsWorkspace}, {parsePartsIssue}] = await Promise.all([
|
|
2171
|
+
import('./parts.ts'), import('../src/parts-comment.ts'),
|
|
2172
|
+
]);
|
|
2173
|
+
if (signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
|
|
2174
|
+
const finalized = window.state().pending.filter(ask =>
|
|
2175
|
+
ask.publicationId === prepared.display.publication.publicationId && ask.subject.kind === 'parts-verdict').at(-1)?.act;
|
|
2176
|
+
if (finalized?.kind === 'parts-verdict') {
|
|
2177
|
+
if (finalized.schema === JOB_PARTS_VERDICT_ACT_SCHEMA) panel.issues = [...finalized.value.issues];
|
|
2178
|
+
else panel.legacy = finalized.value;
|
|
2179
|
+
}
|
|
2180
|
+
panel.issues = panel.issues.map(issue => parsePartsIssue(issue, true, false, false));
|
|
2181
|
+
const routes = jobPublicationRoutes(prepared.display, location.origin);
|
|
2182
|
+
const painting = jobPartsPainting(prepared);
|
|
2183
|
+
const lifetime = new AbortController();
|
|
2184
|
+
let rejectPreparation!: (error: unknown) => void;
|
|
2185
|
+
const preparationCancelled = new Promise<never>((_resolve, reject) => {rejectPreparation = reject;});
|
|
2186
|
+
void preparationCancelled.catch(() => {});
|
|
2187
|
+
let mounted: ReturnType<typeof mountPartsWorkspace> | undefined;
|
|
2188
|
+
const cancelPreparation = () => {lifetime.abort(); rejectPreparation(new Error('JOB_PRELOAD_CANCELLED'));};
|
|
2189
|
+
signal.addEventListener('abort', cancelPreparation, {once: true});
|
|
2190
|
+
panel.dispose = () => {
|
|
2191
|
+
signal.removeEventListener('abort', cancelPreparation);
|
|
2192
|
+
lifetime.abort();
|
|
2193
|
+
const instance = mounted;
|
|
2194
|
+
mounted = undefined;
|
|
2195
|
+
instance?.dispose();
|
|
2196
|
+
};
|
|
2197
|
+
const source: PartsSource = {
|
|
2198
|
+
async view() {
|
|
2199
|
+
const view = await jobJson<JobPartsInventory>(routes.api('stage-parts'), lifetime.signal);
|
|
2200
|
+
if (current !== prepared || lifetime.signal.aborted ||
|
|
2201
|
+
view.sourceHash !== prepared.display.publication.source.sourceHash)
|
|
2202
|
+
throw new Error('JOB_ACT_SOURCE_STALE');
|
|
2203
|
+
return {...view, readOnly: false};
|
|
2204
|
+
},
|
|
2205
|
+
async image(index) {
|
|
2206
|
+
const item = prepared.parts?.items.find(item => item.index === index);
|
|
2207
|
+
const image = item && prepared.partImages.get(item.name);
|
|
2208
|
+
if (!image) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
2209
|
+
return image;
|
|
2210
|
+
},
|
|
2211
|
+
async page(index) {
|
|
2212
|
+
const page = prepared.partPages?.get(index);
|
|
2213
|
+
if (!page) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
2214
|
+
return page;
|
|
2215
|
+
},
|
|
2216
|
+
painting: () => painting?.element instanceof HTMLImageElement ? Promise.resolve(painting.element) : null,
|
|
2217
|
+
async crop(issue) {
|
|
2218
|
+
if (current !== prepared || lifetime.signal.aborted) throw new Error('JOB_ACT_SOURCE_STALE');
|
|
2219
|
+
const response = await fetch(routes.api('stage-parts/comment'), {
|
|
2220
|
+
method: 'POST', signal: lifetime.signal, headers: access.headers({'Content-Type': 'application/json'}),
|
|
2221
|
+
body: JSON.stringify(issue),
|
|
2222
|
+
});
|
|
2223
|
+
const value = await response.json();
|
|
2224
|
+
if (!response.ok) throw new Error(value?.error?.code ?? 'PARTS_COMMENT_UNAVAILABLE');
|
|
2225
|
+
if (current !== prepared || lifetime.signal.aborted) throw new Error('JOB_ACT_SOURCE_STALE');
|
|
2226
|
+
return parsePartsIssue(value.comment);
|
|
2227
|
+
},
|
|
2228
|
+
};
|
|
2229
|
+
const host: PartsHost = {
|
|
2230
|
+
initial: () => panel.issues,
|
|
2231
|
+
changed(issues) {
|
|
2232
|
+
if (current !== prepared || lifetime.signal.aborted) return;
|
|
2233
|
+
panel.issues = issues;
|
|
2234
|
+
for (const [askId, entry] of forms) {
|
|
2235
|
+
if (window.state().pending.find(ask => ask.askId === askId)?.subject.kind !== 'parts-verdict') continue;
|
|
2236
|
+
entry.dirty = true;
|
|
2237
|
+
entry.submissionId = crypto.randomUUID();
|
|
2238
|
+
}
|
|
2239
|
+
saveDraft(); window.refresh();
|
|
2240
|
+
},
|
|
2241
|
+
register(output) {
|
|
2242
|
+
if (current !== prepared || lifetime.signal.aborted) return;
|
|
2243
|
+
if (output.kind === 'parts-verdict' && panel.composition.side?.includes('parts.issues')) panel.output = output;
|
|
2244
|
+
window.refresh();
|
|
2245
|
+
},
|
|
2246
|
+
locked() {
|
|
2247
|
+
if (lifetime.signal.aborted || panel.legacy || window.state().closed) return 'sent';
|
|
2248
|
+
if (current !== prepared || [...forms.values()].some(entry => entry.submitting)) return 'sent';
|
|
2249
|
+
const phase = jobPartsReviewState(window.state().pending, prepared.display.publication.publicationId);
|
|
2250
|
+
return phase === 'reviewing' ? 'open' : phase;
|
|
2251
|
+
},
|
|
2252
|
+
};
|
|
2253
|
+
try {
|
|
2254
|
+
mounted = mountPartsWorkspace(panel.slots, source, host, {defaultView: 'assembled'});
|
|
2255
|
+
if (panel.legacy) {
|
|
2256
|
+
const legacy = node('p', 'JOB_PARTS_LEGACY_DRAFT');
|
|
2257
|
+
const rows = node('pre');
|
|
2258
|
+
rows.className = 'job-source';
|
|
2259
|
+
rows.textContent = JSON.stringify(panel.legacy, null, 2);
|
|
2260
|
+
panel.slots.side.append(legacy, rows);
|
|
2261
|
+
}
|
|
2262
|
+
await Promise.race([mounted.ready, preparationCancelled]);
|
|
2263
|
+
panel.slots.toolbar.querySelector<HTMLButtonElement>('#fit')?.click();
|
|
2264
|
+
await new Promise<void>((resolve, reject) => {
|
|
2265
|
+
let frame = 0;
|
|
2266
|
+
const cancelled = () => {
|
|
2267
|
+
signal.removeEventListener('abort', cancelled);
|
|
2268
|
+
cancelAnimationFrame(frame);
|
|
2269
|
+
reject(new Error('JOB_PRELOAD_CANCELLED'));
|
|
2270
|
+
};
|
|
2271
|
+
signal.addEventListener('abort', cancelled, {once: true});
|
|
2272
|
+
frame = requestAnimationFrame(() => {frame = requestAnimationFrame(() => {
|
|
2273
|
+
signal.removeEventListener('abort', cancelled);
|
|
2274
|
+
resolve();
|
|
2275
|
+
});});
|
|
2276
|
+
if (signal.aborted) cancelled();
|
|
2277
|
+
});
|
|
2278
|
+
if (signal.aborted) throw new Error('JOB_PRELOAD_CANCELLED');
|
|
2279
|
+
} finally {
|
|
2280
|
+
signal.removeEventListener('abort', cancelPreparation);
|
|
1830
2281
|
}
|
|
1831
2282
|
}
|
|
1832
2283
|
function build(prepared: JobPreparedInspection): HTMLElement {
|
|
@@ -1845,6 +2296,51 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1845
2296
|
sourceBinding.textContent = JSON.stringify(prepared.display.publication.source, null, 2);
|
|
1846
2297
|
binding.append(bindingTitle, sourceBinding);
|
|
1847
2298
|
sidebar.append(binding);
|
|
2299
|
+
if (prepared.metadata.capabilities.preRig) {
|
|
2300
|
+
const {composition, invalid} = resolveJobPanels(prepared.metadata, prepared.display.publication.source);
|
|
2301
|
+
root.dataset.jobPartsWorkspace = '';
|
|
2302
|
+
const stage = node('section');
|
|
2303
|
+
stage.className = 'job-stage';
|
|
2304
|
+
const toolbar = node('div');
|
|
2305
|
+
toolbar.className = 'viewbar pv-toolbar';
|
|
2306
|
+
const canvas = node('div');
|
|
2307
|
+
canvas.className = 'job-parts-stage';
|
|
2308
|
+
const left = node('div');
|
|
2309
|
+
const side = node('div');
|
|
2310
|
+
sidebar.prepend(left);
|
|
2311
|
+
const formsHost = node('section');
|
|
2312
|
+
formsHost.className = 'job-forms';
|
|
2313
|
+
formsHost.dataset.jobForms = '';
|
|
2314
|
+
formsHost.append(side);
|
|
2315
|
+
const slots = {left, stage: canvas, toolbar, side};
|
|
2316
|
+
stage.append(toolbar, canvas);
|
|
2317
|
+
root.append(sidebar, stage, formsHost);
|
|
2318
|
+
const components: Record<PanelComponent, PanelSlot | null> = {
|
|
2319
|
+
'parts.list': 'left', 'parts.canvas': 'stage', 'parts.layers': 'toolbar', 'parts.issues': 'side',
|
|
2320
|
+
'act.submit': 'side', 'interview.picks': null, 'plan.body': null, 'rig.playback': null,
|
|
2321
|
+
'scene.composite': null, 'images.set': null,
|
|
2322
|
+
};
|
|
2323
|
+
for (const slot of ['left', 'stage', 'toolbar', 'side'] as const) {
|
|
2324
|
+
const entries = composition[slot] ?? [];
|
|
2325
|
+
slots[slot].hidden = !entries.some(id => components[id] === slot && id !== 'act.submit');
|
|
2326
|
+
for (const id of entries) {
|
|
2327
|
+
if (components[id] === slot) continue;
|
|
2328
|
+
const refusal = node('p');
|
|
2329
|
+
refusal.textContent = t(Object.hasOwn(components, id) ? 'JOB_PANEL_UNAVAILABLE' : 'JOB_PANEL_UNKNOWN', [id]);
|
|
2330
|
+
slots[slot].after(refusal);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
if (invalid) formsHost.prepend(node('p', 'JOB_PANELS_INVALID'));
|
|
2334
|
+
const history = node('div');
|
|
2335
|
+
history.className = 'job-history';
|
|
2336
|
+
history.dataset.jobHistory = '';
|
|
2337
|
+
formsHost.append(history);
|
|
2338
|
+
const panel = {slots, composition, issues: [] as PartsIssue[], legacy: null, dispose: undefined as (() => void) | undefined};
|
|
2339
|
+
partsPanels.set(prepared, panel);
|
|
2340
|
+
const dispose = prepared.dispose;
|
|
2341
|
+
prepared.dispose = () => {try {panel.dispose?.();} finally {dispose();}};
|
|
2342
|
+
return root;
|
|
2343
|
+
}
|
|
1848
2344
|
const parts = node('select');
|
|
1849
2345
|
parts.id = 'job-part';
|
|
1850
2346
|
parts.disabled = !prepared.metadata.manifest?.model || prepared.metadata.feedbackCatalog.slots === null;
|
|
@@ -1881,20 +2377,59 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1881
2377
|
if (current === prepared && next) void referenceSelection.select(next);
|
|
1882
2378
|
};
|
|
1883
2379
|
sidebar.append(inputLabel('Reference', referenceSelect));
|
|
1884
|
-
const images = node('div');
|
|
1885
|
-
images.className = 'job-part-images';
|
|
1886
|
-
for (const [name, image] of prepared.partImages) {
|
|
1887
|
-
const label = node('label');
|
|
1888
|
-
const title = node('span');
|
|
1889
|
-
title.textContent = name;
|
|
1890
|
-
label.append(title, image);
|
|
1891
|
-
images.append(label);
|
|
1892
|
-
}
|
|
1893
|
-
sidebar.append(images);
|
|
1894
2380
|
const stage = node('section');
|
|
1895
2381
|
stage.className = 'job-stage';
|
|
1896
2382
|
const controls = node('div');
|
|
1897
2383
|
controls.className = 'viewbar';
|
|
2384
|
+
const layerSet = node('fieldset');
|
|
2385
|
+
layerSet.id = 'layer-controls';
|
|
2386
|
+
layerSet.className = 'layer-toggles';
|
|
2387
|
+
layerSet.hidden = true;
|
|
2388
|
+
const legend = node('legend', 'Rig layers');
|
|
2389
|
+
legend.className = 'sr-only';
|
|
2390
|
+
layerSet.append(legend);
|
|
2391
|
+
for (const item of layerShortcuts) {
|
|
2392
|
+
const label = node('label');
|
|
2393
|
+
label.className = 'layer-toggle';
|
|
2394
|
+
const box = node('input');
|
|
2395
|
+
box.id = item.id;
|
|
2396
|
+
box.type = 'checkbox';
|
|
2397
|
+
box.setAttribute('aria-keyshortcuts', item.key.toUpperCase());
|
|
2398
|
+
const keyName = item.id === 'layer-images' ? 'images' : item.id === 'layer-mesh' ? 'mesh' : 'bones';
|
|
2399
|
+
box.checked = layers[keyName];
|
|
2400
|
+
box.disabled = true;
|
|
2401
|
+
box.onchange = () => {
|
|
2402
|
+
layers[keyName] = box.checked;
|
|
2403
|
+
if (current === prepared) {
|
|
2404
|
+
redrawOverlay(true);
|
|
2405
|
+
rememberDraw();
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
const kbd = node('kbd');
|
|
2409
|
+
kbd.setAttribute('aria-hidden', 'true');
|
|
2410
|
+
kbd.textContent = item.key.toUpperCase();
|
|
2411
|
+
label.append(box, node('span', item.label), kbd);
|
|
2412
|
+
layerSet.append(label);
|
|
2413
|
+
}
|
|
2414
|
+
describeLayerToggles({ getElementById: id => layerSet.querySelector('#' + id) }, t('No rig supplied'));
|
|
2415
|
+
for (const label of layerSet.querySelectorAll<HTMLElement>('.layer-toggle')) label.title = i18n.tr(label.title);
|
|
2416
|
+
const sentinelKeys = Object.keys(SENTINELS);
|
|
2417
|
+
const bgSelect = selectValues(['', ...sentinelKeys], ['Rig', ...sentinelKeys.map(k => k[0]!.toUpperCase() + k.slice(1))]);
|
|
2418
|
+
bgSelect.id = 'job-background';
|
|
2419
|
+
bgSelect.value = stageBackground;
|
|
2420
|
+
bgSelect.disabled = true;
|
|
2421
|
+
bgSelect.onchange = () => {
|
|
2422
|
+
stageBackground = Object.hasOwn(SENTINELS, bgSelect.value) ? bgSelect.value : '';
|
|
2423
|
+
bgSelect.value = stageBackground;
|
|
2424
|
+
if (current === prepared) {
|
|
2425
|
+
redrawOverlay(false);
|
|
2426
|
+
rememberDraw();
|
|
2427
|
+
}
|
|
2428
|
+
};
|
|
2429
|
+
const bgField = inputLabel('Background', bgSelect);
|
|
2430
|
+
bgField.id = 'job-background-field';
|
|
2431
|
+
bgField.hidden = true;
|
|
2432
|
+
controls.append(layerSet, bgField);
|
|
1898
2433
|
for (const [id, key] of [['zoom-in', 'job.zoomIn'], ['zoom-out', 'job.zoomOut'], ['fit', 'Fit']]) {
|
|
1899
2434
|
const button = node('button', key);
|
|
1900
2435
|
button.id = id!;
|
|
@@ -1911,7 +2446,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1911
2446
|
const pair = node('div');
|
|
1912
2447
|
pair.id = 'stage-layout';
|
|
1913
2448
|
mountViewportPair(pair);
|
|
1914
|
-
for (const id of ['
|
|
2449
|
+
for (const id of ['idle-handles', 'rig-fields-stage'])
|
|
1915
2450
|
pair.querySelector('#' + id)?.remove();
|
|
1916
2451
|
for (const [id, key] of [['reference-label', 'Reference'], ['rig-label', 'Generated rig · read only'],
|
|
1917
2452
|
['reference-empty', 'No reference supplied.'], ['rig-empty', 'No compiled model supplied.']]) {
|
|
@@ -1923,7 +2458,20 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1923
2458
|
}
|
|
1924
2459
|
pair.querySelector('#reference-pane')?.setAttribute('aria-label', t('Reference'));
|
|
1925
2460
|
pair.querySelector('#rig-pane')?.setAttribute('aria-label', t('Rig'));
|
|
2461
|
+
const rigViewport = pair.querySelector<HTMLElement>('#rig-viewport');
|
|
2462
|
+
if (rigViewport) {
|
|
2463
|
+
rigViewport.setAttribute('tabindex', '-1');
|
|
2464
|
+
rigViewport.addEventListener('pointerdown', () => rigViewport.focus?.());
|
|
2465
|
+
}
|
|
1926
2466
|
pair.querySelector('#rig-root')!.replaceWith(prepared.rigRoot);
|
|
2467
|
+
const overlayCanvas = pair.querySelector<HTMLCanvasElement>('#rig-overlay');
|
|
2468
|
+
if (overlayCanvas) {
|
|
2469
|
+
overlayCanvas.setAttribute('aria-label', t('Actual rig mesh and bone overlay'));
|
|
2470
|
+
const instance = new RigOverlays({ canvas: overlayCanvas, rigRoot: prepared.rigRoot });
|
|
2471
|
+
overlays.set(prepared, instance);
|
|
2472
|
+
const prevDispose = prepared.dispose;
|
|
2473
|
+
prepared.dispose = () => { try { instance.dispose(); } finally { prevDispose(); } };
|
|
2474
|
+
}
|
|
1927
2475
|
const transport = node('div');
|
|
1928
2476
|
transport.className = 'job-transport';
|
|
1929
2477
|
const clips = node('select');
|
|
@@ -2029,10 +2577,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2029
2577
|
time = value;
|
|
2030
2578
|
pose();
|
|
2031
2579
|
};
|
|
2032
|
-
|
|
2033
|
-
panels.id = 'job-panel';
|
|
2034
|
-
panels.onchange = () => { panel = panels.value; showPanel(); };
|
|
2035
|
-
transport.append(clips, playButton, inputLabel('Repeat', loopInput), inputLabel('job.time', clock), panels);
|
|
2580
|
+
transport.append(clips, playButton, inputLabel('Repeat', loopInput), inputLabel('job.time', clock));
|
|
2036
2581
|
const numeric = node('pre');
|
|
2037
2582
|
numeric.id = 'view-coordinates';
|
|
2038
2583
|
numeric.hidden = true;
|
|
@@ -2050,40 +2595,10 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2050
2595
|
const digestValue = node('code');
|
|
2051
2596
|
digestValue.textContent = source.imageSetDigest;
|
|
2052
2597
|
digest.append(digestLabel, document.createTextNode(' '), digestValue);
|
|
2053
|
-
const gallery =
|
|
2598
|
+
const gallery = imageGallery(source.imageSet.images.map((image, index) => ({...image,
|
|
2599
|
+
element: prepared.imageSetImages?.[index],
|
|
2600
|
+
duplicate: source.duplicateHashes.some(group => group.names.includes(image.name))})));
|
|
2054
2601
|
gallery.dataset.jobImageSet = '';
|
|
2055
|
-
gallery.style.display = 'grid';
|
|
2056
|
-
gallery.style.gridAutoFlow = 'column';
|
|
2057
|
-
gallery.style.gridAutoColumns = 'minmax(180px, 1fr)';
|
|
2058
|
-
gallery.style.gap = '16px';
|
|
2059
|
-
gallery.style.overflow = 'auto';
|
|
2060
|
-
gallery.style.minHeight = '0';
|
|
2061
|
-
gallery.style.flex = '1';
|
|
2062
|
-
for (const [index, image] of source.imageSet.images.entries()) {
|
|
2063
|
-
const element = prepared.imageSetImages?.[index];
|
|
2064
|
-
if (!element) throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
2065
|
-
const figure = node('figure');
|
|
2066
|
-
figure.style.margin = '0';
|
|
2067
|
-
figure.style.minWidth = '0';
|
|
2068
|
-
figure.dataset.imageName = image.name;
|
|
2069
|
-
const name = node('h3');
|
|
2070
|
-
name.textContent = image.name;
|
|
2071
|
-
name.style.overflowWrap = 'anywhere';
|
|
2072
|
-
const role = node('p', 'job.imageRole.' + image.role);
|
|
2073
|
-
const hash = node('code');
|
|
2074
|
-
hash.className = 'job-source';
|
|
2075
|
-
hash.style.display = 'block';
|
|
2076
|
-
hash.style.overflowWrap = 'anywhere';
|
|
2077
|
-
hash.textContent = image.sha256;
|
|
2078
|
-
element.style.width = '100%';
|
|
2079
|
-
element.style.height = 'auto';
|
|
2080
|
-
element.style.maxHeight = '70vh';
|
|
2081
|
-
element.style.objectFit = 'contain';
|
|
2082
|
-
figure.append(name, role, element, hash);
|
|
2083
|
-
if (source.duplicateHashes.some(group => group.names.includes(image.name)))
|
|
2084
|
-
figure.append(node('p', 'job.identicalImages'));
|
|
2085
|
-
gallery.append(figure);
|
|
2086
|
-
}
|
|
2087
2602
|
stage.prepend(heading, digest, gallery);
|
|
2088
2603
|
controls.hidden = pair.hidden = transport.hidden = true;
|
|
2089
2604
|
controls.style.display = pair.style.display = transport.style.display = 'none';
|
|
@@ -2177,6 +2692,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2177
2692
|
drawn.delete(current);
|
|
2178
2693
|
current.rigPresentation = undefined;
|
|
2179
2694
|
current.inspection.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
2695
|
+
redrawOverlay(true);
|
|
2180
2696
|
rememberDraw();
|
|
2181
2697
|
setText('job-part-observation', selectedPart ? JSON.stringify(current.inspection.observation(), null, 2) : '');
|
|
2182
2698
|
viewport.renderCameraControls();
|
|
@@ -2188,15 +2704,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2188
2704
|
}
|
|
2189
2705
|
function showPanel(): void {
|
|
2190
2706
|
const direction = workspace.querySelector<HTMLElement>('[data-job-direction]');
|
|
2191
|
-
if (direction)
|
|
2192
|
-
direction.hidden = panel !== '4';
|
|
2193
|
-
for (const [askId, entry] of forms) {
|
|
2194
|
-
const ask = window.state().pending.find(item => item.askId === askId);
|
|
2195
|
-
const currentSubject = current?.display.publication.source.subject;
|
|
2196
|
-
entry.form.hidden = currentSubject !== 'image-set' &&
|
|
2197
|
-
currentSubject !== 'option-set' && currentSubject !== 'plan' &&
|
|
2198
|
-
panel === '2' && ask?.subject.kind !== 'interview-picks';
|
|
2199
|
-
}
|
|
2707
|
+
if (direction) direction.hidden = !current?.metadata.direction;
|
|
2200
2708
|
saveWindowState();
|
|
2201
2709
|
}
|
|
2202
2710
|
function pose(seekReference = true): void {
|
|
@@ -2268,7 +2776,9 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2268
2776
|
const inspection = await prepareJobInspection(display, signal);
|
|
2269
2777
|
try {
|
|
2270
2778
|
const element = build(inspection);
|
|
2271
|
-
const
|
|
2779
|
+
const asks = window.state().pending.filter(ask => !(partsPanels.has(inspection) &&
|
|
2780
|
+
ask.subject.kind === 'signoff' && ask.subject.stage === 'parts-review'));
|
|
2781
|
+
const preparedForms = prepareJobForms(display, asks, ask => formFor(ask, inspection));
|
|
2272
2782
|
return Object.assign(inspection, { element, forms: preparedForms });
|
|
2273
2783
|
}
|
|
2274
2784
|
catch (error) {
|
|
@@ -2279,7 +2789,9 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2279
2789
|
captureDraft() { saveDraft(); const dirty = [...forms].filter(([, item]) => item.dirty); return dirty.length ? dirty.map(([askId, item]) => ({ askId, value: item.read() })) : null; },
|
|
2280
2790
|
commit(prepared, display) {
|
|
2281
2791
|
// Pending asks can arrive while assets load. Finish their forms before the visible replacement.
|
|
2282
|
-
const
|
|
2792
|
+
const asks = window.state().pending.filter(ask => !(partsPanels.has(prepared) &&
|
|
2793
|
+
ask.subject.kind === 'signoff' && ask.subject.stage === 'parts-review'));
|
|
2794
|
+
const nextForms = prepareJobForms(display, asks,
|
|
2283
2795
|
ask => prepared.forms.get(ask.askId) ?? formFor(ask, prepared));
|
|
2284
2796
|
const root = prepared.element;
|
|
2285
2797
|
const formHost = root.querySelector<HTMLElement>('[data-job-forms]');
|
|
@@ -2292,6 +2804,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2292
2804
|
const previousForms = new Map(forms);
|
|
2293
2805
|
const restoringCamera = Boolean(previous || restoredCamera);
|
|
2294
2806
|
const navigation = { animation, time, loop, selectedPart, partMode, selectedReference, panel,
|
|
2807
|
+
layers: { images: layers.images, mesh: layers.mesh, bones: layers.bones }, stageBackground,
|
|
2295
2808
|
partIdentity: previous ? (previous.inspection?.value() ?? null) : restoredPartIdentity,
|
|
2296
2809
|
camera: structuredClone(viewportState) };
|
|
2297
2810
|
compatibilityNotice = Boolean(!previous &&
|
|
@@ -2323,12 +2836,14 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2323
2836
|
partMode = navigation.partMode;
|
|
2324
2837
|
selectedReference = navigation.selectedReference;
|
|
2325
2838
|
panel = navigation.panel;
|
|
2839
|
+
Object.assign(layers, navigation.layers);
|
|
2840
|
+
stageBackground = navigation.stageBackground;
|
|
2326
2841
|
forms.clear();
|
|
2327
2842
|
for (const [id, item] of previousForms)
|
|
2328
2843
|
forms.set(id, item);
|
|
2329
2844
|
workspace.replaceChildren(...(previousElement ? [previousElement] : []));
|
|
2330
2845
|
Object.assign(viewportState, navigation.camera);
|
|
2331
|
-
if (current) {
|
|
2846
|
+
if (current && !partsPanels.has(current)) {
|
|
2332
2847
|
el<HTMLSelectElement>('job-reference').value = selectedReference;
|
|
2333
2848
|
syncTransportControls();
|
|
2334
2849
|
viewport.fitCamera();
|
|
@@ -2340,12 +2855,27 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2340
2855
|
forms.clear();
|
|
2341
2856
|
for (const [id, entry] of nextForms) forms.set(id, entry);
|
|
2342
2857
|
workspace.replaceChildren(root);
|
|
2858
|
+
if (partsPanels.has(prepared)) {
|
|
2859
|
+
updateForms(window.state());
|
|
2860
|
+
return {rollback, finalize() {
|
|
2861
|
+
unbindNavigation?.(); resize?.disconnect();
|
|
2862
|
+
unbindNavigation = null; resize = null;
|
|
2863
|
+
previous?.dispose();
|
|
2864
|
+
title.textContent = display.publication.source.package?.id ?? display.publication.label;
|
|
2865
|
+
}};
|
|
2866
|
+
}
|
|
2343
2867
|
el<HTMLSelectElement>('job-part').value = selectedPart;
|
|
2344
2868
|
el<HTMLInputElement>('job-solo').checked = partMode === 'solo';
|
|
2345
2869
|
el<HTMLSelectElement>('job-reference').value = selectedReference;
|
|
2346
2870
|
el<HTMLSelectElement>('job-animation').value = animation;
|
|
2347
2871
|
el<HTMLInputElement>('job-loop').checked = loop;
|
|
2348
|
-
|
|
2872
|
+
layers.images = true;
|
|
2873
|
+
layers.mesh = false;
|
|
2874
|
+
layers.bones = false;
|
|
2875
|
+
stageBackground = '';
|
|
2876
|
+
for (const [id, key] of [['layer-images', 'images'], ['layer-mesh', 'mesh'], ['layer-bones', 'bones']] as const) {
|
|
2877
|
+
el<HTMLInputElement>(id).checked = layers[key];
|
|
2878
|
+
}
|
|
2349
2879
|
el('rig-empty').hidden = !!prepared.player;
|
|
2350
2880
|
Object.assign(viewportState, navigation.camera, { cameraRestoring: restoringCamera });
|
|
2351
2881
|
showReference();
|
|
@@ -2391,6 +2921,10 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2391
2921
|
}
|
|
2392
2922
|
},
|
|
2393
2923
|
async painted(prepared, signal) {
|
|
2924
|
+
if (partsPanels.has(prepared)) {
|
|
2925
|
+
await mountJobParts(prepared, signal);
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2394
2928
|
for (const image of prepared.imageSetImages ?? []) {
|
|
2395
2929
|
if (!image.isConnected || !image.complete || !image.naturalWidth || !image.naturalHeight)
|
|
2396
2930
|
throw new Error('JOB_VISUAL_UNAVAILABLE');
|
|
@@ -2414,7 +2948,15 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2414
2948
|
notice.textContent = t('job.closed');
|
|
2415
2949
|
else if (state.preparing)
|
|
2416
2950
|
notice.textContent = t('job.preparing');
|
|
2951
|
+
else if (state.displayed && current && partsPanels.has(current)) {
|
|
2952
|
+
const panel = partsPanels.get(current)!;
|
|
2953
|
+
const sending = [...forms.values()].some(entry => entry.submitting);
|
|
2954
|
+
const phase = sending ? 'sending' : jobPartsReviewState(state.pending, state.displayed.publication.publicationId);
|
|
2955
|
+
notice.dataset.jobPartsState = phase;
|
|
2956
|
+
notice.textContent = state.displayed.publication.label + ' · ' + t('job.parts.' + phase, [panel.issues.length]);
|
|
2957
|
+
}
|
|
2417
2958
|
else if (state.displayed) {
|
|
2959
|
+
delete notice.dataset.jobPartsState;
|
|
2418
2960
|
notice.textContent = state.previousLabel
|
|
2419
2961
|
? t('job.updated', [state.previousLabel, state.displayed.publication.label]) : state.displayed.publication.label;
|
|
2420
2962
|
if (compatibilityNotice)
|
|
@@ -2454,12 +2996,17 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2454
2996
|
if (state.receipt && !state.preparing) events?.displayed();
|
|
2455
2997
|
},
|
|
2456
2998
|
} });
|
|
2999
|
+
const unbindLayerShortcuts = bindLayerShortcuts(document);
|
|
2457
3000
|
const localize = i18n.onLanguageChange(() => {
|
|
2458
3001
|
for (const element of host.querySelectorAll<HTMLElement>('[data-job-text]'))
|
|
2459
3002
|
element.textContent = t(element.dataset.jobText!);
|
|
2460
3003
|
languages.setAttribute('aria-label', t('interview.language'));
|
|
2461
|
-
if (current)
|
|
3004
|
+
if (current && !partsPanels.has(current)) {
|
|
3005
|
+
workspace.querySelector('#rig-overlay')?.setAttribute('aria-label', t('Actual rig mesh and bone overlay'));
|
|
3006
|
+
describeLayerToggles({ getElementById: id => workspace.querySelector('#' + id) }, t('No rig supplied'));
|
|
3007
|
+
for (const label of workspace.querySelectorAll<HTMLElement>('.layer-toggle')) label.title = i18n.tr(label.title);
|
|
2462
3008
|
viewport.renderCameraControls();
|
|
3009
|
+
}
|
|
2463
3010
|
window.refresh();
|
|
2464
3011
|
});
|
|
2465
3012
|
const hubVisibility = (event: MessageEvent) => {
|
|
@@ -2487,7 +3034,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2487
3034
|
resolution?.removeEventListener('change', resolutionChanged);
|
|
2488
3035
|
resolution = globalThis.matchMedia(`(resolution:${globalThis.devicePixelRatio || 1}dppx)`);
|
|
2489
3036
|
resolution.addEventListener('change', resolutionChanged);
|
|
2490
|
-
if (current) {
|
|
3037
|
+
if (current && !partsPanels.has(current)) {
|
|
2491
3038
|
drawn.delete(current);
|
|
2492
3039
|
current.rigPresentation = undefined;
|
|
2493
3040
|
viewport.fitCamera();
|
|
@@ -2504,6 +3051,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2504
3051
|
abort.abort();
|
|
2505
3052
|
window.stop();
|
|
2506
3053
|
localize();
|
|
3054
|
+
unbindLayerShortcuts();
|
|
2507
3055
|
unbindNavigation?.();
|
|
2508
3056
|
resize?.disconnect();
|
|
2509
3057
|
current?.dispose();
|