@morshoto/framekit 0.1.14 → 0.1.17
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/dist-package/adapters/final-cut/typescript/src/background-materialization.js +28 -0
- package/dist-package/adapters/final-cut/typescript/src/canonical.js +144 -35
- package/dist-package/adapters/final-cut/typescript/src/connection.js +8 -5
- package/dist-package/adapters/final-cut/typescript/src/disposable-native.js +36 -7
- package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +21 -7
- package/dist-package/adapters/final-cut/typescript/src/index.js +2 -0
- package/dist-package/adapters/final-cut/typescript/src/live.js +56 -1
- package/dist-package/adapters/final-cut/typescript/src/native.js +311 -20
- package/dist-package/adapters/final-cut/typescript/src/pasteboard-snapshot.js +312 -0
- package/dist-package/adapters/final-cut/typescript/src/publisher.js +68 -8
- package/dist-package/adapters/final-cut/typescript/src/sqlite-wal-observation.js +263 -0
- package/dist-package/adapters/final-cut/typescript/src/timeline-ir-fcpxml.js +179 -25
- package/dist-package/adapters/headless/typescript/src/ffmpeg-media-probe.js +62 -0
- package/dist-package/adapters/headless/typescript/src/ffmpeg-renderer.js +551 -0
- package/dist-package/adapters/headless/typescript/src/ffmpeg-verifier.js +181 -0
- package/dist-package/adapters/headless/typescript/src/index.js +3 -0
- package/dist-package/apps/mcp-server/src/headless-projects.js +370 -0
- package/dist-package/apps/mcp-server/src/headless-sessions.js +3 -0
- package/dist-package/apps/mcp-server/src/main.js +28 -4
- package/dist-package/apps/mcp-server/src/materialization-jobs.js +233 -4
- package/dist-package/apps/mcp-server/src/readback-policy.js +26 -0
- package/dist-package/apps/mcp-server/src/routing.js +134 -5
- package/dist-package/apps/mcp-server/src/server.js +311 -34
- package/dist-package/packages/runtime/src/application/local-media.js +157 -0
- package/dist-package/packages/runtime/src/application/media-analysis-service.js +347 -27
- package/dist-package/packages/runtime/src/application/project-store.js +234 -0
- package/dist-package/packages/runtime/src/application/project-transactions.js +227 -0
- package/dist-package/packages/runtime/src/application/semantic-media-index-store.js +86 -0
- package/dist-package/packages/runtime/src/index.js +7 -0
- package/dist-package/packages/runtime/src/planning/rough-cut.js +103 -7
- package/dist-package/packages/runtime/src/render/render-and-verify.js +126 -0
- package/dist-package/packages/runtime/src/render/render-contract.js +146 -0
- package/dist-package/packages/runtime/src/runtime.js +5 -2
- package/dist-package/packages/runtime/src/timeline/editing-session.js +277 -9
- package/dist-package/packages/runtime/src/timeline/fast-observation.js +141 -0
- package/package.json +2 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { normalizeFastTimelineObservation, timelineIrDigest, } from "../../../../packages/runtime/src/index.js";
|
|
3
|
+
import { decodeFinalCutKeyedArchive, } from "./sqlite-experiment.js";
|
|
4
|
+
export const FINAL_CUT_PASTEBOARD_UTI = "com.apple.flexo.proFFPasteboardUTI";
|
|
5
|
+
/**
|
|
6
|
+
* Experimental, non-canonical fallback. Without an explicit headed acquisition
|
|
7
|
+
* port this provider is unavailable; it never turns caller-supplied data into
|
|
8
|
+
* evidence of a live Final Cut read by itself.
|
|
9
|
+
*/
|
|
10
|
+
export class FinalCutPasteboardProvider {
|
|
11
|
+
sourceVersion;
|
|
12
|
+
capture;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.sourceVersion = options.sourceVersion.trim();
|
|
15
|
+
if (!this.sourceVersion)
|
|
16
|
+
throw new Error("FINAL_CUT_PASTEBOARD_PROVENANCE_MISSING: source version is required");
|
|
17
|
+
this.capture = options.capture;
|
|
18
|
+
}
|
|
19
|
+
async observe(request) {
|
|
20
|
+
if (!request.allowInteraction) {
|
|
21
|
+
return blockedCapture(request, "FINAL_CUT_PASTEBOARD_INTERACTION_REQUIRED", "pasteboard capture requires explicit focus, selection, and clipboard side effects");
|
|
22
|
+
}
|
|
23
|
+
if (!this.capture) {
|
|
24
|
+
return blockedCapture(request, "FINAL_CUT_PASTEBOARD_CAPTURE_UNAVAILABLE", "no headed pasteboard acquisition port is configured");
|
|
25
|
+
}
|
|
26
|
+
const captured = await this.capture.capture(request);
|
|
27
|
+
if (captured.status !== "captured")
|
|
28
|
+
return captured;
|
|
29
|
+
if (!captured.payload) {
|
|
30
|
+
return {
|
|
31
|
+
...captured,
|
|
32
|
+
status: "failed",
|
|
33
|
+
error: { code: "FINAL_CUT_PASTEBOARD_PAYLOAD_UNAVAILABLE", message: "capture completed without a decoded pasteboard payload" },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (!sameTarget(captured.target.requested, request.target)
|
|
37
|
+
|| !sameTarget(captured.target.observed, request.target)
|
|
38
|
+
|| captured.target.guarantee !== "requested-and-observed") {
|
|
39
|
+
return {
|
|
40
|
+
...captured,
|
|
41
|
+
status: "failed",
|
|
42
|
+
error: { code: "FINAL_CUT_PASTEBOARD_TARGET_UNVERIFIED", message: "pasteboard payload is not bound to the requested project and sequence" },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return decodeFinalCutPasteboardObservation({
|
|
46
|
+
uti: FINAL_CUT_PASTEBOARD_UTI,
|
|
47
|
+
sourceVersion: this.sourceVersion,
|
|
48
|
+
payload: captured.payload,
|
|
49
|
+
target: request.target,
|
|
50
|
+
sideEffects: captured.sideEffects,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function decodeFinalCutPasteboardArchive(payload, decoder) {
|
|
55
|
+
const bytes = Uint8Array.from(payload);
|
|
56
|
+
const archive = await decodeFinalCutKeyedArchive(bytes, decoder);
|
|
57
|
+
return { payloadDigest: createHash("sha256").update(bytes).digest("hex"), archive };
|
|
58
|
+
}
|
|
59
|
+
export function decodeFinalCutPasteboardObservation(input) {
|
|
60
|
+
if (input.uti !== FINAL_CUT_PASTEBOARD_UTI) {
|
|
61
|
+
throw new Error("FINAL_CUT_PASTEBOARD_UTI_UNSUPPORTED: expected Final Cut timeline pasteboard payload");
|
|
62
|
+
}
|
|
63
|
+
const sourceVersion = input.sourceVersion.trim();
|
|
64
|
+
if (!sourceVersion)
|
|
65
|
+
throw new Error("FINAL_CUT_PASTEBOARD_PROVENANCE_MISSING: source version is required");
|
|
66
|
+
const target = parseTarget(input.target);
|
|
67
|
+
const sideEffects = parseSideEffects(input.sideEffects);
|
|
68
|
+
const payload = record(input.payload);
|
|
69
|
+
const timeline = record(payload.timeline);
|
|
70
|
+
const rawItems = timeline.items;
|
|
71
|
+
const rawAnchoredItems = timeline.anchoredItems;
|
|
72
|
+
if (!Array.isArray(rawItems)) {
|
|
73
|
+
throw new Error("FINAL_CUT_PASTEBOARD_COVERAGE_INCOMPLETE: timeline containers are unavailable");
|
|
74
|
+
}
|
|
75
|
+
const items = rawItems.map((item, index) => parseItem(item, `timeline item ${index + 1}`));
|
|
76
|
+
const anchoredItems = Array.isArray(rawAnchoredItems)
|
|
77
|
+
? rawAnchoredItems.map((item, index) => parseItem(item, `anchored item ${index + 1}`))
|
|
78
|
+
: [];
|
|
79
|
+
const unknownFields = [
|
|
80
|
+
"timeline.containerCompleteness",
|
|
81
|
+
"occurrences.completeness",
|
|
82
|
+
"sourceBindings.completeness",
|
|
83
|
+
"timing.completeness",
|
|
84
|
+
...(Array.isArray(rawAnchoredItems) ? [] : ["anchoredItems"]),
|
|
85
|
+
];
|
|
86
|
+
return {
|
|
87
|
+
provider: "final-cut-pasteboard",
|
|
88
|
+
canonical: false,
|
|
89
|
+
target,
|
|
90
|
+
sideEffects,
|
|
91
|
+
provenance: { uti: FINAL_CUT_PASTEBOARD_UTI, sourceVersion },
|
|
92
|
+
payloadDigest: createHash("sha256").update(stableJson(payload)).digest("hex"),
|
|
93
|
+
items,
|
|
94
|
+
anchoredItems,
|
|
95
|
+
unknownFields,
|
|
96
|
+
coverage: {
|
|
97
|
+
containers: Array.isArray(rawAnchoredItems) ? "complete" : "partial",
|
|
98
|
+
occurrences: "partial",
|
|
99
|
+
sourceBindings: "partial",
|
|
100
|
+
timing: "partial",
|
|
101
|
+
anchoredItems: Array.isArray(rawAnchoredItems) ? "partial" : "unavailable",
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** Convert only the fields the pasteboard decoder actually proved into the runtime envelope. */
|
|
106
|
+
export function normalizeFinalCutPasteboardObservation(input, options) {
|
|
107
|
+
const timescale = integer(options.timescale, "timescale");
|
|
108
|
+
const target = parseTarget(input.target);
|
|
109
|
+
const projectName = requiredText(options.projectName, "projectName");
|
|
110
|
+
const sequenceName = requiredText(options.sequenceName, "sequenceName");
|
|
111
|
+
const resources = new Map();
|
|
112
|
+
const occurrences = input.items.map((item) => {
|
|
113
|
+
if (!resources.has(item.resourceId)) {
|
|
114
|
+
resources.set(item.resourceId, {
|
|
115
|
+
id: item.resourceId,
|
|
116
|
+
name: item.resourceId,
|
|
117
|
+
mediaKind: item.role === "audio" || item.role === "music" ? "audio" : "video",
|
|
118
|
+
binding: { provider: "final-cut", kind: "resource", identity: item.resourceId },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
id: item.occurrenceId,
|
|
123
|
+
name: item.occurrenceId,
|
|
124
|
+
startTime: toRational(item.start, options.timeUnit, timescale, "item start"),
|
|
125
|
+
durationTime: toRational(item.duration, options.timeUnit, timescale, "item duration"),
|
|
126
|
+
track: item.lane,
|
|
127
|
+
...(item.role ? { role: item.role === "music" ? "music" : item.role === "audio" ? "audio" : "video" } : {}),
|
|
128
|
+
mediaId: item.resourceId,
|
|
129
|
+
binding: { provider: "final-cut", kind: "occurrence", identity: item.occurrenceId },
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
const anchoredItems = input.anchoredItems.map((item) => ({
|
|
133
|
+
id: item.occurrenceId,
|
|
134
|
+
name: item.occurrenceId,
|
|
135
|
+
startTime: toRational(item.start, options.timeUnit, timescale, "anchored item start"),
|
|
136
|
+
durationTime: toRational(item.duration, options.timeUnit, timescale, "anchored item duration"),
|
|
137
|
+
track: item.lane,
|
|
138
|
+
...(item.role ? { role: item.role === "music" ? "music" : item.role === "audio" ? "audio" : "video" } : {}),
|
|
139
|
+
mediaId: item.resourceId,
|
|
140
|
+
attachedTo: item.occurrenceId,
|
|
141
|
+
binding: { provider: "final-cut", kind: "occurrence", identity: item.occurrenceId },
|
|
142
|
+
}));
|
|
143
|
+
const allItems = [...input.items, ...input.anchoredItems];
|
|
144
|
+
const computedDuration = allItems.reduce((end, item) => Math.max(end, item.start + item.duration), 0);
|
|
145
|
+
const duration = toRational(options.sequenceDuration ?? computedDuration, options.timeUnit, timescale, "sequence duration");
|
|
146
|
+
const timeline = {
|
|
147
|
+
schemaVersion: 1,
|
|
148
|
+
project: {
|
|
149
|
+
id: target.projectId,
|
|
150
|
+
name: projectName,
|
|
151
|
+
binding: { provider: "final-cut", kind: "project", identity: target.projectId },
|
|
152
|
+
},
|
|
153
|
+
sequence: {
|
|
154
|
+
id: target.sequenceId,
|
|
155
|
+
name: sequenceName,
|
|
156
|
+
durationTime: duration,
|
|
157
|
+
frameDuration: { value: "1", timescale: String(timescale) },
|
|
158
|
+
occurrences: [...occurrences, ...anchoredItems],
|
|
159
|
+
storyElements: [],
|
|
160
|
+
markers: [],
|
|
161
|
+
captions: [],
|
|
162
|
+
binding: { provider: "final-cut", kind: "sequence", identity: target.sequenceId },
|
|
163
|
+
},
|
|
164
|
+
resources: [...resources.values()],
|
|
165
|
+
revision: structuredClone(options.providerRevision),
|
|
166
|
+
};
|
|
167
|
+
const unknowns = [...input.unknownFields];
|
|
168
|
+
for (const [field, state] of Object.entries(input.coverage)) {
|
|
169
|
+
if (state !== "complete")
|
|
170
|
+
unknowns.push(`coverage.${field}`);
|
|
171
|
+
}
|
|
172
|
+
for (const [field, state] of Object.entries(input.sideEffects)) {
|
|
173
|
+
if (state === "unknown")
|
|
174
|
+
unknowns.push(`sideEffects.${field}`);
|
|
175
|
+
}
|
|
176
|
+
unknowns.push("storylineRelationships", "markersCaptions");
|
|
177
|
+
const freshness = Object.values(input.sideEffects).every((state) => typeof state === "boolean")
|
|
178
|
+
? "editor-read"
|
|
179
|
+
: "unknown";
|
|
180
|
+
return normalizeFastTimelineObservation({
|
|
181
|
+
schemaVersion: 1,
|
|
182
|
+
provider: "final-cut",
|
|
183
|
+
sourceType: "pasteboard",
|
|
184
|
+
canonical: false,
|
|
185
|
+
target,
|
|
186
|
+
provenance: {
|
|
187
|
+
framekitRevision: structuredClone(options.framekitRevision),
|
|
188
|
+
artifactDigest: requiredText(options.artifactDigest, "artifactDigest"),
|
|
189
|
+
target,
|
|
190
|
+
},
|
|
191
|
+
observedAt: requiredText(options.observedAt, "observedAt"),
|
|
192
|
+
trust: "normalized",
|
|
193
|
+
freshness,
|
|
194
|
+
revision: structuredClone(options.providerRevision),
|
|
195
|
+
observationDigest: input.payloadDigest,
|
|
196
|
+
timelineDigest: timelineIrDigest(timeline),
|
|
197
|
+
coverage: {
|
|
198
|
+
occurrences: input.coverage.occurrences === "complete" ? "complete" : "partial",
|
|
199
|
+
resources: input.coverage.sourceBindings === "complete" ? "complete" : "partial",
|
|
200
|
+
timing: input.coverage.timing === "complete" ? "complete" : "partial",
|
|
201
|
+
roles: input.coverage.sourceBindings === "complete" ? "complete" : "partial",
|
|
202
|
+
storylineRelationships: "unknown",
|
|
203
|
+
markersCaptions: "unknown",
|
|
204
|
+
},
|
|
205
|
+
unknowns: [...new Set(unknowns)],
|
|
206
|
+
timeline,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function blockedCapture(request, code, message) {
|
|
210
|
+
return {
|
|
211
|
+
status: code === "FINAL_CUT_PASTEBOARD_CAPTURE_UNAVAILABLE" ? "unsupported" : "user-interaction-required",
|
|
212
|
+
route: "headed-pasteboard-copy",
|
|
213
|
+
target: { requested: request.target, guarantee: "unavailable" },
|
|
214
|
+
sideEffects: unknownSideEffects(),
|
|
215
|
+
error: { code, message },
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function parseTarget(value) {
|
|
219
|
+
if (!value || typeof value.projectId !== "string" || !value.projectId.trim()
|
|
220
|
+
|| typeof value.sequenceId !== "string" || !value.sequenceId.trim()) {
|
|
221
|
+
throw new Error("FINAL_CUT_PASTEBOARD_TARGET_UNAVAILABLE: project and sequence identities are required");
|
|
222
|
+
}
|
|
223
|
+
return { projectId: value.projectId.trim(), sequenceId: value.sequenceId.trim() };
|
|
224
|
+
}
|
|
225
|
+
function parseSideEffects(value) {
|
|
226
|
+
const keys = [
|
|
227
|
+
"foregroundActivated",
|
|
228
|
+
"selectionChanged",
|
|
229
|
+
"clipboardChanged",
|
|
230
|
+
"clipboardRestored",
|
|
231
|
+
"focusRestored",
|
|
232
|
+
];
|
|
233
|
+
if (!value || keys.some((key) => !Object.prototype.hasOwnProperty.call(value, key)
|
|
234
|
+
|| (value[key] !== "unknown" && typeof value[key] !== "boolean"))) {
|
|
235
|
+
throw new Error("FINAL_CUT_PASTEBOARD_SIDE_EFFECTS_INVALID: capture side effects must be explicit");
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
foregroundActivated: value.foregroundActivated,
|
|
239
|
+
selectionChanged: value.selectionChanged,
|
|
240
|
+
clipboardChanged: value.clipboardChanged,
|
|
241
|
+
clipboardRestored: value.clipboardRestored,
|
|
242
|
+
focusRestored: value.focusRestored,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function unknownSideEffects() {
|
|
246
|
+
return {
|
|
247
|
+
foregroundActivated: "unknown",
|
|
248
|
+
selectionChanged: "unknown",
|
|
249
|
+
clipboardChanged: "unknown",
|
|
250
|
+
clipboardRestored: "unknown",
|
|
251
|
+
focusRestored: "unknown",
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function sameTarget(left, right) {
|
|
255
|
+
return left?.projectId === right.projectId && left.sequenceId === right.sequenceId;
|
|
256
|
+
}
|
|
257
|
+
function parseItem(value, label) {
|
|
258
|
+
const item = record(value);
|
|
259
|
+
if (typeof item.occurrenceId !== "string" || !item.occurrenceId.trim()
|
|
260
|
+
|| typeof item.resourceId !== "string" || !item.resourceId.trim()) {
|
|
261
|
+
throw new Error(`FINAL_CUT_PASTEBOARD_COVERAGE_INCOMPLETE: ${label} lacks stable identities`);
|
|
262
|
+
}
|
|
263
|
+
for (const key of ["start", "duration", "lane"]) {
|
|
264
|
+
if (typeof item[key] !== "number" || !Number.isFinite(item[key])) {
|
|
265
|
+
throw new Error(`FINAL_CUT_PASTEBOARD_COVERAGE_INCOMPLETE: ${label} lacks finite ${key}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (item.start < 0 || item.duration <= 0 || item.lane < 0) {
|
|
269
|
+
throw new Error(`FINAL_CUT_PASTEBOARD_COVERAGE_INCOMPLETE: ${label} has invalid timeline coordinates`);
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
occurrenceId: item.occurrenceId,
|
|
273
|
+
resourceId: item.resourceId,
|
|
274
|
+
start: item.start,
|
|
275
|
+
duration: item.duration,
|
|
276
|
+
lane: item.lane,
|
|
277
|
+
...(typeof item.role === "string" && item.role.trim() ? { role: item.role } : {}),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function record(value) {
|
|
281
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
282
|
+
return {};
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
function stableJson(value) {
|
|
286
|
+
if (Array.isArray(value))
|
|
287
|
+
return `[${value.map(stableJson).join(",")}]`;
|
|
288
|
+
if (value && typeof value === "object") {
|
|
289
|
+
return `{${Object.entries(value)
|
|
290
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
291
|
+
.map(([key, entry]) => `${JSON.stringify(key)}:${stableJson(entry)}`).join(",")}}`;
|
|
292
|
+
}
|
|
293
|
+
return JSON.stringify(value);
|
|
294
|
+
}
|
|
295
|
+
function toRational(value, unit, timescale, label) {
|
|
296
|
+
if (!Number.isFinite(value) || value < 0)
|
|
297
|
+
throw new Error(`FINAL_CUT_PASTEBOARD_TIMING_INVALID: ${label} must be non-negative and finite`);
|
|
298
|
+
const frames = unit === "frames" ? value : value * timescale;
|
|
299
|
+
if (!Number.isSafeInteger(frames))
|
|
300
|
+
throw new Error(`FINAL_CUT_PASTEBOARD_TIMING_INVALID: ${label} is not exactly representable at ${timescale} fps`);
|
|
301
|
+
return { value: String(frames), timescale: String(timescale) };
|
|
302
|
+
}
|
|
303
|
+
function integer(value, name) {
|
|
304
|
+
if (!Number.isSafeInteger(value) || value <= 0)
|
|
305
|
+
throw new Error(`FINAL_CUT_PASTEBOARD_INPUT_INVALID: ${name} must be a positive integer`);
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
function requiredText(value, name) {
|
|
309
|
+
if (typeof value !== "string" || !value.trim())
|
|
310
|
+
throw new Error(`FINAL_CUT_PASTEBOARD_INPUT_INVALID: ${name} is required`);
|
|
311
|
+
return value.trim();
|
|
312
|
+
}
|
|
@@ -12,6 +12,9 @@ export class FinalCutProjectPublisher {
|
|
|
12
12
|
executor;
|
|
13
13
|
liveState;
|
|
14
14
|
targetBinding;
|
|
15
|
+
documentDelivery;
|
|
16
|
+
targetLibraryUid;
|
|
17
|
+
allowHeadedFallback;
|
|
15
18
|
verificationTimeoutMs;
|
|
16
19
|
pollIntervalMs;
|
|
17
20
|
publishJobs = new Map();
|
|
@@ -22,12 +25,18 @@ export class FinalCutProjectPublisher {
|
|
|
22
25
|
this.executor = options.executor ?? runAppleScript;
|
|
23
26
|
this.liveState = options.liveState;
|
|
24
27
|
this.targetBinding = options.targetBinding;
|
|
28
|
+
this.documentDelivery = options.documentDelivery;
|
|
29
|
+
this.targetLibraryUid = options.targetLibraryUid;
|
|
30
|
+
this.allowHeadedFallback = options.allowHeadedFallback ?? false;
|
|
25
31
|
this.verificationTimeoutMs = Math.max(0, options.verificationTimeoutMs ?? 15_000);
|
|
26
32
|
this.pollIntervalMs = Math.max(0, options.pollIntervalMs ?? options.waitMs ?? 100);
|
|
27
33
|
}
|
|
28
34
|
isAvailable() {
|
|
29
35
|
return this.enabled;
|
|
30
36
|
}
|
|
37
|
+
executionMode() {
|
|
38
|
+
return this.documentDelivery ? "background-capable" : "headed-only";
|
|
39
|
+
}
|
|
31
40
|
async preparePublish(request) {
|
|
32
41
|
const { identity } = await this.readValidatedSource(request);
|
|
33
42
|
const job = {
|
|
@@ -35,7 +44,7 @@ export class FinalCutProjectPublisher {
|
|
|
35
44
|
state: "awaiting-confirmation",
|
|
36
45
|
nextAction: "confirm",
|
|
37
46
|
retryable: false,
|
|
38
|
-
executionMode: "headed-only",
|
|
47
|
+
executionMode: this.documentDelivery ? "background-capable" : "headed-only",
|
|
39
48
|
sourceTransactionId: request.sourceTransactionId,
|
|
40
49
|
sourcePath: this.sourcePath,
|
|
41
50
|
sourceTarget: { kind: "artifact", artifactPath: this.sourcePath },
|
|
@@ -44,9 +53,11 @@ export class FinalCutProjectPublisher {
|
|
|
44
53
|
sequenceName: identity.sequenceName,
|
|
45
54
|
confirmationRequired: true,
|
|
46
55
|
handoff: {
|
|
47
|
-
mode: "headed-only",
|
|
48
|
-
backgroundSupported:
|
|
49
|
-
reason:
|
|
56
|
+
mode: this.documentDelivery ? "background-document-open" : "headed-only",
|
|
57
|
+
backgroundSupported: Boolean(this.documentDelivery),
|
|
58
|
+
reason: this.documentDelivery
|
|
59
|
+
? "Uses the native FCPXML document-open bridge with activates=false; Final Cut may still return an explicit user-interaction-required boundary when target selection cannot be guaranteed."
|
|
60
|
+
: "Final Cut has no supported non-UI project publishing contract; use the explicit headed handoff and verify the created target.",
|
|
50
61
|
},
|
|
51
62
|
};
|
|
52
63
|
this.publishJobs.set(job.jobId, job);
|
|
@@ -176,10 +187,58 @@ export class FinalCutProjectPublisher {
|
|
|
176
187
|
if (runtime)
|
|
177
188
|
runtime.importedPath = importedPath;
|
|
178
189
|
await writeFile(importedPath, source, "utf8");
|
|
190
|
+
let delivery;
|
|
179
191
|
try {
|
|
180
|
-
|
|
192
|
+
if (this.documentDelivery) {
|
|
193
|
+
const dispatched = await this.documentDelivery.deliverFcpxml({
|
|
194
|
+
artifactPath: importedPath,
|
|
195
|
+
...(this.targetLibraryUid ? { targetLibraryUid: this.targetLibraryUid } : {}),
|
|
196
|
+
activates: false,
|
|
197
|
+
});
|
|
198
|
+
if (dispatched.status !== "dispatched" && !this.allowHeadedFallback) {
|
|
199
|
+
const error = dispatched.error ?? {
|
|
200
|
+
code: "FINAL_CUT_DELIVERY_USER_INTERACTION_REQUIRED",
|
|
201
|
+
message: "Final Cut did not accept the background document-open request",
|
|
202
|
+
};
|
|
203
|
+
throw new Error(`${error.code}: ${error.message}`);
|
|
204
|
+
}
|
|
205
|
+
if (dispatched.status === "dispatched") {
|
|
206
|
+
delivery = {
|
|
207
|
+
status: "verified",
|
|
208
|
+
route: dispatched.route,
|
|
209
|
+
requestedActivates: dispatched.requestedActivates,
|
|
210
|
+
activation: dispatched.activation,
|
|
211
|
+
ui: dispatched.ui,
|
|
212
|
+
target: dispatched.target,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
await this.executor(importXmlScript(importedPath));
|
|
217
|
+
delivery = {
|
|
218
|
+
status: "verified",
|
|
219
|
+
route: "headed-accessibility",
|
|
220
|
+
requestedActivates: true,
|
|
221
|
+
activation: "activated",
|
|
222
|
+
ui: "displayed",
|
|
223
|
+
target: dispatched.target,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
await this.executor(importXmlScript(importedPath));
|
|
229
|
+
delivery = {
|
|
230
|
+
status: "verified",
|
|
231
|
+
route: "headed-accessibility",
|
|
232
|
+
requestedActivates: true,
|
|
233
|
+
activation: "activated",
|
|
234
|
+
ui: "displayed",
|
|
235
|
+
target: { guarantee: "unavailable" },
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (runtime)
|
|
239
|
+
runtime.delivery = delivery;
|
|
181
240
|
const live = await waitForImportedProject(this.liveState, identity, beforeLive, runtime?.targetBinding, this.verificationTimeoutMs, this.pollIntervalMs);
|
|
182
|
-
return publishResult(request, importedPath, identity, beforeLive, live);
|
|
241
|
+
return publishResult(request, importedPath, identity, beforeLive, live, delivery);
|
|
183
242
|
}
|
|
184
243
|
finally {
|
|
185
244
|
await rm(directory, { recursive: true, force: true });
|
|
@@ -200,7 +259,7 @@ export class FinalCutProjectPublisher {
|
|
|
200
259
|
artifactPath: job.sourcePath,
|
|
201
260
|
artifactDigest: job.artifactDigest,
|
|
202
261
|
confirm: true,
|
|
203
|
-
}, runtime.importedPath ?? job.sourcePath, runtime.identity, runtime.beforeLive, live);
|
|
262
|
+
}, runtime.importedPath ?? job.sourcePath, runtime.identity, runtime.beforeLive, live, runtime.delivery);
|
|
204
263
|
return this.markVerified(job, result);
|
|
205
264
|
}
|
|
206
265
|
catch (error) {
|
|
@@ -473,7 +532,7 @@ function hash(content) {
|
|
|
473
532
|
function clonePublishJob(job) {
|
|
474
533
|
return structuredClone(job);
|
|
475
534
|
}
|
|
476
|
-
function publishResult(request, importedPath, identity, beforeLive, live) {
|
|
535
|
+
function publishResult(request, importedPath, identity, beforeLive, live, delivery) {
|
|
477
536
|
return {
|
|
478
537
|
sourceTransactionId: request.sourceTransactionId,
|
|
479
538
|
sourcePath: request.artifactPath,
|
|
@@ -495,6 +554,7 @@ function publishResult(request, importedPath, identity, beforeLive, live) {
|
|
|
495
554
|
: {}),
|
|
496
555
|
},
|
|
497
556
|
verified: true,
|
|
557
|
+
...(delivery ? { delivery } : {}),
|
|
498
558
|
...(live.project?.name ? { liveProject: live.project.name } : {}),
|
|
499
559
|
...(live.sequence?.name ? { liveSequence: live.sequence.name } : {}),
|
|
500
560
|
};
|