conformtools 0.6.4 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/account-HDXVTS5T.js +3 -0
- package/dist/avid-panel/MANIFEST.json +11 -0
- package/dist/avid-panel/avid-manifest.json +46 -0
- package/dist/avid-panel/icon.svg +4 -0
- package/dist/avid-panel/icons/conformtools.svg +4 -0
- package/dist/avid-panel/index.html +26 -0
- package/dist/avid-panel/panel.css +12 -0
- package/dist/avid-panel/panel.js +7 -0
- package/dist/bridge-D5KPIUSY.js +3 -0
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/chunk-3OCQA33E.js +3 -0
- package/dist/chunk-3XD6NC4G.js +10 -0
- package/dist/chunk-5JBUCVRI.js +20 -0
- package/dist/chunk-5RSNFPED.js +8 -0
- package/dist/{chunk-BW2NQ54J.js → chunk-5SUGU2YR.js} +1 -1
- package/dist/{chunk-HKP4P6JN.js → chunk-6ML26TIK.js} +1 -1
- package/dist/chunk-7MC7M2Y5.js +3 -0
- package/dist/chunk-AS7IXHYM.js +19 -0
- package/dist/chunk-BL6L5ZBP.js +39 -0
- package/dist/chunk-C5IX63YF.js +3 -0
- package/dist/chunk-EJGVNQ3E.js +8 -0
- package/dist/{chunk-EPZ6NWE4.js → chunk-HGDO3OED.js} +1 -1
- package/dist/chunk-JV7TZDKJ.js +3 -0
- package/dist/chunk-LFJLRLEP.js +3 -0
- package/dist/chunk-NFJHWZJX.js +3 -0
- package/dist/{chunk-WT6NIJCB.js → chunk-NQHQKEP5.js} +1 -1
- package/dist/chunk-NU3X7P4N.js +3 -0
- package/dist/chunk-OJWIBQK4.js +376 -0
- package/dist/chunk-OVUCL3YY.js +5 -0
- package/dist/chunk-PFISREY4.js +3 -0
- package/dist/chunk-PFZVET7S.js +3 -0
- package/dist/chunk-PLRB2YXJ.js +3 -0
- package/dist/chunk-RFIPLBQ4.js +5 -0
- package/dist/chunk-SZD4C5MB.js +6 -0
- package/dist/chunk-TXQR2HI2.js +4 -0
- package/dist/chunk-UKKRZ574.js +7 -0
- package/dist/{chunk-EO5NIBOV.js → chunk-VS3MKKJ5.js} +1 -1
- package/dist/{chunk-42QQI3WX.js → chunk-X53BNWNV.js} +1 -1
- package/dist/{chunk-QTPCU2TF.js → chunk-XNR7M4VX.js} +1 -1
- package/dist/{claude-setup-BM3AAUKR.js → claude-setup-IIWUB4CE.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/conformtools-analyze +0 -0
- package/dist/conformtools-decode +0 -0
- package/dist/{cr3-wasm-WKWMEK3V.js → cr3-wasm-L2LFY3LM.js} +1 -1
- package/dist/{dng-wasm-Z5OVO4UI.js → dng-wasm-U6NC3MDK.js} +1 -1
- package/dist/{dpx-wasm-QNYXAOAJ.js → dpx-wasm-RMKEUKED.js} +1 -1
- package/dist/engine-P6H5P6HP.js +5 -0
- package/dist/{exr-wasm-BHSBJLQH.js → exr-wasm-LBAOMOZD.js} +1 -1
- package/dist/flame/hook/conformtools_flame/__init__.py +10 -0
- package/dist/flame/hook/conformtools_flame/building.py +191 -0
- package/dist/flame/hook/conformtools_flame/hook.py +177 -0
- package/dist/flame/hook/conformtools_flame/render.py +622 -0
- package/dist/flame/hook/conformtools_flame/util.py +33 -0
- package/dist/flame/hook/conformtools_flame/verbs.py +1037 -0
- package/dist/flame/hook/conformtools_flame_hook.py +42 -0
- package/dist/fonts/gfx/BarlowCondensed-Bold.ttf +0 -0
- package/dist/fonts/gfx/BarlowCondensed-Regular.ttf +0 -0
- package/dist/fonts/gfx/InstrumentSerif-Regular.ttf +0 -0
- package/dist/fonts/gfx/Inter-Bold.ttf +0 -0
- package/dist/fonts/gfx/Inter-Regular.ttf +0 -0
- package/dist/fonts/gfx/JetBrainsMono-Bold.ttf +0 -0
- package/dist/fonts/gfx/JetBrainsMono-Regular.ttf +0 -0
- package/dist/fonts/gfx/OFL.txt +100 -0
- package/dist/framing-SRCJKAYO.js +3 -0
- package/dist/gfx-worker.js +3 -0
- package/dist/h264-3ESGVT6G.js +3 -0
- package/dist/{h264-mxf-MWS7DDV7.js → h264-mxf-NPFS7NGH.js} +1 -1
- package/dist/host-relink-D6CB2VOQ.js +10 -0
- package/dist/hosts-W4AD2MYH.js +3 -0
- package/dist/http.js +3 -2
- package/dist/i2o-transfer +0 -0
- package/dist/inspect-7ASUPU73.js +68 -0
- package/dist/isobmff-SIOE67WL.js +3 -0
- package/dist/mcp.js +7 -8
- package/dist/media-7AUNRKHF.js +3 -0
- package/dist/media_core-Q2PIEV7D.js +9 -0
- package/dist/{media_core_bg-FGAR5KA5.js → media_core_bg-FDL7GJZP.js} +1 -1
- package/dist/mxf-74TTDICM.js +3 -0
- package/dist/nuke/panel/python/Startup/conformtools_nuke_startup.py +44 -0
- package/dist/nuke/panel/python/conformtools_nuke/__init__.py +10 -0
- package/dist/nuke/panel/python/conformtools_nuke/panel.py +217 -0
- package/dist/nuke/panel/python/conformtools_nuke/verbs.py +837 -0
- package/dist/{ops-73NR3X6R.js → ops-FSOOBXMV.js} +1 -1
- package/dist/peer-kit/ctpeer/__init__.py +21 -0
- package/dist/peer-kit/ctpeer/client.py +247 -0
- package/dist/peer-kit/ctpeer/neutral.py +178 -0
- package/dist/peer-kit/ctpeer/pairing.py +139 -0
- package/dist/peer-kit/ctpeer/protocol.py +209 -0
- package/dist/peer-kit/ctpeer/websocket.py +289 -0
- package/dist/premiere-uxp/index.js +5 -5
- package/dist/premiere-uxp/lib/clipmeta.js +6 -6
- package/dist/premiere-uxp/lib/ctx.js +30 -24
- package/dist/premiere-uxp/lib/edit.js +516 -0
- package/dist/premiere-uxp/lib/markers.js +5 -5
- package/dist/premiere-uxp/lib/pairing.js +14 -5
- package/dist/premiere-uxp/lib/premiere.js +10 -1
- package/dist/premiere-uxp/lib/probe.js +102 -0
- package/dist/premiere-uxp/lib/render.js +15 -8
- package/dist/premiere-uxp/lib/session.js +1 -1
- package/dist/premiere-uxp/lib/sizing.js +30 -17
- package/dist/premiere-uxp/lib/time.js +7 -1
- package/dist/premiere-uxp/lib/timeline.js +2 -2
- package/dist/premiere-uxp/lib/verbs.js +3 -2
- package/dist/premiere-uxp/lib/write.js +3 -3
- package/dist/premiere-uxp/manifest.json +1 -1
- package/dist/probe-F7WQHMIA.js +3 -0
- package/dist/r3d-YTLOMC7C.js +3 -0
- package/dist/{r3d-VUOYU2KQ.js → r3d-ZDJ3WURS.js} +1 -1
- package/dist/resolve-bridge.py +1262 -13
- package/dist/{still-4G25EYN5.js → still-ZG2RUQAL.js} +1 -1
- package/dist/store-ZHXLQCGN.js +3 -0
- package/dist/{tiff-wasm-QJPCR7JT.js → tiff-wasm-D2FJ3L56.js} +1 -1
- package/dist/timeline-6DYFDVEH.js +3 -0
- package/dist/timeline_core-IOENXK4Z.js +3 -0
- package/dist/wasm/media_core_bg.wasm +0 -0
- package/dist/wasm-threads/media_core_bg.wasm +0 -0
- package/dist/wav-OWMUGQMM.js +3 -0
- package/package.json +6 -4
- package/dist/chunk-6FVGUJ6L.js +0 -3
- package/dist/chunk-6TM32YIJ.js +0 -7
- package/dist/chunk-BUEIRRNY.js +0 -3
- package/dist/chunk-CL26XMDO.js +0 -3
- package/dist/chunk-DRHOPOC7.js +0 -3
- package/dist/chunk-GXEVALBL.js +0 -3
- package/dist/chunk-JB7PR2TQ.js +0 -3
- package/dist/chunk-QDWB7QU7.js +0 -3
- package/dist/chunk-QTKRMXL5.js +0 -363
- package/dist/chunk-SP5RGDAM.js +0 -3
- package/dist/chunk-TEZP6VEQ.js +0 -3
- package/dist/chunk-Y2BEEOPB.js +0 -3
- package/dist/h264-LIZVHN2W.js +0 -3
- package/dist/inspect-DZF537QL.js +0 -46
- package/dist/isobmff-HM3UPWPZ.js +0 -3
- package/dist/media_core-R5PPN3AY.js +0 -9
- package/dist/mxf-K465SWBN.js +0 -3
- package/dist/onnxruntime-web-stub-PKJ2NZBF.js +0 -3
- package/dist/r3d-RR3FUM6H.js +0 -3
- package/dist/sscd-embed-DHFTEIOC.js +0 -3
- package/dist/sscd-sweep-OYS4XAID.js +0 -3
- package/dist/timeline_core-VK2ZWPCO.js +0 -3
- package/dist/wav-63QF6SCT.js +0 -3
- /package/dist/{arriraw-3GKCR6K2.js → arriraw-YIJ3BYNN.js} +0 -0
- /package/dist/{chunk-WHY3DVXS.js → chunk-D6YDLKSA.js} +0 -0
- /package/dist/{media_core_bg-YK63OUDM.js → media_core_bg-XRBVKQZH.js} +0 -0
- /package/dist/{prores-L4JZZWGH.js → prores-RIG37OIH.js} +0 -0
- /package/dist/{timeline_core_bg-2TYWZ35G.js → timeline_core_bg-JW42YM3G.js} +0 -0
- /package/dist/{udf_bg-A4WEMSAX.js → udf_bg-B37GKRIH.js} +0 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
// `edit`: clip-level live edits, addressed the way Resolve's are (hosts/resolve/bridge.py
|
|
2
|
+
// `_op`): an item is {kind, track, start} - 1-based track, record start in frames from the
|
|
3
|
+
// sequence start - or {id} from edit.items. A whole batch of undoable ops is ONE transaction,
|
|
4
|
+
// so ONE undo step in Premiere; every op also hands back the op that puts it back (`undo`,
|
|
5
|
+
// newest first), the same vocabulary, for host_apply {undo}.
|
|
6
|
+
//
|
|
7
|
+
// What the DOM cannot do is refused by name, never faked: a track item has no colour label of
|
|
8
|
+
// its own in UXP (clip_color sets the PROJECT item's label, which every use of the media shows),
|
|
9
|
+
// no flags, no set-speed / time remap (the engine's .prproj writer carries retimes).
|
|
10
|
+
// relink (ClipProjectItem.changeMediaFilePath) is not undoable in Premiere: it runs after the
|
|
11
|
+
// transaction and its undo is a relink back to the old path.
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
const { h, g, transact, activeProject, PeerError, P } = require("./ctx");
|
|
15
|
+
const T = require("./time");
|
|
16
|
+
const TL = require("./timeline");
|
|
17
|
+
const S = require("./sizing");
|
|
18
|
+
const CM = require("./clipmeta");
|
|
19
|
+
|
|
20
|
+
/** Premiere's 16 label colours (Preferences > Labels, BE.Prefs.LabelColors.N) by index, default names. */
|
|
21
|
+
const LABELS = ["Violet", "Iris", "Caribbean", "Lavender", "Cerulean", "Forest", "Rose", "Mango", "Purple", "Blue", "Teal", "Magenta", "Tan", "Green", "Brown", "Yellow"];
|
|
22
|
+
/** Resolve's clip colours with no same-named Premiere label: the nearest one. */
|
|
23
|
+
const NEAREST = { Orange: "Mango", Apricot: "Mango", Pink: "Rose", Lime: "Green", Olive: "Forest", Navy: "Cerulean", Beige: "Tan", Chocolate: "Brown" };
|
|
24
|
+
|
|
25
|
+
function labelIndex(color) {
|
|
26
|
+
if (typeof color === "number" || /^\d+$/.test(String(color))) return Number(color);
|
|
27
|
+
const name = String(color || "");
|
|
28
|
+
const i = LABELS.findIndex((l) => l.toLowerCase() === name.toLowerCase());
|
|
29
|
+
if (i >= 0) return i;
|
|
30
|
+
const near = Object.keys(NEAREST).find((k) => k.toLowerCase() === name.toLowerCase());
|
|
31
|
+
if (near) return LABELS.indexOf(NEAREST[near]);
|
|
32
|
+
throw new PeerError("bad_color", `no Premiere label "${name}" (have: ${LABELS.join(", ")})`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function asClip(pi) {
|
|
36
|
+
const ppro = P.api();
|
|
37
|
+
try { if (pi && ppro.ClipProjectItem && P.has(ppro.ClipProjectItem, "cast")) return ppro.ClipProjectItem.cast(pi) || pi; } catch (_) { /* not a clip */ }
|
|
38
|
+
return pi;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function tracksOf(seq, kind) {
|
|
42
|
+
return TL.tracksOf(seq, kind === "audio" ? "audio" : "video");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Every clip item of the sequence, with its address. Frames from the sequence start. */
|
|
46
|
+
async function index(seq, kinds = ["video", "audio"], only) {
|
|
47
|
+
const tb = await TL.timebaseOf(seq);
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const kind of kinds) {
|
|
50
|
+
const tracks = await tracksOf(seq, kind);
|
|
51
|
+
for (let i = 0; i < tracks.length; i += 1) {
|
|
52
|
+
if (only && only !== i + 1) continue;
|
|
53
|
+
for (const it of await TL.clipItems(tracks[i])) {
|
|
54
|
+
const start = T.ticksToFrames(T.toTicks(await P.callAny(it, ["getStartTime"])), tb);
|
|
55
|
+
const end = T.ticksToFrames(T.toTicks(await P.callAny(it, ["getEndTime"])), tb);
|
|
56
|
+
out.push({ kind, track: i + 1, start, end, item: it, id: h("item", it)["$h"] });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { tb, rows: out };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function effectsOf(item) {
|
|
64
|
+
const out = [];
|
|
65
|
+
try {
|
|
66
|
+
const chain = await P.callAny(item, ["getComponentChain"]);
|
|
67
|
+
const n = Number(await P.callAny(chain, ["getComponentCount"]) || 0);
|
|
68
|
+
for (let i = 0; i < n; i += 1) {
|
|
69
|
+
const c = await P.callAny(chain, ["getComponentAtIndex"], i);
|
|
70
|
+
let m = "", d = "";
|
|
71
|
+
try { m = String(await P.callAny(c, ["getMatchName"])); } catch (_) { /* nameless */ }
|
|
72
|
+
try { d = String(await P.callAny(c, ["getDisplayName"])); } catch (_) { /* nameless */ }
|
|
73
|
+
// Motion and Opacity are on every clip: only what someone added counts as an effect
|
|
74
|
+
if (m && !/ADBE (Motion|Opacity)$/.test(m)) out.push({ match: m, name: d || m });
|
|
75
|
+
}
|
|
76
|
+
} catch (_) { /* no chain (an audio item on an old build) */ }
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function row(r) {
|
|
81
|
+
const it = r.item;
|
|
82
|
+
let pi = null;
|
|
83
|
+
try { pi = await P.callAny(it, ["getProjectItem"]); } catch (_) { /* a title, a bar */ }
|
|
84
|
+
const clip = asClip(pi);
|
|
85
|
+
let label = -1;
|
|
86
|
+
try { if (clip && P.has(clip, "getColorLabelIndex")) label = Number(await clip.getColorLabelIndex()); } catch (_) { /* none */ }
|
|
87
|
+
let file = "";
|
|
88
|
+
try { file = clip ? String(await P.callAny(clip, ["getMediaFilePath"]) || "") : ""; } catch (_) { /* a sequence, a title */ }
|
|
89
|
+
let enabled = true;
|
|
90
|
+
try { enabled = !(await P.callAny(it, ["isDisabled"])); } catch (_) { /* assume on */ }
|
|
91
|
+
let name = "";
|
|
92
|
+
try { name = String(it.name || (P.has(it, "getName") ? await it.getName() : "") || (pi && pi.name) || ""); } catch (_) { /* nameless */ }
|
|
93
|
+
let speed = 1, reversed = false, adjustment = false;
|
|
94
|
+
try { speed = Number(await P.callAny(it, ["getSpeed"])) || 1; } catch (_) { /* none */ }
|
|
95
|
+
try { reversed = !!(await P.callAny(it, ["isSpeedReversed"])); } catch (_) { /* none */ }
|
|
96
|
+
try { adjustment = !!(await P.callAny(it, ["isAdjustmentLayer"])); } catch (_) { /* none */ }
|
|
97
|
+
let offline = false;
|
|
98
|
+
try { offline = !!(clip && P.has(clip, "isOffline") && await clip.isOffline()); } catch (_) { /* unknown */ }
|
|
99
|
+
const fx = r.kind === "video" ? await effectsOf(it) : [];
|
|
100
|
+
return {
|
|
101
|
+
kind: r.kind, track: r.track, start: r.start, end: r.end, id: r.id, name, enabled,
|
|
102
|
+
// the label is the project item's (every use of the media shows it): UXP has no track-item label
|
|
103
|
+
color: label >= 0 ? LABELS[label] || String(label) : "", label, flags: [], version: "", group: "", markers: 0, nodes: 0,
|
|
104
|
+
media_id: pi ? String(pi.guid || (P.has(pi, "getId") ? await pi.getId() : "") || "") : "", keywords: "",
|
|
105
|
+
file, offline, speed: reversed ? -Math.abs(speed) : speed, effects: fx.map((e) => e.name), adjustment,
|
|
106
|
+
// the edit index's columns: what a conform artist checks before a turnover
|
|
107
|
+
stabilized: fx.some((e) => /Stabiliz/i.test(e.match)), remapped: fx.some((e) => /Time Remap/i.test(e.match)),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function seqOf(timeline) {
|
|
112
|
+
if (timeline) return g(timeline, "seq");
|
|
113
|
+
const p = await activeProject();
|
|
114
|
+
const seq = p && await P.callAny(p, ["getActiveSequence"]);
|
|
115
|
+
if (!seq) throw new PeerError("no_timeline", "No sequence active");
|
|
116
|
+
return seq;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function tick(ticks) {
|
|
120
|
+
const ppro = P.api();
|
|
121
|
+
return ppro.TickTime && P.has(ppro.TickTime, "createWithTicks") ? ppro.TickTime.createWithTicks(String(Math.round(ticks))) : Math.round(ticks);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Source frames → ticks at the item's media rate (in/out points are source time). */
|
|
125
|
+
async function srcTicks(item, frames, seqFps) {
|
|
126
|
+
let pi = null;
|
|
127
|
+
try { pi = await P.callAny(item, ["getProjectItem"]); } catch (_) { /* none */ }
|
|
128
|
+
let fps = seqFps;
|
|
129
|
+
try {
|
|
130
|
+
const fi = pi && P.has(pi, "getFootageInterpretation") ? await pi.getFootageInterpretation() : null;
|
|
131
|
+
const fr = fi && (P.has(fi, "getFrameRate") ? await fi.getFrameRate() : fi.frameRate);
|
|
132
|
+
if (Number(fr) > 0) fps = Number(fr);
|
|
133
|
+
} catch (_) { /* sequence rate */ }
|
|
134
|
+
return T.framesToTicks(frames, T.timebaseFromFps(fps));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function xmpFields(pi) {
|
|
138
|
+
const ppro = P.api();
|
|
139
|
+
if (!ppro.Metadata || !P.has(ppro.Metadata, "getXMPMetadata")) return "";
|
|
140
|
+
try { return String(await ppro.Metadata.getXMPMetadata(pi) || ""); } catch (_) { return ""; }
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* One op → { actions: [...] (undoable, built now, committed with the batch), undo: [...ops], after?: fn (not undoable),
|
|
145
|
+
* detail? } or throws. `ref` is the op's item as given (handed back in its undo ops, re-addressed when it moves).
|
|
146
|
+
*/
|
|
147
|
+
async function build(op, it, ctx) {
|
|
148
|
+
const ppro = P.api();
|
|
149
|
+
const kind = op.op;
|
|
150
|
+
const item = op.item;
|
|
151
|
+
const need = () => { if (!it) throw new PeerError("usage", `${kind} needs an item`); };
|
|
152
|
+
if (kind === "enabled") {
|
|
153
|
+
need();
|
|
154
|
+
const was = !(await P.callAny(it, ["isDisabled"]));
|
|
155
|
+
return { actions: [() => P.callAnySync(it, ["createSetDisabledAction"], !op.on)], undo: [{ op: "enabled", item, on: was }], check: async () => (!(await P.callAny(it, ["isDisabled"]))) === !!op.on };
|
|
156
|
+
}
|
|
157
|
+
if (kind === "name") {
|
|
158
|
+
need();
|
|
159
|
+
const was = String(it.name || (P.has(it, "getName") ? await it.getName() : "") || "");
|
|
160
|
+
return { actions: [() => P.callAnySync(it, ["createSetNameAction"], String(op.name))], undo: [{ op: "name", item, name: was }] };
|
|
161
|
+
}
|
|
162
|
+
if (kind === "clip_color") {
|
|
163
|
+
need();
|
|
164
|
+
const pi = asClip(await P.callAny(it, ["getProjectItem"]));
|
|
165
|
+
if (!pi) throw new PeerError("no_media", "no project item behind this clip");
|
|
166
|
+
const was = Number(await P.callAny(pi, ["getColorLabelIndex"]));
|
|
167
|
+
if (!op.color) throw new PeerError("unsupported", "Premiere always shows a label; set one (clip_color {color})");
|
|
168
|
+
return { actions: [() => P.callAnySync(pi, ["createSetColorLabelAction"], labelIndex(op.color))], undo: [{ op: "clip_color", item, color: LABELS[was] || was }],
|
|
169
|
+
detail: "Premiere labels the project item (every use of this media), not the one clip: UXP has no track-item label" };
|
|
170
|
+
}
|
|
171
|
+
if (kind === "move") {
|
|
172
|
+
// createMoveAction shifts the item by a time (Adobe's reference); `to` is a record frame from the sequence start
|
|
173
|
+
need();
|
|
174
|
+
const start = ctx.startOf(it);
|
|
175
|
+
const by = op.by !== undefined ? Number(op.by) : Number(op.to) - start;
|
|
176
|
+
if (op.track !== undefined) throw new PeerError("unsupported", "UXP moves a clip in time only, not to another track");
|
|
177
|
+
if (!by) return { actions: [], undo: [] };
|
|
178
|
+
return { actions: [() => P.callAnySync(it, ["createMoveAction"], tick(T.framesToTicks(by, ctx.tb)))], undo: [{ op: "move", item: { ...item, start: start + by }, by: -by }], moved: start + by };
|
|
179
|
+
}
|
|
180
|
+
if (kind === "trim") {
|
|
181
|
+
// record start/end (frames from the sequence start) and/or source in/out (frames of the media)
|
|
182
|
+
need();
|
|
183
|
+
const actions = [];
|
|
184
|
+
const undo = { op: "trim", item: { ...item } };
|
|
185
|
+
const startNow = ctx.startOf(it);
|
|
186
|
+
if (op.start !== undefined) { actions.push(() => P.callAnySync(it, ["createSetStartAction"], tick(T.framesToTicks(Number(op.start), ctx.tb)))); undo.start = startNow; undo.item.start = Number(op.start); }
|
|
187
|
+
if (op.end !== undefined) { undo.end = T.ticksToFrames(T.toTicks(await P.callAny(it, ["getEndTime"])), ctx.tb); actions.push(() => P.callAnySync(it, ["createSetEndAction"], tick(T.framesToTicks(Number(op.end), ctx.tb)))); }
|
|
188
|
+
if (op.in !== undefined) { undo.in_ticks = String(T.toTicks(await P.callAny(it, ["getInPoint"]))); const t = tick(await srcTicks(it, Number(op.in), ctx.fps)); actions.push(() => P.callAnySync(it, ["createSetInPointAction"], t)); }
|
|
189
|
+
if (op.out !== undefined) { undo.out_ticks = String(T.toTicks(await P.callAny(it, ["getOutPoint"]))); const t = tick(await srcTicks(it, Number(op.out), ctx.fps)); actions.push(() => P.callAnySync(it, ["createSetOutPointAction"], t)); }
|
|
190
|
+
if (op.in_ticks !== undefined) actions.push(() => P.callAnySync(it, ["createSetInPointAction"], tick(Number(op.in_ticks))));
|
|
191
|
+
if (op.out_ticks !== undefined) actions.push(() => P.callAnySync(it, ["createSetOutPointAction"], tick(Number(op.out_ticks))));
|
|
192
|
+
if (!actions.length) throw new PeerError("usage", "trim needs start, end, in or out");
|
|
193
|
+
return { actions, undo: [undo], moved: op.start !== undefined ? Number(op.start) : undefined };
|
|
194
|
+
}
|
|
195
|
+
if (kind === "remove") {
|
|
196
|
+
need();
|
|
197
|
+
const editor = await P.callAny(ppro.SequenceEditor, ["getEditor"], ctx.seq);
|
|
198
|
+
const mt = ppro.Constants && ppro.Constants.MediaType ? (ctx.kindOf(it) === "audio" ? ppro.Constants.MediaType.AUDIO : ppro.Constants.MediaType.VIDEO) : 0;
|
|
199
|
+
let sel = [it];
|
|
200
|
+
// 26.x takes a TrackItemSelection; older builds took an array
|
|
201
|
+
try { if (ppro.TrackItemSelection && P.has(ppro.TrackItemSelection, "createEmptySelection")) { sel = await ppro.TrackItemSelection.createEmptySelection(); sel.addItem(it); } } catch (_) { sel = [it]; }
|
|
202
|
+
return { actions: [() => P.callAnySync(editor, ["createRemoveItemsAction"], sel, !!op.ripple, mt)], undo: [],
|
|
203
|
+
detail: "removed (Premiere's ⌘Z brings it back; host_apply undo cannot)" };
|
|
204
|
+
}
|
|
205
|
+
if (kind === "properties") {
|
|
206
|
+
need();
|
|
207
|
+
const set = op.set || {};
|
|
208
|
+
const known = ["Pan", "Tilt", "ZoomX", "ZoomY", "RotationAngle", "AnchorPointX", "AnchorPointY", "Opacity"];
|
|
209
|
+
const bad = Object.keys(set).filter((k) => !known.includes(k));
|
|
210
|
+
if (bad.length) throw new PeerError("usage", `unknown propert${bad.length === 1 ? "y" : "ies"} ${bad.join(", ")} (known: ${known.join(", ")})`);
|
|
211
|
+
const before = await S.readPose(it, ctx.raster);
|
|
212
|
+
const r = await S.poseActions(it, set, ctx.raster);
|
|
213
|
+
const old = {};
|
|
214
|
+
for (const k of Object.keys(set)) old[k] = before[k];
|
|
215
|
+
// the setters are made at commit: whether each took is known only then (post)
|
|
216
|
+
return { actions: r.actions, undo: [{ op: "properties", item, set: old }], post: () => ({ ok: r.written.length > 0 && !r.skipped.length, ...(r.skipped.length ? { refused: r.skipped } : {}) }) };
|
|
217
|
+
}
|
|
218
|
+
if (kind === "metadata") {
|
|
219
|
+
need();
|
|
220
|
+
const pi = await P.callAny(it, ["getProjectItem"]);
|
|
221
|
+
if (!pi) throw new PeerError("no_media", "no project item behind this clip");
|
|
222
|
+
let xml = await xmpFields(pi);
|
|
223
|
+
if (!xml) throw new PeerError("api_missing", "this Premiere has no XMP access");
|
|
224
|
+
const old = {};
|
|
225
|
+
const refused = [];
|
|
226
|
+
for (const [k, v] of Object.entries(op.set || {})) {
|
|
227
|
+
const f = CM.XMP_FIELDS[k];
|
|
228
|
+
if (!f) { refused.push(k); continue; }
|
|
229
|
+
old[k] = CM.xmpGet(xml, f);
|
|
230
|
+
xml = CM.xmpSet(xml, f, String(v));
|
|
231
|
+
}
|
|
232
|
+
const actions = Object.keys(old).length ? [() => P.callAnySync(ppro.Metadata, ["createSetXMPMetadataAction"], pi, xml)] : [];
|
|
233
|
+
return { actions, undo: Object.keys(old).length ? [{ op: "metadata", item, set: old }] : [], refused, ok: !refused.length };
|
|
234
|
+
}
|
|
235
|
+
if (kind === "relink") {
|
|
236
|
+
need();
|
|
237
|
+
const pi = asClip(await P.callAny(it, ["getProjectItem"]));
|
|
238
|
+
if (!pi) throw new PeerError("no_media", "no project item behind this clip");
|
|
239
|
+
const was = String(await P.callAny(pi, ["getMediaFilePath"]) || "");
|
|
240
|
+
if (P.has(pi, "canChangeMediaPath") && !(await pi.canChangeMediaPath())) throw new PeerError("refused", "Premiere will not change this clip's media path");
|
|
241
|
+
return {
|
|
242
|
+
actions: [], undo: was ? [{ op: "relink", item, path: was }] : [],
|
|
243
|
+
after: async () => {
|
|
244
|
+
// (newPath, overrideChecks): Premiere checks the new file matches unless told not to
|
|
245
|
+
const ok = await P.callAny(pi, ["changeMediaFilePath"], String(op.path), !!op.force);
|
|
246
|
+
if (ok === false) throw new PeerError("refused", "Premiere refused the new media (pass force=true to skip its match check)");
|
|
247
|
+
try { if (P.has(pi, "refreshMedia")) await pi.refreshMedia(); } catch (_) { /* best effort */ }
|
|
248
|
+
return String(await P.callAny(pi, ["getMediaFilePath"]) || "") === String(op.path);
|
|
249
|
+
},
|
|
250
|
+
detail: "relinks the project item (every use of this media); not in Premiere's undo, host_apply undo relinks back",
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (kind === "playhead") {
|
|
254
|
+
const frames = op.frame !== undefined ? Number(op.frame) : T.timecodeToFrames(String(op.tc), ctx.fps) - ctx.zero;
|
|
255
|
+
const ok = await P.callAny(ctx.seq, ["setPlayerPosition"], tick(T.framesToTicks(Math.max(0, frames), ctx.tb)));
|
|
256
|
+
return { actions: [], undo: [], ok: ok !== false };
|
|
257
|
+
}
|
|
258
|
+
if (kind === "timeline_rename") {
|
|
259
|
+
const pi = await P.callAny(ctx.seq, ["getProjectItem"]);
|
|
260
|
+
const was = String(ctx.seq.name || "");
|
|
261
|
+
return { actions: [() => P.callAnySync(pi, ["createSetNameAction"], String(op.name))], undo: [{ op: "timeline_rename", name: was }] };
|
|
262
|
+
}
|
|
263
|
+
if (kind === "flags") throw new PeerError("unsupported", "Premiere has no clip flags (use clip_color, markers or metadata)");
|
|
264
|
+
if (["version", "color_group", "copy_grade", "drx", "node_copy", "cache", "lut", "fades", "output_blanking", "copy_properties"].includes(kind)) {
|
|
265
|
+
throw new PeerError("unsupported", `${kind} is a DaVinci Resolve edit; Premiere has no equivalent over UXP`);
|
|
266
|
+
}
|
|
267
|
+
throw new PeerError("unsupported", `premiere: no op ${kind}`);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Every clip project item in the project (bins walked), with what a matcher needs. */
|
|
271
|
+
async function projectClips(project) {
|
|
272
|
+
const out = [];
|
|
273
|
+
const walk = async (folder, path) => {
|
|
274
|
+
let items = [];
|
|
275
|
+
try { items = await P.callAny(folder, ["getItems"]) || []; } catch (_) { return; }
|
|
276
|
+
for (const it of items) {
|
|
277
|
+
if (CM.isFolderItem(it)) { await walk(it, path ? `${path}/${it.name}` : String(it.name || "")); continue; }
|
|
278
|
+
const clip = asClip(it);
|
|
279
|
+
if (!clip || !P.has(clip, "getMediaFilePath")) continue;
|
|
280
|
+
try { if (P.has(clip, "isSequence") && await clip.isSequence()) continue; } catch (_) { /* a clip */ }
|
|
281
|
+
let file = "";
|
|
282
|
+
try { file = String(await clip.getMediaFilePath() || ""); } catch (_) { continue; }
|
|
283
|
+
if (!file) continue;
|
|
284
|
+
let fps = 0;
|
|
285
|
+
try { const fi = await clip.getFootageInterpretation(); fps = Number(P.has(fi, "getFrameRate") ? await fi.getFrameRate() : fi.frameRate) || 0; } catch (_) { /* unknown */ }
|
|
286
|
+
const row = { id: h("clip", it)["$h"], name: String(it.name || ""), file, bin: path, fps,
|
|
287
|
+
start_frame: fps ? await TL.sourceStartFrames(clip, fps) : null, offline: false, has_proxy: false, proxy: "", label: -1 };
|
|
288
|
+
try { row.offline = !!(P.has(clip, "isOffline") && await clip.isOffline()); } catch (_) { /* unknown */ }
|
|
289
|
+
try { row.has_proxy = !!(P.has(clip, "hasProxy") && await clip.hasProxy()); } catch (_) { /* unknown */ }
|
|
290
|
+
try { if (row.has_proxy) row.proxy = String(await clip.getProxyPath() || ""); } catch (_) { /* unknown */ }
|
|
291
|
+
try { row.label = Number(await clip.getColorLabelIndex()); } catch (_) { /* unknown */ }
|
|
292
|
+
out.push(row);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
await walk(await P.callAny(project, ["getRootItem"]), "");
|
|
296
|
+
return out;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const verbs = {
|
|
300
|
+
/** Every clip in the project panel (bins walked): file, bin, start TC frame, fps, proxy, offline. */
|
|
301
|
+
"edit.project_clips": async () => {
|
|
302
|
+
const p = await activeProject();
|
|
303
|
+
if (!p) throw new PeerError("no_project", "No project open");
|
|
304
|
+
return { project: String(p.name || ""), project_path: typeof p.path === "string" ? p.path : "", clips: await projectClips(p) };
|
|
305
|
+
},
|
|
306
|
+
/** Repoint project clips: mode replace (changeMediaFilePath: every use follows), hires (attach `path` as the
|
|
307
|
+
* full-res media behind this proxy) or proxy (attach `path` as its proxy). Not in Premiere's undo; a replace's
|
|
308
|
+
* undo is the replace back. {items: [{clip, path, mode?, force?}]} */
|
|
309
|
+
"edit.relink_clips": async ({ items }) => {
|
|
310
|
+
const results = [];
|
|
311
|
+
const undo = [];
|
|
312
|
+
for (const x of Array.isArray(items) ? items : []) {
|
|
313
|
+
try {
|
|
314
|
+
const clip = asClip(g(x.clip, "clip"));
|
|
315
|
+
const was = String(await P.callAny(clip, ["getMediaFilePath"]) || "");
|
|
316
|
+
const mode = x.mode || "replace";
|
|
317
|
+
let ok;
|
|
318
|
+
if (mode === "replace") {
|
|
319
|
+
if (P.has(clip, "canChangeMediaPath") && !(await clip.canChangeMediaPath())) throw new PeerError("refused", "Premiere will not change this clip's media path");
|
|
320
|
+
ok = await P.callAny(clip, ["changeMediaFilePath"], String(x.path), !!x.force);
|
|
321
|
+
try { if (P.has(clip, "refreshMedia")) await clip.refreshMedia(); } catch (_) { /* best effort */ }
|
|
322
|
+
ok = ok !== false && String(await P.callAny(clip, ["getMediaFilePath"]) || "") === String(x.path);
|
|
323
|
+
if (ok) undo.unshift({ clip: x.clip, path: was, mode: "replace", force: true });
|
|
324
|
+
} else {
|
|
325
|
+
if (P.has(clip, "canProxy") && !(await clip.canProxy())) throw new PeerError("refused", "Premiere will not attach media to this clip");
|
|
326
|
+
ok = (await P.callAny(clip, ["attachProxy"], String(x.path), mode === "hires")) !== false;
|
|
327
|
+
}
|
|
328
|
+
results.push({ clip: x.clip, ok, was });
|
|
329
|
+
} catch (e) { results.push({ clip: x.clip, ok: false, detail: e.message || String(e) }); }
|
|
330
|
+
}
|
|
331
|
+
return { results, undo };
|
|
332
|
+
},
|
|
333
|
+
/** Cut media in OVER a clip, the conform artist's way (a VFX / colour return onto the track above, the original
|
|
334
|
+
* left underneath): {timeline?, cuts: [{path | clip, track, start, src_in, duration, audio?: false, copy_from?: item}]}
|
|
335
|
+
* start = record frame from the sequence start, src_in = first frame of the media (file-local), duration in frames.
|
|
336
|
+
* The files are imported into one bin; all the overwrites are ONE transaction = one undo step. */
|
|
337
|
+
"edit.cut_in": async ({ timeline, cuts, bin }) => {
|
|
338
|
+
const ppro = P.api();
|
|
339
|
+
const seq = await seqOf(timeline);
|
|
340
|
+
const project = await activeProject();
|
|
341
|
+
if (!project) throw new PeerError("no_project", "No project open");
|
|
342
|
+
const tb = await TL.timebaseOf(seq);
|
|
343
|
+
const list = Array.isArray(cuts) ? cuts : [];
|
|
344
|
+
const results = list.map(() => ({ ok: false }));
|
|
345
|
+
// 1. the media, imported once each into our bin
|
|
346
|
+
const paths = Array.from(new Set(list.filter((c) => c.path).map((c) => String(c.path))));
|
|
347
|
+
const byPath = new Map();
|
|
348
|
+
if (paths.length) {
|
|
349
|
+
const root = await P.callAny(project, ["getRootItem"]);
|
|
350
|
+
let target = root;
|
|
351
|
+
try { if (P.has(project, "getInsertionBin")) target = (await project.getInsertionBin()) || root; } catch (_) { /* root */ }
|
|
352
|
+
const before = new Set((await projectClips(project)).map((c) => c.file));
|
|
353
|
+
await P.callAny(project, ["importFiles"], paths, true, target, false);
|
|
354
|
+
for (const c of await projectClips(project)) if (paths.includes(c.file) && (!byPath.has(c.file) || !before.has(c.file))) byPath.set(c.file, c.id);
|
|
355
|
+
}
|
|
356
|
+
const editor = await P.callAny(ppro.SequenceEditor, ["getEditor"], seq);
|
|
357
|
+
const { rows } = await index(seq, ["video"]);
|
|
358
|
+
const byPos = new Map(rows.map((r) => [`${r.kind}:${r.track}:${r.start}`, r.item]));
|
|
359
|
+
const raster = await TL.frameSize(seq);
|
|
360
|
+
const vCount = (await TL.tracksOf(seq, "video")).length;
|
|
361
|
+
const aCount = (await TL.tracksOf(seq, "audio")).length;
|
|
362
|
+
const prepared = [];
|
|
363
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
364
|
+
const c = list[i];
|
|
365
|
+
try {
|
|
366
|
+
const id = c.clip ? c.clip : byPath.get(String(c.path));
|
|
367
|
+
if (!id) throw new PeerError("import_failed", `Premiere did not import ${c.path}`);
|
|
368
|
+
// MEASURED 26.5.2 (debug.place_probe): SequenceEditor takes the RAW project item — the ClipProjectItem
|
|
369
|
+
// cast of the same item is "Invalid parameter"; the in/out marks live on the cast
|
|
370
|
+
const raw = g(id, "clip");
|
|
371
|
+
const clip = asClip(raw);
|
|
372
|
+
const fpsSeq = T.fpsFromTimebase(tb);
|
|
373
|
+
const inT = tick(await srcTicks({ getProjectItem: () => clip }, Number(c.src_in), fpsSeq));
|
|
374
|
+
const outT = tick(await srcTicks({ getProjectItem: () => clip }, Number(c.src_in) + Number(c.duration), fpsSeq));
|
|
375
|
+
prepared.push({ i, clip, raw, id, key: typeof id === "string" ? id : id["$h"], inT, outT, at: tick(T.framesToTicks(Number(c.start), tb)), v: Math.max(0, Number(c.track) - 1), audio: !!c.audio, copy_from: c.copy_from, track: Number(c.track), start: Number(c.start) });
|
|
376
|
+
results[i] = { ok: true, clip: id };
|
|
377
|
+
} catch (e) { results[i] = { ok: false, detail: e.message || String(e) }; }
|
|
378
|
+
}
|
|
379
|
+
// MEASURED 26.5.2: an overwrite onto a track that does not exist is "Invalid parameter", and UXP has no add-track
|
|
380
|
+
// call — but an INSERT past the last track makes one (Adobe's reference); with limitShift on a new, empty track it
|
|
381
|
+
// moves nothing. So the first cut onto a missing track goes in as that insert (its own step), the rest overwrite.
|
|
382
|
+
// The audio index is not documented: -1 (no audio) first, else a new empty audio track; the reply says which took.
|
|
383
|
+
const place = (p, insert) => () => {
|
|
384
|
+
const errors = [];
|
|
385
|
+
for (const a of p.audio ? [0] : [-1, aCount]) {
|
|
386
|
+
try {
|
|
387
|
+
const act = insert ? P.callAnySync(editor, ["createInsertProjectItemAction"], p.raw, p.at, p.v, a, true)
|
|
388
|
+
: P.callAnySync(editor, ["createOverwriteItemAction"], p.raw, p.at, p.v, a);
|
|
389
|
+
results[p.i].how = `${insert ? "insert (new track)" : "overwrite"}, audio ${a}`;
|
|
390
|
+
return act;
|
|
391
|
+
} catch (e) { errors.push(`audio ${a}: ${e.message || e}`); }
|
|
392
|
+
}
|
|
393
|
+
throw new PeerError("refused", errors.join("; "));
|
|
394
|
+
};
|
|
395
|
+
const fail = (p) => (e) => { results[p.i] = { ok: false, detail: e.message || String(e) }; };
|
|
396
|
+
const ready = prepared.filter((p) => results[p.i].ok);
|
|
397
|
+
// MEASURED 26.5.2: an overwrite takes the clip's in/out marks AS THEY ARE WHEN THE ACTION IS MADE, and every
|
|
398
|
+
// action of a transaction is made before any runs — marks set in the same transaction are ignored (the first
|
|
399
|
+
// live pass cut in whole files). So: commit the marks, then make + commit the placements, then clear the marks.
|
|
400
|
+
// A return used for two cuts goes in rounds (one set of marks per clip per round).
|
|
401
|
+
let n = 0, steps = 0, opened = vCount;
|
|
402
|
+
let pending = ready.slice();
|
|
403
|
+
while (pending.length) {
|
|
404
|
+
const seen = new Set();
|
|
405
|
+
const round = pending.filter((p) => (seen.has(p.key) ? false : (seen.add(p.key), true)));
|
|
406
|
+
pending = pending.filter((p) => !round.includes(p));
|
|
407
|
+
await transact(project, "conform.tools: marks on the returns", (add) => { for (const p of round) add(() => P.callAnySync(p.clip, ["createSetInOutPointsAction"], p.inT, p.outT), fail(p)); });
|
|
408
|
+
const opener = round.find((p) => results[p.i].ok && p.v >= opened);
|
|
409
|
+
if (opener) {
|
|
410
|
+
const k = await transact(project, "conform.tools: a track for the returns", (add) => add(place(opener, true), fail(opener)));
|
|
411
|
+
n += k; steps += k ? 1 : 0;
|
|
412
|
+
if (k) opened = opener.v + 1;
|
|
413
|
+
}
|
|
414
|
+
const rest = round.filter((p) => p !== opener && results[p.i].ok);
|
|
415
|
+
if (rest.length) {
|
|
416
|
+
const k = await transact(project, `conform.tools: cut in ${rest.length}`, (add) => { for (const p of rest) add(place(p, false), fail(p)); });
|
|
417
|
+
n += k; steps += k ? 1 : 0;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// the marks stay on each return clip (they are the range it was cut in with): clearing them would be one more
|
|
421
|
+
// undo step in front of the cuts
|
|
422
|
+
const built = ready;
|
|
423
|
+
// 2. sizing carried from the clip underneath (a second step: the new items exist only now)
|
|
424
|
+
const copied = [];
|
|
425
|
+
const after = await index(seq, ["video"]);
|
|
426
|
+
const at = new Map(after.rows.map((r) => [`${r.track}:${r.start}`, r.item]));
|
|
427
|
+
const poses = [];
|
|
428
|
+
for (const b of built) {
|
|
429
|
+
if (!b.copy_from) continue;
|
|
430
|
+
const src = byPos.get(`video:${Number(b.copy_from.track)}:${Number(b.copy_from.start)}`);
|
|
431
|
+
const dst = at.get(`${b.track}:${b.start}`);
|
|
432
|
+
if (!src || !dst) continue;
|
|
433
|
+
const pose = await S.readPose(src, raster);
|
|
434
|
+
const r = await S.poseActions(dst, { Pan: pose.Pan, Tilt: pose.Tilt, ZoomX: pose.ZoomX, ZoomY: pose.ZoomY, RotationAngle: pose.RotationAngle }, raster);
|
|
435
|
+
poses.push(...r.actions);
|
|
436
|
+
copied.push({ i: b.i, written: r.written, skipped: r.skipped });
|
|
437
|
+
}
|
|
438
|
+
if (poses.length) await transact(project, "conform.tools: sizing from the clips below", (add) => { for (const a of poses) add(a); });
|
|
439
|
+
for (const c of copied) Object.assign(results[c.i], { sizing: c.written, ...(c.skipped.length ? { sizing_skipped: c.skipped } : {}) });
|
|
440
|
+
return { timeline: String(seq.name || ""), results, actions: n, undo_steps: steps + (poses.length ? 1 : 0) };
|
|
441
|
+
},
|
|
442
|
+
/** The live attributes of every clip (or one kind/track), addressed like a session row. */
|
|
443
|
+
"edit.items": async ({ timeline, kind, track }) => {
|
|
444
|
+
const seq = await seqOf(timeline);
|
|
445
|
+
const { rows } = await index(seq, kind ? [kind] : ["video", "audio"], track ? Number(track) : undefined);
|
|
446
|
+
const items = [];
|
|
447
|
+
for (const r of rows) items.push(await row(r));
|
|
448
|
+
const tb = await TL.timebaseOf(seq);
|
|
449
|
+
const p = await activeProject();
|
|
450
|
+
// drop-frame: Premiere's time display code (the .prproj's TimeDisplay: 102 / 106 = 29.97 / 59.94 DROP); its OTIO
|
|
451
|
+
// export does not say, and a reader then guesses
|
|
452
|
+
let display = null;
|
|
453
|
+
try { display = await P.callAny(seq, ["getSequenceVideoTimeDisplayFormat"]); } catch (_) { /* older DOM */ }
|
|
454
|
+
const code = display && typeof display === "object" ? Number(display.value !== undefined ? display.value : display.type) : Number(display);
|
|
455
|
+
const drop_frame = Number.isFinite(code) && code > 0 ? code === 102 || code === 106 : null;
|
|
456
|
+
return { timeline: String(seq.name || ""), start_frame: await TL.zeroPointFrames(seq, tb), fps: T.fpsFromTimebase(tb), items, labels: LABELS,
|
|
457
|
+
drop_frame, time_display: display === null || display === undefined ? null : (typeof display === "object" ? JSON.parse(JSON.stringify(display)) : display),
|
|
458
|
+
project: p ? String(p.name || "") : "", project_path: p && typeof p.path === "string" ? p.path : "" };
|
|
459
|
+
},
|
|
460
|
+
/** {timeline?, ops} → {results, undo}. Every undoable op of the batch is one transaction = one undo step. */
|
|
461
|
+
"edit.apply": async ({ timeline, ops }) => {
|
|
462
|
+
const seq = await seqOf(timeline);
|
|
463
|
+
const project = await activeProject();
|
|
464
|
+
if (!project) throw new PeerError("no_project", "No project open");
|
|
465
|
+
const { tb, rows } = await index(seq);
|
|
466
|
+
const byPos = new Map(rows.map((r) => [`${r.kind}:${r.track}:${r.start}`, r]));
|
|
467
|
+
const byId = new Map(rows.map((r) => [r.id, r]));
|
|
468
|
+
const byItem = new Map(rows.map((r) => [r.item, r]));
|
|
469
|
+
const ctx = {
|
|
470
|
+
seq, tb, fps: T.fpsFromTimebase(tb), zero: await TL.zeroPointFrames(seq, tb), raster: await TL.frameSize(seq),
|
|
471
|
+
startOf: (it) => byItem.get(it).start, kindOf: (it) => byItem.get(it).kind,
|
|
472
|
+
};
|
|
473
|
+
const find = (a) => {
|
|
474
|
+
const r = a.id ? byId.get(a.id) : byPos.get(`${a.kind || "video"}:${Number(a.track)}:${Number(a.start)}`);
|
|
475
|
+
if (!r) throw new PeerError("not_found", `no ${a.kind || "video"} item at ${JSON.stringify(a)}`);
|
|
476
|
+
return r.item;
|
|
477
|
+
};
|
|
478
|
+
const list = Array.isArray(ops) ? ops : [];
|
|
479
|
+
const results = [];
|
|
480
|
+
const built = [];
|
|
481
|
+
// 1. resolve every address and build every action BEFORE anything changes (a move cannot re-address a later op)
|
|
482
|
+
for (const op of list) {
|
|
483
|
+
try {
|
|
484
|
+
const it = op.item ? find(op.item) : null;
|
|
485
|
+
const b = await build(op, it, ctx);
|
|
486
|
+
built.push(b);
|
|
487
|
+
results.push({ op: op.op, ok: b.ok !== false, ...(b.detail ? { detail: b.detail } : {}), ...(b.refused && b.refused.length ? { refused: b.refused } : {}) });
|
|
488
|
+
} catch (e) {
|
|
489
|
+
built.push(null);
|
|
490
|
+
results.push({ op: op.op, ok: false, detail: e.message || String(e) });
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// 2. one transaction for all of it
|
|
494
|
+
const label = list.length === 1 ? `conform.tools ${list[0].op}` : `conform.tools: ${list.length} edits`;
|
|
495
|
+
const n = await transact(project, label, (add) => {
|
|
496
|
+
built.forEach((b, i) => { if (b) for (const a of b.actions) add(a, (e) => { results[i].ok = false; results[i].detail = e.message || String(e); }); });
|
|
497
|
+
});
|
|
498
|
+
// 3. what Premiere cannot undo, after
|
|
499
|
+
for (let i = 0; i < built.length; i += 1) {
|
|
500
|
+
const b = built[i];
|
|
501
|
+
if (!b || !b.after || !results[i].ok) continue;
|
|
502
|
+
try { results[i].ok = await b.after(); } catch (e) { results[i].ok = false; results[i].detail = e.message || String(e); }
|
|
503
|
+
}
|
|
504
|
+
for (let i = 0; i < built.length; i += 1) if (built[i] && built[i].post && results[i].ok) Object.assign(results[i], built[i].post());
|
|
505
|
+
for (let i = 0; i < built.length; i += 1) {
|
|
506
|
+
const b = built[i];
|
|
507
|
+
if (b && b.check && results[i].ok) { try { results[i].ok = await b.check(); } catch (_) { /* read-back unavailable */ } }
|
|
508
|
+
}
|
|
509
|
+
const undo = [];
|
|
510
|
+
// a half-refused op (one bad key) still changed the rest: its undo stays
|
|
511
|
+
for (let i = 0; i < built.length; i += 1) if (built[i] && (results[i].ok || built[i].actions.length)) undo.unshift(...built[i].undo);
|
|
512
|
+
return { timeline: String(seq.name || ""), results, undo, actions: n, undo_steps: n > 0 ? 1 : 0 };
|
|
513
|
+
},
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
module.exports = { verbs, LABELS, labelIndex };
|
|
@@ -136,7 +136,7 @@ const verbs = {
|
|
|
136
136
|
// (MARKER_TYPE_COMMENT = "Comment"); `Constants.MarkerType` does not exist.
|
|
137
137
|
const type = (ppro.Marker && ppro.Marker.MARKER_TYPE_COMMENT) || (ppro.Constants && ppro.Constants.MarkerType && (ppro.Constants.MarkerType.COMMENT || ppro.Constants.MarkerType.MARKER)) || "Comment";
|
|
138
138
|
const n = await transact(project, `Add marker "${name || ""}"`, async (add) => {
|
|
139
|
-
add(
|
|
139
|
+
add(() => P.callAnySync(holder, ["createAddMarkerAction"], String(name || ""), type, tick(ppro, startTicks), tick(ppro, durTicks), String(note || "")));
|
|
140
140
|
});
|
|
141
141
|
if (!n) return false;
|
|
142
142
|
// Colour is a second action on the created marker (there is no colour
|
|
@@ -144,7 +144,7 @@ const verbs = {
|
|
|
144
144
|
if (color) {
|
|
145
145
|
const created = await findMarker(holder, timebase, Number(frame));
|
|
146
146
|
if (created && (P.has(created._obj, "createSetColorByIndexAction") || P.has(created._obj, "createSetColorAction"))) {
|
|
147
|
-
await transact(project, "Marker colour", async (add) => { add(
|
|
147
|
+
await transact(project, "Marker colour", async (add) => { add(() => P.callAnySync(created._obj, ["createSetColorByIndexAction", "createSetColorAction"], colorIndex(color))); });
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
return true;
|
|
@@ -155,7 +155,7 @@ const verbs = {
|
|
|
155
155
|
const { holder, timebase } = await markersObjectFor(target);
|
|
156
156
|
const found = await findMarker(holder, timebase, Number(frame));
|
|
157
157
|
if (!found) return false;
|
|
158
|
-
const n = await transact(project, "Delete marker", async (add) => { add(
|
|
158
|
+
const n = await transact(project, "Delete marker", async (add) => { add(() => P.callAnySync(holder, ["createRemoveMarkerAction"], found._obj)); });
|
|
159
159
|
return n > 0;
|
|
160
160
|
},
|
|
161
161
|
"markers.move": async ({ target, frame, to_frame }) => {
|
|
@@ -165,7 +165,7 @@ const verbs = {
|
|
|
165
165
|
const found = await findMarker(holder, timebase, Number(frame));
|
|
166
166
|
if (!found) return false;
|
|
167
167
|
const n = await transact(project, "Move marker", async (add) => {
|
|
168
|
-
add(
|
|
168
|
+
add(() => P.callAnySync(holder, ["createMoveMarkerAction"], found._obj, tick(ppro, T.framesToTicks(Number(to_frame), timebase))));
|
|
169
169
|
});
|
|
170
170
|
return n > 0;
|
|
171
171
|
},
|
|
@@ -174,7 +174,7 @@ const verbs = {
|
|
|
174
174
|
const { holder, timebase } = await markersObjectFor(target);
|
|
175
175
|
const found = await findMarker(holder, timebase, Number(frame));
|
|
176
176
|
if (!found) return false;
|
|
177
|
-
const n = await transact(project, "Marker colour", async (add) => { add(
|
|
177
|
+
const n = await transact(project, "Marker colour", async (add) => { add(() => P.callAnySync(found._obj, ["createSetColorByIndexAction", "createSetColorAction"], colorIndex(color))); });
|
|
178
178
|
return n > 0;
|
|
179
179
|
},
|
|
180
180
|
"markers.set_text": async ({ target, frame, name, note }) => {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// Pairing: where the bridge is and the token to reach it. The conform.tools
|
|
2
|
-
// engine (~/.conform-mcp) and the desktop app
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// engine (~/.conform-mcp) and the live desktop app (app.conform.tools) each write
|
|
3
|
+
// `<home>/host-bridge/pairing.json` (0600, new port and token on every start,
|
|
4
|
+
// deleted on stop). This panel READS it; the token never leaves the machine and
|
|
5
|
+
// is never shown in full. Both apps may run: the NEWEST valid file wins (a tie
|
|
6
|
+
// goes to the engine), so the panel follows whichever bridge started last - the
|
|
7
|
+
// same rule as the Python peers (mcp/hosts/peer-kit/ctpeer/pairing.py, which also
|
|
8
|
+
// honours CONFORM_MCP_HOME / CONFORM_TOOLS_DATA_ROOT; UXP has no environment).
|
|
5
9
|
//
|
|
6
|
-
// Three ways, in order: the
|
|
10
|
+
// Three ways, in order: the files in the apps' data folders (needs the
|
|
7
11
|
// manifest's localFileSystem "fullAccess"); a folder the user picked once
|
|
8
12
|
// (persistent token); a pasted JSON (local only, kept in localStorage).
|
|
9
13
|
"use strict";
|
|
@@ -33,12 +37,17 @@ function makeReader(deps) {
|
|
|
33
37
|
const { readFileAt, pickedFolderRead, storage } = deps;
|
|
34
38
|
return async function readPairing() {
|
|
35
39
|
const errors = [];
|
|
40
|
+
let best = null;
|
|
36
41
|
for (const path of deps.candidates()) {
|
|
37
42
|
try {
|
|
38
43
|
const text = await readFileAt(path);
|
|
39
|
-
if (text)
|
|
44
|
+
if (!text) continue;
|
|
45
|
+
const p = { ...parsePairing(text), source: path };
|
|
46
|
+
const mtime = deps.mtimeAt ? await deps.mtimeAt(path).catch(() => 0) : 0; // unknown age: oldest, never dropped
|
|
47
|
+
if (!best || mtime > best.mtime) best = { p, mtime };
|
|
40
48
|
} catch (e) { errors.push(`${path}: ${e.message || e}`); }
|
|
41
49
|
}
|
|
50
|
+
if (best) return best.p;
|
|
42
51
|
if (pickedFolderRead) {
|
|
43
52
|
try {
|
|
44
53
|
const text = await pickedFolderRead();
|
|
@@ -64,6 +64,15 @@ async function callAny(obj, names, ...args) {
|
|
|
64
64
|
throw new PeerError("api_missing", `Premiere API has none of ${names.join("/")} here`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/** callAny, synchronously: the action factories (create*Action) inside project.lockedAccess(), whose callback
|
|
68
|
+
* must not await (26.3+: "Requires locked access" when an action is made outside it). */
|
|
69
|
+
function callAnySync(obj, names, ...args) {
|
|
70
|
+
for (const n of names) {
|
|
71
|
+
if (obj && typeof obj[n] === "function") return obj[n](...args);
|
|
72
|
+
}
|
|
73
|
+
throw new PeerError("api_missing", `Premiere API has none of ${names.join("/")} here`);
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
function has(obj, name) { return !!obj && typeof obj[name] === "function"; }
|
|
68
77
|
|
|
69
78
|
/** Own + prototype member names of an object, for the probe. */
|
|
@@ -79,4 +88,4 @@ function members(obj) {
|
|
|
79
88
|
return Array.from(out).sort();
|
|
80
89
|
}
|
|
81
90
|
|
|
82
|
-
module.exports = { api, uxp, setApi, hostVersion, platform, call, callAny, has, members, PeerError };
|
|
91
|
+
module.exports = { api, uxp, setApi, hostVersion, platform, call, callAny, callAnySync, has, members, PeerError };
|