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.
Files changed (149) hide show
  1. package/README.md +18 -13
  2. package/dist/account-DJTD3KYK.js +3 -0
  3. package/dist/arriraw-YIJ3BYNN.js +525 -0
  4. package/dist/avid-panel/MANIFEST.json +11 -0
  5. package/dist/avid-panel/avid-manifest.json +46 -0
  6. package/dist/avid-panel/icon.svg +4 -0
  7. package/dist/avid-panel/icons/conformtools.svg +4 -0
  8. package/dist/avid-panel/index.html +26 -0
  9. package/dist/avid-panel/panel.css +12 -0
  10. package/dist/avid-panel/panel.js +7 -0
  11. package/dist/bridge-JQF4V3V2.js +3 -0
  12. package/dist/browser/timeline_core_bg.wasm +0 -0
  13. package/dist/chunk-2BPR6LK6.js +3 -0
  14. package/dist/chunk-3D3Z4TBR.js +3 -0
  15. package/dist/chunk-55BKURYP.js +378 -0
  16. package/dist/chunk-5WEZRGXG.js +39 -0
  17. package/dist/chunk-6V4OEOOX.js +3 -0
  18. package/dist/chunk-7D7H6VFW.js +3 -0
  19. package/dist/chunk-A7FNR3T5.js +3 -0
  20. package/dist/chunk-AACY2V3L.js +3 -0
  21. package/dist/chunk-AMRJXYL4.js +3 -0
  22. package/dist/chunk-C2ESM27Z.js +3 -0
  23. package/dist/chunk-D4WPRRBT.js +3 -0
  24. package/dist/chunk-D6YDLKSA.js +3 -0
  25. package/dist/chunk-DKGGJM6Z.js +3 -0
  26. package/dist/chunk-EUBXH67N.js +7 -0
  27. package/dist/chunk-GK4YYKJ6.js +19 -0
  28. package/dist/chunk-GM6QKY7W.js +3 -0
  29. package/dist/chunk-J2JXLEAI.js +3 -0
  30. package/dist/chunk-JV7TZDKJ.js +3 -0
  31. package/dist/chunk-NAFLOZER.js +9 -0
  32. package/dist/chunk-NFJHWZJX.js +3 -0
  33. package/dist/chunk-NU3X7P4N.js +3 -0
  34. package/dist/chunk-P2LL3JMC.js +20 -0
  35. package/dist/chunk-PFISREY4.js +3 -0
  36. package/dist/chunk-PFZVET7S.js +3 -0
  37. package/dist/chunk-PHAMF4JF.js +4 -0
  38. package/dist/chunk-PLRB2YXJ.js +3 -0
  39. package/dist/chunk-PSANHDZM.js +3 -0
  40. package/dist/chunk-RGMTLNMF.js +3 -0
  41. package/dist/chunk-RJ6JA2LZ.js +3 -0
  42. package/dist/chunk-S5JDS5PQ.js +5 -0
  43. package/dist/chunk-SGLQY53R.js +3 -0
  44. package/dist/chunk-SKFMOLUO.js +8 -0
  45. package/dist/chunk-SNTAZJ5A.js +6 -0
  46. package/dist/chunk-TK55FA56.js +3 -0
  47. package/dist/chunk-TXQR2HI2.js +4 -0
  48. package/dist/chunk-VIBEEWPC.js +10 -0
  49. package/dist/chunk-WN53ARHJ.js +3 -0
  50. package/dist/chunk-XLEINKFL.js +5 -0
  51. package/dist/claude-setup-IIWUB4CE.js +5 -0
  52. package/dist/cli.js +17 -0
  53. package/dist/clip-state-B6JOX3JE.js +3 -0
  54. package/dist/conformtools-analyze +0 -0
  55. package/dist/conformtools-decode +0 -0
  56. package/dist/cr3-wasm-HLJWEV2S.js +3 -0
  57. package/dist/dng-wasm-CQDLPM5V.js +3 -0
  58. package/dist/dpx-wasm-TLGMM7BO.js +3 -0
  59. package/dist/engine-P6H5P6HP.js +5 -0
  60. package/dist/esm-SFFBP7PS.js +3 -0
  61. package/dist/exr-wasm-2NPKPTVB.js +3 -0
  62. package/dist/flame/hook/conformtools_flame/__init__.py +10 -0
  63. package/dist/flame/hook/conformtools_flame/building.py +191 -0
  64. package/dist/flame/hook/conformtools_flame/hook.py +177 -0
  65. package/dist/flame/hook/conformtools_flame/render.py +622 -0
  66. package/dist/flame/hook/conformtools_flame/util.py +33 -0
  67. package/dist/flame/hook/conformtools_flame/verbs.py +1037 -0
  68. package/dist/flame/hook/conformtools_flame_hook.py +42 -0
  69. package/dist/fonts/gfx/BarlowCondensed-Bold.ttf +0 -0
  70. package/dist/fonts/gfx/BarlowCondensed-Regular.ttf +0 -0
  71. package/dist/fonts/gfx/InstrumentSerif-Regular.ttf +0 -0
  72. package/dist/fonts/gfx/Inter-Bold.ttf +0 -0
  73. package/dist/fonts/gfx/Inter-Regular.ttf +0 -0
  74. package/dist/fonts/gfx/JetBrainsMono-Bold.ttf +0 -0
  75. package/dist/fonts/gfx/JetBrainsMono-Regular.ttf +0 -0
  76. package/dist/fonts/gfx/OFL.txt +100 -0
  77. package/dist/framing-SWOD4CWB.js +3 -0
  78. package/dist/gfx-worker.js +3 -0
  79. package/dist/h264-JJMZSUWW.js +3 -0
  80. package/dist/h264-mxf-DCUOGLDU.js +3 -0
  81. package/dist/host-relink-TWAF6WIG.js +10 -0
  82. package/dist/hosts-Z666EF7V.js +3 -0
  83. package/dist/http.js +5 -0
  84. package/dist/i2o-transfer +0 -0
  85. package/dist/inspect-FJKYPEXL.js +68 -0
  86. package/dist/isobmff-VJOWP4MH.js +3 -0
  87. package/dist/mc-video-5MGGOQN4.js +3 -0
  88. package/dist/mcp.js +13 -0
  89. package/dist/media-NZYVREUF.js +3 -0
  90. package/dist/media_core-YZ3PABEG.js +9 -0
  91. package/dist/media_core_bg-FDL7GJZP.js +3 -0
  92. package/dist/media_core_bg-XRBVKQZH.js +3 -0
  93. package/dist/mxf-FJSRFLJC.js +3 -0
  94. package/dist/nuke/panel/python/Startup/conformtools_nuke_startup.py +44 -0
  95. package/dist/nuke/panel/python/conformtools_nuke/__init__.py +10 -0
  96. package/dist/nuke/panel/python/conformtools_nuke/panel.py +217 -0
  97. package/dist/nuke/panel/python/conformtools_nuke/verbs.py +837 -0
  98. package/dist/ops-X7NAREC4.js +3 -0
  99. package/dist/peer-kit/ctpeer/__init__.py +21 -0
  100. package/dist/peer-kit/ctpeer/client.py +247 -0
  101. package/dist/peer-kit/ctpeer/neutral.py +178 -0
  102. package/dist/peer-kit/ctpeer/pairing.py +139 -0
  103. package/dist/peer-kit/ctpeer/protocol.py +209 -0
  104. package/dist/peer-kit/ctpeer/websocket.py +289 -0
  105. package/dist/premiere-uxp/icons/panel.png +0 -0
  106. package/dist/premiere-uxp/icons/panel@2x.png +0 -0
  107. package/dist/premiere-uxp/icons/plugin.png +0 -0
  108. package/dist/premiere-uxp/icons/plugin@2x.png +0 -0
  109. package/dist/premiere-uxp/index.html +38 -0
  110. package/dist/premiere-uxp/index.js +93 -0
  111. package/dist/premiere-uxp/lib/clipmeta.js +170 -0
  112. package/dist/premiere-uxp/lib/ctx.js +68 -0
  113. package/dist/premiere-uxp/lib/edit.js +516 -0
  114. package/dist/premiere-uxp/lib/handles.js +57 -0
  115. package/dist/premiere-uxp/lib/markers.js +198 -0
  116. package/dist/premiere-uxp/lib/pairing.js +67 -0
  117. package/dist/premiere-uxp/lib/premiere.js +91 -0
  118. package/dist/premiere-uxp/lib/probe.js +452 -0
  119. package/dist/premiere-uxp/lib/protocol.js +165 -0
  120. package/dist/premiere-uxp/lib/render.js +45 -0
  121. package/dist/premiere-uxp/lib/session.js +85 -0
  122. package/dist/premiere-uxp/lib/sizing.js +325 -0
  123. package/dist/premiere-uxp/lib/time.js +88 -0
  124. package/dist/premiere-uxp/lib/timeline.js +336 -0
  125. package/dist/premiere-uxp/lib/verbs.js +21 -0
  126. package/dist/premiere-uxp/lib/write.js +97 -0
  127. package/dist/premiere-uxp/manifest.json +102 -0
  128. package/dist/probe-F7WQHMIA.js +3 -0
  129. package/dist/prores-RIG37OIH.js +526 -0
  130. package/dist/r3d-CXUNG6VS.js +1025 -0
  131. package/dist/r3d-T5O6IIZZ.js +3 -0
  132. package/dist/resolve-bridge.py +2286 -0
  133. package/dist/resolve-presets/conform.tools.xml +127 -0
  134. package/dist/source-QGWWLMME.js +3 -0
  135. package/dist/statusline-GMMCFMOA.js +4 -0
  136. package/dist/statusline.js +3 -0
  137. package/dist/still-P4JJNTEO.js +3 -0
  138. package/dist/still-wasm-DN5LPASS.js +3 -0
  139. package/dist/store-7IOEBOZY.js +3 -0
  140. package/dist/tiff-wasm-BPRDR6EB.js +3 -0
  141. package/dist/timeline-DQG6TVPF.js +3 -0
  142. package/dist/timeline_core-IOENXK4Z.js +3 -0
  143. package/dist/timeline_core_bg-JW42YM3G.js +3 -0
  144. package/dist/udf_bg-B37GKRIH.js +3 -0
  145. package/dist/wasm/media_core_bg.wasm +0 -0
  146. package/dist/wasm/udf_bg.wasm +0 -0
  147. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  148. package/dist/wav-64SC6P7U.js +3 -0
  149. package/package.json +6 -4
@@ -0,0 +1,85 @@
1
+ // `session`: the open project and its sequences.
2
+ "use strict";
3
+
4
+ const { handles, h, g, transact, activeProject, projectOf, PeerError, P } = require("./ctx");
5
+
6
+ async function sequencesOf(project) {
7
+ const seqs = await P.callAny(project, ["getSequences"]);
8
+ return Array.isArray(seqs) ? seqs : [];
9
+ }
10
+
11
+ function nameOf(obj) {
12
+ if (!obj) return "";
13
+ if (typeof obj.name === "string") return obj.name;
14
+ if (typeof obj.getName === "function") return obj.getName();
15
+ return "";
16
+ }
17
+
18
+ const verbs = {
19
+ "session.current_project": async () => {
20
+ const p = await activeProject();
21
+ return p ? h("project", p) : null;
22
+ },
23
+ "session.current_timeline": async ({ project }) => {
24
+ const p = await projectOf(project);
25
+ if (!p) return null;
26
+ const seq = await P.callAny(p, ["getActiveSequence"]);
27
+ return seq ? h("seq", seq) : null;
28
+ },
29
+ "session.timeline_count": async ({ project }) => {
30
+ const p = await projectOf(project);
31
+ return p ? (await sequencesOf(p)).length : 0;
32
+ },
33
+ "session.timeline_by_index": async ({ project, index }) => {
34
+ const p = await projectOf(project);
35
+ if (!p) return null;
36
+ const seqs = await sequencesOf(p);
37
+ const seq = seqs[Number(index) - 1];
38
+ return seq ? h("seq", seq) : null;
39
+ },
40
+ "session.set_current_timeline": async ({ project, timeline }) => {
41
+ const p = await projectOf(project);
42
+ const seq = g(timeline, "seq");
43
+ const ok = await P.callAny(p, ["setActiveSequence"], seq);
44
+ return ok !== false;
45
+ },
46
+ "session.name": async ({ handle }) => {
47
+ const obj = g(handle);
48
+ const n = nameOf(obj);
49
+ if (n) return n;
50
+ // A track item names itself after its project item.
51
+ if (P.has(obj, "getProjectItem")) {
52
+ const pi = await obj.getProjectItem();
53
+ return nameOf(pi);
54
+ }
55
+ return "";
56
+ },
57
+ "session.set_name": async ({ handle, name }) => {
58
+ const obj = g(handle);
59
+ const kind = handles.kindOf(handle);
60
+ const project = await activeProject();
61
+ if (!project) throw new PeerError("no_project", "No project open");
62
+ if (kind === "project") throw new PeerError("refused", "a project is renamed on disk, not here");
63
+ const n = await transact(project, `Rename to "${name}"`, async (add) => {
64
+ add(() => P.callAnySync(obj, ["createSetNameAction"], String(name)));
65
+ });
66
+ return n > 0;
67
+ },
68
+ "session.unique_id": async ({ handle }) => {
69
+ const obj = g(handle);
70
+ if (typeof obj.guid === "string") return obj.guid;
71
+ if (typeof obj.guid === "object" && obj.guid && typeof obj.guid.toString === "function") return String(obj.guid);
72
+ if (P.has(obj, "getGuid")) return String(await obj.getGuid());
73
+ if (typeof obj.nodeId === "string") return obj.nodeId;
74
+ return handle["$h"];
75
+ },
76
+ "session.describe": async () => {
77
+ const p = await activeProject();
78
+ if (!p) return { project: "", timelines: [], current: "" };
79
+ const seqs = await sequencesOf(p);
80
+ const cur = await P.callAny(p, ["getActiveSequence"]);
81
+ return { project: nameOf(p), timelines: seqs.map(nameOf), current: cur ? nameOf(cur) : "" };
82
+ },
83
+ };
84
+
85
+ module.exports = { verbs, sequencesOf, nameOf };
@@ -0,0 +1,325 @@
1
+ // `sizing`: a clip's Motion + Opacity, read and written through the component
2
+ // chain. Parameter ORDER and UNITS are undocumented; the table below is the
3
+ // ExtendScript order Adobe never changed, verified live on 26.2 (see
4
+ // docs/INTERNAL_HOST_BRIDGE.md, Premiere section) - `findParam` matches by
5
+ // display name first and falls back to the index, so a reordering cannot
6
+ // silently write the wrong control.
7
+ //
8
+ // Units, Premiere's own:
9
+ // Position PointF, FRACTION of the sequence frame, (0.5, 0.5) = centred,
10
+ // y grows DOWN
11
+ // Scale percent (100 = 1:1); Scale Width applies when Uniform Scale is off
12
+ // Rotation degrees, clockwise positive
13
+ // Anchor PointF, fraction of the CLIP frame, (0.5, 0.5) = centre
14
+ // Opacity percent
15
+ // The neutral pose (Resolve's names) is pixels of the sequence frame, tilt
16
+ // UP-positive, zoom a factor, rotation counter-clockwise positive - exactly
17
+ // `editlist.ir_sizing`, so a Premiere side compares with a file side.
18
+ "use strict";
19
+
20
+ const { h, g, transact, activeProject, PeerError, P } = require("./ctx");
21
+ const S = { _sizingSetForm: null };
22
+ const T = require("./time");
23
+ const isThen = (x) => !!x && typeof x.then === "function";
24
+
25
+ const MOTION = { matchNames: ["AE.ADBE Motion", "ADBE Motion"], display: ["Motion"] };
26
+ const OPACITY = { matchNames: ["AE.ADBE Opacity", "ADBE Opacity"], display: ["Opacity"] };
27
+ const MOTION_PARAMS = { position: ["Position", 0], scale: ["Scale", 1], scale_width: ["Scale Width", 2], uniform: ["Uniform Scale", 3], rotation: ["Rotation", 4], anchor: ["Anchor Point", 5] };
28
+ const OPACITY_PARAMS = { opacity: ["Opacity", 0], blend: ["Blend Mode", 1] };
29
+ const TIME_REMAP = ["AE.ADBE Time Remapping", "ADBE Time Remapping"];
30
+
31
+ async function chainOf(item) {
32
+ return P.callAny(item, ["getComponentChain"]);
33
+ }
34
+
35
+ async function componentsOf(chain) {
36
+ const n = await P.callAny(chain, ["getComponentCount"]);
37
+ const out = [];
38
+ for (let i = 0; i < Number(n || 0); i += 1) out.push(await P.callAny(chain, ["getComponentAtIndex"], i));
39
+ return out;
40
+ }
41
+
42
+ async function matchName(c) {
43
+ try { return String(await P.callAny(c, ["getMatchName"])); } catch (_) { return ""; }
44
+ }
45
+ async function displayName(c) {
46
+ try { return String(await P.callAny(c, ["getDisplayName"])); } catch (_) { return c.displayName || ""; }
47
+ }
48
+
49
+ async function findComponent(chain, spec) {
50
+ for (const c of await componentsOf(chain)) {
51
+ const mn = await matchName(c);
52
+ if (spec.matchNames.includes(mn)) return c;
53
+ const dn = await displayName(c);
54
+ if (spec.display.includes(dn)) return c;
55
+ }
56
+ return null;
57
+ }
58
+
59
+ async function paramsOf(component) {
60
+ const n = await P.callAny(component, ["getParamCount"]);
61
+ const out = [];
62
+ for (let i = 0; i < Number(n || 0); i += 1) out.push(await P.callAny(component, ["getParam"], i));
63
+ return out;
64
+ }
65
+
66
+ async function findParam(component, [display, index]) {
67
+ const params = await paramsOf(component);
68
+ for (const p of params) {
69
+ const dn = p.displayName || (P.has(p, "getDisplayName") ? await p.getDisplayName() : "");
70
+ if (String(dn) === display) return p;
71
+ }
72
+ return params[index] || null;
73
+ }
74
+
75
+ async function paramValue(param, time) {
76
+ if (!param) return null;
77
+ if (P.has(param, "getValueAtTime") && time !== undefined) return param.getValueAtTime(time);
78
+ if (P.has(param, "getStartValue")) return param.getStartValue();
79
+ if (P.has(param, "getValue")) return param.getValue();
80
+ return param.value !== undefined ? param.value : null;
81
+ }
82
+
83
+ async function isVarying(param) {
84
+ try { return !!(await P.callAny(param, ["isTimeVarying"])); } catch (_) { return false; }
85
+ }
86
+
87
+ function pt(v) {
88
+ // MEASURED 26.2: a param's start value is a Keyframe whose `.value` is the
89
+ // PointF; the PointF itself has `x` / `y`.
90
+ if (v && typeof v === "object" && v.value && typeof v.value === "object") v = v.value;
91
+ if (v && typeof v === "object") return { x: Number(v.x !== undefined ? v.x : v[0]) || 0, y: Number(v.y !== undefined ? v.y : v[1]) || 0 };
92
+ return { x: 0, y: 0 };
93
+ }
94
+ function num(v, d) { const n = Number(v && typeof v === "object" && "value" in v ? v.value : v); return Number.isFinite(n) ? n : d; }
95
+
96
+ /** Premiere's raw Motion / Opacity values at the clip's first frame. */
97
+ async function readRaw(item) {
98
+ const chain = await chainOf(item);
99
+ const out = { position: { x: 0.5, y: 0.5 }, scale: 100, scale_width: 100, uniform: true, rotation: 0, anchor: { x: 0.5, y: 0.5 }, opacity: 100, keyframed: false, variable_speed: false, has_motion: false };
100
+ const motion = await findComponent(chain, MOTION);
101
+ if (motion) {
102
+ out.has_motion = true;
103
+ const at = P.has(item, "getStartTime") ? await item.getStartTime() : undefined;
104
+ for (const [key, spec] of Object.entries(MOTION_PARAMS)) {
105
+ const p = await findParam(motion, spec);
106
+ if (!p) continue;
107
+ const v = await paramValue(p, at);
108
+ if (key === "position" || key === "anchor") out[key] = pt(v);
109
+ else if (key === "uniform") out.uniform = !!(v && typeof v === "object" && "value" in v ? v.value : v);
110
+ else out[key] = num(v, out[key]);
111
+ if (await isVarying(p)) out.keyframed = true;
112
+ }
113
+ }
114
+ const opacity = await findComponent(chain, OPACITY);
115
+ if (opacity) {
116
+ const p = await findParam(opacity, OPACITY_PARAMS.opacity);
117
+ if (p) { out.opacity = num(await paramValue(p), 100); if (await isVarying(p)) out.keyframed = true; }
118
+ }
119
+ for (const c of await componentsOf(chain)) {
120
+ if (TIME_REMAP.includes(await matchName(c))) { out.variable_speed = true; break; }
121
+ }
122
+ return out;
123
+ }
124
+
125
+ /** Neutral sizing for the model (editlist.ir_sizing's keys and units). */
126
+ function toNeutral(raw, raster) {
127
+ const w = raster && raster[0] ? raster[0] : 1920;
128
+ const hgt = raster && raster[1] ? raster[1] : 1080;
129
+ const out = {};
130
+ const px = raw.position.x - 0.5;
131
+ const py = raw.position.y - 0.5;
132
+ if (Math.abs(px) > 1e-9) out.Pan = Math.round(px * w * 1000) / 1000;
133
+ if (Math.abs(py) > 1e-9) out.Tilt = Math.round(-py * hgt * 1000) / 1000;
134
+ const sx = raw.uniform ? raw.scale : raw.scale_width;
135
+ const sy = raw.scale;
136
+ if (Math.abs(sx - 100) > 1e-6) out.ZoomX = Math.round(sx / 100 * 1e5) / 1e5;
137
+ if (Math.abs(sy - 100) > 1e-6) out.ZoomY = Math.round(sy / 100 * 1e5) / 1e5;
138
+ if (Math.abs(raw.rotation) > 1e-9) out.RotationAngle = Math.round(-raw.rotation * 1e4) / 1e4;
139
+ const ax = raw.anchor.x - 0.5;
140
+ const ay = raw.anchor.y - 0.5;
141
+ if (Math.abs(ax) > 1e-9) out.AnchorPointX = Math.round(ax * w * 1000) / 1000;
142
+ if (Math.abs(ay) > 1e-9) out.AnchorPointY = Math.round(-ay * hgt * 1000) / 1000;
143
+ if (Math.abs(raw.opacity - 100) > 1e-6) out.Opacity = Math.round(raw.opacity * 1000) / 1000;
144
+ if (raw.keyframed) out.keyframed = 1.0;
145
+ return out;
146
+ }
147
+
148
+ async function readSizingForModel(item, raster) {
149
+ try {
150
+ const raw = await readRaw(item);
151
+ return { sizing: toNeutral(raw, raster), keyframed: raw.keyframed, variable_speed: raw.variable_speed };
152
+ } catch (_) {
153
+ return { sizing: {}, keyframed: false, variable_speed: false };
154
+ }
155
+ }
156
+
157
+ /** The neutral POSE (what `align_cv.read_pose_full` returns for Resolve):
158
+ * Pan/Tilt in sequence pixels, ZoomX/ZoomY factors, RotationAngle,
159
+ * AnchorPointX/Y, FlipX/FlipY (Premiere has none on Motion), Opacity. */
160
+ async function readPose(item, raster) {
161
+ const raw = await readRaw(item);
162
+ const n = toNeutral(raw, raster);
163
+ return {
164
+ Pan: n.Pan || 0, Tilt: n.Tilt || 0, ZoomX: n.ZoomX || 1, ZoomY: n.ZoomY || 1, RotationAngle: n.RotationAngle || 0,
165
+ AnchorPointX: n.AnchorPointX || 0, AnchorPointY: n.AnchorPointY || 0, FlipX: 0, FlipY: 0, Opacity: raw.opacity,
166
+ keyframed: raw.keyframed, raw,
167
+ };
168
+ }
169
+
170
+ /** Write a pose (neutral units) as Premiere values, as ONE undo step. Only the
171
+ * keys present are written; a keyframed parameter is left alone and named. */
172
+ async function writePose(item, pose, raster, label) {
173
+ const project = await activeProject();
174
+ if (!project) throw new PeerError("no_project", "No project open");
175
+ const r = await poseActions(item, pose, raster);
176
+ const n = await transact(project, label || "conform.tools sizing", (add) => { for (const a of r.actions) add(a); });
177
+ return { actions: n, written: r.written, skipped: r.skipped };
178
+ }
179
+
180
+ /** The actions that set `pose` on `item`, not committed: edit.apply adds them to its one transaction. */
181
+ async function poseActions(item, pose, raster) {
182
+ const actions = [];
183
+ const add = (a) => { if (a) actions.push(a); };
184
+ const w = raster && raster[0] ? raster[0] : 1920;
185
+ const hgt = raster && raster[1] ? raster[1] : 1080;
186
+ const chain = await chainOf(item);
187
+ const motion = await findComponent(chain, MOTION);
188
+ if (!motion) throw new PeerError("no_motion", "this clip has no Motion effect");
189
+ const skipped = [];
190
+ const written = [];
191
+ const at = P.has(item, "getStartTime") ? await item.getStartTime() : undefined;
192
+ const raw = await readRaw(item);
193
+ await (async () => {
194
+ // MEASURED 26.2: createSetValueAction's exact signature is not documented
195
+ // and a wrong shape raises "Illegal Parameter type". Try the forms in
196
+ // order and remember the first that builds an action - a keyframe with
197
+ // updateUI, a keyframe alone, the raw value with updateUI, the raw value
198
+ // alone. `_sizingSetForm` (set once per pass) skips the probing next time.
199
+ // MEASURED 26.2 (debug.sizing_probe): createSetValueAction takes a
200
+ // KEYFRAME, not a raw value - `createSetValueAction(130)` raises "Illegal
201
+ // Parameter type", `createSetValueAction(param.createKeyframe(130))`
202
+ // commits. The keyframe is created INSIDE each try so a value shape
203
+ // createKeyframe rejects (a PointF, say) falls through instead of
204
+ // throwing before the loop. The first shape that builds is cached.
205
+ // A THUNK the transaction runs under project.lockedAccess (26.3+ makes every action there, synchronously).
206
+ // The first form that builds is cached for the rest of the pass.
207
+ const buildSetValue = (p, value) => () => {
208
+ const forms = [
209
+ ["keyframe,updateUI", () => { const k = p.createKeyframe(value); return isThen(k) ? k.then((kf) => p.createSetValueAction(kf, true)) : p.createSetValueAction(k, true); }],
210
+ ["keyframe", () => { const k = p.createKeyframe(value); return isThen(k) ? k.then((kf) => p.createSetValueAction(kf)) : p.createSetValueAction(k); }],
211
+ ["value,updateUI", () => p.createSetValueAction(value, true)],
212
+ ["value", () => p.createSetValueAction(value)],
213
+ ].filter(([name]) => P.has(p, "createKeyframe") || !name.startsWith("keyframe"));
214
+ const only = forms.filter(([name]) => !S._sizingSetForm || name === S._sizingSetForm);
215
+ const errors = [];
216
+ for (const [name, make] of (only.length ? only : forms)) {
217
+ try { const a = make(); if (a) { S._sizingSetForm = name; return a; } } catch (e) { errors.push(`${name}: ${e.message || e}`); }
218
+ }
219
+ throw new PeerError("set_value_failed", `createSetValueAction: ${errors.join("; ")}`);
220
+ };
221
+ const setValueAction = (p, value) => buildSetValue(p, value);
222
+ // the key counts as written once its action is made (under the lock, at commit); a refusal names it
223
+ const guard = (thunk, key) => { written.push(key); return () => { try { return thunk(); } catch (e) { written.splice(written.indexOf(key), 1); skipped.push(`${key} (${e.message || e})`); return null; } }; };
224
+ // One param failing does not abort the pose: the ones that write, write,
225
+ // and the rest are named. (MEASURED 26.2: scalar Motion params - Scale,
226
+ // Rotation, Opacity - write through the keyframe form; the two-axis
227
+ // params - Position, Anchor Point - reject every createKeyframe /
228
+ // createSetValueAction shape tried, so they are reported unwritten. No
229
+ // shipped tool writes sizing over the bridge yet; the Reconformer READS
230
+ // it and carries it through the engine's .prproj writer.)
231
+ const setNum = async (spec, value, key) => {
232
+ const p = await findParam(motion, spec);
233
+ if (!p) return;
234
+ if (await isVarying(p)) { skipped.push(key); return; }
235
+ add(guard(setValueAction(p, value), key));
236
+ };
237
+ const setPoint = async (spec, x, y, key) => {
238
+ const p = await findParam(motion, spec);
239
+ if (!p) return;
240
+ if (await isVarying(p)) { skipped.push(key); return; }
241
+ const ppro = P.api();
242
+ // 26.5 documents `new PointF(x, y)`; 26.2 had neither shape working (PointF.create, a plain {x, y})
243
+ let point = { x, y };
244
+ try { point = typeof ppro.PointF === "function" ? new ppro.PointF(x, y) : P.has(ppro.PointF, "create") ? ppro.PointF.create(x, y) : point; } catch (_) { try { point = ppro.PointF.create(x, y); } catch (_e) { /* plain */ } }
245
+ add(guard(setValueAction(p, point), key));
246
+ };
247
+ if (pose.Pan !== undefined || pose.Tilt !== undefined) {
248
+ const x = 0.5 + Number(pose.Pan !== undefined ? pose.Pan : (raw.position.x - 0.5) * w) / w;
249
+ const y = 0.5 - Number(pose.Tilt !== undefined ? pose.Tilt : -(raw.position.y - 0.5) * hgt) / hgt;
250
+ await setPoint(MOTION_PARAMS.position, x, y, "Pan/Tilt");
251
+ }
252
+ if (pose.ZoomX !== undefined || pose.ZoomY !== undefined) {
253
+ const zx = pose.ZoomX !== undefined ? Number(pose.ZoomX) : (raw.uniform ? raw.scale : raw.scale_width) / 100;
254
+ const zy = pose.ZoomY !== undefined ? Number(pose.ZoomY) : raw.scale / 100;
255
+ if (Math.abs(zx - zy) < 1e-6) {
256
+ await setNum(MOTION_PARAMS.uniform, true, "Uniform");
257
+ await setNum(MOTION_PARAMS.scale, zy * 100, "Zoom");
258
+ } else {
259
+ await setNum(MOTION_PARAMS.uniform, false, "Uniform");
260
+ await setNum(MOTION_PARAMS.scale, zy * 100, "ZoomY");
261
+ await setNum(MOTION_PARAMS.scale_width, zx * 100, "ZoomX");
262
+ }
263
+ }
264
+ if (pose.RotationAngle !== undefined) await setNum(MOTION_PARAMS.rotation, -Number(pose.RotationAngle), "Rotation");
265
+ if (pose.AnchorPointX !== undefined || pose.AnchorPointY !== undefined) {
266
+ const x = 0.5 + Number(pose.AnchorPointX !== undefined ? pose.AnchorPointX : (raw.anchor.x - 0.5) * w) / w;
267
+ const y = 0.5 - Number(pose.AnchorPointY !== undefined ? pose.AnchorPointY : -(raw.anchor.y - 0.5) * hgt) / hgt;
268
+ await setPoint(MOTION_PARAMS.anchor, x, y, "Anchor");
269
+ }
270
+ if (pose.Opacity !== undefined) {
271
+ const op = await findComponent(chain, OPACITY);
272
+ const p = op && await findParam(op, OPACITY_PARAMS.opacity);
273
+ if (p) {
274
+ if (await isVarying(p)) skipped.push("Opacity");
275
+ else {
276
+ add(guard(buildSetValue(p, Number(pose.Opacity)), "Opacity"));
277
+ }
278
+ }
279
+ }
280
+ if (pose.FlipX || pose.FlipY) skipped.push("Flip (Premiere's Motion has no flip; use a Transform effect)");
281
+ })();
282
+ return { actions, written, skipped };
283
+ }
284
+
285
+ async function rasterOfItemSeq() {
286
+ const project = await activeProject();
287
+ const seq = project && await P.callAny(project, ["getActiveSequence"]);
288
+ if (!seq) return [1920, 1080];
289
+ try { const fs = await P.callAny(seq, ["getFrameSize"]); return [Number(fs.width || 0) || 1920, Number(fs.height || 0) || 1080]; } catch (_) { return [1920, 1080]; }
290
+ }
291
+
292
+ const verbs = {
293
+ "sizing.read_pose": async ({ item }) => readPose(g(item, "item"), await rasterOfItemSeq()),
294
+ "sizing.restore_pose": async ({ item, pose }) => {
295
+ const r = await writePose(g(item, "item"), pose || {}, await rasterOfItemSeq(), "conform.tools restore sizing");
296
+ return r.actions > 0;
297
+ },
298
+ "sizing.apply_transform": async ({ item, transform, compose }) => {
299
+ const it = g(item, "item");
300
+ const raster = await rasterOfItemSeq();
301
+ const t = transform || {};
302
+ let pose = { ...t };
303
+ if (compose !== false) {
304
+ const cur = await readPose(it, raster);
305
+ pose = {};
306
+ if (t.Pan !== undefined) pose.Pan = cur.Pan + Number(t.Pan);
307
+ if (t.Tilt !== undefined) pose.Tilt = cur.Tilt + Number(t.Tilt);
308
+ if (t.ZoomX !== undefined) pose.ZoomX = cur.ZoomX * Number(t.ZoomX);
309
+ if (t.ZoomY !== undefined) pose.ZoomY = cur.ZoomY * Number(t.ZoomY);
310
+ if (t.RotationAngle !== undefined) pose.RotationAngle = cur.RotationAngle + Number(t.RotationAngle);
311
+ for (const k of ["AnchorPointX", "AnchorPointY", "Opacity", "FlipX", "FlipY"]) if (t[k] !== undefined) pose[k] = t[k];
312
+ }
313
+ const r = await writePose(it, pose, raster, "conform.tools align");
314
+ return { applied: r.written, skipped: r.skipped, pose: await readPose(it, raster) };
315
+ },
316
+ "sizing.units": async ({ timeline_w, timeline_h }) => {
317
+ // Pan / tilt in the neutral pose are already sequence pixels: 1 unit = 1 px.
318
+ const w = Number(timeline_w) || 1920;
319
+ const hgt = Number(timeline_h) || 1080;
320
+ return { kx: 1.0, ky: 1.0, basis: "sequence_pixels", raster: [w, hgt], position_fraction_of_frame: true };
321
+ },
322
+ "sizing.raw": async ({ item }) => readRaw(g(item, "item")),
323
+ };
324
+
325
+ module.exports = { verbs, readRaw, toNeutral, readPose, writePose, poseActions, readSizingForModel, MOTION_PARAMS, OPACITY_PARAMS, findComponent, findParam, h };
@@ -0,0 +1,88 @@
1
+ // Premiere counts time in TICKS: 254016000000 per second. A sequence's
2
+ // timebase is the tick count of one frame. The neutral model counts FRAMES at
3
+ // the sequence rate, so every conversion lives here and is tested in node.
4
+ "use strict";
5
+
6
+ const TICKS_PER_SECOND = 254016000000;
7
+
8
+ /** `ticks` may be a number, a numeric string (the API returns strings for
9
+ * large tick values) or a TickTime-like object with `ticks`/`ticksNumber`/`seconds`. */
10
+ function toTicks(v) {
11
+ if (v === null || v === undefined) return 0;
12
+ if (typeof v === "number") return v;
13
+ if (typeof v === "string") return Number(v);
14
+ if (typeof v === "object") {
15
+ if (typeof v.ticksNumber === "number") return v.ticksNumber;
16
+ if (v.ticks !== undefined) return Number(v.ticks);
17
+ if (typeof v.seconds === "number") return Math.round(v.seconds * TICKS_PER_SECOND);
18
+ }
19
+ return Number(v) || 0;
20
+ }
21
+
22
+ /** Frames per second from a sequence timebase (ticks per frame). */
23
+ function fpsFromTimebase(timebase) {
24
+ const tpf = toTicks(timebase);
25
+ return tpf > 0 ? TICKS_PER_SECOND / tpf : 0;
26
+ }
27
+
28
+ function ticksToFrames(ticks, timebase) {
29
+ const tpf = toTicks(timebase);
30
+ if (tpf <= 0) return 0;
31
+ return Math.round(toTicks(ticks) / tpf);
32
+ }
33
+
34
+ function framesToTicks(frames, timebase) {
35
+ return Math.round(Number(frames) * toTicks(timebase));
36
+ }
37
+
38
+ /** Timebase for common rates when only fps is known (tests, model_from fps). */
39
+ // MEASURED 26.5.2: Premiere reports a DJI clip's rate as its measured 29.970089…, not 30000/1001; ticks per frame
40
+ // from that put a source in-point just short of its frame, which Premiere floors — every cut-in landed 1 frame
41
+ // early. A rate within 0.01 % of a standard one is that standard rate, with Premiere's exact ticks per frame.
42
+ const STANDARD = [[24000, 1001], [24, 1], [25, 1], [30000, 1001], [30, 1], [48000, 1001], [48, 1], [50, 1], [60000, 1001], [60, 1], [120000, 1001], [120, 1]];
43
+ function timebaseFromFps(fps) {
44
+ const f = Number(fps);
45
+ for (const [n, d] of STANDARD) if (Math.abs(f - n / d) < (n / d) * 1e-4) return Math.round(TICKS_PER_SECOND * d / n);
46
+ return Math.round(TICKS_PER_SECOND / f);
47
+ }
48
+
49
+ /** HH:MM:SS:FF (or ; for drop-frame) from a frame count at `fps`. Drop-frame
50
+ * applies to 29.97 / 59.94 only when `drop` is true; Premiere's own display
51
+ * setting decides that, so callers pass it. */
52
+ function framesToTimecode(frames, fps, drop) {
53
+ const nominal = Math.round(fps);
54
+ let f = Math.max(0, Math.round(frames));
55
+ if (drop && (nominal === 30 || nominal === 60)) {
56
+ const dropPerMin = nominal === 30 ? 2 : 4;
57
+ const framesPer10 = nominal * 60 * 10 - dropPerMin * 9;
58
+ const d = Math.floor(f / framesPer10);
59
+ let m = f % framesPer10;
60
+ if (m < dropPerMin) m = m + dropPerMin;
61
+ f = f + dropPerMin * 9 * d + dropPerMin * Math.floor((m - dropPerMin) / (nominal * 60 - dropPerMin));
62
+ }
63
+ const ff = f % nominal;
64
+ const s = Math.floor(f / nominal) % 60;
65
+ const m = Math.floor(f / (nominal * 60)) % 60;
66
+ const h = Math.floor(f / (nominal * 3600));
67
+ const sep = drop ? ";" : ":";
68
+ const p = (n) => String(n).padStart(2, "0");
69
+ return `${p(h)}:${p(m)}:${p(s)}${sep}${p(ff)}`;
70
+ }
71
+
72
+ /** The inverse of framesToTimecode; accepts : or ; separators. */
73
+ function timecodeToFrames(tc, fps) {
74
+ const m = /^(\d+)[:;](\d+)[:;](\d+)[:;](\d+)$/.exec(String(tc).trim());
75
+ if (!m) throw new Error(`not a timecode: ${tc}`);
76
+ const nominal = Math.round(fps);
77
+ const [h, mi, s, f] = m.slice(1).map(Number);
78
+ const drop = tc.includes(";");
79
+ let frames = ((h * 60 + mi) * 60 + s) * nominal + f;
80
+ if (drop && (nominal === 30 || nominal === 60)) {
81
+ const dropPerMin = nominal === 30 ? 2 : 4;
82
+ const totalMinutes = h * 60 + mi;
83
+ frames -= dropPerMin * (totalMinutes - Math.floor(totalMinutes / 10));
84
+ }
85
+ return frames;
86
+ }
87
+
88
+ module.exports = { TICKS_PER_SECOND, toTicks, fpsFromTimebase, ticksToFrames, framesToTicks, timebaseFromFps, framesToTimecode, timecodeToFrames };