popost 4.6.8 → 4.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -275,7 +275,7 @@ var VERSION;
275
275
  var init_version = __esm({
276
276
  "src/version.ts"() {
277
277
  "use strict";
278
- VERSION = "4.6.8";
278
+ VERSION = "4.6.9";
279
279
  }
280
280
  });
281
281
 
@@ -963,8 +963,8 @@ var init_post_bundle = __esm({
963
963
  const blocker = await resourceBlocker(rt, res, baseDir);
964
964
  if (blocker) blockers.push(blocker);
965
965
  }
966
- const missing3 = Array.isArray(bundle.missing) ? bundle.missing : [];
967
- for (const item2 of missing3) blockers.push(msg(`the bundle still declares a missing item: ${plain(item2)}`, `bundle \u4ECD\u58F0\u660E\u7F3A\u9879: ${plain(item2)}`));
966
+ const missing4 = Array.isArray(bundle.missing) ? bundle.missing : [];
967
+ for (const item2 of missing4) blockers.push(msg(`the bundle still declares a missing item: ${plain(item2)}`, `bundle \u4ECD\u58F0\u660E\u7F3A\u9879: ${plain(item2)}`));
968
968
  return { buildable: blockers.length === 0, blockers };
969
969
  };
970
970
  }
@@ -1618,11 +1618,11 @@ var init_args = __esm({
1618
1618
  );
1619
1619
  values.set(keyOf(positional.name), positional.variadic ? raws : raws[0]);
1620
1620
  });
1621
- const missing3 = [
1621
+ const missing4 = [
1622
1622
  ...declared.filter((p) => p.required !== false && !values.has(keyOf(p.name))).map((p) => p.name),
1623
1623
  ...(spec8.options ?? []).filter((o) => o.required && !values.has(keyOf(o.flag))).map((o) => o.flag)
1624
1624
  ];
1625
- if (missing3.length) throw new UsageError(`the following arguments are required: ${missing3.join(", ")}`);
1625
+ if (missing4.length) throw new UsageError(`the following arguments are required: ${missing4.join(", ")}`);
1626
1626
  for (const option of spec8.options ?? []) {
1627
1627
  const key2 = keyOf(option.flag);
1628
1628
  if (!values.has(key2) && option.default !== void 0) values.set(key2, option.default);
@@ -8338,18 +8338,18 @@ var init_steps = __esm({
8338
8338
  };
8339
8339
  fontsStep = async (ctx) => {
8340
8340
  const project = projectOf(ctx);
8341
- const missing3 = [];
8342
- for (const role of ctx.spec.fonts) if (!await isInstalled(project, role)) missing3.push(role);
8343
- if (!missing3.length)
8341
+ const missing4 = [];
8342
+ for (const role of ctx.spec.fonts) if (!await isInstalled(project, role)) missing4.push(role);
8343
+ if (!missing4.length)
8344
8344
  return skipped(
8345
8345
  msg(`font roles already installed: ${ctx.spec.fonts.join(", ")}`, `\u5B57\u4F53\u89D2\u8272\u5DF2\u5B89\u88C5\uFF1A${ctx.spec.fonts.join(", ")}`) + linksNote(project)
8346
8346
  );
8347
- const { result, fontLinks } = await installFonts(ctx.rt, project, missing3.join(","), true);
8347
+ const { result, fontLinks } = await installFonts(ctx.rt, project, missing4.join(","), true);
8348
8348
  const { installed } = result;
8349
- const kept2 = ctx.spec.fonts.length - missing3.length;
8349
+ const kept2 = ctx.spec.fonts.length - missing4.length;
8350
8350
  const detail2 = msg(
8351
- `installed ${missing3.join(", ")}${kept2 ? `; ${kept2} already installed` : ""}`,
8352
- `\u5DF2\u5B89\u88C5 ${missing3.join(", ")}${kept2 ? `\uFF1B${kept2} \u4E2A\u6B64\u524D\u5DF2\u5B89\u88C5` : ""}`
8351
+ `installed ${missing4.join(", ")}${kept2 ? `; ${kept2} already installed` : ""}`,
8352
+ `\u5DF2\u5B89\u88C5 ${missing4.join(", ")}${kept2 ? `\uFF1B${kept2} \u4E2A\u6B64\u524D\u5DF2\u5B89\u88C5` : ""}`
8353
8353
  ) + linksNote(project);
8354
8354
  return done(detail2, [], cjkFontWarnings(project, installed.map((role) => role.id)), fontLinks);
8355
8355
  };
@@ -10303,9 +10303,9 @@ var init_routes_get = __esm({
10303
10303
  const html2 = editorHtml(await ctx.load(), source2, ctx.req.rawQuery, ctx.state.cloud.mode());
10304
10304
  return noStoreResponse(html2, "text/html; charset=utf-8");
10305
10305
  };
10306
- staticFile = async (ctx, root, urlPath, missing3) => {
10306
+ staticFile = async (ctx, root, urlPath, missing4) => {
10307
10307
  const file = await readProjectFile(ctx.rt, root, urlPath);
10308
- return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx, missing3);
10308
+ return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx, missing4);
10309
10309
  };
10310
10310
  EXACT = {
10311
10311
  "/api/export-options": async (ctx) => {
@@ -12598,8 +12598,8 @@ var init_inspiration_plan = __esm({
12598
12598
  const b = bundle;
12599
12599
  if (b.parseStatus !== "ready" && !options.allowIncomplete) {
12600
12600
  const errorsOf = b.errors ?? [];
12601
- const missing3 = (b.missing ?? []).map((m) => msg(`missing ${m}`, `\u7F3A ${m}`));
12602
- const detail2 = [...errorsOf, ...missing3].join(msg("; ", "\uFF1B")) || msg("no reason given", "\u672A\u8BF4\u660E");
12601
+ const missing4 = (b.missing ?? []).map((m) => msg(`missing ${m}`, `\u7F3A ${m}`));
12602
+ const detail2 = [...errorsOf, ...missing4].join(msg("; ", "\uFF1B")) || msg("no reason given", "\u672A\u8BF4\u660E");
12603
12603
  throw new InputError(
12604
12604
  msg(
12605
12605
  `PostBundle parseStatus=${String(b.parseStatus)}: the content is incomplete (${detail2}). Complete it from local screenshots or text and mark it ready first, or, to save only what is there, add --allow-incomplete`,
@@ -12743,7 +12743,7 @@ var init_inspiration = __esm({
12743
12743
  });
12744
12744
 
12745
12745
  // src/providers/link-bundle.ts
12746
- var text3, badResponse, tagsOf2, imageOf, validPublishedAt, planPost, remoteView, COMMON_RATIOS, gcd2, ratioOf, fileName, sizeOf, reason, downloadPictures, utcNow2, buildBundle;
12746
+ var text3, badResponse, tagsOf2, imageOf, validPublishedAt, planPost, remoteView, COMMON_RATIOS, gcd2, ratioOf, fileName, sizeOf, reason, downloadPictures, utcNow2, pictureResource, videoResource, buildBundle;
12747
12747
  var init_link_bundle = __esm({
12748
12748
  "src/providers/link-bundle.ts"() {
12749
12749
  "use strict";
@@ -12786,6 +12786,7 @@ var init_link_bundle = __esm({
12786
12786
  const serverNote = text3(post.note) || (note ?? "").trim();
12787
12787
  return {
12788
12788
  platform: post.platform,
12789
+ kind: post.kind === "images" || post.kind === "video" ? post.kind : null,
12789
12790
  sourceUrl,
12790
12791
  title: text3(post.title),
12791
12792
  text: text3(post.text),
@@ -12800,6 +12801,7 @@ var init_link_bundle = __esm({
12800
12801
  };
12801
12802
  remoteView = (plan4) => ({
12802
12803
  platform: plan4.platform,
12804
+ ...plan4.kind ? { kind: plan4.kind } : {},
12803
12805
  title: plan4.title,
12804
12806
  text: plan4.text,
12805
12807
  tags: plan4.tags,
@@ -12854,7 +12856,17 @@ var init_link_bundle = __esm({
12854
12856
  return { saved, failure: null };
12855
12857
  };
12856
12858
  utcNow2 = (rt) => `${rt.now().toISOString().slice(0, 19)}+00:00`;
12857
- buildBundle = (rt, plan4, saved) => {
12859
+ pictureResource = (s) => ({
12860
+ id: `img${s.index}`,
12861
+ kind: "image",
12862
+ path: s.file,
12863
+ mimeType: s.mimeType,
12864
+ sha256: s.sha256,
12865
+ ...s.width && s.height ? { width: s.width, height: s.height } : {},
12866
+ ...s.alt ? { alt: s.alt } : {}
12867
+ });
12868
+ videoResource = (v) => ({ id: "video", kind: "video", path: v.file, mimeType: v.mimeType, sha256: v.sha256, bytes: v.bytes });
12869
+ buildBundle = (rt, plan4, saved, video) => {
12858
12870
  const first = saved[0];
12859
12871
  const complete3 = saved.length > 0;
12860
12872
  return {
@@ -12867,15 +12879,7 @@ var init_link_bundle = __esm({
12867
12879
  music: { title: "", url: "" },
12868
12880
  pageOrder: saved.map((s) => s.index),
12869
12881
  ratio: first?.width && first.height ? ratioOf(first.width, first.height) : null,
12870
- resources: saved.map((s) => ({
12871
- id: `img${s.index}`,
12872
- kind: "image",
12873
- path: s.file,
12874
- mimeType: s.mimeType,
12875
- sha256: s.sha256,
12876
- ...s.width && s.height ? { width: s.width, height: s.height } : {},
12877
- ...s.alt ? { alt: s.alt } : {}
12878
- })),
12882
+ resources: [...saved.map(pictureResource), ...video ? [videoResource(video)] : []],
12879
12883
  parseStatus: complete3 ? "ready" : "missing_resources",
12880
12884
  auth: {
12881
12885
  required: false,
@@ -12894,6 +12898,71 @@ var init_link_bundle = __esm({
12894
12898
  }
12895
12899
  });
12896
12900
 
12901
+ // src/providers/link-video.ts
12902
+ var MAX_VIDEO_BYTES, REQUEST_TIMEOUT_SEC, DOWNLOAD_TIMEOUT_SEC, EXTENSIONS2, LEADING_BOXES, ascii4, sniffVideoMime, missing, videoLink, downloadVideo;
12903
+ var init_link_video = __esm({
12904
+ "src/providers/link-video.ts"() {
12905
+ "use strict";
12906
+ init_util();
12907
+ init_i18n();
12908
+ init_api();
12909
+ init_base();
12910
+ init_errors3();
12911
+ MAX_VIDEO_BYTES = 200 * 1024 * 1024;
12912
+ REQUEST_TIMEOUT_SEC = 300;
12913
+ DOWNLOAD_TIMEOUT_SEC = 600;
12914
+ EXTENSIONS2 = { "video/mp4": ".mp4", "video/quicktime": ".mov", "video/webm": ".webm" };
12915
+ LEADING_BOXES = ["moov", "mdat", "free", "wide", "skip"];
12916
+ ascii4 = (bytes, from, to) => String.fromCharCode(...bytes.subarray(from, to));
12917
+ sniffVideoMime = (head, claimed) => {
12918
+ if (head.length >= 4 && head[0] === 26 && head[1] === 69 && head[2] === 223 && head[3] === 163) return "video/webm";
12919
+ if (head.length < 12) return null;
12920
+ const box2 = ascii4(head, 4, 8);
12921
+ if (box2 === "ftyp") return ascii4(head, 8, 12) === "qt " ? "video/quicktime" : "video/mp4";
12922
+ if (LEADING_BOXES.includes(box2)) return claimed === "video/quicktime" ? "video/quicktime" : "video/mp4";
12923
+ return null;
12924
+ };
12925
+ missing = (code, error2) => ({ missing: { code, error: error2 } });
12926
+ videoLink = async (client2, inspirationId) => {
12927
+ let answer3;
12928
+ try {
12929
+ answer3 = await client2.request("GET", `/inspirations/${encodeURIComponent(inspirationId)}/video`, { timeoutSec: REQUEST_TIMEOUT_SEC });
12930
+ } catch (error2) {
12931
+ if (error2 instanceof PopostApiError && error2.code === "VIDEO_GENERATION_DISABLED") return { skipped: true };
12932
+ if (error2 instanceof PopostApiError) return missing(error2.code || "API_ERROR", error2.message);
12933
+ if (error2 instanceof ImageProviderError) return missing("API_ERROR", error2.message);
12934
+ throw error2;
12935
+ }
12936
+ if (!isRecord(answer3) || typeof answer3.url !== "string" || typeof answer3.mimeType !== "string" || !EXTENSIONS2[answer3.mimeType])
12937
+ return missing("BAD_RESPONSE", msg("the answer for the post video has no usable link", "\u5E16\u5B50\u89C6\u9891\u7684\u54CD\u5E94\u91CC\u6CA1\u6709\u53EF\u7528\u7684\u94FE\u63A5"));
12938
+ return { url: answer3.url, mimeType: answer3.mimeType };
12939
+ };
12940
+ downloadVideo = async (rt, client2, inspirationId, outDir2, retry) => {
12941
+ const link = await videoLink(client2, inspirationId);
12942
+ if (!("url" in link)) return link;
12943
+ const what = msg("the post video", "\u5E16\u5B50\u89C6\u9891");
12944
+ const tmp = rt.path.join(outDir2, "video.download");
12945
+ let raw;
12946
+ try {
12947
+ raw = await downloadResult(rt, link.url, tmp, MAX_VIDEO_BYTES, DOWNLOAD_TIMEOUT_SEC, { what, retry });
12948
+ } catch (error2) {
12949
+ await rt.fs.rm(tmp).catch(() => void 0);
12950
+ if (error2 instanceof PopostApiError) return missing(error2.code || "DOWNLOAD_FAILED", error2.message);
12951
+ throw error2;
12952
+ }
12953
+ const mimeType2 = sniffVideoMime(raw.subarray(0, 16), link.mimeType);
12954
+ if (!mimeType2) {
12955
+ await rt.fs.rm(tmp);
12956
+ return missing("BAD_RESPONSE", msg(`the download of ${what} is not an MP4/MOV/WebM video; ${retry}`, `${what}\u4E0B\u8F7D\u7684\u5185\u5BB9\u4E0D\u662F MP4/MOV/WebM \u89C6\u9891\uFF1B${retry}`));
12957
+ }
12958
+ const file = `video${EXTENSIONS2[mimeType2]}`;
12959
+ const path4 = rt.path.join(outDir2, file);
12960
+ await rt.fs.rename(tmp, path4);
12961
+ return { saved: { file, path: path4, mimeType: mimeType2, sha256: sha256(raw), bytes: raw.length } };
12962
+ };
12963
+ }
12964
+ });
12965
+
12897
12966
  // src/providers/link-task.ts
12898
12967
  var POLL_INTERVAL_MS, MAX_POLL_FAILURES, RATE_LIMIT_WAIT_MS, RATE_LIMIT_WAIT_MAX_MS, TASK_ID2, STATUSES, taskOf2, isTerminal, TRANSIENT_CODES2, isTransient2, rateLimitWaitMs, fetchTask, waitForTask2;
12899
12968
  var init_link_task = __esm({
@@ -12969,7 +13038,7 @@ var init_link_task = __esm({
12969
13038
  });
12970
13039
 
12971
13040
  // src/providers/link.ts
12972
- var NOTE_MAX, TIMEOUT_MAX_SEC, LOCAL_CODES, shellArg, resumeCommand, briefOf, badArgs, checkOptions, parseBody, outDirOf, makeClient, dryRunOf, createTask, codeText, failedOutcome, unfinishedOutcome, succeededOutcome, finish2, failureOf5, report, parseLink, linkStatus;
13041
+ var NOTE_MAX, TIMEOUT_MAX_SEC, LOCAL_CODES, shellArg, resumeCommand, briefOf, badArgs, checkOptions, parseBody, outDirOf, makeClient, dryRunOf, createTask, codeText, failedOutcome, unfinishedOutcome, videoPart, succeededOutcome, finish2, failureOf5, report, parseLink, linkStatus;
12973
13042
  var init_link = __esm({
12974
13043
  "src/providers/link.ts"() {
12975
13044
  "use strict";
@@ -12981,6 +13050,7 @@ var init_link = __esm({
12981
13050
  init_cli_config();
12982
13051
  init_errors3();
12983
13052
  init_link_bundle();
13053
+ init_link_video();
12984
13054
  init_link_task();
12985
13055
  init_paths();
12986
13056
  init_secrets();
@@ -13061,7 +13131,30 @@ var init_link = __esm({
13061
13131
  );
13062
13132
  return { exit: 1, body: { ok: false, code, error: error2, task: { id: id2, status: task?.status ?? null, chargedCredits: task?.chargedCredits ?? null }, resume } };
13063
13133
  };
13064
- succeededOutcome = async (rt, task, call2, fallback) => {
13134
+ videoPart = async (rt, client2, plan4, call2, outDir2, retry) => {
13135
+ if (plan4.kind !== "video" || call2.noVideo || !plan4.inspirationId) return { fields: {}, note: "" };
13136
+ const outcome = await downloadVideo(rt, client2, plan4.inspirationId, outDir2, retry);
13137
+ if ("skipped" in outcome) return { fields: {}, note: "" };
13138
+ if ("saved" in outcome) {
13139
+ const path4 = shellArg(outcome.saved.path);
13140
+ return {
13141
+ saved: outcome.saved,
13142
+ fields: { video: outcome.saved.path },
13143
+ note: msg(
13144
+ `; the post's original video is ${path4}: use it as the reference video (for example popost video replication init <project> --reference ${path4})`,
13145
+ `\uFF1B\u5E16\u5B50\u539F\u89C6\u9891\u5728 ${path4}\uFF1A\u7528\u5B83\u4F5C\u53C2\u8003\u89C6\u9891\uFF08\u4F8B\u5982 popost video replication init <\u9879\u76EE> --reference ${path4}\uFF09`
13146
+ )
13147
+ };
13148
+ }
13149
+ return {
13150
+ fields: { videoMissing: outcome.missing },
13151
+ note: msg(
13152
+ `; the original video could not be fetched (${outcome.missing.code}): the bundle has the cover and text only; for shot, subtitle or sound analysis ask the user for the video file or a screen recording`,
13153
+ `\uFF1B\u6CA1\u80FD\u53D6\u5230\u5E16\u5B50\u539F\u89C6\u9891\uFF08${outcome.missing.code}\uFF09\uFF1Abundle \u53EA\u6709\u5C01\u9762\u548C\u6587\u5B57\uFF1B\u8981\u505A\u5206\u955C\u3001\u5B57\u5E55\u6216\u58F0\u97F3\u5206\u6790\uFF0C\u8BF7\u7528\u6237\u63D0\u4F9B\u89C6\u9891\u6587\u4EF6\u6216\u5F55\u5C4F`
13154
+ )
13155
+ };
13156
+ };
13157
+ succeededOutcome = async (rt, client2, task, call2, fallback) => {
13065
13158
  if (!task.post) throw badResponse(msg("the task succeeded but the answer has no post", "\u4EFB\u52A1\u5DF2\u6210\u529F\uFF0C\u4F46\u54CD\u5E94\u91CC\u6CA1\u6709 post"));
13066
13159
  const plan4 = planPost(task.post, fallback.url, fallback.note);
13067
13160
  const info = { id: task.id, status: task.status, created: task.created, chargedCredits: task.chargedCredits };
@@ -13088,7 +13181,8 @@ var init_link = __esm({
13088
13181
  const { saved, failure: failure4 } = await downloadPictures(rt, plan4.images, outDir2, retry);
13089
13182
  const images = saved.map((s) => s.path);
13090
13183
  if (failure4) return { exit: 1, body: { ok: false, code: "DOWNLOAD_FAILED", error: failure4, task: { id: task.id, status: task.status, chargedCredits: task.chargedCredits }, images, resume: resumeCommand(task.id, call2) } };
13091
- const bundle = buildBundle(rt, plan4, saved);
13184
+ const video = await videoPart(rt, client2, plan4, call2, outDir2, retry);
13185
+ const bundle = buildBundle(rt, plan4, saved, video.saved);
13092
13186
  const [valid, errors] = validateBundle(bundle);
13093
13187
  if (!valid) throw badResponse(msg(`the parsed result does not make a valid PostBundle: ${errors.join("; ")}`, `\u89E3\u6790\u7ED3\u679C\u65E0\u6CD5\u7EC4\u6210\u5408\u6CD5\u7684 PostBundle\uFF1A${errors.join("\uFF1B")}`));
13094
13188
  const bundlePath = rt.path.join(outDir2, "postbundle.json");
@@ -13098,8 +13192,8 @@ var init_link = __esm({
13098
13192
  "the post has no pictures: the bundle is marked missing_resources and cannot be built directly; the platform saved this post to My Inspirations",
13099
13193
  "\u5E16\u5B50\u91CC\u6CA1\u6709\u56FE\u7247\uFF1Abundle \u6807\u4E3A missing_resources\uFF0C\u4E0D\u80FD\u76F4\u63A5 build\uFF1B\u5E73\u53F0\u5DF2\u628A\u8FD9\u6761\u5E16\u5B50\u5B58\u5165\u300C\u6211\u7684\u7075\u611F\u300D"
13100
13194
  );
13101
- const post = { platform: plan4.platform, title: plan4.title, sourceUrl: plan4.sourceUrl, imageCount: saved.length, ...plan4.inspirationId ? { inspirationId: plan4.inspirationId } : {} };
13102
- return { exit: 0, body: { ok: true, task: info, bundle: bundlePath, images, post, next: `popost validate --file ${file} && popost import --file ${file}`, note } };
13195
+ const post = { platform: plan4.platform, ...plan4.kind ? { kind: plan4.kind } : {}, title: plan4.title, sourceUrl: plan4.sourceUrl, imageCount: saved.length, ...plan4.inspirationId ? { inspirationId: plan4.inspirationId } : {} };
13196
+ return { exit: 0, body: { ok: true, task: info, bundle: bundlePath, images, ...video.fields, post, next: `popost validate --file ${file} && popost import --file ${file}`, note: note + video.note } };
13103
13197
  };
13104
13198
  finish2 = async (rt, client2, state, first, call2, fallback) => {
13105
13199
  const id2 = state.id;
@@ -13114,7 +13208,7 @@ var init_link = __esm({
13114
13208
  );
13115
13209
  return unfinishedOutcome("POLL_FAILED", what, id2, waited.task, call2);
13116
13210
  }
13117
- return waited.task.status === "failed" ? failedOutcome(waited.task) : succeededOutcome(rt, waited.task, call2, fallback);
13211
+ return waited.task.status === "failed" ? failedOutcome(waited.task) : succeededOutcome(rt, client2, waited.task, call2, fallback);
13118
13212
  };
13119
13213
  failureOf5 = (error2) => {
13120
13214
  if (error2 instanceof CliReject) return { code: "CONFIG", exit: error2.code, message: error2.message };
@@ -13633,7 +13727,7 @@ var link_exports = {};
13633
13727
  __export(link_exports, {
13634
13728
  main: () => main16
13635
13729
  });
13636
- var out, timeout, noDownload, config2, main16;
13730
+ var out, timeout, noDownload, noVideo, config2, main16;
13637
13731
  var init_link2 = __esm({
13638
13732
  "src/commands/link.ts"() {
13639
13733
  "use strict";
@@ -13667,6 +13761,14 @@ var init_link2 = __esm({
13667
13761
  "\u4E0D\u4E0B\u8F7D\u56FE\u7247\uFF0C\u53EA\u6253\u5370\u5E16\u5B50\u5185\u5BB9\u548C\u56FE\u7247\u5730\u5740\uFF08\u5730\u5740\u662F\u77ED\u671F\u7B7E\u540D\u94FE\u63A5\uFF0C\u5F88\u5FEB\u5931\u6548\uFF09"
13668
13762
  )
13669
13763
  });
13764
+ noVideo = () => ({
13765
+ flag: "--no-video",
13766
+ kind: "flag",
13767
+ help: msg(
13768
+ "for a video post, keep the cover and text only: do not fetch the original video file",
13769
+ "\u89C6\u9891\u5E16\u53EA\u4FDD\u7559\u5C01\u9762\u548C\u6587\u5B57\uFF0C\u4E0D\u53D6\u539F\u89C6\u9891\u6587\u4EF6"
13770
+ )
13771
+ });
13670
13772
  config2 = () => ({ flag: "--config", help: msg("private config JSON (popost.baseUrl / popost.auth.envVar)", "\u79C1\u6709\u914D\u7F6E JSON\uFF08popost.baseUrl / popost.auth.envVar\uFF09") });
13671
13773
  main16 = (argv, rt) => runSubcommand2(
13672
13774
  "popost link",
@@ -13681,8 +13783,8 @@ var init_link2 = __esm({
13681
13783
  parse: {
13682
13784
  spec: {
13683
13785
  description: msg(
13684
- `Have popost.ai parse a social post link (${platformNameList("or")}; YouTube, Bilibili and WeChat Channels video links provide the cover and post details when available), wait for the result, download the pictures and write a PostBundle (postbundle.v1). Get the live price with link quote first, then submit with --confirm --max-credits N, the ceiling the user authorized; the actual net charge is task.chargedCredits; a link already saved is reused without a new charge. The parsed post is also saved to My Inspirations.`,
13685
- `\u8BA9 popost.ai \u89E3\u6790\u4E00\u6761\u793E\u5A92\u5E16\u5B50\u94FE\u63A5\uFF08${platformNameList("or")}\uFF1BYouTube\u3001\u54D4\u54E9\u54D4\u54E9\u548C\u5FAE\u4FE1\u89C6\u9891\u53F7\u94FE\u63A5\u53EF\u4FDD\u5B58\u53EF\u7528\u7684\u5C01\u9762\u548C\u5E16\u5B50\u4FE1\u606F\uFF09\uFF0C\u7B49\u5F85\u7ED3\u679C\uFF0C\u628A\u56FE\u7247\u4E0B\u8F7D\u5230\u672C\u5730\u5E76\u5199\u51FA PostBundle\uFF08postbundle.v1\uFF09\u3002\u5148 link quote \u67E5\u8BE2\u52A8\u6001\u4EF7\u683C\uFF0C\u518D\u5E26 --confirm --max-credits N \u6309\u5DF2\u6388\u6743\u4E0A\u9650\u63D0\u4EA4\uFF1B\u5B9E\u9645\u51C0\u6263\u89C1 task.chargedCredits\uFF1B\u5DF2\u4FDD\u5B58\u8FC7\u7684\u94FE\u63A5\u76F4\u63A5\u590D\u7528\u3001\u4E0D\u518D\u6263\u3002\u89E3\u6790\u7ED3\u679C\u540C\u65F6\u5B58\u5165\u300C\u6211\u7684\u7075\u611F\u300D\u3002`
13786
+ `Have popost.ai parse a social post link (${platformNameList("or")}), wait for the result, download the pictures and write a PostBundle (postbundle.v1). A video post also gets its original video file (video.mp4, free) for shot, subtitle and sound analysis; YouTube, Bilibili and WeChat Channels give the cover and post details only. Get the live price with link quote first, then submit with --confirm --max-credits N, the ceiling the user authorized; the actual net charge is task.chargedCredits; a link already saved is reused without a new charge. The parsed post is also saved to My Inspirations.`,
13787
+ `\u8BA9 popost.ai \u89E3\u6790\u4E00\u6761\u793E\u5A92\u5E16\u5B50\u94FE\u63A5\uFF08${platformNameList("or")}\uFF09\uFF0C\u7B49\u5F85\u7ED3\u679C\uFF0C\u628A\u56FE\u7247\u4E0B\u8F7D\u5230\u672C\u5730\u5E76\u5199\u51FA PostBundle\uFF08postbundle.v1\uFF09\u3002\u89C6\u9891\u5E16\u8FD8\u4F1A\u53D6\u56DE\u539F\u89C6\u9891\u6587\u4EF6\uFF08video.mp4\uFF0C\u4E0D\u53E6\u6263\u79EF\u5206\uFF09\uFF0C\u7528\u4E8E\u5206\u955C\u3001\u5B57\u5E55\u548C\u58F0\u97F3\u5206\u6790\uFF1BYouTube\u3001\u54D4\u54E9\u54D4\u54E9\u548C\u5FAE\u4FE1\u89C6\u9891\u53F7\u53EA\u6709\u5C01\u9762\u548C\u5E16\u5B50\u4FE1\u606F\u3002\u5148 link quote \u67E5\u8BE2\u52A8\u6001\u4EF7\u683C\uFF0C\u518D\u5E26 --confirm --max-credits N \u6309\u5DF2\u6388\u6743\u4E0A\u9650\u63D0\u4EA4\uFF1B\u5B9E\u9645\u51C0\u6263\u89C1 task.chargedCredits\uFF1B\u5DF2\u4FDD\u5B58\u8FC7\u7684\u94FE\u63A5\u76F4\u63A5\u590D\u7528\u3001\u4E0D\u518D\u6263\u3002\u89E3\u6790\u7ED3\u679C\u540C\u65F6\u5B58\u5165\u300C\u6211\u7684\u7075\u611F\u300D\u3002`
13686
13788
  ),
13687
13789
  positionals: [{ name: "url", help: msg("the post link (http/https)", "\u5E16\u5B50\u94FE\u63A5\uFF08http/https\uFF09") }],
13688
13790
  options: [
@@ -13692,12 +13794,13 @@ var init_link2 = __esm({
13692
13794
  out(),
13693
13795
  timeout(),
13694
13796
  noDownload(),
13797
+ noVideo(),
13695
13798
  { flag: "--dry-run", kind: "flag", help: msg("offline, no key, no charge: only show the requests that would be sent", "\u4E0D\u8054\u7F51\u3001\u4E0D\u9700\u8981\u5BC6\u94A5\u3001\u4E0D\u6263\u79EF\u5206\uFF0C\u53EA\u5C55\u793A\u5C06\u53D1\u51FA\u7684\u8BF7\u6C42") },
13696
13799
  config2()
13697
13800
  ]
13698
13801
  },
13699
13802
  // Into a project (--out inside one): the parse is charged under the project's task (providers/task.ts).
13700
- run: async (a) => parseLink(await aroundPath(rt, a.string("out")), { url: a.req("url"), note: a.string("note"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), dryRun: a.flag("dry-run"), confirm: a.flag("confirm"), maxCredits: a.number("max-credits"), config: a.string("config") })
13803
+ run: async (a) => parseLink(await aroundPath(rt, a.string("out")), { url: a.req("url"), note: a.string("note"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), noVideo: a.flag("no-video"), dryRun: a.flag("dry-run"), confirm: a.flag("confirm"), maxCredits: a.number("max-credits"), config: a.string("config") })
13701
13804
  },
13702
13805
  status: {
13703
13806
  spec: {
@@ -13706,9 +13809,9 @@ var init_link2 = __esm({
13706
13809
  "\u7EE7\u7EED\u7B49\u5F85\u4E00\u4E2A\u5DF2\u5B58\u5728\u7684\u89E3\u6790\u4EFB\u52A1\u5E76\u4E0B\u8F7D\u7ED3\u679C\uFF08\u7528\u4E8E link parse \u8D85\u65F6\u6216\u88AB\u6253\u65AD\u4E4B\u540E\uFF09\u3002\u4E0D\u65B0\u5EFA\u4EFB\u52A1\u3001\u4E0D\u6263\u79EF\u5206\u3002"
13707
13810
  ),
13708
13811
  positionals: [{ name: "task-id", help: msg("the task.id printed by link parse", "link parse \u8F93\u51FA\u7684 task.id") }],
13709
- options: [out(), timeout(), noDownload(), config2()]
13812
+ options: [out(), timeout(), noDownload(), noVideo(), config2()]
13710
13813
  },
13711
- run: (a) => linkStatus(rt, { taskId: a.req("task-id"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), config: a.string("config") })
13814
+ run: (a) => linkStatus(rt, { taskId: a.req("task-id"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), noVideo: a.flag("no-video"), config: a.string("config") })
13712
13815
  }
13713
13816
  },
13714
13817
  argv,
@@ -16317,10 +16420,10 @@ var init_footage2 = __esm({
16317
16420
  const { fs, path: path4 } = rt;
16318
16421
  await fs.mkdir(job.dir);
16319
16422
  const have = new Set(await fs.readdir(job.dir));
16320
- const missing3 = job.frames.filter((f) => !have.has(frameName(f)));
16321
- if (missing3.length === 0) return { extracted: 0, reused: job.frames.length };
16322
- const lo = missing3[0] ?? 0;
16323
- const hi = missing3[missing3.length - 1] ?? 0;
16423
+ const missing4 = job.frames.filter((f) => !have.has(frameName(f)));
16424
+ if (missing4.length === 0) return { extracted: 0, reused: job.frames.length };
16425
+ const lo = missing4[0] ?? 0;
16426
+ const hi = missing4[missing4.length - 1] ?? 0;
16324
16427
  const tmp = path4.join(job.dir, ".extract-" + rt.randomUUID());
16325
16428
  await fs.mkdir(tmp);
16326
16429
  try {
@@ -16347,11 +16450,11 @@ var init_footage2 = __esm({
16347
16450
  path4.join(tmp, "%0" + FRAME_DIGITS + "d.png")
16348
16451
  ]);
16349
16452
  const written2 = new Set(await fs.readdir(tmp));
16350
- const absent = missing3.filter((f) => !written2.has(frameName(f - lo)));
16453
+ const absent = missing4.filter((f) => !written2.has(frameName(f - lo)));
16351
16454
  if (absent.length > 0)
16352
16455
  throw new Error("Extracting frames " + lo + ".." + hi + " of " + job.file + " gave " + written2.size + " pictures; frame " + absent[0] + " is missing. The file may be damaged or shorter than its header says; re-encode it with ffmpeg.");
16353
- for (const f of missing3) await fs.rename(path4.join(tmp, frameName(f - lo)), path4.join(job.dir, frameName(f)));
16354
- return { extracted: missing3.length, reused: job.frames.length - missing3.length };
16456
+ for (const f of missing4) await fs.rename(path4.join(tmp, frameName(f - lo)), path4.join(job.dir, frameName(f)));
16457
+ return { extracted: missing4.length, reused: job.frames.length - missing4.length };
16355
16458
  } finally {
16356
16459
  await fs.rm(tmp);
16357
16460
  }
@@ -20430,14 +20533,14 @@ var init_check3 = __esm({
20430
20533
  measuredLabel = (b) => [b.kind, b.mode, b.direction, b.via ? "via " + b.via : ""].filter(Boolean).join(" ");
20431
20534
  coverageProblems = ({ r, m, at: at7 }) => {
20432
20535
  const fps = m.source.fps, s22 = (f) => (f / fps).toFixed(2);
20433
- const missing3 = m.shots.filter((s) => !r.present.includes(s.index + 1)).map((s) => error("shots", "Shot " + (s.index + 1) + " (" + s22(s.start) + "-" + s22(s.end) + " s) has no entry.", "Open " + shotSheetFile(s.index + 1) + ' and add {"shot": ' + (s.index + 1) + ', "time": [' + s22(s.start) + ", " + s22(s.end) + '], "layout": "...", "layers": [...]} for it.'));
20536
+ const missing4 = m.shots.filter((s) => !r.present.includes(s.index + 1)).map((s) => error("shots", "Shot " + (s.index + 1) + " (" + s22(s.start) + "-" + s22(s.end) + " s) has no entry.", "Open " + shotSheetFile(s.index + 1) + ' and add {"shot": ' + (s.index + 1) + ', "time": [' + s22(s.start) + ", " + s22(s.end) + '], "layout": "...", "layers": [...]} for it.'));
20434
20537
  const extra2 = r.present.filter((n) => n > m.shots.length).map((n) => error(at7(n) + ".shot", "There is no shot " + n + ": the measurement has " + m.shots.length + ".", "Remove the entry, or give it the number of the shot it describes."));
20435
20538
  const times = r.elements.shots.flatMap((s) => {
20436
20539
  const ms = m.shots[s.shot - 1];
20437
20540
  if (!ms || Math.abs(s.time[0] - ms.start / fps) <= TIME_SLACK && Math.abs(s.time[1] - ms.end / fps) <= TIME_SLACK) return [];
20438
20541
  return [warning(at7(s.shot) + ".time", "Shot " + s.shot + " is " + s22(ms.start) + "-" + s22(ms.end) + " s in the measurement; its entry says " + s.time[0] + "-" + s.time[1] + " s.", "Copy the measured time, [" + s22(ms.start) + ", " + s22(ms.end) + ']: entries go by the measured shots. Where the frames show a change the measurement missed, say so in "rebuild".')];
20439
20542
  });
20440
- return [...missing3, ...extra2, ...times];
20543
+ return [...missing4, ...extra2, ...times];
20441
20544
  };
20442
20545
  transitionProblems2 = ({ r, m, at: at7 }) => r.elements.shots.flatMap((s) => {
20443
20546
  const here = at7(s.shot) + ".transitionIn", t = s.transitionIn;
@@ -30056,7 +30159,7 @@ var init_generate = __esm({
30056
30159
  });
30057
30160
 
30058
30161
  // src/video/generate/cloud.ts
30059
- var GenerateError, MINUTE_MS, POLL_MS2, DEFAULT_WAIT_MIN, DEFAULT_SECONDS, CREATE_TRIES, CREATE_TIMEOUT_SEC, UPLOAD_TIMEOUT_MS, DOWNLOAD_TIMEOUT_SEC, MAX_CLIP_BYTES, RETRY_HINT, setting, numberSetting, keysOf, cloudSettings, agreeToPrice, requestKey, LISTS2, has, mediaType, readReference3, readReferences, recordFile, readRecord2, save2, keyOf4, stillValid, text6, putBytes, upload2, ensureUploads2, specOf, ensureQuote, taskOf3, createTask2, submit, getTask, findTask, ENDED, PASSING2, waitFor, NEXT_AFTER, ended, fetchClip, gateOf, modelFacts, wavSeconds, checkReferenceSounds, makeClip, listModels;
30162
+ var GenerateError, MINUTE_MS, POLL_MS2, DEFAULT_WAIT_MIN, DEFAULT_SECONDS, CREATE_TRIES, CREATE_TIMEOUT_SEC, UPLOAD_TIMEOUT_MS, DOWNLOAD_TIMEOUT_SEC2, MAX_CLIP_BYTES, RETRY_HINT, setting, numberSetting, keysOf, cloudSettings, agreeToPrice, requestKey, LISTS2, has, mediaType, readReference3, readReferences, recordFile, readRecord2, save2, keyOf4, stillValid, text6, putBytes, upload2, ensureUploads2, specOf, ensureQuote, taskOf3, createTask2, submit, getTask, findTask, ENDED, PASSING2, waitFor, NEXT_AFTER, ended, fetchClip, gateOf, modelFacts, wavSeconds, checkReferenceSounds, makeClip, listModels;
30060
30163
  var init_cloud2 = __esm({
30061
30164
  "src/video/generate/cloud.ts"() {
30062
30165
  "use strict";
@@ -30087,7 +30190,7 @@ var init_cloud2 = __esm({
30087
30190
  CREATE_TRIES = 3;
30088
30191
  CREATE_TIMEOUT_SEC = 120;
30089
30192
  UPLOAD_TIMEOUT_MS = 10 * MINUTE_MS;
30090
- DOWNLOAD_TIMEOUT_SEC = 900;
30193
+ DOWNLOAD_TIMEOUT_SEC2 = 900;
30091
30194
  MAX_CLIP_BYTES = 1024 * 1024 * 1024;
30092
30195
  RETRY_HINT = "Run the same command again: it sends the same idempotency key, so it is never paid twice.";
30093
30196
  setting = (rt, name) => rt.env[name]?.trim() || void 0;
@@ -30318,7 +30421,7 @@ var init_cloud2 = __esm({
30318
30421
  const url = task.video?.url;
30319
30422
  if (typeof url !== "string") throw new GenerateError("popost.ai says the clip of task " + task.id + " is made but gives no link to it. Run the command again later.");
30320
30423
  try {
30321
- const data = await downloadResult(rt, url, out2, MAX_CLIP_BYTES, DOWNLOAD_TIMEOUT_SEC, labels);
30424
+ const data = await downloadResult(rt, url, out2, MAX_CLIP_BYTES, DOWNLOAD_TIMEOUT_SEC2, labels);
30322
30425
  const bytes = task.video?.bytes;
30323
30426
  if (typeof bytes === "number" && data.length !== bytes) {
30324
30427
  await rt.fs.rm(out2);
@@ -32355,9 +32458,9 @@ var init_readback_kept = __esm({
32355
32458
  const who = readerOf(rt);
32356
32459
  const [hashes2, kept2] = await Promise.all([Promise.all(frames.map(async (f) => sha256(await rt.fs.readFile(f.file)))), keptLines(rt, file, who)]);
32357
32460
  const old = hashes2.map((h) => Array.isArray(kept2[h]) ? kept2[h] : void 0);
32358
- const missing3 = frames.filter((_f, i) => old[i] === void 0);
32359
- onKept?.(frames.length - missing3.length, frames.length);
32360
- const read2 = new Map((missing3.length ? await reader.read(missing3) : []).map((s) => [s.frame, s.lines]));
32461
+ const missing4 = frames.filter((_f, i) => old[i] === void 0);
32462
+ onKept?.(frames.length - missing4.length, frames.length);
32463
+ const read2 = new Map((missing4.length ? await reader.read(missing4) : []).map((s) => [s.frame, s.lines]));
32361
32464
  const found = frames.flatMap((f, i) => {
32362
32465
  const lines = old[i] ?? read2.get(f.frame);
32363
32466
  return lines ? [{ hash: hashes2[i], sample: { frame: f.frame, lines } }] : [];
@@ -33581,7 +33684,7 @@ var init_check5 = __esm({
33581
33684
  fileProblems = async (rt, pkg, fill4, dir, lengths) => {
33582
33685
  const exists3 = async (p) => await rt.fs.stat(p) !== null;
33583
33686
  const out2 = [];
33584
- const missing3 = (at7, file) => error(at7, quote13(file) + " does not exist in " + dir + ".", "Put the file there, or correct the path (it is relative to the project directory).");
33687
+ const missing4 = (at7, file) => error(at7, quote13(file) + " does not exist in " + dir + ".", "Put the file there, or correct the path (it is relative to the project directory).");
33585
33688
  for (const [k, raw] of fill4.shots.entries()) {
33586
33689
  const s = raw;
33587
33690
  if (k >= pkg.template.shots.length || kindsOf2(s).length !== 1) continue;
@@ -33590,7 +33693,7 @@ var init_check5 = __esm({
33590
33693
  if (typeof file !== "string" || !file.trim() || isOutside(file)) continue;
33591
33694
  const full = rt.path.resolve(dir, file);
33592
33695
  if (!await exists3(full)) {
33593
- out2.push(missing3("shots[" + k + "]." + key2, file));
33696
+ out2.push(missing4("shots[" + k + "]." + key2, file));
33594
33697
  continue;
33595
33698
  }
33596
33699
  if (key2 === "picture" && !PICTURES3.includes(rt.path.extname(file).toLowerCase())) out2.push(error("shots[" + k + "].picture", quote13(file) + " is not a picture file (" + PICTURES3.join(", ") + ").", "Convert it to WebP or PNG."));
@@ -33600,8 +33703,8 @@ var init_check5 = __esm({
33600
33703
  }
33601
33704
  out2.push(...await itemFileProblems(rt, pkg, s, k, dir, lengths));
33602
33705
  }
33603
- if (typeof fill4.sound === "string" && !await exists3(rt.path.resolve(dir, fill4.sound))) out2.push(missing3("sound", fill4.sound));
33604
- for (const [i, bed] of (Array.isArray(fill4.beds) ? fill4.beds : []).entries()) if (typeof bed?.footage === "string" && !isOutside(bed.footage) && !await exists3(rt.path.resolve(dir, bed.footage))) out2.push(missing3("beds[" + i + "].footage", bed.footage));
33706
+ if (typeof fill4.sound === "string" && !await exists3(rt.path.resolve(dir, fill4.sound))) out2.push(missing4("sound", fill4.sound));
33707
+ for (const [i, bed] of (Array.isArray(fill4.beds) ? fill4.beds : []).entries()) if (typeof bed?.footage === "string" && !isOutside(bed.footage) && !await exists3(rt.path.resolve(dir, bed.footage))) out2.push(missing4("beds[" + i + "].footage", bed.footage));
33605
33708
  out2.push(...await stillProblems(rt, pkg, fill4, dir, lengths));
33606
33709
  for (const p of await slotPictures(rt, fill4, dir)) out2.push(...await slotPictureProblems(rt, p, dir));
33607
33710
  return out2;
@@ -40776,11 +40879,11 @@ var init_findings2 = __esm({
40776
40879
  };
40777
40880
  unseenProblem = (shot, mine, longer, theirs, picture3) => {
40778
40881
  const shown3 = theirs.filter((t) => t.visible).map((t) => t.index);
40779
- const missing3 = outermost(mine.filter((t) => !t.visible && shown3.includes(t.index))).slice(0, 3);
40780
- if (!missing3.length) return void 0;
40882
+ const missing4 = outermost(mine.filter((t) => !t.visible && shown3.includes(t.index))).slice(0, 3);
40883
+ if (!missing4.length) return void 0;
40781
40884
  return warning(
40782
40885
  at4(shot.k),
40783
- "In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted3(missing3.map((t) => t.text)) + (missing3.length > 1 ? " are" : " is") + " never visible (" + picture3 + '), though segment "' + longer.id + '" (' + s2(longer.seconds) + ") shows " + (missing3.length > 1 ? "them" : "it") + " with the same scene file: the entrance starts after this shorter shot has ended.",
40886
+ "In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted3(missing4.map((t) => t.text)) + (missing4.length > 1 ? " are" : " is") + " never visible (" + picture3 + '), though segment "' + longer.id + '" (' + s2(longer.seconds) + ") shows " + (missing4.length > 1 ? "them" : "it") + " with the same scene file: the entrance starts after this shorter shot has ended.",
40784
40887
  'Time the entrances for the shortest shot that shows "' + shot.src + '": every text visible by ' + s2(readBy(shot.seconds)) + ", then held. Or give this segment a scene file of its own."
40785
40888
  );
40786
40889
  };
@@ -42484,9 +42587,9 @@ var init_speech_check = __esm({
42484
42587
  const a = comparedWords(script), b = comparedWords(heard);
42485
42588
  const pairs = commonPairs(a, b);
42486
42589
  const saidA = new Set(pairs.map(([i]) => i)), saidB = new Set(pairs.map(([, j]) => j));
42487
- const missing3 = a.filter((_w, i) => !saidA.has(i)), extra2 = b.filter((_w, j) => !saidB.has(j));
42590
+ const missing4 = a.filter((_w, i) => !saidA.has(i)), extra2 = b.filter((_w, j) => !saidB.has(j));
42488
42591
  const n = a.length, matched = pairs.length;
42489
- return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing: missing3.slice(0, 12), extra: extra2.slice(0, 12) };
42592
+ return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing: missing4.slice(0, 12), extra: extra2.slice(0, 12) };
42490
42593
  };
42491
42594
  lineTimes = (lines, words) => {
42492
42595
  const perLine = lines.map((l) => comparedWords(l));
@@ -44195,8 +44298,8 @@ var init_hosted3 = __esm({
44195
44298
  lengthOf = async (rt, o, known2) => {
44196
44299
  const had = known2 ?? await audioSeconds(rt, o.out).catch(() => void 0);
44197
44300
  if (had === void 0) return { seconds: null };
44198
- const seconds7 = round22(had), missing3 = round22((o.fit ?? o.seconds) - had);
44199
- return { seconds: seconds7, ...missing3 > SHORT_TOLERANCE ? { short: { seconds: seconds7, missing: missing3 } } : {} };
44301
+ const seconds7 = round22(had), missing4 = round22((o.fit ?? o.seconds) - had);
44302
+ return { seconds: seconds7, ...missing4 > SHORT_TOLERANCE ? { short: { seconds: seconds7, missing: missing4 } } : {} };
44200
44303
  };
44201
44304
  written = async (rt, o, receipt, job) => {
44202
44305
  if (job.state !== "ready" || !job.audioUrl) throw new ToolError("The popost.ai music is " + (job.state || "not ready") + "; run the same command again.");
@@ -44281,7 +44384,7 @@ var init_media = __esm({
44281
44384
  const account = connected(rt);
44282
44385
  const tools2 = { ...named, transcribe: named.transcribe ?? (account ? HOSTED : null), speak: named.speak ?? (account ? HOSTED : null), music: musicEnabled(rt) ? HOSTED : null };
44283
44386
  const offers = account ? { hosted: HOSTED_NOTE } : { connect: CONNECT };
44284
- const missing3 = [
44387
+ const missing4 = [
44285
44388
  ...rt.programs ? [] : ["this host cannot run local programs, so no video command works here"],
44286
44389
  ...rt.programs && version === null ? ['ffmpeg was not found: install it or set POPOST_FFMPEG (asked for "' + ffmpegPath(rt) + '")'] : [],
44287
44390
  ...browser === true ? [] : [browser]
@@ -44289,8 +44392,8 @@ var init_media = __esm({
44289
44392
  const budget2 = rt.programs ? cpuBudgetOf(rt) : void 0;
44290
44393
  const cpus = budget2 ? { budget: budget2.cpus, from: budget2.source } : null;
44291
44394
  const reading = named.readText !== null || named.transcribe !== null;
44292
- printJson(rt, { ok: missing3.length === 0, ffmpeg: version, browser: browser === true, cpus, tools: tools2, ...offers, ...reading ? { note: FIRST_RUN } : {}, ...missing3.length ? { missing: missing3 } : {} });
44293
- return missing3.length ? 2 : 0;
44395
+ printJson(rt, { ok: missing4.length === 0, ffmpeg: version, browser: browser === true, cpus, tools: tools2, ...offers, ...reading ? { note: FIRST_RUN } : {}, ...missing4.length ? { missing: missing4 } : {} });
44396
+ return missing4.length ? 2 : 0;
44294
44397
  }
44295
44398
  );
44296
44399
  soundOnly = async (rt, file, e) => {
@@ -44639,8 +44742,8 @@ var init_music = __esm({
44639
44742
  lengthLine = (made, file, of) => {
44640
44743
  if (made.seconds === null) return "The length of " + file + " could not be read here (ffmpeg): check it against the video's " + of.toFixed(2) + " s before the music is placed.\n";
44641
44744
  if (!made.short) return void 0;
44642
- const { seconds: seconds7, missing: missing3 } = made.short;
44643
- return "The music is " + seconds7.toFixed(2) + " s long, " + missing3.toFixed(2) + " s shorter than the " + of.toFixed(2) + " s it is for: the last " + missing3.toFixed(2) + " s of the video would have no music. Order a longer track (this command with --seconds " + musicSeconds(of + missing3 + MARGIN_SECONDS) + " is a new order, priced and agreed anew; the music is faded out at the end of the video), or end the video with the music (shorten its last scene by " + missing3.toFixed(2) + " s).\n";
44745
+ const { seconds: seconds7, missing: missing4 } = made.short;
44746
+ return "The music is " + seconds7.toFixed(2) + " s long, " + missing4.toFixed(2) + " s shorter than the " + of.toFixed(2) + " s it is for: the last " + missing4.toFixed(2) + " s of the video would have no music. Order a longer track (this command with --seconds " + musicSeconds(of + missing4 + MARGIN_SECONDS) + " is a new order, priced and agreed anew; the music is faded out at the end of the video), or end the video with the music (shorten its last scene by " + missing4.toFixed(2) + " s).\n";
44644
44747
  };
44645
44748
  overLimit = (e, items, max) => {
44646
44749
  if (!(e instanceof PopostApiError && e.code === "CREDIT_LIMIT_EXCEEDED")) throw e;
@@ -45274,7 +45377,7 @@ var init_sfx = __esm({
45274
45377
  });
45275
45378
 
45276
45379
  // src/video/sound/analysis.ts
45277
- var MAX_ANALYSIS_SECONDS, MAX_ANALYSIS_BYTES, POLL_MS5, WAIT_LIMIT_MS3, heardSound, measureFile, missing, firstLine, planAnalysis, untilDone3, runAnalysis;
45380
+ var MAX_ANALYSIS_SECONDS, MAX_ANALYSIS_BYTES, POLL_MS5, WAIT_LIMIT_MS3, heardSound, measureFile, missing2, firstLine, planAnalysis, untilDone3, runAnalysis;
45278
45381
  var init_analysis = __esm({
45279
45382
  "src/video/sound/analysis.ts"() {
45280
45383
  "use strict";
@@ -45305,7 +45408,7 @@ var init_analysis = __esm({
45305
45408
  const m = measureSound(pcm, 22050, picture3);
45306
45409
  return loudness === void 0 ? m : { ...m, loudness };
45307
45410
  };
45308
- missing = (e) => e instanceof PopostApiError && (e.status === 404 || e.code === "NOT_FOUND");
45411
+ missing2 = (e) => e instanceof PopostApiError && (e.status === 404 || e.code === "NOT_FOUND");
45309
45412
  firstLine = (e) => (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "failed";
45310
45413
  planAnalysis = async (rt, sound2, o = {}) => {
45311
45414
  if (!sound2) return { kind: "none", record: { status: "silent" } };
@@ -45318,7 +45421,7 @@ var init_analysis = __esm({
45318
45421
  const credits = await quoteSoundAnalysis(rt, sound2.seconds);
45319
45422
  return { kind: "run", credits, item: { kind: "sound-analysis", what: o.what ?? "the sound of the reference (music, ambience, effects)", credits, seconds: sound2.seconds } };
45320
45423
  } catch (e) {
45321
- if (missing(e)) return { kind: "none", record: { status: "unavailable" } };
45424
+ if (missing2(e)) return { kind: "none", record: { status: "unavailable" } };
45322
45425
  if (e instanceof PopostApiError) return { kind: "none", record: { status: "failed", why: "its price could not be read: " + firstLine(e) } };
45323
45426
  throw e;
45324
45427
  }
@@ -45351,7 +45454,7 @@ var init_analysis = __esm({
45351
45454
  if (done2.state !== "ready" || !done2.result) return { status: "failed", id: done2.id, chargedCredits: 0, why: done2.failure ?? "the analysis ended " + (done2.state || "without a result") };
45352
45455
  return { status: "done", id: done2.id, chargedCredits: charged, result: done2.result };
45353
45456
  } catch (e) {
45354
- if (missing(e)) return { status: "unavailable" };
45457
+ if (missing2(e)) return { status: "unavailable" };
45355
45458
  if (e instanceof AmbiguousSubmitError || e instanceof ToolError || e instanceof PopostApiError) return { status: "failed", why: firstLine(e) };
45356
45459
  throw e;
45357
45460
  }
@@ -46801,11 +46904,11 @@ var init_review2 = __esm({
46801
46904
  const seconds7 = Math.round(v.frames / v.fps * 1e3) / 1e3;
46802
46905
  const audio = rebind(old?.audio, [{ kind: "observed", detail: "The sound of the final video, all " + seconds7 + " s: its voices, music and effects against the reference.", file: v.file, sha256: v.fingerprint, media: "video", at: [0, seconds7] }], v, old?.artifactFingerprint, changed2);
46803
46906
  const visual = rebind(old?.visual, o.visual.map((f) => frameEvidence(v, f, "its medium, finish and layout against the reference.")), v, old?.artifactFingerprint, changed2);
46804
- const missing3 = [];
46907
+ const missing4 = [];
46805
46908
  const events = c.events.map((e) => {
46806
46909
  const planned = o.plan?.events.find((p) => p.id === e.id);
46807
46910
  const frames = o.events[e.id] ?? (planned ? spanFrames2(planned.span, v.frames) : void 0);
46808
- if (!frames) missing3.push(e.id);
46911
+ if (!frames) missing4.push(e.id);
46809
46912
  const names = ["lead-in", "middle", "resolved state"];
46810
46913
  const bound = (frames ?? []).map((f, k, all) => frameEvidence(v, f, (all.length === 3 ? names[k] : "a state") + ' of "' + short(e.description) + '" (' + e.id + ")."));
46811
46914
  return { id: e.id, ...rebind(old?.events?.find((x) => x.id === e.id), bound, v, old?.artifactFingerprint, changed2), frames: frames ?? [] };
@@ -46821,7 +46924,7 @@ var init_review2 = __esm({
46821
46924
  events: events.map(({ frames: _frames, ...finding }) => finding),
46822
46925
  ...old?.audioUses ? { audioUses: old.audioUses } : o.audioUses ? { audioUses: o.audioUses } : {}
46823
46926
  };
46824
- return { review: review3, changed: changed2, missing: missing3, frames: [{ name: "audio", frames: [] }, { name: "visual", frames: o.visual }, ...events.map((e) => ({ name: e.id, frames: e.frames }))] };
46927
+ return { review: review3, changed: changed2, missing: missing4, frames: [{ name: "audio", frames: [] }, { name: "visual", frames: o.visual }, ...events.map((e) => ({ name: e.id, frames: e.frames }))] };
46825
46928
  };
46826
46929
  withVerdicts = (r, passed, failed4) => {
46827
46930
  const names = /* @__PURE__ */ new Set(["audio", "visual", ...(r.events ?? []).map((e) => e.id)]);
@@ -47695,7 +47798,7 @@ var openSystemBrowser = async (url, host) => {
47695
47798
  };
47696
47799
 
47697
47800
  // src/node-runtime.ts
47698
- var missing2 = (error2) => error2?.code === "ENOENT";
47801
+ var missing3 = (error2) => error2?.code === "ENOENT";
47699
47802
  var nodeFileSystem = {
47700
47803
  realpath: (p) => fsp.realpath(p),
47701
47804
  readFile: async (p) => new Uint8Array(await fsp.readFile(p)),
@@ -47723,7 +47826,7 @@ var nodeFileSystem = {
47723
47826
  const s = await fsp.stat(p);
47724
47827
  return { isFile: s.isFile(), isDirectory: s.isDirectory(), size: s.size, mtimeMs: s.mtimeMs };
47725
47828
  } catch (error2) {
47726
- if (missing2(error2)) return null;
47829
+ if (missing3(error2)) return null;
47727
47830
  throw error2;
47728
47831
  }
47729
47832
  },
@@ -47867,7 +47970,7 @@ var readOptional = (file) => {
47867
47970
  try {
47868
47971
  return readFileSync(file, "utf8");
47869
47972
  } catch (error2) {
47870
- if (missing2(error2)) return null;
47973
+ if (missing3(error2)) return null;
47871
47974
  throw error2;
47872
47975
  }
47873
47976
  };