conformtools 0.6.5 → 0.6.7
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 +18 -13
- package/dist/account-DJTD3KYK.js +3 -0
- package/dist/arriraw-YIJ3BYNN.js +525 -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-JQF4V3V2.js +3 -0
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/chunk-2BPR6LK6.js +3 -0
- package/dist/chunk-3D3Z4TBR.js +3 -0
- package/dist/chunk-55BKURYP.js +378 -0
- package/dist/chunk-5WEZRGXG.js +39 -0
- package/dist/chunk-6V4OEOOX.js +3 -0
- package/dist/chunk-7D7H6VFW.js +3 -0
- package/dist/chunk-A7FNR3T5.js +3 -0
- package/dist/chunk-AACY2V3L.js +3 -0
- package/dist/chunk-AMRJXYL4.js +3 -0
- package/dist/chunk-C2ESM27Z.js +3 -0
- package/dist/chunk-D4WPRRBT.js +3 -0
- package/dist/chunk-D6YDLKSA.js +3 -0
- package/dist/chunk-DKGGJM6Z.js +3 -0
- package/dist/chunk-EUBXH67N.js +7 -0
- package/dist/chunk-GK4YYKJ6.js +19 -0
- package/dist/chunk-GM6QKY7W.js +3 -0
- package/dist/chunk-J2JXLEAI.js +3 -0
- package/dist/chunk-JV7TZDKJ.js +3 -0
- package/dist/chunk-NAFLOZER.js +9 -0
- package/dist/chunk-NFJHWZJX.js +3 -0
- package/dist/chunk-NU3X7P4N.js +3 -0
- package/dist/chunk-P2LL3JMC.js +20 -0
- package/dist/chunk-PFISREY4.js +3 -0
- package/dist/chunk-PFZVET7S.js +3 -0
- package/dist/chunk-PHAMF4JF.js +4 -0
- package/dist/chunk-PLRB2YXJ.js +3 -0
- package/dist/chunk-PSANHDZM.js +3 -0
- package/dist/chunk-RGMTLNMF.js +3 -0
- package/dist/chunk-RJ6JA2LZ.js +3 -0
- package/dist/chunk-S5JDS5PQ.js +5 -0
- package/dist/chunk-SGLQY53R.js +3 -0
- package/dist/chunk-SKFMOLUO.js +8 -0
- package/dist/chunk-SNTAZJ5A.js +6 -0
- package/dist/chunk-TK55FA56.js +3 -0
- package/dist/chunk-TXQR2HI2.js +4 -0
- package/dist/chunk-VIBEEWPC.js +10 -0
- package/dist/chunk-WN53ARHJ.js +3 -0
- package/dist/chunk-XLEINKFL.js +5 -0
- package/dist/claude-setup-IIWUB4CE.js +5 -0
- package/dist/cli.js +17 -0
- package/dist/clip-state-B6JOX3JE.js +3 -0
- package/dist/conformtools-analyze +0 -0
- package/dist/conformtools-decode +0 -0
- package/dist/cr3-wasm-HLJWEV2S.js +3 -0
- package/dist/dng-wasm-CQDLPM5V.js +3 -0
- package/dist/dpx-wasm-TLGMM7BO.js +3 -0
- package/dist/engine-P6H5P6HP.js +5 -0
- package/dist/esm-SFFBP7PS.js +3 -0
- package/dist/exr-wasm-2NPKPTVB.js +3 -0
- 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-SWOD4CWB.js +3 -0
- package/dist/gfx-worker.js +3 -0
- package/dist/h264-JJMZSUWW.js +3 -0
- package/dist/h264-mxf-DCUOGLDU.js +3 -0
- package/dist/host-relink-TWAF6WIG.js +10 -0
- package/dist/hosts-Z666EF7V.js +3 -0
- package/dist/http.js +5 -0
- package/dist/i2o-transfer +0 -0
- package/dist/inspect-FJKYPEXL.js +68 -0
- package/dist/isobmff-VJOWP4MH.js +3 -0
- package/dist/mc-video-5MGGOQN4.js +3 -0
- package/dist/mcp.js +13 -0
- package/dist/media-NZYVREUF.js +3 -0
- package/dist/media_core-YZ3PABEG.js +9 -0
- package/dist/media_core_bg-FDL7GJZP.js +3 -0
- package/dist/media_core_bg-XRBVKQZH.js +3 -0
- package/dist/mxf-FJSRFLJC.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-X7NAREC4.js +3 -0
- 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/icons/panel.png +0 -0
- package/dist/premiere-uxp/icons/panel@2x.png +0 -0
- package/dist/premiere-uxp/icons/plugin.png +0 -0
- package/dist/premiere-uxp/icons/plugin@2x.png +0 -0
- package/dist/premiere-uxp/index.html +38 -0
- package/dist/premiere-uxp/index.js +93 -0
- package/dist/premiere-uxp/lib/clipmeta.js +170 -0
- package/dist/premiere-uxp/lib/ctx.js +68 -0
- package/dist/premiere-uxp/lib/edit.js +516 -0
- package/dist/premiere-uxp/lib/handles.js +57 -0
- package/dist/premiere-uxp/lib/markers.js +198 -0
- package/dist/premiere-uxp/lib/pairing.js +67 -0
- package/dist/premiere-uxp/lib/premiere.js +91 -0
- package/dist/premiere-uxp/lib/probe.js +452 -0
- package/dist/premiere-uxp/lib/protocol.js +165 -0
- package/dist/premiere-uxp/lib/render.js +45 -0
- package/dist/premiere-uxp/lib/session.js +85 -0
- package/dist/premiere-uxp/lib/sizing.js +325 -0
- package/dist/premiere-uxp/lib/time.js +88 -0
- package/dist/premiere-uxp/lib/timeline.js +336 -0
- package/dist/premiere-uxp/lib/verbs.js +21 -0
- package/dist/premiere-uxp/lib/write.js +97 -0
- package/dist/premiere-uxp/manifest.json +102 -0
- package/dist/probe-F7WQHMIA.js +3 -0
- package/dist/prores-RIG37OIH.js +526 -0
- package/dist/r3d-CXUNG6VS.js +1025 -0
- package/dist/r3d-T5O6IIZZ.js +3 -0
- package/dist/resolve-bridge.py +2286 -0
- package/dist/resolve-presets/conform.tools.xml +127 -0
- package/dist/source-QGWWLMME.js +3 -0
- package/dist/statusline-GMMCFMOA.js +4 -0
- package/dist/statusline.js +3 -0
- package/dist/still-P4JJNTEO.js +3 -0
- package/dist/still-wasm-DN5LPASS.js +3 -0
- package/dist/store-7IOEBOZY.js +3 -0
- package/dist/tiff-wasm-BPRDR6EB.js +3 -0
- package/dist/timeline-DQG6TVPF.js +3 -0
- package/dist/timeline_core-IOENXK4Z.js +3 -0
- package/dist/timeline_core_bg-JW42YM3G.js +3 -0
- package/dist/udf_bg-B37GKRIH.js +3 -0
- package/dist/wasm/media_core_bg.wasm +0 -0
- package/dist/wasm/udf_bg.wasm +0 -0
- package/dist/wasm-threads/media_core_bg.wasm +0 -0
- package/dist/wav-64SC6P7U.js +3 -0
- package/package.json +6 -4
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
// `debug.probe`: what THIS Premiere exposes. Data only (member names and
|
|
2
|
+
// constant values); nothing is evaluated. The live pass reads this first.
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { P, g, activeProject } = require("./ctx");
|
|
6
|
+
|
|
7
|
+
const verbs = {
|
|
8
|
+
// Premiere's OWN re-save of a project file: open `path`, saveAs `out`, close it. The title law rig
|
|
9
|
+
// (oracle/titles) writes a text document in the JSON form and reads back the binary form Premiere
|
|
10
|
+
// converts it to, so every binary field is placed by Premiere itself. The project open before stays
|
|
11
|
+
// open and untouched.
|
|
12
|
+
// A .mogrt placed by Premiere itself (SequenceEditor.insertMogrtFromPath) into a NEW scratch project, saved to
|
|
13
|
+
// `out`: the graphic as Premiere instantiates it, which is the form an artist's project carries.
|
|
14
|
+
"debug.mogrt_resave": async ({ mogrts, out }) => {
|
|
15
|
+
const ppro = P.api();
|
|
16
|
+
const proj = await ppro.Project.createProject(String(out));
|
|
17
|
+
if (!proj) throw new Error(`createProject(${out}) returned nothing`);
|
|
18
|
+
const seq = await proj.createSequence("titles");
|
|
19
|
+
const editor = await ppro.SequenceEditor.getEditor(seq);
|
|
20
|
+
const placed = [];
|
|
21
|
+
let t = 0;
|
|
22
|
+
for (const m of mogrts || []) {
|
|
23
|
+
try {
|
|
24
|
+
const at = ppro.TickTime.createWithSeconds(t);
|
|
25
|
+
let items;
|
|
26
|
+
proj.lockedAccess(() => { items = editor.insertMogrtFromPath(String(m), at, 0, 0); });
|
|
27
|
+
placed.push({ mogrt: String(m), ok: !!items, n: items && items.length });
|
|
28
|
+
} catch (e) { placed.push({ mogrt: String(m), err: String(e.message || e) }); }
|
|
29
|
+
t += 30;
|
|
30
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
31
|
+
}
|
|
32
|
+
let count = 0;
|
|
33
|
+
for (let i = 0; i < (await seq.getVideoTrackCount()); i += 1) count += ((await (await seq.getVideoTrack(i)).getTrackItems(1, false)) || []).length;
|
|
34
|
+
const ok = await proj.save();
|
|
35
|
+
const closed = await proj.close();
|
|
36
|
+
return { saved: ok !== false, closed: closed !== false, placed, track_items: count };
|
|
37
|
+
},
|
|
38
|
+
// Premiere's OWN import of interchange files (FCP7 XML, AAF, EDL…) into a NEW scratch project saved to `out`:
|
|
39
|
+
// the sequence as Premiere builds it, which our .prproj reader then reads (e.g. how it sets a clip's source
|
|
40
|
+
// in-point from an XML <in> on a different-rate file). The project open before is untouched. Needs ONLINE media:
|
|
41
|
+
// with the media offline Premiere 26.5.2 never returns from importFiles (2026-10-27).
|
|
42
|
+
"debug.import_save": async ({ files, out }) => {
|
|
43
|
+
const ppro = P.api();
|
|
44
|
+
const proj = await ppro.Project.createProject(String(out));
|
|
45
|
+
if (!proj) throw new Error(`createProject(${out}) returned nothing`);
|
|
46
|
+
const root = await proj.getRootItem();
|
|
47
|
+
const ok = await proj.importFiles((files || []).map(String), true, root, false);
|
|
48
|
+
const seqs = ((await proj.getSequences()) || []).map((s) => s.name);
|
|
49
|
+
const saved = await proj.save();
|
|
50
|
+
const closed = await proj.close();
|
|
51
|
+
return { imported: ok !== false, sequences: seqs, saved: saved !== false, closed: closed !== false };
|
|
52
|
+
},
|
|
53
|
+
// Every component and param of every track item of a project file (display / match names, value at 0), read-only:
|
|
54
|
+
// where a setting lives before a rig authors it.
|
|
55
|
+
"debug.params_dump": async ({ path }) => {
|
|
56
|
+
const ppro = P.api();
|
|
57
|
+
const proj = await ppro.Project.open(String(path));
|
|
58
|
+
if (!proj) throw new Error(`Project.open(${path}) returned nothing`);
|
|
59
|
+
const out = [];
|
|
60
|
+
try {
|
|
61
|
+
for (const seq of (await proj.getSequences()) || []) {
|
|
62
|
+
const nv = await seq.getVideoTrackCount();
|
|
63
|
+
for (let t = 0; t < nv; t += 1) {
|
|
64
|
+
const track = await seq.getVideoTrack(t);
|
|
65
|
+
for (const it of (await track.getTrackItems(1, false)) || []) {
|
|
66
|
+
const item = { name: await it.getName(), members: P.members(it), components: [] };
|
|
67
|
+
const chain = await it.getComponentChain();
|
|
68
|
+
const n = await chain.getComponentCount();
|
|
69
|
+
for (let i = 0; i < n; i += 1) {
|
|
70
|
+
const c = await chain.getComponentAtIndex(i);
|
|
71
|
+
const comp = { display: await c.getDisplayName(), match: await c.getMatchName(), params: [] };
|
|
72
|
+
const pn = await c.getParamCount();
|
|
73
|
+
for (let j = 0; j < pn; j += 1) {
|
|
74
|
+
const prm = await c.getParam(j);
|
|
75
|
+
let v = null;
|
|
76
|
+
try { const k = await prm.getStartValue(); v = k && k.value !== undefined ? String(k.value).slice(0, 120) : String(k).slice(0, 120); } catch (e) { v = "ERR " + (e.message || e); }
|
|
77
|
+
comp.params.push({ name: prm.displayName, v });
|
|
78
|
+
}
|
|
79
|
+
item.components.push(comp);
|
|
80
|
+
}
|
|
81
|
+
out.push(item);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} finally {
|
|
86
|
+
await proj.close();
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
},
|
|
90
|
+
// Premiere's own render of a project file: open `path`, export its sequence (the one named `sequence`, else
|
|
91
|
+
// the first) with the .epr `preset` to `out` (EXPORT_IMMEDIATELY: returns when the file is written), close it.
|
|
92
|
+
// The title law rig renders a PNG-with-alpha sequence of its cells this way.
|
|
93
|
+
"debug.project_render": async ({ path, out, preset, sequence }) => {
|
|
94
|
+
const ppro = P.api();
|
|
95
|
+
const proj = await ppro.Project.open(String(path));
|
|
96
|
+
if (!proj) throw new Error(`Project.open(${path}) returned nothing`);
|
|
97
|
+
try {
|
|
98
|
+
const seqs = (await proj.getSequences()) || [];
|
|
99
|
+
const seq = seqs.find((s) => s.name === sequence) || seqs[0];
|
|
100
|
+
if (!seq) throw new Error("no sequence in the project");
|
|
101
|
+
const EM = ppro.EncoderManager;
|
|
102
|
+
const m = await EM.getManager();
|
|
103
|
+
const ok = await m.exportSequence(seq, EM.EXPORT_IMMEDIATELY, String(out), String(preset));
|
|
104
|
+
return { ok: ok !== false, sequence: seq.name };
|
|
105
|
+
} finally {
|
|
106
|
+
await proj.close();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"debug.project_resave": async ({ path, out }) => {
|
|
110
|
+
const ppro = P.api();
|
|
111
|
+
const proj = await ppro.Project.open(String(path));
|
|
112
|
+
if (!proj) throw new Error(`Project.open(${path}) returned nothing`);
|
|
113
|
+
// Premiere keeps a text document in the form it was read until the graphic is changed: set every Source Text
|
|
114
|
+
// back to its own value so it re-encodes, as an artist's edit does.
|
|
115
|
+
const touched = [];
|
|
116
|
+
for (const seq of (await proj.getSequences()) || []) {
|
|
117
|
+
const nv = await seq.getVideoTrackCount();
|
|
118
|
+
for (let t = 0; t < nv; t += 1) {
|
|
119
|
+
const track = await seq.getVideoTrack(t);
|
|
120
|
+
for (const it of (await track.getTrackItems(1, false)) || []) {
|
|
121
|
+
const chain = await it.getComponentChain();
|
|
122
|
+
const n = await chain.getComponentCount();
|
|
123
|
+
for (let i = 0; i < n; i += 1) {
|
|
124
|
+
const c = await chain.getComponentAtIndex(i);
|
|
125
|
+
const pn = await c.getParamCount();
|
|
126
|
+
for (let j = 0; j < pn; j += 1) {
|
|
127
|
+
const prm = await c.getParam(j);
|
|
128
|
+
if (prm.displayName !== "Source Text") continue;
|
|
129
|
+
const kf = await prm.getStartValue();
|
|
130
|
+
const row = { name: await it.getName(), members: P.members(prm), kf: kf === null ? "null" : typeof kf, kfv: kf && kf.value !== undefined ? String(kf.value).slice(0, 300) : null };
|
|
131
|
+
try { row.varying = await prm.isTimeVarying(); } catch (e) { row.varying = "ERR " + e.message; }
|
|
132
|
+
try { const vt = await prm.getValueAtTime(P.api().TickTime.createWithTicks("0")); row.at0 = vt === null ? "null" : String(vt && vt.value !== undefined ? vt.value : vt).slice(0, 300); } catch (e) { row.at0 = "ERR " + e.message; }
|
|
133
|
+
try {
|
|
134
|
+
const v = kf.value;
|
|
135
|
+
const key = prm.createKeyframe(v);
|
|
136
|
+
proj.lockedAccess(() => proj.executeTransaction((ca) => ca.addAction(prm.createSetValueAction(key, true)), "resave"));
|
|
137
|
+
row.set = "ok";
|
|
138
|
+
} catch (e) { row.set = "ERR " + (e.message || e); }
|
|
139
|
+
touched.push(row);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const ok = await proj.saveAs(String(out));
|
|
146
|
+
const closed = await proj.close();
|
|
147
|
+
return { saved: ok !== false, closed: closed !== false, out: String(out), touched };
|
|
148
|
+
},
|
|
149
|
+
// Premiere authors the keyframes: open `path`, and on each track item named in `keys` give the param
|
|
150
|
+
// (`component` display/match name, `param` display name) Premiere's own keyframes — `keys: [[seconds, value]]`,
|
|
151
|
+
// value a number, [x, y] (PointF), a boolean or a string (Source Text JSON) — with interpolation `interp`
|
|
152
|
+
// (KeyframeInterpolationMode name, e.g. "LINEAR", "HOLD", "BEZIER"); then save as `out`. The title rig diffs the
|
|
153
|
+
// saved file to place how Premiere stores an animated text layer.
|
|
154
|
+
"debug.keyframe_resave": async ({ path, out, keys }) => {
|
|
155
|
+
const ppro = P.api();
|
|
156
|
+
const proj = await ppro.Project.open(String(path));
|
|
157
|
+
if (!proj) throw new Error(`Project.open(${path}) returned nothing`);
|
|
158
|
+
const report = [];
|
|
159
|
+
const items = [];
|
|
160
|
+
for (const seq of (await proj.getSequences()) || []) {
|
|
161
|
+
for (let t = 0; t < (await seq.getVideoTrackCount()); t += 1) {
|
|
162
|
+
for (const it of (await (await seq.getVideoTrack(t)).getTrackItems(1, false)) || []) items.push(it);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
for (const k of keys || []) {
|
|
166
|
+
const row = { ...k, keys: undefined };
|
|
167
|
+
try {
|
|
168
|
+
let it = null;
|
|
169
|
+
for (const x of items) if ((await x.getName()) === k.item) it = x;
|
|
170
|
+
if (!it) throw new Error(`no track item ${k.item}`);
|
|
171
|
+
const t0 = Number((await it.getInPoint()).seconds || 0);
|
|
172
|
+
const start = Number((await it.getStartTime()).seconds || 0);
|
|
173
|
+
const chain = await it.getComponentChain();
|
|
174
|
+
let prm = null;
|
|
175
|
+
for (let i = 0; i < (await chain.getComponentCount()) && !prm; i += 1) {
|
|
176
|
+
const c = await chain.getComponentAtIndex(i);
|
|
177
|
+
const names = [await c.getDisplayName(), await c.getMatchName()];
|
|
178
|
+
if (k.component && !names.includes(k.component)) continue;
|
|
179
|
+
for (let j = 0; j < (await c.getParamCount()); j += 1) {
|
|
180
|
+
const p = await c.getParam(j);
|
|
181
|
+
if (p.displayName === k.param) { prm = p; break; }
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!prm) throw new Error(`no param ${k.component}/${k.param}`);
|
|
185
|
+
const val = (v) => (Array.isArray(v) ? new ppro.PointF(v[0], v[1]) : v);
|
|
186
|
+
const mode = ppro.Constants && ppro.Constants.InterpolationMode
|
|
187
|
+
? ppro.Constants.InterpolationMode[k.interp || "LINEAR"] : undefined;
|
|
188
|
+
row.mode = mode;
|
|
189
|
+
let err = null;
|
|
190
|
+
proj.lockedAccess(() => {
|
|
191
|
+
try {
|
|
192
|
+
proj.executeTransaction((ca) => {
|
|
193
|
+
ca.addAction(prm.createSetTimeVaryingAction(true));
|
|
194
|
+
for (const [s, v] of k.keys) {
|
|
195
|
+
const key = prm.createKeyframe(val(v));
|
|
196
|
+
// a track item's param time is clip time: the item's in point plus the offset into the item
|
|
197
|
+
key.position = ppro.TickTime.createWithSeconds(t0 + Number(s));
|
|
198
|
+
ca.addAction(prm.createAddKeyframeAction(key));
|
|
199
|
+
}
|
|
200
|
+
}, "keys");
|
|
201
|
+
if (mode !== undefined) {
|
|
202
|
+
proj.executeTransaction((ca) => {
|
|
203
|
+
for (const [s] of k.keys) ca.addAction(prm.createSetInterpolationAtKeyframeAction(ppro.TickTime.createWithSeconds(t0 + Number(s)), mode, false));
|
|
204
|
+
}, "interp");
|
|
205
|
+
}
|
|
206
|
+
} catch (e) { err = e; }
|
|
207
|
+
});
|
|
208
|
+
if (err) throw err;
|
|
209
|
+
row.ok = true;
|
|
210
|
+
row.start = start;
|
|
211
|
+
row.in = t0;
|
|
212
|
+
} catch (e) { row.err = String(e.message || e); }
|
|
213
|
+
report.push(row);
|
|
214
|
+
}
|
|
215
|
+
const ok = await proj.saveAs(String(out));
|
|
216
|
+
await proj.close();
|
|
217
|
+
return { saved: ok !== false, out: String(out), report };
|
|
218
|
+
},
|
|
219
|
+
// Which add / commit / lock arrangement lands a sequence marker on THIS Premiere (26.5.2 answered "Requires
|
|
220
|
+
// locked access" with the action made inside lockedAccess). Each variant adds one marker at its own frame
|
|
221
|
+
// (`frame` + i), reports the step that threw, then every marker it landed is removed again.
|
|
222
|
+
"debug.marker_probe": async ({ timeline, frame }) => {
|
|
223
|
+
const ppro = P.api();
|
|
224
|
+
const project = await activeProject();
|
|
225
|
+
const seq = timeline ? g(timeline, "seq") : await project.getActiveSequence();
|
|
226
|
+
const tb = Number(await seq.getTimebase());
|
|
227
|
+
const t = (f) => ppro.TickTime.createWithTicks(String(Math.round(f * tb)));
|
|
228
|
+
const type = (ppro.Marker && ppro.Marker.MARKER_TYPE_COMMENT) || "Comment";
|
|
229
|
+
const base = Number(frame || 300);
|
|
230
|
+
const out = {};
|
|
231
|
+
const run = (label, fn) => { try { const r = fn(); out[label] = { ok: true, ...(r && typeof r === "object" ? r : {}) }; } catch (e) { out[label] = { ok: false, error: String(e && e.message || e), stack: String(e && e.stack || "").split("\n").slice(0, 3).join(" | ") }; } };
|
|
232
|
+
let holder = await ppro.Markers.getMarkers(seq);
|
|
233
|
+
const mk = (i) => holder.createAddMarkerAction(`ct-probe-${i}`, type, t(base + i), t(1), "conform.tools lock probe");
|
|
234
|
+
// A: made + committed inside lockedAccess
|
|
235
|
+
run("A_inside_lock", () => { let err = null; project.lockedAccess(() => { try { const a = mk(0); project.executeTransaction((c) => c.addAction(a), "probe A"); } catch (e) { err = e; } }); if (err) throw err; });
|
|
236
|
+
// B: made inside the transaction callback, inside the lock
|
|
237
|
+
run("B_inside_transaction", () => { let err = null; project.lockedAccess(() => { try { project.executeTransaction((c) => c.addAction(mk(1)), "probe B"); } catch (e) { err = e; } }); if (err) throw err; });
|
|
238
|
+
// C: no lock at all
|
|
239
|
+
run("C_no_lock", () => { const a = mk(2); project.executeTransaction((c) => c.addAction(a), "probe C"); });
|
|
240
|
+
// D: made outside, committed inside the lock
|
|
241
|
+
run("D_made_outside", () => { const a = mk(3); let err = null; project.lockedAccess(() => { try { project.executeTransaction((c) => c.addAction(a), "probe D"); } catch (e) { err = e; } }); if (err) throw err; });
|
|
242
|
+
// E: no lock, made inside the transaction callback
|
|
243
|
+
run("E_txn_only", () => { project.executeTransaction((c) => c.addAction(mk(4)), "probe E"); });
|
|
244
|
+
// F: a fresh Markers object (fetched now), then A
|
|
245
|
+
holder = await ppro.Markers.getMarkers(seq);
|
|
246
|
+
run("F_fresh_holder", () => { let err = null; project.lockedAccess(() => { try { const a = mk(5); project.executeTransaction((c) => c.addAction(a), "probe F"); } catch (e) { err = e; } }); if (err) throw err; });
|
|
247
|
+
// what landed
|
|
248
|
+
holder = await ppro.Markers.getMarkers(seq);
|
|
249
|
+
let landed = [];
|
|
250
|
+
try { landed = holder.getMarkers().filter((m) => String(m.name || "").startsWith("ct-probe-")); } catch (e) { out.list_error = String(e.message || e); }
|
|
251
|
+
out.landed = landed.map((m) => m.name);
|
|
252
|
+
// clean up with whichever arrangement works for a remove
|
|
253
|
+
const removed = {};
|
|
254
|
+
for (const m of landed) {
|
|
255
|
+
for (const [label, fn] of [["inside_lock", () => { let err = null; project.lockedAccess(() => { try { const a = holder.createRemoveMarkerAction(m); project.executeTransaction((c) => c.addAction(a), "probe cleanup"); } catch (e) { err = e; } }); if (err) throw err; }],
|
|
256
|
+
["no_lock", () => { const a = holder.createRemoveMarkerAction(m); project.executeTransaction((c) => c.addAction(a), "probe cleanup"); }]]) {
|
|
257
|
+
try { fn(); removed[m.name] = label; break; } catch (e) { removed[m.name] = `failed: ${e.message || e}`; }
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
out.removed = removed;
|
|
261
|
+
return out;
|
|
262
|
+
},
|
|
263
|
+
// Which createInsertProjectItemAction / createOverwriteItemAction argument shapes THIS Premiere accepts: each is
|
|
264
|
+
// only CREATED under the lock (never committed), so nothing in the sequence changes. {timeline, clip, frame}
|
|
265
|
+
"debug.place_probe": async ({ timeline, clip, frame }) => {
|
|
266
|
+
const ppro = P.api();
|
|
267
|
+
const project = await activeProject();
|
|
268
|
+
const seq = g(timeline, "seq");
|
|
269
|
+
const raw = g(clip);
|
|
270
|
+
let cast = raw;
|
|
271
|
+
try { cast = ppro.ClipProjectItem.cast(raw) || raw; } catch (_) { /* raw */ }
|
|
272
|
+
const editor = await ppro.SequenceEditor.getEditor(seq);
|
|
273
|
+
const tb = Number(await seq.getTimebase());
|
|
274
|
+
const vCount = await seq.getVideoTrackCount();
|
|
275
|
+
const aCount = await seq.getAudioTrackCount();
|
|
276
|
+
const times = { ticktime: ppro.TickTime.createWithTicks(String(Math.round(Number(frame || 0) * tb))), seconds_tt: ppro.TickTime.createWithSeconds(Number(frame || 0) * tb / 254016000000) };
|
|
277
|
+
const out = { vCount, aCount, raw_type: String(raw && raw.type), insert: {}, overwrite: {} };
|
|
278
|
+
project.lockedAccess(() => {
|
|
279
|
+
for (const [iname, item] of [["raw", raw], ["cast", cast]]) {
|
|
280
|
+
for (const [tname, t] of Object.entries(times)) {
|
|
281
|
+
for (const v of [0, vCount - 1, vCount]) {
|
|
282
|
+
for (const a of [-1, 0, aCount - 1, aCount]) {
|
|
283
|
+
for (const lim of [true, false]) {
|
|
284
|
+
const key = `${iname}/${tname}/v${v}/a${a}/lim${lim}`;
|
|
285
|
+
try { const act = editor.createInsertProjectItemAction(item, t, v, a, lim); out.insert[key] = act ? "ok" : "null"; } catch (e) { out.insert[key] = String(e.message || e); }
|
|
286
|
+
}
|
|
287
|
+
const key = `${iname}/${tname}/v${v}/a${a}`;
|
|
288
|
+
try { const act = editor.createOverwriteItemAction(item, t, v, a); out.overwrite[key] = act ? "ok" : "null"; } catch (e) { out.overwrite[key] = String(e.message || e); }
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
return out;
|
|
295
|
+
},
|
|
296
|
+
// What a sequence's settings object holds and offers (for an in-place resize): members and current values of
|
|
297
|
+
// getSettings(), the frame size, and whether createSetSettingsAction exists. Read-only.
|
|
298
|
+
"debug.settings_probe": async ({ timeline }) => {
|
|
299
|
+
const seq = g(timeline, "seq");
|
|
300
|
+
const st = await seq.getSettings();
|
|
301
|
+
const out = { members: P.members(st), values: {}, frame: null, has_set: P.has(seq, "createSetSettingsAction") };
|
|
302
|
+
for (const m of out.members) {
|
|
303
|
+
if (!/^get/.test(m)) continue;
|
|
304
|
+
try { const v = await st[m](); out.values[m] = v && typeof v === "object" ? { str: String(v), members: P.members(v).filter((x) => !/^__|^(constructor|hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf)$/.test(x)).slice(0, 20), w: v.width, h: v.height, value: v.value } : v; } catch (e) { out.values[m] = `error: ${e.message || e}`; }
|
|
305
|
+
}
|
|
306
|
+
try { out.frame = await seq.getFrameSize(); out.frame = { w: out.frame.width, h: out.frame.height }; } catch (_) { /* none */ }
|
|
307
|
+
return out;
|
|
308
|
+
},
|
|
309
|
+
// ProjectConverter's OTIO export, signature probed like the XML one: does it write without a modal report?
|
|
310
|
+
"timeline_write.export_otio": async ({ project, timeline, path }) => {
|
|
311
|
+
const ppro = P.api();
|
|
312
|
+
const p = project ? g(project, "project") : await activeProject();
|
|
313
|
+
const seq = timeline ? g(timeline, "seq") : await p.getActiveSequence();
|
|
314
|
+
const conv = ppro.ProjectConverter;
|
|
315
|
+
const errors = [];
|
|
316
|
+
for (const [label, fn] of [["sequence,path", () => conv.exportAsOpenTimelineIO(seq, String(path))], ["project,path,sequence", () => conv.exportAsOpenTimelineIO(p, String(path), seq)], ["project,sequence,path", () => conv.exportAsOpenTimelineIO(p, seq, String(path))]]) {
|
|
317
|
+
try { const ok = await fn(); if (ok !== false && ok !== undefined) return { ok: true, how: label, errors, path: String(path) }; errors.push(`${label}: returned ${ok}`); } catch (e) { errors.push(`${label}: ${e.message || e}`); }
|
|
318
|
+
}
|
|
319
|
+
return { ok: false, how: "", errors, path: String(path) };
|
|
320
|
+
},
|
|
321
|
+
// Try every plausible createKeyframe / createSetValueAction shape on ONE
|
|
322
|
+
// Motion param of `item` (Scale), inside a real transaction, and report
|
|
323
|
+
// which builds and which raises - so the write path uses the form Premiere
|
|
324
|
+
// actually wants. Data only; it writes Scale to itself (no net change).
|
|
325
|
+
"debug.sizing_probe": async ({ item }) => {
|
|
326
|
+
const PP = P;
|
|
327
|
+
const ppro = PP.api();
|
|
328
|
+
const it = g(item, "item");
|
|
329
|
+
const chain = await it.getComponentChain();
|
|
330
|
+
let motion = null;
|
|
331
|
+
for (let i = 0, n = await chain.getComponentCount(); i < n; i += 1) {
|
|
332
|
+
const c = await chain.getComponentAtIndex(i);
|
|
333
|
+
if (String(await c.getMatchName()).indexOf("Motion") >= 0) { motion = c; break; }
|
|
334
|
+
}
|
|
335
|
+
if (!motion) return { error: "no motion" };
|
|
336
|
+
let scale = null; let pos = null;
|
|
337
|
+
for (let j = 0, pn = await motion.getParamCount(); j < pn; j += 1) {
|
|
338
|
+
const prm = await motion.getParam(j);
|
|
339
|
+
if (String(prm.displayName) === "Scale") scale = prm;
|
|
340
|
+
if (String(prm.displayName) === "Position") pos = prm;
|
|
341
|
+
}
|
|
342
|
+
const out = { keyframe_forms: {}, setvalue_forms: {} };
|
|
343
|
+
const val = 130;
|
|
344
|
+
// createKeyframe variants
|
|
345
|
+
const tick0 = ppro.TickTime && ppro.TickTime.TIME_ZERO;
|
|
346
|
+
const kfTries = {
|
|
347
|
+
"num": () => scale.createKeyframe(val),
|
|
348
|
+
"num,tick": () => scale.createKeyframe(val, tick0),
|
|
349
|
+
"noarg": () => scale.createKeyframe(),
|
|
350
|
+
"obj_value": () => scale.createKeyframe({ value: val }),
|
|
351
|
+
};
|
|
352
|
+
let goodKf = null; let goodKfName = null;
|
|
353
|
+
for (const [name, fn] of Object.entries(kfTries)) {
|
|
354
|
+
try { const k = await fn(); out.keyframe_forms[name] = k === undefined ? "undefined" : (k && typeof k === "object" ? Object.keys(k).slice(0, 8) : String(k)); if (goodKf === null && k) { goodKf = k; goodKfName = name; } }
|
|
355
|
+
catch (e) { out.keyframe_forms[name] = "ERR " + (e.message || e); }
|
|
356
|
+
}
|
|
357
|
+
out.good_keyframe = goodKfName;
|
|
358
|
+
// createSetValueAction variants, each committed in its own transaction
|
|
359
|
+
const svTries = {
|
|
360
|
+
"value,ui": () => scale.createSetValueAction(val, true),
|
|
361
|
+
"value": () => scale.createSetValueAction(val),
|
|
362
|
+
"keyframe,ui": () => goodKf && scale.createSetValueAction(goodKf, true),
|
|
363
|
+
"keyframe": () => goodKf && scale.createSetValueAction(goodKf),
|
|
364
|
+
};
|
|
365
|
+
for (const [name, fn] of Object.entries(svTries)) {
|
|
366
|
+
try {
|
|
367
|
+
const action = await fn();
|
|
368
|
+
if (!action) { out.setvalue_forms[name] = "no-keyframe"; continue; }
|
|
369
|
+
await it.getProjectItem(); // touch, no-op
|
|
370
|
+
const proj = await PP.callAny(ppro.Project, ["getActiveProject"]);
|
|
371
|
+
let committed = false;
|
|
372
|
+
const run = () => { proj.executeTransaction((c) => c.addAction(action), "probe"); committed = true; };
|
|
373
|
+
if (PP.has(proj, "lockedAccess")) proj.lockedAccess(run); else run();
|
|
374
|
+
out.setvalue_forms[name] = committed ? "OK" : "built-not-committed";
|
|
375
|
+
} catch (e) { out.setvalue_forms[name] = "ERR " + (e.message || e); }
|
|
376
|
+
}
|
|
377
|
+
// Also whether the param itself has a direct setter
|
|
378
|
+
out.scale_members = PP.members(scale).filter((m) => /[Ss]et|[Kk]ey|[Vv]alue/.test(m));
|
|
379
|
+
return out;
|
|
380
|
+
},
|
|
381
|
+
"debug.probe": async () => {
|
|
382
|
+
const ppro = P.api();
|
|
383
|
+
const out = { host_version: P.hostVersion(), platform: P.platform(), top: Object.keys(ppro).sort(), classes: {}, constants: {} };
|
|
384
|
+
for (const k of ["TextSegments", "Properties", "Component", "VideoComponentChain", "VideoFilterFactory", "Utils", "Project", "Sequence", "VideoTrack", "VideoClipTrackItem", "TrackItem", "Markers", "Marker", "Metadata", "ClipProjectItem", "FolderItem", "ProjectItem", "ComponentChain", "Component", "ComponentParam", "Keyframe", "TickTime", "SequenceEditor", "EncoderManager", "ProjectConverter", "VideoFilterFactory", "PointF", "Media"]) {
|
|
385
|
+
if (ppro[k]) out.classes[k] = { static: P.members(ppro[k]).filter((n) => !["length", "name", "prototype"].includes(n)), proto: ppro[k].prototype ? P.members(ppro[k].prototype) : [] };
|
|
386
|
+
}
|
|
387
|
+
if (ppro.Constants) for (const k of Object.keys(ppro.Constants)) { try { out.constants[k] = ppro.Constants[k]; } catch (_) { /* skip */ } }
|
|
388
|
+
try {
|
|
389
|
+
const p = await activeProject();
|
|
390
|
+
if (p) {
|
|
391
|
+
out.project = { members: P.members(p), name: p.name, path: p.path };
|
|
392
|
+
const seq = P.has(p, "getActiveSequence") ? await p.getActiveSequence() : null;
|
|
393
|
+
if (seq) {
|
|
394
|
+
out.sequence = { members: P.members(seq), name: seq.name, timebase: String(await seq.getTimebase()) };
|
|
395
|
+
const track = P.has(seq, "getVideoTrack") ? await seq.getVideoTrack(0) : null;
|
|
396
|
+
if (track) {
|
|
397
|
+
out.track = { members: P.members(track) };
|
|
398
|
+
const items = await track.getTrackItems(ppro.Constants && ppro.Constants.TrackItemType ? ppro.Constants.TrackItemType.CLIP : 1, false);
|
|
399
|
+
// Every clip's raw numbers, as Premiere hands them out (ticks and
|
|
400
|
+
// seconds): what the model's frame maths is built on.
|
|
401
|
+
const tickOf = (v) => (v && typeof v === "object" ? { ticks: String(v.ticks !== undefined ? v.ticks : ""), seconds: Number(v.seconds !== undefined ? v.seconds : NaN) } : v);
|
|
402
|
+
out.items_raw = [];
|
|
403
|
+
for (const it of items || []) {
|
|
404
|
+
const row = {};
|
|
405
|
+
for (const m of ["getStartTime", "getEndTime", "getInPoint", "getOutPoint", "getDuration", "getSpeed", "isSpeedReversed", "isDisabled", "getName"]) {
|
|
406
|
+
try { row[m] = P.has(it, m) ? tickOf(await it[m]()) : "n/a"; } catch (e) { row[m] = `error: ${e.message || e}`; }
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
const chain = P.has(it, "getComponentChain") ? await it.getComponentChain() : null;
|
|
410
|
+
const n = chain ? await chain.getComponentCount() : 0;
|
|
411
|
+
row.params = [];
|
|
412
|
+
for (let i = 0; i < n; i += 1) {
|
|
413
|
+
const c = await chain.getComponentAtIndex(i);
|
|
414
|
+
const pn = P.has(c, "getParamCount") ? await c.getParamCount() : 0;
|
|
415
|
+
for (let j = 0; j < pn; j += 1) {
|
|
416
|
+
const prm = await c.getParam(j);
|
|
417
|
+
let v = null;
|
|
418
|
+
try { v = P.has(prm, "getStartValue") ? await prm.getStartValue() : null; } catch (e) { v = `error: ${e.message || e}`; }
|
|
419
|
+
const val = v && typeof v === "object" ? { keys: Object.keys(v), value: v.value !== undefined ? (v.value && typeof v.value === "object" ? { x: v.value.x, y: v.value.y, keys: Object.keys(v.value) } : v.value) : undefined, x: v.x, y: v.y } : v;
|
|
420
|
+
let varying = null;
|
|
421
|
+
try { varying = P.has(prm, "isTimeVarying") ? await prm.isTimeVarying() : null; } catch (_) { varying = null; }
|
|
422
|
+
row.params.push({ component: P.has(c, "getDisplayName") ? await c.getDisplayName() : "", index: j, name: prm.displayName, start_value: val, time_varying: varying });
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
} catch (e) { row.params_error = String(e.message || e); }
|
|
426
|
+
out.items_raw.push(row);
|
|
427
|
+
}
|
|
428
|
+
if (items && items[0]) {
|
|
429
|
+
const it = items[0];
|
|
430
|
+
out.item = { members: P.members(it) };
|
|
431
|
+
const chain = P.has(it, "getComponentChain") ? await it.getComponentChain() : null;
|
|
432
|
+
if (chain) {
|
|
433
|
+
const n = await chain.getComponentCount();
|
|
434
|
+
out.components = [];
|
|
435
|
+
for (let i = 0; i < n; i += 1) {
|
|
436
|
+
const c = await chain.getComponentAtIndex(i);
|
|
437
|
+
const pn = P.has(c, "getParamCount") ? await c.getParamCount() : 0;
|
|
438
|
+
const params = [];
|
|
439
|
+
for (let j = 0; j < pn; j += 1) { const prm = await c.getParam(j); params.push({ index: j, displayName: prm.displayName, members: P.members(prm).slice(0, 40) }); }
|
|
440
|
+
out.components.push({ match: P.has(c, "getMatchName") ? await c.getMatchName() : "", display: P.has(c, "getDisplayName") ? await c.getDisplayName() : "", params });
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
} catch (e) { out.probe_error = String(e && e.message || e); }
|
|
448
|
+
return out;
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
module.exports = { verbs };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// The wire protocol, plugin side (docs/INTERNAL_HOST_BRIDGE.md, protocol 1).
|
|
2
|
+
//
|
|
3
|
+
// The app hosts a loopback WebSocket; this panel is the CLIENT (a UXP panel
|
|
4
|
+
// cannot listen). First frame out is `hello` with the pairing token; the app
|
|
5
|
+
// answers `welcome`. After that the app sends `request`s and we answer
|
|
6
|
+
// `response`s. We never send a request: there is no message that makes the
|
|
7
|
+
// app run anything.
|
|
8
|
+
//
|
|
9
|
+
// Pure: the WebSocket constructor and the verb table are injected, so the
|
|
10
|
+
// node tests drive this file without Premiere or a socket.
|
|
11
|
+
"use strict";
|
|
12
|
+
|
|
13
|
+
const { PeerError } = require("./handles");
|
|
14
|
+
|
|
15
|
+
const PROTOCOL_VERSION = 1;
|
|
16
|
+
const RECONNECT_MS = [500, 1000, 2000, 4000, 8000, 15000];
|
|
17
|
+
|
|
18
|
+
class BridgeClient {
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} opts
|
|
21
|
+
* @param {(url:string)=>WebSocket} opts.makeSocket
|
|
22
|
+
* @param {()=>Promise<{url:string,token:string}|null>} opts.readPairing
|
|
23
|
+
* @param {{id:string,name:string,version:string,platform:string}} opts.host
|
|
24
|
+
* @param {string[]} opts.capabilities
|
|
25
|
+
* @param {string[]} [opts.optionalVerbs]
|
|
26
|
+
* @param {Record<string,(params:object)=>Promise<any>|any>} opts.verbs "cap.verb" -> fn
|
|
27
|
+
* @param {(line:string)=>void} [opts.log]
|
|
28
|
+
* @param {(state:string, detail?:string)=>void} [opts.onState]
|
|
29
|
+
* @param {(fn:Function, ms:number)=>any} [opts.setTimeout]
|
|
30
|
+
*/
|
|
31
|
+
constructor(opts) {
|
|
32
|
+
this.o = opts;
|
|
33
|
+
this.ws = null;
|
|
34
|
+
this.state = "idle";
|
|
35
|
+
this.attempt = 0;
|
|
36
|
+
this._stopped = false;
|
|
37
|
+
this._timer = null;
|
|
38
|
+
this._setTimeout = opts.setTimeout || ((fn, ms) => setTimeout(fn, ms));
|
|
39
|
+
this._clearTimeout = opts.clearTimeout || ((t) => clearTimeout(t));
|
|
40
|
+
this.inflight = 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
log(line) { if (this.o.log) this.o.log(line); }
|
|
44
|
+
setState(s, detail) { this.state = s; if (this.o.onState) this.o.onState(s, detail || ""); }
|
|
45
|
+
|
|
46
|
+
start() {
|
|
47
|
+
this._stopped = false;
|
|
48
|
+
this.attempt = 0;
|
|
49
|
+
return this.connect();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
stop() {
|
|
53
|
+
this._stopped = true;
|
|
54
|
+
if (this._timer) { this._clearTimeout(this._timer); this._timer = null; }
|
|
55
|
+
if (this.ws) { try { this.ws.close(); } catch (_) { /* closing */ } this.ws = null; }
|
|
56
|
+
this.setState("stopped");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async connect() {
|
|
60
|
+
if (this._stopped) return;
|
|
61
|
+
let pairing = null;
|
|
62
|
+
try { pairing = await this.o.readPairing(); } catch (e) { this.log(`pairing: ${e.message || e}`); }
|
|
63
|
+
if (!pairing || !pairing.url || !pairing.token) {
|
|
64
|
+
this.setState("unpaired", "no pairing file - enable the host bridge in conform.tools");
|
|
65
|
+
return this.scheduleReconnect();
|
|
66
|
+
}
|
|
67
|
+
// The pairing names 127.0.0.1; UXP matches the manifest's network
|
|
68
|
+
// domains by string, so the same loopback is also tried as `localhost`
|
|
69
|
+
// (both are listed) - alternating per attempt.
|
|
70
|
+
const url = this.attempt % 2 === 1 ? pairing.url.replace("ws://127.0.0.1:", "ws://localhost:") : pairing.url;
|
|
71
|
+
this.setState("connecting", url);
|
|
72
|
+
let ws;
|
|
73
|
+
try {
|
|
74
|
+
ws = this.o.makeSocket(url);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
// UXP raises here when the manifest permission has not been granted yet
|
|
77
|
+
// (seen on cold start of an installed .ccx); a reconnect fixes it.
|
|
78
|
+
this.log(`socket: ${e.message || e}`);
|
|
79
|
+
return this.scheduleReconnect();
|
|
80
|
+
}
|
|
81
|
+
this.ws = ws;
|
|
82
|
+
ws.onopen = () => {
|
|
83
|
+
this.attempt = 0;
|
|
84
|
+
const hello = {
|
|
85
|
+
type: "hello", protocol: PROTOCOL_VERSION, token: pairing.token,
|
|
86
|
+
host: this.o.host, capabilities: this.o.capabilities, optional_verbs: this.o.optionalVerbs || [],
|
|
87
|
+
};
|
|
88
|
+
this.send(hello);
|
|
89
|
+
this.setState("hello");
|
|
90
|
+
};
|
|
91
|
+
ws.onmessage = (ev) => { this.onFrame(typeof ev === "string" ? ev : ev.data); };
|
|
92
|
+
ws.onerror = (ev) => { this.log(`socket error${ev && ev.message ? ": " + ev.message : ""}`); };
|
|
93
|
+
ws.onclose = (ev) => {
|
|
94
|
+
const wasConnected = this.state === "connected";
|
|
95
|
+
this.ws = null;
|
|
96
|
+
this.setState("closed", ev && ev.code ? `code ${ev.code}` : "");
|
|
97
|
+
if (!this._stopped) this.scheduleReconnect(wasConnected);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
scheduleReconnect(fast) {
|
|
102
|
+
if (this._stopped || this._timer) return;
|
|
103
|
+
const ms = fast ? RECONNECT_MS[0] : RECONNECT_MS[Math.min(this.attempt, RECONNECT_MS.length - 1)];
|
|
104
|
+
this.attempt += 1;
|
|
105
|
+
this._timer = this._setTimeout(() => { this._timer = null; this.connect(); }, ms);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
send(obj) {
|
|
109
|
+
if (!this.ws) return false;
|
|
110
|
+
try { this.ws.send(JSON.stringify(obj)); return true; } catch (e) { this.log(`send: ${e.message || e}`); return false; }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** One text frame from the app. Never throws; a bad frame is logged. */
|
|
114
|
+
async onFrame(text) {
|
|
115
|
+
let msg;
|
|
116
|
+
try { msg = JSON.parse(text); } catch (_) { this.log("bad frame (not JSON)"); return; }
|
|
117
|
+
if (!msg || typeof msg !== "object") return;
|
|
118
|
+
switch (msg.type) {
|
|
119
|
+
case "welcome":
|
|
120
|
+
this.app = msg.app || {};
|
|
121
|
+
this.setState("connected", `${this.app.name || "app"} ${this.app.version || ""}`.trim());
|
|
122
|
+
return;
|
|
123
|
+
case "error":
|
|
124
|
+
this.log(`app refused: ${msg.code || "error"}${msg.message ? " - " + msg.message : ""}`);
|
|
125
|
+
this.setState("refused", msg.code || "error");
|
|
126
|
+
if (msg.code === "bad_token" || msg.code === "protocol_mismatch") {
|
|
127
|
+
// A stale pairing file: re-read it next time rather than hammering.
|
|
128
|
+
this.attempt = Math.max(this.attempt, 3);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
case "request":
|
|
132
|
+
return this.onRequest(msg);
|
|
133
|
+
default:
|
|
134
|
+
this.log(`unexpected frame type ${msg.type}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async onRequest(msg) {
|
|
139
|
+
const id = msg.id;
|
|
140
|
+
const method = String(msg.method || "");
|
|
141
|
+
const fn = this.o.verbs[method];
|
|
142
|
+
if (!fn) {
|
|
143
|
+
const cap = method.split(".")[0];
|
|
144
|
+
const code = this.o.capabilities.includes(cap) ? "unknown_method" : "capability_missing";
|
|
145
|
+
return this.send({ type: "response", id, ok: false, error: { code, message: method } });
|
|
146
|
+
}
|
|
147
|
+
this.inflight += 1;
|
|
148
|
+
try {
|
|
149
|
+
const result = await fn(msg.params || {});
|
|
150
|
+
this.send({ type: "response", id, ok: true, result: result === undefined ? null : result });
|
|
151
|
+
} catch (e) {
|
|
152
|
+
const code = (e && e.code) || "peer_error";
|
|
153
|
+
const message = (e && e.message) || String(e);
|
|
154
|
+
this.log(`${method}: ${message}`);
|
|
155
|
+
this.send({ type: "response", id, ok: false, error: { code, message } });
|
|
156
|
+
} finally {
|
|
157
|
+
this.inflight -= 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** A peer may push an event; it is inert JSON on the app side. */
|
|
162
|
+
event(name, data) { this.send({ type: "event", name, data: data || {} }); }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
module.exports = { BridgeClient, PROTOCOL_VERSION, RECONNECT_MS, PeerError };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// `render`: Adobe Media Encoder through EncoderManager. The app has no
|
|
2
|
+
// `render` interface yet (reserved); these verbs exist so the Marker Batch
|
|
3
|
+
// Renderer can move when it is wanted, and for the live proof.
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const { g, projectOf, PeerError, P } = require("./ctx");
|
|
7
|
+
|
|
8
|
+
const progress = { jobs: {} };
|
|
9
|
+
|
|
10
|
+
async function manager() {
|
|
11
|
+
const ppro = P.api();
|
|
12
|
+
const EM = ppro.EncoderManager;
|
|
13
|
+
if (!EM) throw new PeerError("api_missing", "EncoderManager is not in this Premiere");
|
|
14
|
+
const m = await P.callAny(EM, ["getManager"]);
|
|
15
|
+
const target = m && P.has(m, "addEventListener") ? m : P.has(EM, "addEventListener") ? EM : null;
|
|
16
|
+
if (target && manager._wired !== target) {
|
|
17
|
+
manager._wired = target;
|
|
18
|
+
// The DOM's events are EncoderManager's EVENT_RENDER_* constants (probe.json, 26.2); older builds used onEncode*.
|
|
19
|
+
const named = ["PROGRESS", "COMPLETE", "ERROR", "CANCEL", "QUEUE"].filter((k) => EM["EVENT_RENDER_" + k] !== undefined).map((k) => [k.toLowerCase(), EM["EVENT_RENDER_" + k]]);
|
|
20
|
+
const evs = named.length ? named : [["progress", "onEncodeProgress"], ["complete", "onEncodeComplete"], ["error", "onEncodeError"]];
|
|
21
|
+
for (const [label, ev] of evs) {
|
|
22
|
+
try { target.addEventListener(ev, (e) => { progress.jobs[String((e && e.jobId) || "last")] = { event: label, data: e && e.progress !== undefined ? e.progress : (e && e.status) }; }); } catch (_) { /* not this build */ }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return m;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const verbs = {
|
|
29
|
+
"render.ame_installed": async () => { try { return !!(await P.callAny(await manager(), ["isAMEInstalled"])); } catch (_) { return false; } },
|
|
30
|
+
// {timeline, output_path, preset_path, queue: bool}
|
|
31
|
+
"render.export_sequence": async ({ timeline, output_path, preset_path, queue }) => {
|
|
32
|
+
const ppro = P.api();
|
|
33
|
+
const seq = g(timeline, "seq");
|
|
34
|
+
const m = await manager();
|
|
35
|
+
// the export types are EncoderManager's own constants (EXPORT_QUEUE_TO_AME, EXPORT_IMMEDIATELY); Constants.ExportType on older builds
|
|
36
|
+
const EM = ppro.EncoderManager, types = ppro.Constants && ppro.Constants.ExportType ? ppro.Constants.ExportType : {};
|
|
37
|
+
const pick = (a, b, n) => (EM[a] !== undefined ? EM[a] : types[b] !== undefined ? types[b] : n);
|
|
38
|
+
const type = queue ? pick("EXPORT_QUEUE_TO_AME", "QUEUE_TO_AME", 1) : pick("EXPORT_IMMEDIATELY", "IMMEDIATELY", 0);
|
|
39
|
+
const job = await P.callAny(m, ["exportSequence"], seq, type, String(output_path), String(preset_path || ""));
|
|
40
|
+
return { ok: job !== false, job: job && typeof job === "object" ? String(job.jobId || job.id || "") : String(job || "") };
|
|
41
|
+
},
|
|
42
|
+
"render.progress": async () => progress.jobs,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = { verbs };
|