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,170 @@
|
|
|
1
|
+
// `clip_meta`: the project panel (bins = FolderItems, clips = ClipProjectItems)
|
|
2
|
+
// and clip properties. The neutral property names are Resolve's ("Clip Name",
|
|
3
|
+
// "File Path", "Scene", "Shot", "Take", "Comments", "Keywords", "Clip Color");
|
|
4
|
+
// Premiere keeps them in three places - the item name, the project metadata
|
|
5
|
+
// (Column.Intrinsic.*), and XMP (xmpDM:scene / shotName / takeNumber /
|
|
6
|
+
// logComment) - and the map below says which. Field names were checked
|
|
7
|
+
// against Premiere 26.2's own writes (see the internal doc).
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
const { handles, h, g, transact, activeProject, projectOf, PeerError, P } = require("./ctx");
|
|
11
|
+
|
|
12
|
+
const XMP_FIELDS = {
|
|
13
|
+
"Scene": "xmpDM:scene", "Shot": "xmpDM:shotName", "Take": "xmpDM:takeNumber", "Comments": "xmpDM:logComment",
|
|
14
|
+
"Keywords": "dc:subject", "Description": "dc:description", "Camera": "xmpDM:cameraModel", "Reel Name": "xmpDM:tapeName",
|
|
15
|
+
"Tape Name": "xmpDM:tapeName", "Good Take": "xmpDM:good",
|
|
16
|
+
};
|
|
17
|
+
const READONLY = new Set(["File Path", "Clip Name", "Start TC", "Duration", "Frame Rate"]);
|
|
18
|
+
|
|
19
|
+
async function itemsOf(folder) {
|
|
20
|
+
const items = await P.callAny(folder, ["getItems"]);
|
|
21
|
+
return Array.isArray(items) ? items : [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isFolder(item) {
|
|
25
|
+
const ppro = P.api();
|
|
26
|
+
try { if (ppro.FolderItem && P.has(ppro.FolderItem, "cast")) return !!ppro.FolderItem.cast(item); } catch (_) { /* not a folder */ }
|
|
27
|
+
return P.has(item, "getItems");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function asClip(item) {
|
|
31
|
+
const ppro = P.api();
|
|
32
|
+
try { if (ppro.ClipProjectItem && P.has(ppro.ClipProjectItem, "cast")) return ppro.ClipProjectItem.cast(item) || item; } catch (_) { /* not a clip */ }
|
|
33
|
+
return item;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function xmpGet(xml, field) {
|
|
37
|
+
const local = field.split(":")[1];
|
|
38
|
+
const m = new RegExp(`<${field}[^>]*>([\\s\\S]*?)</${field}>`).exec(xml) || new RegExp(`${field}="([^"]*)"`).exec(xml)
|
|
39
|
+
|| new RegExp(`<[^:>]*:${local}[^>]*>([\\s\\S]*?)</[^:>]*:${local}>`).exec(xml);
|
|
40
|
+
if (!m) return "";
|
|
41
|
+
// dc:subject / rdf:Bag lists -> comma-joined
|
|
42
|
+
const inner = m[1];
|
|
43
|
+
const li = Array.from(inner.matchAll(/<rdf:li[^>]*>([\s\S]*?)<\/rdf:li>/g)).map((x) => x[1].trim());
|
|
44
|
+
return li.length ? li.join(", ") : inner.trim();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function xmpSet(xml, field, value) {
|
|
48
|
+
const esc = String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
49
|
+
const re = new RegExp(`(<${field}[^>]*>)([\\s\\S]*?)(</${field}>)`);
|
|
50
|
+
if (re.test(xml)) return xml.replace(re, `$1${esc}$3`);
|
|
51
|
+
const attr = new RegExp(`(${field}=")([^"]*)(")`);
|
|
52
|
+
if (attr.test(xml)) return xml.replace(attr, `$1${esc}$3`);
|
|
53
|
+
// Insert into the first rdf:Description of the document.
|
|
54
|
+
const ins = `<${field}>${esc}</${field}>`;
|
|
55
|
+
const desc = /<rdf:Description[^>]*>/.exec(xml);
|
|
56
|
+
if (desc) return xml.slice(0, desc.index + desc[0].length) + ins + xml.slice(desc.index + desc[0].length);
|
|
57
|
+
return xml;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function xmpOf(item) {
|
|
61
|
+
const ppro = P.api();
|
|
62
|
+
if (!ppro.Metadata || !P.has(ppro.Metadata, "getXMPMetadata")) return "";
|
|
63
|
+
try { return String(await ppro.Metadata.getXMPMetadata(item) || ""); } catch (_) { return ""; }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** "Timeline" for a sequence in the project panel (the Clip Renamer skips
|
|
67
|
+
* those on the media-pool target, as it does in Resolve), else "Video". */
|
|
68
|
+
async function itemType(clip) {
|
|
69
|
+
if (!clip) return "Timeline";
|
|
70
|
+
try { if (P.has(clip, "isSequence") && await clip.isSequence()) return "Timeline"; } catch (_) { /* not a sequence */ }
|
|
71
|
+
try { if (P.has(clip, "getSequence") && await clip.getSequence()) return "Timeline"; } catch (_) { /* not a sequence */ }
|
|
72
|
+
// A Sequence object itself (the project panel hands one back where a
|
|
73
|
+
// ClipProjectItem cast fails): it has a timebase and tracks, a clip has not.
|
|
74
|
+
if (P.has(clip, "getTimebase") && P.has(clip, "getVideoTrackCount")) return "Timeline";
|
|
75
|
+
return "Video";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function clipProps(item) {
|
|
79
|
+
const clip = asClip(item);
|
|
80
|
+
const out = { "Clip Name": String(item.name || ""), "File Path": "", Type: await itemType(clip) };
|
|
81
|
+
try { out["File Path"] = String(await P.callAny(clip, ["getMediaFilePath"]) || ""); } catch (_) { /* a bin or sequence */ }
|
|
82
|
+
try { out["Clip Color"] = String(P.has(clip, "getColorLabelIndex") ? await clip.getColorLabelIndex() : ""); } catch (_) { out["Clip Color"] = ""; }
|
|
83
|
+
const xml = await xmpOf(item);
|
|
84
|
+
for (const [k, f] of Object.entries(XMP_FIELDS)) out[k] = xml ? xmpGet(xml, f) : "";
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const verbs = {
|
|
89
|
+
"clip_meta.media_pool": async ({ project }) => {
|
|
90
|
+
const p = await projectOf(project);
|
|
91
|
+
return p ? h("project", p) : null; // Premiere's pool IS the project
|
|
92
|
+
},
|
|
93
|
+
"clip_meta.root_folder": async ({ media_pool }) => {
|
|
94
|
+
const p = g(media_pool, "project");
|
|
95
|
+
const root = await P.callAny(p, ["getRootItem"]);
|
|
96
|
+
return root ? h("bin", root) : null;
|
|
97
|
+
},
|
|
98
|
+
"clip_meta.current_folder": async ({ media_pool }) => {
|
|
99
|
+
const p = g(media_pool, "project");
|
|
100
|
+
const root = await P.callAny(p, ["getRootItem"]);
|
|
101
|
+
return root ? h("bin", root) : null; // Premiere has no "current bin"; the root stands in
|
|
102
|
+
},
|
|
103
|
+
"clip_meta.subfolders": async ({ folder }) => {
|
|
104
|
+
const out = [];
|
|
105
|
+
for (const it of await itemsOf(g(folder, "bin"))) if (isFolder(it)) out.push(h("bin", it));
|
|
106
|
+
return out;
|
|
107
|
+
},
|
|
108
|
+
"clip_meta.clips": async ({ folder }) => {
|
|
109
|
+
const out = [];
|
|
110
|
+
for (const it of await itemsOf(g(folder, "bin"))) if (!isFolder(it)) out.push(h("clip", it));
|
|
111
|
+
return out;
|
|
112
|
+
},
|
|
113
|
+
"clip_meta.clip_property": async ({ clip, key }) => {
|
|
114
|
+
const item = g(clip);
|
|
115
|
+
const props = await clipProps(item);
|
|
116
|
+
if (key === null || key === undefined) return props;
|
|
117
|
+
return key in props ? props[key] : "";
|
|
118
|
+
},
|
|
119
|
+
"clip_meta.set_clip_property": async ({ clip, key, value }) => {
|
|
120
|
+
const ppro = P.api();
|
|
121
|
+
const item = g(clip);
|
|
122
|
+
const project = await activeProject();
|
|
123
|
+
if (!project) throw new PeerError("no_project", "No project open");
|
|
124
|
+
if (key === "Clip Name") {
|
|
125
|
+
const n = await transact(project, "Rename clip", async (add) => { add(() => P.callAnySync(item, ["createSetNameAction"], String(value))); });
|
|
126
|
+
return n > 0;
|
|
127
|
+
}
|
|
128
|
+
if (key === "Clip Color") {
|
|
129
|
+
const c = asClip(item);
|
|
130
|
+
const n = await transact(project, "Clip label", async (add) => { add(() => P.callAnySync(c, ["createSetColorLabelAction"], Number(value))); });
|
|
131
|
+
return n > 0;
|
|
132
|
+
}
|
|
133
|
+
if (READONLY.has(key)) return false;
|
|
134
|
+
const field = XMP_FIELDS[key];
|
|
135
|
+
if (!field) return false;
|
|
136
|
+
if (!ppro.Metadata || !P.has(ppro.Metadata, "createSetXMPMetadataAction")) return false;
|
|
137
|
+
const xml = await xmpOf(item);
|
|
138
|
+
if (!xml) return false;
|
|
139
|
+
const next = xmpSet(xml, field, value);
|
|
140
|
+
const n = await transact(project, `Set ${key}`, async (add) => { add(() => ppro.Metadata.createSetXMPMetadataAction(item, next)); });
|
|
141
|
+
return n > 0;
|
|
142
|
+
},
|
|
143
|
+
/** Several writes as ONE transaction = one undo step in Premiere. Only
|
|
144
|
+
* plain writes (Clip Name, Clip Color, an XMP field); one bool per item,
|
|
145
|
+
* in order; a read-only key is false and skipped, never a failure. */
|
|
146
|
+
"clip_meta.set_clip_properties": async ({ items }) => {
|
|
147
|
+
const ppro = P.api();
|
|
148
|
+
const project = await activeProject();
|
|
149
|
+
if (!project) throw new PeerError("no_project", "No project open");
|
|
150
|
+
const list = Array.isArray(items) ? items : [];
|
|
151
|
+
const results = new Array(list.length).fill(false);
|
|
152
|
+
const n = await transact(project, `Rename ${list.length} item(s)`, async (add) => {
|
|
153
|
+
for (let i = 0; i < list.length; i++) {
|
|
154
|
+
const { clip, key, value } = list[i] || {};
|
|
155
|
+
try {
|
|
156
|
+
const item = g(clip);
|
|
157
|
+
if (key === "Clip Name") { add(() => P.callAnySync(item, ["createSetNameAction"], String(value))); results[i] = true; }
|
|
158
|
+
else if (key === "Clip Color") { add(await P.callAny(asClip(item), ["createSetColorLabelAction"], Number(value))); results[i] = true; }
|
|
159
|
+
else if (!READONLY.has(key) && XMP_FIELDS[key]) {
|
|
160
|
+
const xml = xmpSet(await xmpOf(item), XMP_FIELDS[key], String(value));
|
|
161
|
+
add(() => P.callAnySync(ppro.Metadata, ["createSetXMPMetadataAction"], item, xml)); results[i] = true;
|
|
162
|
+
}
|
|
163
|
+
} catch (_) { results[i] = false; }
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return n > 0 ? results : results.map(() => false);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
module.exports = { verbs, XMP_FIELDS, xmpGet, xmpSet, clipProps, h, isFolderItem: isFolder };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Shared plumbing for the capability modules: the handle registry, the API,
|
|
2
|
+
// and the ONE way an edit reaches Premiere - inside a transaction (one undo
|
|
3
|
+
// step), inside lockedAccess() where the host requires it (26.3+).
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const { Handles, PeerError } = require("./handles");
|
|
7
|
+
const P = require("./premiere");
|
|
8
|
+
|
|
9
|
+
const handles = new Handles();
|
|
10
|
+
|
|
11
|
+
/** Run `build(add)` to collect the batch, then commit it as ONE transaction = one undo step.
|
|
12
|
+
*
|
|
13
|
+
* `add(x, onError?)` takes an action or, better, a THUNK that makes one. MEASURED 26.5.2 (2026-10-19): every
|
|
14
|
+
* clip action (createSetNameAction, createSetDisabledAction, createSetEndAction, a param's createSetValueAction)
|
|
15
|
+
* must be MADE inside project.lockedAccess(), whose callback is synchronous ("Requires locked access" /
|
|
16
|
+
* "The script object is no longer valid" when made outside and committed later); marker actions are not checked.
|
|
17
|
+
* So: `build` does every async read first, the thunks make the actions synchronously under the lock, and the
|
|
18
|
+
* same callback commits them. A thunk that throws fails only its own op (`onError`), never the batch.
|
|
19
|
+
* MEASURED 26.2.2: factories may return promises there; those are resolved outside and committed under the lock. */
|
|
20
|
+
const isThenable = (x) => !!x && typeof x.then === "function";
|
|
21
|
+
|
|
22
|
+
async function transact(project, label, build) {
|
|
23
|
+
const items = [];
|
|
24
|
+
const add = (a, onError) => { if (a) items.push({ a, onError }); };
|
|
25
|
+
const built = build(add);
|
|
26
|
+
if (isThenable(built)) await built;
|
|
27
|
+
const make = () => {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (const { a, onError } of items) {
|
|
30
|
+
try { const x = typeof a === "function" ? a() : a; if (x) out.push(x); }
|
|
31
|
+
catch (e) { if (onError) onError(e); else throw e; }
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
};
|
|
35
|
+
const commit = (actions) => {
|
|
36
|
+
if (!actions.length) return 0;
|
|
37
|
+
project.executeTransaction((compound) => { for (const a of actions) compound.addAction(a); }, label);
|
|
38
|
+
return actions.length;
|
|
39
|
+
};
|
|
40
|
+
if (!P.has(project, "lockedAccess")) return commit(await Promise.all(make()));
|
|
41
|
+
let n = null, err = null, pending = null;
|
|
42
|
+
project.lockedAccess(() => {
|
|
43
|
+
try { const acts = make(); if (acts.some(isThenable)) pending = acts; else n = commit(acts); } catch (e) { err = e; }
|
|
44
|
+
});
|
|
45
|
+
if (err) throw err;
|
|
46
|
+
if (n !== null) return n;
|
|
47
|
+
const acts = await Promise.all(pending);
|
|
48
|
+
project.lockedAccess(() => { try { n = commit(acts); } catch (e) { err = e; } });
|
|
49
|
+
if (err) throw err;
|
|
50
|
+
return n;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function h(kind, obj, key) { return handles.wrap(kind, obj, key); }
|
|
54
|
+
function g(handle, kind) { return handles.get(handle, kind); }
|
|
55
|
+
|
|
56
|
+
async function activeProject() {
|
|
57
|
+
const ppro = P.api();
|
|
58
|
+
const project = await P.callAny(ppro.Project, ["getActiveProject"]);
|
|
59
|
+
return project || null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A project from a handle, or the active one when the caller passed null. */
|
|
63
|
+
async function projectOf(handle) {
|
|
64
|
+
if (handle) return g(handle, "project");
|
|
65
|
+
return activeProject();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = { handles, h, g, transact, activeProject, projectOf, PeerError, P };
|