demoman 0.8.0 → 0.8.1

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 (69) hide show
  1. package/THIRD_PARTY_NOTICES +1 -1
  2. package/dist/demoman.mjs +5182 -2298
  3. package/dist/page/decode-probe-entry.js +23071 -0
  4. package/dist/page/mux-entry.js +171 -52
  5. package/dist/page/render-entry.js +1102 -469
  6. package/dist/recipe.md +92 -100
  7. package/dist/studio/assets/confirm-dialog-B20ZVWlP.css +1 -0
  8. package/dist/studio/assets/confirm-dialog-DgJ946Hc.js +72 -0
  9. package/dist/studio/assets/editor-BC4sLdWT.js +4 -0
  10. package/dist/studio/assets/library-DVubUJtn.js +1 -0
  11. package/dist/studio/assets/{library-inline-216fd6fd.css → library-inline-ff1b0c15.css} +3 -27
  12. package/dist/studio/assets/settings-DLH9VoT0.js +1 -0
  13. package/dist/studio/assets/{settings-inline-ff6d2eee.css → settings-inline-7bb8bf61.css} +8 -0
  14. package/dist/studio/assets/state-DyL2jOOv.js +1 -0
  15. package/dist/studio/assets/view-Df6XUnyO.js +1 -0
  16. package/dist/studio/editor.html +5 -5
  17. package/dist/studio/library.html +5 -5
  18. package/dist/studio/settings.html +5 -5
  19. package/dist/studio/studio-build.json +3 -3
  20. package/dist/studio/wallpapers/dark-1-landscape.webp +0 -0
  21. package/dist/studio/wallpapers/dark-1-portrait.webp +0 -0
  22. package/dist/studio/wallpapers/dark-1-thumb.webp +0 -0
  23. package/dist/studio/wallpapers/dark-2-landscape.webp +0 -0
  24. package/dist/studio/wallpapers/dark-2-portrait.webp +0 -0
  25. package/dist/studio/wallpapers/dark-2-thumb.webp +0 -0
  26. package/dist/studio/wallpapers/light-1-landscape.webp +0 -0
  27. package/dist/studio/wallpapers/light-1-portrait.webp +0 -0
  28. package/dist/studio/wallpapers/light-1-thumb.webp +0 -0
  29. package/dist/studio/wallpapers/light-2-landscape.webp +0 -0
  30. package/dist/studio/wallpapers/light-2-portrait.webp +0 -0
  31. package/dist/studio/wallpapers/light-2-thumb.webp +0 -0
  32. package/dist/studio/wallpapers/muted-1-landscape.webp +0 -0
  33. package/dist/studio/wallpapers/muted-1-portrait.webp +0 -0
  34. package/dist/studio/wallpapers/muted-1-thumb.webp +0 -0
  35. package/dist/studio/wallpapers/muted-2-landscape.webp +0 -0
  36. package/dist/studio/wallpapers/muted-2-portrait.webp +0 -0
  37. package/dist/studio/wallpapers/muted-2-thumb.webp +0 -0
  38. package/dist/studio/wallpapers/muted-3-landscape.webp +0 -0
  39. package/dist/studio/wallpapers/muted-3-portrait.webp +0 -0
  40. package/dist/studio/wallpapers/muted-3-thumb.webp +0 -0
  41. package/dist/studio/wallpapers/muted-4-landscape.webp +0 -0
  42. package/dist/studio/wallpapers/muted-4-portrait.webp +0 -0
  43. package/dist/studio/wallpapers/muted-4-thumb.webp +0 -0
  44. package/dist/studio/wallpapers/vivid-1-landscape.webp +0 -0
  45. package/dist/studio/wallpapers/vivid-1-portrait.webp +0 -0
  46. package/dist/studio/wallpapers/vivid-1-thumb.webp +0 -0
  47. package/dist/studio/wallpapers/vivid-2-landscape.webp +0 -0
  48. package/dist/studio/wallpapers/vivid-2-portrait.webp +0 -0
  49. package/dist/studio/wallpapers/vivid-2-thumb.webp +0 -0
  50. package/dist/studio/wallpapers/vivid-3-landscape.webp +0 -0
  51. package/dist/studio/wallpapers/vivid-3-portrait.webp +0 -0
  52. package/dist/studio/wallpapers/vivid-3-thumb.webp +0 -0
  53. package/dist/studio/wallpapers/vivid-4-landscape.webp +0 -0
  54. package/dist/studio/wallpapers/vivid-4-portrait.webp +0 -0
  55. package/dist/studio/wallpapers/vivid-4-thumb.webp +0 -0
  56. package/dist/studio/wallpapers/vivid-5-landscape.webp +0 -0
  57. package/dist/studio/wallpapers/vivid-5-portrait.webp +0 -0
  58. package/dist/studio/wallpapers/vivid-5-thumb.webp +0 -0
  59. package/dist/studio/wallpapers/vivid-6-landscape.webp +0 -0
  60. package/dist/studio/wallpapers/vivid-6-portrait.webp +0 -0
  61. package/dist/studio/wallpapers/vivid-6-thumb.webp +0 -0
  62. package/package.json +1 -1
  63. package/dist/studio/assets/confirm-dialog-Bcrw3f1a.js +0 -72
  64. package/dist/studio/assets/confirm-dialog-DSKBZQdV.css +0 -1
  65. package/dist/studio/assets/editor-DUZKtJ2T.js +0 -4
  66. package/dist/studio/assets/library-BPokDo6m.js +0 -1
  67. package/dist/studio/assets/settings-RZj4oUzT.js +0 -1
  68. package/dist/studio/assets/state-tew-ACWl.js +0 -1
  69. package/dist/studio/assets/view-SxAupNyx.js +0 -1
@@ -944,6 +944,63 @@
944
944
  };
945
945
  }
946
946
 
947
+ // ../../packages/run-core/dist/render/mp4-cap.js
948
+ var HEADROOM = 0.92;
949
+ function fitBitrate(maxBytes, durationMs) {
950
+ return Math.round(maxBytes * HEADROOM * 8 / (durationMs / 1e3));
951
+ }
952
+ var sizeOf = (t) => ({ width: t.width, height: t.height });
953
+ function capLadder(asked, { share, floor }, fit) {
954
+ const rungs = [];
955
+ let at = asked;
956
+ if (at.fps > share.fps) {
957
+ const target = {
958
+ ...at,
959
+ fps: share.fps,
960
+ bitrate: Math.round(at.bitrate * share.fps / at.fps)
961
+ };
962
+ rungs.push({ target, step: { kind: "fps", from: at.fps, to: share.fps } });
963
+ at = target;
964
+ }
965
+ const shareQuality = share.encoder?.quality;
966
+ const quality = at.encoder?.quality;
967
+ const atShare = at.width === share.width && at.height === share.height && (shareQuality === void 0 || quality !== void 0 && quality <= shareQuality);
968
+ if (!atShare) {
969
+ rungs.push({
970
+ target: share,
971
+ step: {
972
+ kind: "share",
973
+ from: sizeOf(at),
974
+ to: sizeOf(share),
975
+ ...shareQuality === void 0 ? {} : { quality: shareQuality }
976
+ }
977
+ });
978
+ at = share;
979
+ }
980
+ if (at.width !== floor.width || at.height !== floor.height) {
981
+ rungs.push({
982
+ target: floor,
983
+ step: { kind: "frame", from: sizeOf(at), to: sizeOf(floor) }
984
+ });
985
+ }
986
+ const { quality: _byQuality, ...byBitrate } = floor.encoder ?? {};
987
+ rungs.push({
988
+ target: { ...floor, bitrate: fit.bitrate, encoder: byBitrate },
989
+ step: { kind: "fit", ...fit }
990
+ });
991
+ return rungs;
992
+ }
993
+ function fitRetry(fit, maxBytes, actualBytes) {
994
+ const bitrate = Math.round(fit.target.bitrate * maxBytes * HEADROOM / actualBytes);
995
+ if (fit.step.kind !== "fit") {
996
+ throw new Error(`fitRetry retries a fit rung, not a ${fit.step.kind} one`);
997
+ }
998
+ return {
999
+ target: { ...fit.target, bitrate },
1000
+ step: { kind: "fit", bitrate, durationMs: fit.step.durationMs }
1001
+ };
1002
+ }
1003
+
947
1004
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
948
1005
  var external_exports = {};
949
1006
  __export(external_exports, {
@@ -15978,6 +16035,73 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15978
16035
  userAgentMetadata: UserAgentMetadataSchema.optional()
15979
16036
  });
15980
16037
 
16038
+ // ../../packages/scene-schema/dist/wallpapers.js
16039
+ var WALLPAPERS = [
16040
+ {
16041
+ id: "muted-1",
16042
+ family: "muted",
16043
+ swatch: { from: "#141422", to: "#26233e" }
16044
+ },
16045
+ {
16046
+ id: "muted-2",
16047
+ family: "muted",
16048
+ swatch: { from: "#bfb5aa", to: "#a19486" }
16049
+ },
16050
+ {
16051
+ id: "muted-3",
16052
+ family: "muted",
16053
+ swatch: { from: "#1b1e1d", to: "#51625d" }
16054
+ },
16055
+ {
16056
+ id: "muted-4",
16057
+ family: "muted",
16058
+ swatch: { from: "#a3a299", to: "#cfcbc3" }
16059
+ },
16060
+ {
16061
+ id: "vivid-1",
16062
+ family: "vivid",
16063
+ swatch: { from: "#3527bc", to: "#ce1676" }
16064
+ },
16065
+ {
16066
+ id: "vivid-2",
16067
+ family: "vivid",
16068
+ swatch: { from: "#0769ca", to: "#1e26b7" }
16069
+ },
16070
+ {
16071
+ id: "vivid-3",
16072
+ family: "vivid",
16073
+ swatch: { from: "#c90757", to: "#ed480d" }
16074
+ },
16075
+ {
16076
+ id: "vivid-4",
16077
+ family: "vivid",
16078
+ swatch: { from: "#0ba393", to: "#0575c7" }
16079
+ },
16080
+ {
16081
+ id: "vivid-5",
16082
+ family: "vivid",
16083
+ swatch: { from: "#f28b0a", to: "#df2d21" }
16084
+ },
16085
+ {
16086
+ id: "vivid-6",
16087
+ family: "vivid",
16088
+ swatch: { from: "#3d0dbf", to: "#133ac7" }
16089
+ },
16090
+ {
16091
+ id: "light-1",
16092
+ family: "light",
16093
+ swatch: { from: "#b7bff3", to: "#eda9c5" }
16094
+ },
16095
+ {
16096
+ id: "light-2",
16097
+ family: "light",
16098
+ swatch: { from: "#afe5f0", to: "#98c5e8" }
16099
+ },
16100
+ { id: "dark-1", family: "dark", swatch: { from: "#150217", to: "#3d044b" } },
16101
+ { id: "dark-2", family: "dark", swatch: { from: "#02576e", to: "#023758" } }
16102
+ ];
16103
+ var DEFAULT_WALLPAPER_ID = "muted-1";
16104
+
15981
16105
  // ../../packages/scene-schema/dist/document.js
15982
16106
  var CURRENT_SCHEMA_VERSION = 13;
15983
16107
  var Rect = external_exports.object({
@@ -16302,7 +16426,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16302
16426
  * it came with the v10 bump all the same: a build from before would read
16303
16427
  * `capture` without it and rebuild a phone take on the desktop.
16304
16428
  */
16305
- device: CaptureDeviceSchema.optional()
16429
+ device: CaptureDeviceSchema.optional(),
16430
+ /**
16431
+ * The display scale the run filmed motion at: the scale screencast spans
16432
+ * follow, which `dpr` (the stills' scale) is not. Written by the run that
16433
+ * decided it (the CLI's browser session, at launch), so `keep` reads it
16434
+ * rather than guessing from the frames. Absent on takes filmed before it
16435
+ * and where the run could not know it (a visible window, whose scale is
16436
+ * the OS's). Widening with an optional field is backward compatible, as
16437
+ * `mode`'s was: `CURRENT_SCHEMA_VERSION` stays and no migration is owed.
16438
+ */
16439
+ displayScale: external_exports.number().positive().optional()
16306
16440
  }),
16307
16441
  /**
16308
16442
  * Which render this scene wants: `screen` serves the frames the take
@@ -16382,6 +16516,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16382
16516
  aspect: "auto"
16383
16517
  });
16384
16518
  var BrandColorSchema = external_exports.string().regex(/^#[0-9a-f]{6}$/);
16519
+ var WallpaperBlurSchema = external_exports.number().min(0).max(1).optional();
16520
+ var DEFAULT_WALLPAPER_BLUR = 0;
16385
16521
  var BackgroundSchema = external_exports.discriminatedUnion("kind", [
16386
16522
  external_exports.object({ kind: external_exports.literal("solid"), color: BrandColorSchema }),
16387
16523
  external_exports.object({
@@ -16390,6 +16526,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16390
16526
  to: BrandColorSchema,
16391
16527
  /** CSS convention: 0 = to top, 90 = to right, 180 = to bottom. */
16392
16528
  angle: external_exports.number().int().min(0).max(359)
16529
+ }),
16530
+ // Not restricted to `WALLPAPERS`: a take naming an id a later build
16531
+ // removed still loads, and export says so. A script is checked against
16532
+ // the list in `DemoScriptSchema`.
16533
+ external_exports.object({
16534
+ kind: external_exports.literal("wallpaper"),
16535
+ id: external_exports.string().regex(/^[a-z0-9-]+$/),
16536
+ blur: WallpaperBlurSchema
16537
+ }),
16538
+ external_exports.object({
16539
+ kind: external_exports.literal("image"),
16540
+ ref: external_exports.string().min(1),
16541
+ blur: WallpaperBlurSchema
16393
16542
  })
16394
16543
  ]);
16395
16544
  var LOGO_CORNERS = [
@@ -16424,21 +16573,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16424
16573
  angle: 150
16425
16574
  });
16426
16575
  var BRANDING_DEFAULTS = Object.freeze({
16427
- background: NEUTRAL_BACKGROUND,
16576
+ background: Object.freeze({
16577
+ kind: "wallpaper",
16578
+ id: DEFAULT_WALLPAPER_ID,
16579
+ blur: DEFAULT_WALLPAPER_BLUR
16580
+ }),
16428
16581
  logo: null,
16429
16582
  /**
16430
- * 8%: the margin of a polished recording, near enough (8.4% measured on
16431
- * 2026-10-05), and the smallest padding that draws the default logo at
16432
- * full size.
16433
- * `placeLogo` keeps a mark 0.02 × short in from the edge and clear of the
16434
- * recording, so a logo of size `s` fits only when the padding is at least
16435
- * `s + 0.02`, and `LOGO_DEFAULTS.size` is 0.06.
16583
+ * 12%: the author's call on 2026-10-28, from a side-by-side with the
16584
+ * wallpapers, which want more of the frame to show. It was 8% from
16585
+ * 2026-10-05 (the margin of a polished recording, 8.4% measured), the
16586
+ * smallest padding that draws the default logo at full size; documents
16587
+ * migrated from v7 still get that 8% (`migrations.ts`), so nothing saved
16588
+ * changes. `placeLogo` keeps a mark 0.02 × short in from the edge and
16589
+ * clear of the recording, so a logo of size `s` fits only when the padding
16590
+ * is at least `s + 0.02`; `LOGO_DEFAULTS.size` is 0.06, well inside.
16436
16591
  *
16437
16592
  * Landscape exports used 15% until 2026-10-05 for zoom headroom: a
16438
16593
  * smaller window leaves more source detail per output pixel. That trade
16439
16594
  * is the author's now; `clampToSourceDetail` reports what it costs.
16440
16595
  */
16441
- padding: 0.08
16596
+ padding: 0.12
16442
16597
  });
16443
16598
  var LOGO_DEFAULTS = Object.freeze({
16444
16599
  corner: "bottom-right",
@@ -16854,6 +17009,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16854
17009
  path: ["scriptVersion"]
16855
17010
  });
16856
17011
  }
17012
+ const bg = script.look?.branding?.background;
17013
+ if (bg?.kind === "wallpaper" && !WALLPAPERS.some((w) => w.id === bg.id)) {
17014
+ ctx.addIssue({
17015
+ code: "custom",
17016
+ message: `unknown wallpaper "${bg.id}" \u2014 one of ${WALLPAPERS.map((w) => w.id).join(", ")}`,
17017
+ path: ["look", "branding", "background", "id"]
17018
+ });
17019
+ }
16857
17020
  if (script.look?.motion !== void 0 && script.scriptVersion < SCRIPT_VERSION_MOTION) {
16858
17021
  ctx.addIssue({
16859
17022
  code: "custom",
@@ -17858,8 +18021,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17858
18021
  }
17859
18022
  return stretches;
17860
18023
  }
17861
- function sampleTrack(track, outputTimeMs) {
17862
- const base = sampleCamera(track.cameraKeys, outputTimeMs);
18024
+ function sampleTrack(track, outputTimeMs, legal = (center) => center) {
18025
+ const keys = track.cameraKeys.map((key) => ({
18026
+ ...key,
18027
+ center: legal(key.center, key.scale)
18028
+ }));
18029
+ const base = sampleCamera(keys, outputTimeMs);
17863
18030
  if (base.scale <= 1)
17864
18031
  return base;
17865
18032
  const stretch = track.cameraFollow.find((s) => s.startMs <= outputTimeMs && outputTimeMs <= s.endMs);
@@ -17872,13 +18039,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17872
18039
  const next = stretch.centers[i + 1];
17873
18040
  const spring = next === void 0 ? here : lerpVec(here, next, (outputTimeMs - timeOf(i)) / (timeOf(i + 1) - timeOf(i)));
17874
18041
  if (outputTimeMs < stretch.pullOutDepartMs) {
17875
- return { center: spring, scale: base.scale };
18042
+ return { center: legal(spring, base.scale), scale: base.scale };
17876
18043
  }
17877
- const from = sampleCamera(track.cameraKeys, stretch.pullOutDepartMs).scale;
18044
+ const from = sampleCamera(keys, stretch.pullOutDepartMs).scale;
17878
18045
  if (from <= 1)
17879
18046
  return base;
17880
- const w = (base.scale - 1) / (from - 1);
17881
- return { center: lerpVec(base.center, spring, w), scale: base.scale };
18047
+ const landing = sampleCamera(keys, stretch.endMs).center;
18048
+ const w = (1 / from - 1 / base.scale) / (1 / from - 1);
18049
+ return {
18050
+ center: lerpVec(legal(spring, from), landing, w),
18051
+ scale: base.scale
18052
+ };
18053
+ }
18054
+ function frameTrack(track, outputTimeMs, base, frameRect, viewport, canvas) {
18055
+ const legal = (center, scale) => frameCamera({ center, scale }, base, frameRect, viewport, canvas).center;
18056
+ return frameCamera(sampleTrack(track, outputTimeMs, legal), base, frameRect, viewport, canvas);
17882
18057
  }
17883
18058
 
17884
18059
  // ../../packages/compositor/dist/plan/cursor.js
@@ -17964,123 +18139,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17964
18139
  });
17965
18140
  }
17966
18141
 
17967
- // ../../packages/compositor/dist/version.js
17968
- var COMPOSITOR_VERSION = "1.1.0";
17969
-
17970
- // ../../packages/compositor/dist/plan/cosmetics.js
17971
- function planCosmetics(scene) {
17972
- return scene.edits.masks.map((m) => ({
17973
- id: m.id,
17974
- kind: "mask",
17975
- rect: m.rect,
17976
- // Both or neither, by the schema's refinement. Neither is the whole take.
17977
- range: m.start && m.end ? { start: m.start, end: m.end } : null
17978
- }));
17979
- }
17980
-
17981
- // ../../packages/compositor/dist/plan/plan.js
17982
- var RETIMING_DEFAULTS = {
17983
- motionDiffThreshold: 0.02
17984
- };
17985
- function planScene(scene, opts = {}) {
17986
- const anchorRects = /* @__PURE__ */ new Map();
17987
- for (const anchor2 of scene.anchors) {
17988
- const rect2 = anchor2.fingerprint.boundingRect;
17989
- if (rect2)
17990
- anchorRects.set(anchor2.id, rect2);
17991
- }
17992
- const actionRects = /* @__PURE__ */ new Map();
17993
- for (const action of scene.actions) {
17994
- if (action.rect)
17995
- actionRects.set(action.id, action.rect);
17996
- }
17997
- const rectOf = (anchorId, actionId) => actionRects.get(actionId) ?? anchorRects.get(anchorId) ?? null;
17998
- const lastAction = scene.actions[scene.actions.length - 1];
17999
- const removed = scene.edits.removed ?? [];
18000
- const cutSteps = stepsInsideRemoved(scene);
18001
- const attachedToCuts = [];
18002
- const gapAfter = new Map((scene.edits.gaps ?? []).map((gap) => [gap.afterActionId, gap]));
18003
- const paces = [];
18004
- for (let i = 0; i + 1 < scene.actions.length; i++) {
18005
- const from = scene.actions[i];
18006
- const to = scene.actions[i + 1];
18007
- if (!from || !to)
18008
- continue;
18009
- const authored = gapAfter.get(from.id);
18010
- const anchors = { afterActionId: from.id, beforeActionId: to.id };
18011
- paces.push(authored ? { ...anchors, origin: "authored", idleTargetMs: authored.durationMs } : {
18012
- ...anchors,
18013
- origin: "recorded",
18014
- // Raw, and negative when the log does not ascend. This carried a
18015
- // `max(0, …)` until 2026-09-25, under a comment claiming the
18016
- // floor "cannot fire through any path the editor offers" —
18017
- // `resequence` rewrites timestamps after a reorder, the trims
18018
- // only remove entries, `insertedAt` interpolates. All true, and
18019
- // all about the EDITOR; the capture path was never checked.
18020
- // `expandWaits` (extension `core/reduce.ts`) stamped a readiness
18021
- // wait at the moment its element appeared, which for anything
18022
- // present at page load is the take's origin, and placed it
18023
- // beside the action it gates — dropping an early timestamp into
18024
- // the middle of an otherwise ascending log. The floor turned
18025
- // that pair's interval into a clean 0, indistinguishable from
18026
- // two simultaneous actions, while the pair AFTER it went on to
18027
- // claim the dead air this pair should have carried. A rebuild
18028
- // froze for both and rendered 0:44 against a 0:31 take.
18029
- //
18030
- // The stamp is fixed at its source. The floor moves to
18031
- // `idleTargetMsFor`, which needs it anyway (a negative target
18032
- // would walk the output cursor backwards and break the
18033
- // monotonicity of `toSourceMs`/`toOutputMs`), and the fact
18034
- // survives the trip so `buildTimeline` can count it into
18035
- // `Timeline.nonMonotonicPaces` rather than smooth it away.
18036
- recordedSpanMs: to.timestamp - from.timestamp
18037
- });
18038
- }
18039
- return {
18040
- planVersion: 1,
18041
- compositorVersion: COMPOSITOR_VERSION,
18042
- sceneId: scene.meta.id,
18043
- viewport: scene.meta.capture.viewport,
18044
- // Deliberately NOT filtered by `cutSteps`. This is SP5's replay
18045
- // instruction list, not a drawing decision: a rebuild performs every
18046
- // step the take holds, and the cut removes the frames it produced
18047
- // afterwards. Skipping a cut step here would drive the app down a path
18048
- // the author never recorded.
18049
- cursorSegments: planCursorSegments(scene, rectOf),
18050
- cameraIntents: planCameraIntents(scene, cutSteps, attachedToCuts),
18051
- cosmetics: planCosmetics(scene),
18052
- holds: (scene.edits.holds ?? []).flatMap((hold) => {
18053
- if (cutSteps.has(hold.marker.actionId)) {
18054
- attachedToCuts.push({
18055
- id: hold.id,
18056
- kind: "hold",
18057
- actionId: hold.marker.actionId
18058
- });
18059
- return [];
18060
- }
18061
- return [
18062
- {
18063
- id: hold.id,
18064
- actionId: hold.marker.actionId,
18065
- offsetMs: hold.marker.offsetMs,
18066
- durationMs: hold.durationMs
18067
- }
18068
- ];
18069
- }),
18070
- paces,
18071
- removed,
18072
- removedSteps: [...cutSteps],
18073
- attachedToCuts,
18074
- trim: {
18075
- head: scene.edits.trim?.head ?? null,
18076
- tail: scene.edits.trim?.tail ?? null
18077
- },
18078
- retiming: { ...RETIMING_DEFAULTS, ...opts.retiming },
18079
- hoverSensitive: scene.flags.hoverSensitive,
18080
- durationHintMs: lastAction?.timestamp ?? 0
18081
- };
18082
- }
18083
-
18084
18142
  // ../../packages/compositor/dist/plan/smooth.js
18085
18143
  var CURSOR_SMOOTHING_MS = 30;
18086
18144
  var KERNEL_REACH_SIGMAS = 3;
@@ -18669,6 +18727,123 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18669
18727
  var speedOf = (v) => Math.hypot(v.x, v.y);
18670
18728
  var negate = (v) => ({ x: -v.x, y: -v.y });
18671
18729
 
18730
+ // ../../packages/compositor/dist/version.js
18731
+ var COMPOSITOR_VERSION = "1.1.0";
18732
+
18733
+ // ../../packages/compositor/dist/plan/cosmetics.js
18734
+ function planCosmetics(scene) {
18735
+ return scene.edits.masks.map((m) => ({
18736
+ id: m.id,
18737
+ kind: "mask",
18738
+ rect: m.rect,
18739
+ // Both or neither, by the schema's refinement. Neither is the whole take.
18740
+ range: m.start && m.end ? { start: m.start, end: m.end } : null
18741
+ }));
18742
+ }
18743
+
18744
+ // ../../packages/compositor/dist/plan/plan.js
18745
+ var RETIMING_DEFAULTS = {
18746
+ motionDiffThreshold: 0.02
18747
+ };
18748
+ function planScene(scene, opts = {}) {
18749
+ const anchorRects = /* @__PURE__ */ new Map();
18750
+ for (const anchor2 of scene.anchors) {
18751
+ const rect2 = anchor2.fingerprint.boundingRect;
18752
+ if (rect2)
18753
+ anchorRects.set(anchor2.id, rect2);
18754
+ }
18755
+ const actionRects = /* @__PURE__ */ new Map();
18756
+ for (const action of scene.actions) {
18757
+ if (action.rect)
18758
+ actionRects.set(action.id, action.rect);
18759
+ }
18760
+ const rectOf = (anchorId, actionId) => actionRects.get(actionId) ?? anchorRects.get(anchorId) ?? null;
18761
+ const lastAction = scene.actions[scene.actions.length - 1];
18762
+ const removed = scene.edits.removed ?? [];
18763
+ const cutSteps = stepsInsideRemoved(scene);
18764
+ const attachedToCuts = [];
18765
+ const gapAfter = new Map((scene.edits.gaps ?? []).map((gap) => [gap.afterActionId, gap]));
18766
+ const paces = [];
18767
+ for (let i = 0; i + 1 < scene.actions.length; i++) {
18768
+ const from = scene.actions[i];
18769
+ const to = scene.actions[i + 1];
18770
+ if (!from || !to)
18771
+ continue;
18772
+ const authored = gapAfter.get(from.id);
18773
+ const anchors = { afterActionId: from.id, beforeActionId: to.id };
18774
+ paces.push(authored ? { ...anchors, origin: "authored", idleTargetMs: authored.durationMs } : {
18775
+ ...anchors,
18776
+ origin: "recorded",
18777
+ // Raw, and negative when the log does not ascend. This carried a
18778
+ // `max(0, …)` until 2026-09-25, under a comment claiming the
18779
+ // floor "cannot fire through any path the editor offers" —
18780
+ // `resequence` rewrites timestamps after a reorder, the trims
18781
+ // only remove entries, `insertedAt` interpolates. All true, and
18782
+ // all about the EDITOR; the capture path was never checked.
18783
+ // `expandWaits` (extension `core/reduce.ts`) stamped a readiness
18784
+ // wait at the moment its element appeared, which for anything
18785
+ // present at page load is the take's origin, and placed it
18786
+ // beside the action it gates — dropping an early timestamp into
18787
+ // the middle of an otherwise ascending log. The floor turned
18788
+ // that pair's interval into a clean 0, indistinguishable from
18789
+ // two simultaneous actions, while the pair AFTER it went on to
18790
+ // claim the dead air this pair should have carried. A rebuild
18791
+ // froze for both and rendered 0:44 against a 0:31 take.
18792
+ //
18793
+ // The stamp is fixed at its source. The floor moves to
18794
+ // `idleTargetMsFor`, which needs it anyway (a negative target
18795
+ // would walk the output cursor backwards and break the
18796
+ // monotonicity of `toSourceMs`/`toOutputMs`), and the fact
18797
+ // survives the trip so `buildTimeline` can count it into
18798
+ // `Timeline.nonMonotonicPaces` rather than smooth it away.
18799
+ recordedSpanMs: to.timestamp - from.timestamp
18800
+ });
18801
+ }
18802
+ return {
18803
+ planVersion: 1,
18804
+ compositorVersion: COMPOSITOR_VERSION,
18805
+ sceneId: scene.meta.id,
18806
+ viewport: scene.meta.capture.viewport,
18807
+ // Deliberately NOT filtered by `cutSteps`. This is SP5's replay
18808
+ // instruction list, not a drawing decision: a rebuild performs every
18809
+ // step the take holds, and the cut removes the frames it produced
18810
+ // afterwards. Skipping a cut step here would drive the app down a path
18811
+ // the author never recorded.
18812
+ cursorSegments: planCursorSegments(scene, rectOf),
18813
+ cameraIntents: planCameraIntents(scene, cutSteps, attachedToCuts),
18814
+ cosmetics: planCosmetics(scene),
18815
+ holds: (scene.edits.holds ?? []).flatMap((hold) => {
18816
+ if (cutSteps.has(hold.marker.actionId)) {
18817
+ attachedToCuts.push({
18818
+ id: hold.id,
18819
+ kind: "hold",
18820
+ actionId: hold.marker.actionId
18821
+ });
18822
+ return [];
18823
+ }
18824
+ return [
18825
+ {
18826
+ id: hold.id,
18827
+ actionId: hold.marker.actionId,
18828
+ offsetMs: hold.marker.offsetMs,
18829
+ durationMs: hold.durationMs
18830
+ }
18831
+ ];
18832
+ }),
18833
+ paces,
18834
+ removed,
18835
+ removedSteps: [...cutSteps],
18836
+ attachedToCuts,
18837
+ trim: {
18838
+ head: scene.edits.trim?.head ?? null,
18839
+ tail: scene.edits.trim?.tail ?? null
18840
+ },
18841
+ retiming: { ...RETIMING_DEFAULTS, ...opts.retiming },
18842
+ hoverSensitive: scene.flags.hoverSensitive,
18843
+ durationHintMs: lastAction?.timestamp ?? 0
18844
+ };
18845
+ }
18846
+
18672
18847
  // ../../packages/compositor/dist/plan/screen-space.js
18673
18848
  function transformAt(transforms, sourceTimeMs) {
18674
18849
  let at = transforms[0] ?? null;
@@ -19151,6 +19326,303 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19151
19326
  };
19152
19327
  }
19153
19328
 
19329
+ // ../../packages/compositor/dist/render/draw-cursor.js
19330
+ var PULSE_DURATION_MS = 400;
19331
+ var PRESS_DURATION_MS = 110;
19332
+ var CURSOR_UPRIGHT = Object.freeze({
19333
+ press: 1,
19334
+ angleRad: 0
19335
+ });
19336
+ var ARROW = [
19337
+ { x: 0, y: 0 },
19338
+ { x: 0, y: 0.75 },
19339
+ { x: 0.19, y: 0.58 },
19340
+ { x: 0.31, y: 0.87 },
19341
+ { x: 0.45, y: 0.81 },
19342
+ { x: 0.33, y: 0.53 },
19343
+ { x: 0.56, y: 0.52 }
19344
+ ];
19345
+ var TOUCH_RADIUS = 0.42;
19346
+ var CURSOR_ART = {
19347
+ light: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
19348
+ dark: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
19349
+ touch: {
19350
+ height: 40,
19351
+ hotspot: { x: 0.5, y: 0.5 },
19352
+ ink: {
19353
+ min: { x: 0.5 - TOUCH_RADIUS, y: 0.5 - TOUCH_RADIUS },
19354
+ max: { x: 0.5 + TOUCH_RADIUS, y: 0.5 + TOUCH_RADIUS }
19355
+ }
19356
+ }
19357
+ };
19358
+ function bounds(points) {
19359
+ const xs = points.map((p) => p.x);
19360
+ const ys = points.map((p) => p.y);
19361
+ return {
19362
+ min: { x: Math.min(...xs), y: Math.min(...ys) },
19363
+ max: { x: Math.max(...xs), y: Math.max(...ys) }
19364
+ };
19365
+ }
19366
+ var INK = {
19367
+ light: { fill: "#ffffff", stroke: "#111827" },
19368
+ dark: { fill: "#111827", stroke: "#ffffff" },
19369
+ touch: { fill: "rgba(255, 255, 255, 0.45)", stroke: "#111827" }
19370
+ };
19371
+ function drawCursor(ctx, at, scale, pose, style = "light") {
19372
+ const size = CURSOR_ART[style].height * scale * pose.press;
19373
+ const ink = INK[style];
19374
+ ctx.save();
19375
+ ctx.translate(at.x, at.y);
19376
+ if (style !== "touch" && pose.angleRad !== 0)
19377
+ ctx.rotate(pose.angleRad);
19378
+ ctx.beginPath();
19379
+ if (style === "touch") {
19380
+ ctx.arc(0, 0, size * TOUCH_RADIUS, 0, Math.PI * 2);
19381
+ } else {
19382
+ const first = ARROW[0];
19383
+ if (first) {
19384
+ ctx.moveTo(first.x * size, first.y * size);
19385
+ for (const point2 of ARROW.slice(1))
19386
+ ctx.lineTo(point2.x * size, point2.y * size);
19387
+ }
19388
+ }
19389
+ ctx.closePath();
19390
+ ctx.shadowColor = "rgba(15, 23, 42, 0.35)";
19391
+ ctx.shadowBlur = 3 * scale;
19392
+ ctx.shadowOffsetY = 1.5 * scale;
19393
+ ctx.fillStyle = ink.fill;
19394
+ ctx.fill();
19395
+ ctx.shadowColor = "transparent";
19396
+ ctx.lineWidth = Math.max(1, 1.4 * scale);
19397
+ ctx.lineJoin = "round";
19398
+ ctx.strokeStyle = ink.stroke;
19399
+ ctx.stroke();
19400
+ ctx.restore();
19401
+ }
19402
+ var CURSOR_EXPOSURE_MS = 32;
19403
+ var CURSOR_TRAIL_MIN_TRAVEL_PX = 1;
19404
+ var TRAIL_PEAK_ALPHA = 0.55;
19405
+ function cursorTrailStamps(motionBlur) {
19406
+ if (motionBlur <= 0)
19407
+ return 0;
19408
+ return Math.ceil(2 + 8 * clamp(motionBlur, 0, 1));
19409
+ }
19410
+ function drawCursorTrail(ctx, positions, scale, style) {
19411
+ if (positions.length === 0)
19412
+ return;
19413
+ const priorAlpha = ctx.globalAlpha;
19414
+ positions.forEach((position, i) => {
19415
+ const t = (i + 1) / (positions.length + 1);
19416
+ ctx.globalAlpha = priorAlpha * t * t * TRAIL_PEAK_ALPHA;
19417
+ const pose = { press: 1, angleRad: position.angleRad ?? 0 };
19418
+ drawCursor(ctx, position, scale, pose, style);
19419
+ });
19420
+ ctx.globalAlpha = priorAlpha;
19421
+ }
19422
+ function drawClickPulse(ctx, at, scale, t) {
19423
+ if (t < 0 || t > 1)
19424
+ return;
19425
+ const eased = 1 - (1 - t) ** 3;
19426
+ const radius = 16 * scale * (1 + 2.2 * eased);
19427
+ const alpha = 1 - t;
19428
+ const core = Math.max(1, 2.5 * scale);
19429
+ const edge = Math.max(0.75, 1.25 * scale);
19430
+ const offset = (core + edge) / 2;
19431
+ ctx.save();
19432
+ ring(ctx, at, radius - offset, edge, `rgba(15, 23, 42, ${0.75 * alpha})`);
19433
+ ring(ctx, at, radius + offset, edge, `rgba(15, 23, 42, ${0.75 * alpha})`);
19434
+ ring(ctx, at, radius, core, `rgba(255, 255, 255, ${0.95 * alpha})`);
19435
+ ctx.restore();
19436
+ }
19437
+ function ring(ctx, at, radius, width, style) {
19438
+ if (radius <= 0)
19439
+ return;
19440
+ ctx.beginPath();
19441
+ ctx.arc(at.x, at.y, radius, 0, Math.PI * 2);
19442
+ ctx.lineWidth = width;
19443
+ ctx.strokeStyle = style;
19444
+ ctx.stroke();
19445
+ }
19446
+
19447
+ // ../../packages/compositor/dist/render/cursor-pose.js
19448
+ var PRESS_DEPTH = 0.14;
19449
+ var RELEASE_DECAY_MS = 80;
19450
+ var RELEASE_PERIOD_MS = 320;
19451
+ var RELEASE_MS = 450;
19452
+ var smoothstep = (u) => {
19453
+ const x = clamp(u, 0, 1);
19454
+ return x * x * (3 - 2 * x);
19455
+ };
19456
+ function cursorPressScale(outputTimeMs, clickOutputMs, bounce, holds = []) {
19457
+ const depth = PRESS_DEPTH * clamp(bounce, 0, 2);
19458
+ if (depth <= 0)
19459
+ return 1;
19460
+ if (holds.some((h) => outputTimeMs >= h.startMs && outputTimeMs < h.endMs)) {
19461
+ return 1 - depth;
19462
+ }
19463
+ let previous = Number.NEGATIVE_INFINITY;
19464
+ let next = Number.POSITIVE_INFINITY;
19465
+ for (const click of [...clickOutputMs, ...holds.map((h) => h.endMs)]) {
19466
+ if (click <= outputTimeMs)
19467
+ previous = Math.max(previous, click);
19468
+ else
19469
+ next = Math.min(next, click);
19470
+ }
19471
+ const release = (at) => {
19472
+ const since = at - previous;
19473
+ if (!(since >= 0 && since <= RELEASE_MS))
19474
+ return 1;
19475
+ return 1 - depth * Math.exp(-since / RELEASE_DECAY_MS) * Math.cos(2 * Math.PI * since / RELEASE_PERIOD_MS);
19476
+ };
19477
+ if (next !== Number.POSITIVE_INFINITY) {
19478
+ const pressStart = Math.max(next - PRESS_DURATION_MS, previous);
19479
+ if (outputTimeMs >= pressStart) {
19480
+ const from = release(pressStart);
19481
+ const u = (outputTimeMs - pressStart) / (next - pressStart);
19482
+ return from + (1 - depth - from) * smoothstep(u);
19483
+ }
19484
+ }
19485
+ return release(outputTimeMs);
19486
+ }
19487
+ var TILT_MAX_RAD = 15 * Math.PI / 180;
19488
+ var TILT_VELOCITY_MS = 16;
19489
+ var TILT_FULL_SPEED_WIDTHS_PER_S = 1.1;
19490
+ var TILT_VERTICAL_WEIGHT = 0.65;
19491
+ var TILT_TAPS = 8;
19492
+ var TILT_TAP_MS = 20;
19493
+ var TILT_TAU_MS = 60;
19494
+ var TILT_SETTLE_MS = TILT_VELOCITY_MS + (TILT_TAPS - 1) * TILT_TAP_MS;
19495
+ function cursorTiltRawRad(resolved, outputTimeMs, tilt) {
19496
+ const amount = clamp(tilt, 0, 1);
19497
+ const first = resolved.cursor[0];
19498
+ const fromMs = outputTimeMs - TILT_VELOCITY_MS;
19499
+ if (amount <= 0 || !first || fromMs < 0)
19500
+ return 0;
19501
+ const fromSourceMs = toSourceMs(resolved.timeline, fromMs);
19502
+ if (fromSourceMs < first.sourceTimeMs)
19503
+ return 0;
19504
+ const from = sampleCursor(resolved.cursor, fromSourceMs);
19505
+ const to = sampleCursor(resolved.cursor, toSourceMs(resolved.timeline, outputTimeMs));
19506
+ if (!from || !to)
19507
+ return 0;
19508
+ const vx = (to.x - from.x) * 1e3 / TILT_VELOCITY_MS;
19509
+ const vy = (to.y - from.y) * 1e3 / TILT_VELOCITY_MS;
19510
+ const speed = Math.hypot(vx, vy);
19511
+ if (speed < 1e-3)
19512
+ return 0;
19513
+ const bias = clamp((vx + TILT_VERTICAL_WEIGHT * vy) / speed, -1, 1);
19514
+ const width = resolved.plan.viewport.width;
19515
+ const fullSpeed = TILT_FULL_SPEED_WIDTHS_PER_S * (width > 0 ? width : 1);
19516
+ return bias * Math.min(1, speed / fullSpeed) * TILT_MAX_RAD * amount;
19517
+ }
19518
+ function cursorTiltRad(resolved, outputTimeMs, tilt) {
19519
+ if (!(tilt > 0))
19520
+ return 0;
19521
+ let sum = 0;
19522
+ let weights = 0;
19523
+ for (let k = 0; k < TILT_TAPS; k++) {
19524
+ const weight = Math.exp(-k * TILT_TAP_MS / TILT_TAU_MS);
19525
+ sum += weight * cursorTiltRawRad(resolved, outputTimeMs - k * TILT_TAP_MS, tilt);
19526
+ weights += weight;
19527
+ }
19528
+ return sum / weights;
19529
+ }
19530
+
19531
+ // ../../packages/compositor/dist/plan/moments.js
19532
+ var MIN_SCREEN_MS = 100;
19533
+ var CAMERA_STILL_PX = 0.05;
19534
+ var CAMERA_STILL_SCALE = 1e-4;
19535
+ var CURSOR_SETTLE_MS = 200;
19536
+ function merge3(spans) {
19537
+ const out = [];
19538
+ for (const s of [...spans].sort((a, b) => a.startMs - b.startMs)) {
19539
+ const last2 = out[out.length - 1];
19540
+ if (last2 && s.startMs <= last2.endMs) {
19541
+ last2.endMs = Math.max(last2.endMs, s.endMs);
19542
+ } else {
19543
+ out.push({ ...s });
19544
+ }
19545
+ }
19546
+ return out;
19547
+ }
19548
+ function busySpans(resolved) {
19549
+ const { timeline } = resolved;
19550
+ const cursor = merge3(cursorMotionSpans(resolved.cursor).map((s) => ({
19551
+ startMs: toOutputMs(timeline, s.startMs),
19552
+ endMs: toOutputMs(timeline, s.endMs) + CURSOR_SETTLE_MS
19553
+ })));
19554
+ const page = timeline.segments.filter((s) => s.kind === "motion").map((s) => ({ startMs: s.outStartMs, endMs: s.outEndMs }));
19555
+ const presses = [
19556
+ ...resolved.clickOutputMs.map((ms) => ({ startMs: ms, endMs: ms })),
19557
+ ...resolved.taps.map((tap) => ({
19558
+ startMs: tap.outputMs,
19559
+ endMs: tap.outputMs
19560
+ })),
19561
+ ...resolved.holdOutputMs
19562
+ ].map((h) => ({
19563
+ startMs: h.startMs - PRESS_DURATION_MS,
19564
+ endMs: h.endMs + Math.max(PULSE_DURATION_MS, RELEASE_MS)
19565
+ }));
19566
+ const fades = resolved.cursorLook.hideWhenIdle ? resolved.cursorRestOutputMs.flatMap((rest) => [
19567
+ {
19568
+ startMs: rest.startMs + CURSOR_IDLE_HIDE_MS,
19569
+ endMs: rest.startMs + CURSOR_IDLE_HIDE_MS + CURSOR_IDLE_FADE_MS
19570
+ },
19571
+ { startMs: rest.endMs, endMs: rest.endMs + CURSOR_IDLE_FADE_MS }
19572
+ ]) : [];
19573
+ const camera = [];
19574
+ let before = sampleTrack(resolved, 0);
19575
+ for (let t = 0; t < timeline.outputDurationMs; t += FOLLOW_STEP_MS) {
19576
+ const next = Math.min(t + FOLLOW_STEP_MS, timeline.outputDurationMs);
19577
+ const at = sampleTrack(resolved, next);
19578
+ if (Math.hypot(at.center.x - before.center.x, at.center.y - before.center.y) > CAMERA_STILL_PX || Math.abs(at.scale - before.scale) > CAMERA_STILL_SCALE) {
19579
+ camera.push({ startMs: t, endMs: next });
19580
+ }
19581
+ before = at;
19582
+ }
19583
+ return {
19584
+ busy: merge3([...cursor, ...page, ...presses, ...fades, ...camera]),
19585
+ cursor,
19586
+ camera: merge3(camera)
19587
+ };
19588
+ }
19589
+ function stillUpTo(busy, fromMs, toMs) {
19590
+ let start = fromMs;
19591
+ for (const span of busy) {
19592
+ if (span.startMs < toMs)
19593
+ start = Math.max(start, span.endMs);
19594
+ }
19595
+ return toMs - start >= MIN_SCREEN_MS ? (start + toMs) / 2 : null;
19596
+ }
19597
+ function screenMoments(resolved, scene, bundle) {
19598
+ const { timeline, range } = resolved;
19599
+ const { busy, cursor, camera } = busySpans(resolved);
19600
+ const approaches = merge3([...cursor, ...camera]);
19601
+ const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
19602
+ const stepOfIntent = new Map(resolved.plan.cameraIntents.map((c) => [c.id, c.actionId]));
19603
+ const moments = [];
19604
+ const place = (step, at) => {
19605
+ if (at !== null && at >= range.startMs && at <= range.endMs) {
19606
+ moments.push({ step, ms: at - range.startMs });
19607
+ }
19608
+ };
19609
+ let fromMs = 0;
19610
+ for (const [i, action] of scene.actions.entries()) {
19611
+ const sourceMs = markerAt.get(action.id);
19612
+ if (sourceMs === void 0)
19613
+ continue;
19614
+ const atMs = toOutputMs(timeline, sourceMs);
19615
+ const zoom = resolved.cameraSegments.filter((seg) => stepOfIntent.get(seg.id) === action.id).flatMap((seg) => camera.filter((c) => c.startMs < seg.startMs && c.endMs > seg.departMs).map((c) => c.startMs));
19616
+ const run = approaches.filter((s) => s.startMs > fromMs && s.startMs <= atMs);
19617
+ const moving = busy.find((s) => s.startMs <= atMs && atMs <= s.endMs);
19618
+ const approachMs = Math.min(atMs, ...zoom, ...run.length > 0 ? [run[run.length - 1].startMs] : [], ...moving ? [moving.startMs] : []);
19619
+ place(i, stillUpTo(busy, fromMs, approachMs));
19620
+ fromMs = atMs;
19621
+ }
19622
+ place(null, stillUpTo(busy, fromMs, timeline.outputDurationMs));
19623
+ return { steps: scene.actions.length, moments };
19624
+ }
19625
+
19154
19626
  // ../../packages/compositor/dist/ports/keyframe.js
19155
19627
  function findKeyframe(bundle, sourceTimeMs) {
19156
19628
  const keyframe = keyframeAt(bundle, sourceTimeMs);
@@ -39083,7 +39555,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
39083
39555
  const { id, color, alpha } = event.data;
39084
39556
  chain = chain.then(async () => {
39085
39557
  try {
39086
- const frame2 = await merge3(color, alpha);
39558
+ const frame2 = await merge4(color, alpha);
39087
39559
  self.postMessage({ id, frame: frame2 }, { transfer: [frame2] });
39088
39560
  } catch (error51) {
39089
39561
  self.postMessage({ id, error: error51.message });
@@ -39093,7 +39565,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
39093
39565
  }
39094
39566
  });
39095
39567
  });
39096
- const merge3 = async (color, alpha) => {
39568
+ const merge4 = async (color, alpha) => {
39097
39569
  const format = color.format;
39098
39570
  const alphaFormat = alpha.format;
39099
39571
  if (!format || !alphaFormat) {
@@ -46873,7 +47345,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
46873
47345
  { x: canvas.width, y: canvas.height }
46874
47346
  ];
46875
47347
  const passAt = (at) => {
46876
- const then = frameCamera(sampleTrack(args.camera, at), args.base, frameRect, args.viewport, canvas);
47348
+ const then = frameTrack(args.camera, at, args.base, frameRect, args.viewport, canvas);
46877
47349
  const r = then.scale / current.scale;
46878
47350
  return {
46879
47351
  scale: r,
@@ -46959,208 +47431,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
46959
47431
  ctx.restore();
46960
47432
  }
46961
47433
 
46962
- // ../../packages/compositor/dist/render/draw-cursor.js
46963
- var PULSE_DURATION_MS = 400;
46964
- var PRESS_DURATION_MS = 110;
46965
- var CURSOR_UPRIGHT = Object.freeze({
46966
- press: 1,
46967
- angleRad: 0
46968
- });
46969
- var ARROW = [
46970
- { x: 0, y: 0 },
46971
- { x: 0, y: 0.75 },
46972
- { x: 0.19, y: 0.58 },
46973
- { x: 0.31, y: 0.87 },
46974
- { x: 0.45, y: 0.81 },
46975
- { x: 0.33, y: 0.53 },
46976
- { x: 0.56, y: 0.52 }
46977
- ];
46978
- var TOUCH_RADIUS = 0.42;
46979
- var CURSOR_ART = {
46980
- light: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
46981
- dark: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
46982
- touch: {
46983
- height: 40,
46984
- hotspot: { x: 0.5, y: 0.5 },
46985
- ink: {
46986
- min: { x: 0.5 - TOUCH_RADIUS, y: 0.5 - TOUCH_RADIUS },
46987
- max: { x: 0.5 + TOUCH_RADIUS, y: 0.5 + TOUCH_RADIUS }
46988
- }
46989
- }
46990
- };
46991
- function bounds(points) {
46992
- const xs = points.map((p) => p.x);
46993
- const ys = points.map((p) => p.y);
46994
- return {
46995
- min: { x: Math.min(...xs), y: Math.min(...ys) },
46996
- max: { x: Math.max(...xs), y: Math.max(...ys) }
46997
- };
46998
- }
46999
- var INK = {
47000
- light: { fill: "#ffffff", stroke: "#111827" },
47001
- dark: { fill: "#111827", stroke: "#ffffff" },
47002
- touch: { fill: "rgba(255, 255, 255, 0.45)", stroke: "#111827" }
47003
- };
47004
- function drawCursor(ctx, at, scale, pose, style = "light") {
47005
- const size = CURSOR_ART[style].height * scale * pose.press;
47006
- const ink = INK[style];
47007
- ctx.save();
47008
- ctx.translate(at.x, at.y);
47009
- if (style !== "touch" && pose.angleRad !== 0)
47010
- ctx.rotate(pose.angleRad);
47011
- ctx.beginPath();
47012
- if (style === "touch") {
47013
- ctx.arc(0, 0, size * TOUCH_RADIUS, 0, Math.PI * 2);
47014
- } else {
47015
- const first = ARROW[0];
47016
- if (first) {
47017
- ctx.moveTo(first.x * size, first.y * size);
47018
- for (const point2 of ARROW.slice(1))
47019
- ctx.lineTo(point2.x * size, point2.y * size);
47020
- }
47021
- }
47022
- ctx.closePath();
47023
- ctx.shadowColor = "rgba(15, 23, 42, 0.35)";
47024
- ctx.shadowBlur = 3 * scale;
47025
- ctx.shadowOffsetY = 1.5 * scale;
47026
- ctx.fillStyle = ink.fill;
47027
- ctx.fill();
47028
- ctx.shadowColor = "transparent";
47029
- ctx.lineWidth = Math.max(1, 1.4 * scale);
47030
- ctx.lineJoin = "round";
47031
- ctx.strokeStyle = ink.stroke;
47032
- ctx.stroke();
47033
- ctx.restore();
47034
- }
47035
- var CURSOR_EXPOSURE_MS = 32;
47036
- var CURSOR_TRAIL_MIN_TRAVEL_PX = 1;
47037
- var TRAIL_PEAK_ALPHA = 0.55;
47038
- function cursorTrailStamps(motionBlur) {
47039
- if (motionBlur <= 0)
47040
- return 0;
47041
- return Math.ceil(2 + 8 * clamp(motionBlur, 0, 1));
47042
- }
47043
- function drawCursorTrail(ctx, positions, scale, style) {
47044
- if (positions.length === 0)
47045
- return;
47046
- const priorAlpha = ctx.globalAlpha;
47047
- positions.forEach((position, i) => {
47048
- const t = (i + 1) / (positions.length + 1);
47049
- ctx.globalAlpha = priorAlpha * t * t * TRAIL_PEAK_ALPHA;
47050
- const pose = { press: 1, angleRad: position.angleRad ?? 0 };
47051
- drawCursor(ctx, position, scale, pose, style);
47052
- });
47053
- ctx.globalAlpha = priorAlpha;
47054
- }
47055
- function drawClickPulse(ctx, at, scale, t) {
47056
- if (t < 0 || t > 1)
47057
- return;
47058
- const eased = 1 - (1 - t) ** 3;
47059
- const radius = 16 * scale * (1 + 2.2 * eased);
47060
- const alpha = 1 - t;
47061
- const core = Math.max(1, 2.5 * scale);
47062
- const edge = Math.max(0.75, 1.25 * scale);
47063
- const offset = (core + edge) / 2;
47064
- ctx.save();
47065
- ring(ctx, at, radius - offset, edge, `rgba(15, 23, 42, ${0.75 * alpha})`);
47066
- ring(ctx, at, radius + offset, edge, `rgba(15, 23, 42, ${0.75 * alpha})`);
47067
- ring(ctx, at, radius, core, `rgba(255, 255, 255, ${0.95 * alpha})`);
47068
- ctx.restore();
47069
- }
47070
- function ring(ctx, at, radius, width, style) {
47071
- if (radius <= 0)
47072
- return;
47073
- ctx.beginPath();
47074
- ctx.arc(at.x, at.y, radius, 0, Math.PI * 2);
47075
- ctx.lineWidth = width;
47076
- ctx.strokeStyle = style;
47077
- ctx.stroke();
47078
- }
47079
-
47080
- // ../../packages/compositor/dist/render/cursor-pose.js
47081
- var PRESS_DEPTH = 0.14;
47082
- var RELEASE_DECAY_MS = 80;
47083
- var RELEASE_PERIOD_MS = 320;
47084
- var RELEASE_MS = 450;
47085
- var smoothstep = (u) => {
47086
- const x = clamp(u, 0, 1);
47087
- return x * x * (3 - 2 * x);
47088
- };
47089
- function cursorPressScale(outputTimeMs, clickOutputMs, bounce, holds = []) {
47090
- const depth = PRESS_DEPTH * clamp(bounce, 0, 2);
47091
- if (depth <= 0)
47092
- return 1;
47093
- if (holds.some((h) => outputTimeMs >= h.startMs && outputTimeMs < h.endMs)) {
47094
- return 1 - depth;
47095
- }
47096
- let previous = Number.NEGATIVE_INFINITY;
47097
- let next = Number.POSITIVE_INFINITY;
47098
- for (const click of [...clickOutputMs, ...holds.map((h) => h.endMs)]) {
47099
- if (click <= outputTimeMs)
47100
- previous = Math.max(previous, click);
47101
- else
47102
- next = Math.min(next, click);
47103
- }
47104
- const release = (at) => {
47105
- const since = at - previous;
47106
- if (!(since >= 0 && since <= RELEASE_MS))
47107
- return 1;
47108
- return 1 - depth * Math.exp(-since / RELEASE_DECAY_MS) * Math.cos(2 * Math.PI * since / RELEASE_PERIOD_MS);
47109
- };
47110
- if (next !== Number.POSITIVE_INFINITY) {
47111
- const pressStart = Math.max(next - PRESS_DURATION_MS, previous);
47112
- if (outputTimeMs >= pressStart) {
47113
- const from = release(pressStart);
47114
- const u = (outputTimeMs - pressStart) / (next - pressStart);
47115
- return from + (1 - depth - from) * smoothstep(u);
47116
- }
47117
- }
47118
- return release(outputTimeMs);
47119
- }
47120
- var TILT_MAX_RAD = 15 * Math.PI / 180;
47121
- var TILT_VELOCITY_MS = 16;
47122
- var TILT_FULL_SPEED_WIDTHS_PER_S = 1.1;
47123
- var TILT_VERTICAL_WEIGHT = 0.65;
47124
- var TILT_TAPS = 8;
47125
- var TILT_TAP_MS = 20;
47126
- var TILT_TAU_MS = 60;
47127
- var TILT_SETTLE_MS = TILT_VELOCITY_MS + (TILT_TAPS - 1) * TILT_TAP_MS;
47128
- function cursorTiltRawRad(resolved, outputTimeMs, tilt) {
47129
- const amount = clamp(tilt, 0, 1);
47130
- const first = resolved.cursor[0];
47131
- const fromMs = outputTimeMs - TILT_VELOCITY_MS;
47132
- if (amount <= 0 || !first || fromMs < 0)
47133
- return 0;
47134
- const fromSourceMs = toSourceMs(resolved.timeline, fromMs);
47135
- if (fromSourceMs < first.sourceTimeMs)
47136
- return 0;
47137
- const from = sampleCursor(resolved.cursor, fromSourceMs);
47138
- const to = sampleCursor(resolved.cursor, toSourceMs(resolved.timeline, outputTimeMs));
47139
- if (!from || !to)
47140
- return 0;
47141
- const vx = (to.x - from.x) * 1e3 / TILT_VELOCITY_MS;
47142
- const vy = (to.y - from.y) * 1e3 / TILT_VELOCITY_MS;
47143
- const speed = Math.hypot(vx, vy);
47144
- if (speed < 1e-3)
47145
- return 0;
47146
- const bias = clamp((vx + TILT_VERTICAL_WEIGHT * vy) / speed, -1, 1);
47147
- const width = resolved.plan.viewport.width;
47148
- const fullSpeed = TILT_FULL_SPEED_WIDTHS_PER_S * (width > 0 ? width : 1);
47149
- return bias * Math.min(1, speed / fullSpeed) * TILT_MAX_RAD * amount;
47150
- }
47151
- function cursorTiltRad(resolved, outputTimeMs, tilt) {
47152
- if (!(tilt > 0))
47153
- return 0;
47154
- let sum = 0;
47155
- let weights = 0;
47156
- for (let k = 0; k < TILT_TAPS; k++) {
47157
- const weight = Math.exp(-k * TILT_TAP_MS / TILT_TAU_MS);
47158
- sum += weight * cursorTiltRawRad(resolved, outputTimeMs - k * TILT_TAP_MS, tilt);
47159
- weights += weight;
47160
- }
47161
- return sum / weights;
47162
- }
47163
-
47164
47434
  // ../../packages/compositor/dist/render/draw-cosmetics.js
47165
47435
  var MASK_FILL = "#4b5563";
47166
47436
  function drawMask(ctx, rect2) {
@@ -47174,6 +47444,80 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47174
47444
  drawMask(ctx, toOutput(cosmetic.rect));
47175
47445
  }
47176
47446
 
47447
+ // ../../packages/compositor/dist/render/target.js
47448
+ var LANDSCAPE_4K = {
47449
+ format: "mp4",
47450
+ width: 3840,
47451
+ height: 2160,
47452
+ fps: 60,
47453
+ bitrate: 4e7,
47454
+ cornerRadius: 36,
47455
+ fit: "contain"
47456
+ };
47457
+ var LANDSCAPE_1440P = {
47458
+ format: "mp4",
47459
+ width: 2560,
47460
+ height: 1440,
47461
+ fps: 60,
47462
+ bitrate: 18e6,
47463
+ cornerRadius: 24,
47464
+ fit: "contain"
47465
+ };
47466
+ var VERTICAL_1080 = {
47467
+ format: "mp4",
47468
+ width: 1080,
47469
+ height: 1920,
47470
+ fps: 60,
47471
+ bitrate: 12e6,
47472
+ cornerRadius: 24,
47473
+ fit: "cover"
47474
+ };
47475
+ var HIGH_LANDSCAPE = {
47476
+ ...LANDSCAPE_1440P,
47477
+ bitrate: 8e6
47478
+ };
47479
+ var HIGH_VERTICAL = {
47480
+ ...VERTICAL_1080,
47481
+ bitrate: HIGH_LANDSCAPE.bitrate
47482
+ };
47483
+ function verticalCameraIntents(intents) {
47484
+ return intents.map((intent) => {
47485
+ const scale = clamp(intent.scale, 1, CAMERA_DEFAULTS.verticalMaxScale);
47486
+ return scale < intent.scale ? {
47487
+ ...intent,
47488
+ scale,
47489
+ requestedScale: intent.requestedScale ?? intent.scale
47490
+ } : { ...intent, scale };
47491
+ });
47492
+ }
47493
+ function cameraIntentsForTarget(target, intents) {
47494
+ return target.fit === "cover" ? verticalCameraIntents(intents) : intents;
47495
+ }
47496
+
47497
+ // ../../packages/compositor/dist/render/wallpaper.js
47498
+ var WALLPAPER_LONG_SIDE = LANDSCAPE_4K.width * CAMERA_DEFAULTS.maxScale;
47499
+ var WALLPAPER_SHORT_SIDE = WALLPAPER_LONG_SIDE * 3 / 4;
47500
+ function coverRect(image, box2) {
47501
+ const scale = Math.max(box2.width / image.width, box2.height / image.height);
47502
+ const sw = Math.min(image.width, box2.width / scale);
47503
+ const sh = Math.min(image.height, box2.height / scale);
47504
+ return { sx: (image.width - sw) / 2, sy: (image.height - sh) / 2, sw, sh };
47505
+ }
47506
+ function wallpaperShape(target) {
47507
+ return target.height > target.width ? "portrait" : "landscape";
47508
+ }
47509
+ function masterFor(target) {
47510
+ return wallpaperShape(target) === "portrait" ? { width: WALLPAPER_SHORT_SIDE, height: WALLPAPER_LONG_SIDE } : { width: WALLPAPER_LONG_SIDE, height: WALLPAPER_SHORT_SIDE };
47511
+ }
47512
+ function wallpaperRasterSize(target, image = masterFor(target)) {
47513
+ const cover = Math.max(target.width / image.width, target.height / image.height);
47514
+ const scale = Math.min(1, cover * CAMERA_DEFAULTS.maxScale);
47515
+ return {
47516
+ width: Math.ceil(image.width * scale),
47517
+ height: Math.ceil(image.height * scale)
47518
+ };
47519
+ }
47520
+
47177
47521
  // ../../packages/compositor/dist/render/presentation.js
47178
47522
  var MIN_LOGO_SIZE = 0.02;
47179
47523
  function placeLogo(logo, aspect, target, frameRect) {
@@ -47211,7 +47555,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47211
47555
  return 0;
47212
47556
  return Math.ceil(branding.logo.size * Math.min(target.width, target.height));
47213
47557
  }
47214
- function derivePresentation(branding, target, viewport, logo = null) {
47558
+ function derivePresentation(branding, target, viewport, logo = null, wallpaper = null) {
47215
47559
  const pad = Math.min(target.width, target.height) * branding.padding;
47216
47560
  const box2 = {
47217
47561
  x: pad,
@@ -47238,7 +47582,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47238
47582
  frameRect,
47239
47583
  padding: branding.padding,
47240
47584
  logo: spec !== null && logo !== null && logoPlacement !== null && logoPlacement.effectiveSize > 0 ? { image: logo, opacity: spec.opacity, rect: logoPlacement.rect } : null,
47241
- logoPlacement
47585
+ logoPlacement,
47586
+ wallpaper: branding.background.kind === "wallpaper" || branding.background.kind === "image" ? wallpaper : null
47242
47587
  };
47243
47588
  }
47244
47589
  function contentScale(frameRect, viewport) {
@@ -47263,13 +47608,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47263
47608
  if (bg.kind === "solid") {
47264
47609
  ctx.fillStyle = bg.color;
47265
47610
  } else {
47266
- const { x0, y0, x1, y1 } = gradientLine(bg.angle, target.width, target.height);
47611
+ const g = bg.kind === "gradient" ? bg : NEUTRAL_BACKGROUND;
47612
+ const { x0, y0, x1, y1 } = gradientLine(g.angle, target.width, target.height);
47267
47613
  const gradient = ctx.createLinearGradient(x0, y0, x1, y1);
47268
- gradient.addColorStop(0, bg.from);
47269
- gradient.addColorStop(1, bg.to);
47614
+ gradient.addColorStop(0, g.from);
47615
+ gradient.addColorStop(1, g.to);
47270
47616
  ctx.fillStyle = gradient;
47271
47617
  }
47272
47618
  ctx.fillRect(0, 0, target.width, target.height);
47619
+ const image = presentation.wallpaper;
47620
+ if (image === null || bg.kind === "solid" || bg.kind === "gradient")
47621
+ return;
47622
+ const { sx, sy, sw, sh } = coverRect(image, target);
47623
+ ctx.imageSmoothingEnabled = true;
47624
+ ctx.imageSmoothingQuality = "high";
47625
+ ctx.drawImage(image.image, sx, sy, sw, sh, 0, 0, target.width, target.height);
47273
47626
  }
47274
47627
  function framePath(ctx, presentation) {
47275
47628
  const { frameRect: r, cornerRadius } = presentation;
@@ -47311,6 +47664,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47311
47664
  ctx.restore();
47312
47665
  }
47313
47666
 
47667
+ // ../../packages/compositor/dist/render/window.js
47668
+ function sceneCameraAt(resolved, presentation, target, outputTimeMs) {
47669
+ const viewport = resolved.plan.viewport;
47670
+ const { frameRect } = presentation;
47671
+ return frameTrack(resolved, outputTimeMs, contentScale(frameRect, viewport), frameRect, viewport, target);
47672
+ }
47673
+ function windowOnScreen(presentation, camera) {
47674
+ const { frameRect: r, cornerRadius } = presentation;
47675
+ const s = camera.scale;
47676
+ return {
47677
+ x: r.x + r.width / 2 + (r.x - camera.focus.x) * s,
47678
+ y: r.y + r.height / 2 + (r.y - camera.focus.y) * s,
47679
+ width: r.width * s,
47680
+ height: r.height * s,
47681
+ radius: Math.min(cornerRadius, r.width / 2, r.height / 2) * s
47682
+ };
47683
+ }
47684
+
47314
47685
  // ../../packages/compositor/dist/render/compose.js
47315
47686
  function cssToOutput(point2, camera, frameRect, viewport) {
47316
47687
  const k = contentScale(frameRect, viewport) * camera.scale;
@@ -47368,7 +47739,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47368
47739
  const { frameRect } = presentation;
47369
47740
  const sourceMs = toSourceMs(resolved.timeline, outputTimeMs);
47370
47741
  const base = contentScale(frameRect, viewport);
47371
- const camera = frameCamera(sampleTrack(resolved, outputTimeMs), base, frameRect, viewport, target);
47742
+ const camera = sceneCameraAt(resolved, presentation, target, outputTimeMs);
47372
47743
  const fetchStartedAt = args.onStage ? performance.now() : 0;
47373
47744
  const frame2 = await frames.at(sourceMs);
47374
47745
  args.onStage?.("fetch", performance.now() - fetchStartedAt);
@@ -47547,48 +47918,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47547
47918
  return out;
47548
47919
  }
47549
47920
 
47550
- // ../../packages/compositor/dist/render/target.js
47551
- var LANDSCAPE_1440P = {
47552
- format: "mp4",
47553
- width: 2560,
47554
- height: 1440,
47555
- fps: 60,
47556
- bitrate: 18e6,
47557
- cornerRadius: 24,
47558
- fit: "contain"
47559
- };
47560
- var VERTICAL_1080 = {
47561
- format: "mp4",
47562
- width: 1080,
47563
- height: 1920,
47564
- fps: 60,
47565
- bitrate: 12e6,
47566
- cornerRadius: 24,
47567
- fit: "cover"
47568
- };
47569
- var HIGH_LANDSCAPE = {
47570
- ...LANDSCAPE_1440P,
47571
- bitrate: 8e6
47572
- };
47573
- var HIGH_VERTICAL = {
47574
- ...VERTICAL_1080,
47575
- bitrate: HIGH_LANDSCAPE.bitrate
47576
- };
47577
- var SHARE_QUALITY_FLOOR = 0.35;
47578
- function verticalCameraIntents(intents) {
47579
- return intents.map((intent) => {
47580
- const scale = clamp(intent.scale, 1, CAMERA_DEFAULTS.verticalMaxScale);
47581
- return scale < intent.scale ? {
47582
- ...intent,
47583
- scale,
47584
- requestedScale: intent.requestedScale ?? intent.scale
47585
- } : { ...intent, scale };
47586
- });
47587
- }
47588
- function cameraIntentsForTarget(target, intents) {
47589
- return target.fit === "cover" ? verticalCameraIntents(intents) : intents;
47590
- }
47591
-
47592
47921
  // ../../packages/compositor/dist/render/compose-for-target.js
47593
47922
  function framedPlan(plan, target) {
47594
47923
  const cameraIntents = cameraIntentsForTarget(target, plan.cameraIntents);
@@ -47601,9 +47930,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47601
47930
  return { width: frameRect.width / k, height: frameRect.height / k };
47602
47931
  }
47603
47932
  function composeForTarget(args) {
47604
- const { plan, bundle, scene, target, hints, logo = null } = args;
47933
+ const { plan, bundle, scene, target, hints, logo = null, wallpaper = null } = args;
47605
47934
  const detailTarget = args.detailTarget ?? target;
47606
- const presentation = derivePresentation(scene?.branding ?? BRANDING_DEFAULTS, target, plan.viewport, logo);
47935
+ const presentation = derivePresentation(scene?.branding ?? BRANDING_DEFAULTS, target, plan.viewport, logo, wallpaper);
47607
47936
  const detailFrame = detailTarget === target ? presentation.frameRect : derivePresentation(scene?.branding ?? BRANDING_DEFAULTS, detailTarget, plan.viewport, logo).frameRect;
47608
47937
  const resolved = resolvePlan(framedPlan(plan, target), bundle, scene, hints, coverWindow(target, detailFrame, plan.viewport));
47609
47938
  const detail = clampToSourceDetail({
@@ -47679,13 +48008,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47679
48008
 
47680
48009
  // ../../packages/compositor/dist/render/render.js
47681
48010
  async function renderScene(args) {
47682
- const { plan, bundle, scene, target, ports, logo = null, onFrame } = args;
48011
+ const { plan, bundle, scene, target, ports, logo = null, wallpaper = null, onFrame } = args;
47683
48012
  const sink = target.format === "mp4" ? ports.video : target.format === "gif" ? ports.gif : ports.images;
47684
48013
  if (!sink) {
47685
48014
  throw new Error(`render target "${target.format}" needs a matching ${target.format === "mp4" ? "video sink" : `${target.format} sink`}`);
47686
48015
  }
47687
48016
  const hints = target.format === "png" ? [] : await detectKeyframeMotion(bundle, ports.frames, plan.retiming.motionDiffThreshold);
47688
- const { resolved: composed, presentation, violations } = composeForTarget({ plan, bundle, scene, target, hints, logo });
48017
+ const { resolved: composed, presentation, violations } = composeForTarget({
48018
+ plan,
48019
+ bundle,
48020
+ scene,
48021
+ target,
48022
+ hints,
48023
+ logo,
48024
+ wallpaper
48025
+ });
47689
48026
  const canvas = ports.surface.create(target.width, target.height);
47690
48027
  const ctx = canvas.getContext("2d");
47691
48028
  const step = 1e3 / target.fps;
@@ -47723,6 +48060,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47723
48060
  }
47724
48061
  onFrame?.(i + 1, frameCount);
47725
48062
  }
48063
+ const found = scene ? screenMoments(composed, scene, bundle) : { steps: 0, moments: [] };
48064
+ const r = (v) => Math.round(v * 100) / 100;
48065
+ const screens = {
48066
+ ...found,
48067
+ moments: found.moments.map((m) => {
48068
+ const w = windowOnScreen(presentation, sceneCameraAt(composed, presentation, target, startMs + m.ms));
48069
+ return {
48070
+ ...m,
48071
+ window: {
48072
+ x: r(w.x),
48073
+ y: r(w.y),
48074
+ width: r(w.width),
48075
+ height: r(w.height),
48076
+ radius: r(w.radius)
48077
+ }
48078
+ };
48079
+ })
48080
+ };
47726
48081
  const bytes2 = await (async () => {
47727
48082
  if (target.format === "mp4" && ports.video)
47728
48083
  return ports.video.finish();
@@ -47742,7 +48097,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47742
48097
  detailViolations: violations,
47743
48098
  unavailableSpans: ports.frames.unavailable?.() ?? [],
47744
48099
  loweredZooms: composed.loweredZooms,
47745
- clampedRanges: composed.clampedRanges
48100
+ clampedRanges: composed.clampedRanges,
48101
+ screens,
48102
+ deepestScale: composed.cameraKeys.reduce((m, k) => Math.max(m, k.scale), 1)
47746
48103
  };
47747
48104
  }
47748
48105
  function stillSourceMs(bundle, marker) {
@@ -47784,11 +48141,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47784
48141
  return { beats, unplaced };
47785
48142
  }
47786
48143
  async function renderStills(args) {
47787
- const { plan, bundle, scene, target, ports, logo = null } = args;
48144
+ const { plan, bundle, scene, target, ports, logo = null, wallpaper = null } = args;
47788
48145
  const images = ports.images;
47789
48146
  if (!images)
47790
48147
  throw new Error('render target "png" needs a matching png sink');
47791
- const { resolved: composed, presentation, violations } = composeForTarget({ plan, bundle, scene, target, logo });
48148
+ const { resolved: composed, presentation, violations } = composeForTarget({ plan, bundle, scene, target, logo, wallpaper });
47792
48149
  const canvas = ports.surface.create(target.width, target.height);
47793
48150
  const ctx = canvas.getContext("2d");
47794
48151
  const supplied = args.outputTimesMs;
@@ -47873,43 +48230,34 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47873
48230
  };
47874
48231
  }
47875
48232
 
47876
- // ../../packages/run-core/dist/render/mp4-cap.js
47877
- var MAX_CAP_STEPS = 3;
47878
- function nextCapStep(at, share) {
47879
- if (at.fps > share.fps) {
47880
- return {
47881
- target: {
47882
- ...at,
47883
- fps: share.fps,
47884
- bitrate: Math.round(at.bitrate * share.fps / at.fps)
47885
- },
47886
- step: { kind: "fps", from: at.fps, to: share.fps }
47887
- };
47888
- }
47889
- const shareQuality = share.encoder?.quality;
47890
- const quality = at.encoder?.quality;
47891
- const atShare = at.width === share.width && at.height === share.height && (shareQuality === void 0 || quality !== void 0 && quality <= shareQuality);
47892
- if (!atShare) {
47893
- return {
47894
- target: share,
47895
- step: {
47896
- kind: "share",
47897
- from: { width: at.width, height: at.height },
47898
- to: { width: share.width, height: share.height },
47899
- ...shareQuality === void 0 ? {} : { quality: shareQuality }
47900
- }
47901
- };
47902
- }
47903
- if (quality !== void 0 && quality > SHARE_QUALITY_FLOOR) {
47904
- return {
47905
- target: {
47906
- ...at,
47907
- encoder: { ...at.encoder, quality: SHARE_QUALITY_FLOOR }
47908
- },
47909
- step: { kind: "quality", from: quality, to: SHARE_QUALITY_FLOOR }
47910
- };
47911
- }
47912
- return null;
48233
+ // ../../packages/compositor/dist/render/wallpaper-blur.js
48234
+ var WALLPAPER_BLUR_MAX = 0.12;
48235
+ function wallpaperBlurPx(target, raster, blur) {
48236
+ const perFramePx = coverRect(raster, target).sw / target.width;
48237
+ return blur * WALLPAPER_BLUR_MAX * Math.min(target.width, target.height) * perFramePx;
48238
+ }
48239
+ function blurWallpaper(image, radiusPx) {
48240
+ if (radiusPx <= 0)
48241
+ return image;
48242
+ const { width: w, height: h } = image;
48243
+ const pad = Math.min(Math.ceil(radiusPx * 3), w, h);
48244
+ const padded = new OffscreenCanvas(w + 2 * pad, h + 2 * pad);
48245
+ const p = padded.getContext("2d");
48246
+ if (p === null)
48247
+ throw new Error(`no 2D context to blur ${w}\xD7${h} on`);
48248
+ for (const i of [-1, 0, 1]) {
48249
+ for (const j of [-1, 0, 1]) {
48250
+ p.setTransform(i === 0 ? 1 : -1, 0, 0, j === 0 ? 1 : -1, i === 1 ? pad + 2 * w : pad, j === 1 ? pad + 2 * h : pad);
48251
+ p.drawImage(image.image, 0, 0, w, h);
48252
+ }
48253
+ }
48254
+ const out = new OffscreenCanvas(w, h);
48255
+ const ctx = out.getContext("2d");
48256
+ if (ctx === null)
48257
+ throw new Error(`no 2D context to blur ${w}\xD7${h} on`);
48258
+ ctx.filter = `blur(${radiusPx}px)`;
48259
+ ctx.drawImage(padded, -pad, -pad);
48260
+ return { ...image, image: out.transferToImageBitmap() };
47913
48261
  }
47914
48262
 
47915
48263
  // ../../packages/run-core/dist/export/target.js
@@ -48004,6 +48352,88 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48004
48352
  };
48005
48353
  }
48006
48354
  };
48355
+ const wallpaperAt = async (at2) => {
48356
+ const load2 = input.wallpaper;
48357
+ const kind = scene.branding.background.kind;
48358
+ if (load2 === null)
48359
+ return {
48360
+ image: null,
48361
+ failed: kind === "wallpaper" || kind === "image" ? "no wallpaper was supplied to the render" : null
48362
+ };
48363
+ if (!load2.ok)
48364
+ return { image: null, failed: load2.error };
48365
+ const size = wallpaperRasterSize(at2, load2.natural);
48366
+ let held;
48367
+ try {
48368
+ held = await load2.image(size);
48369
+ } catch (error51) {
48370
+ return {
48371
+ image: null,
48372
+ failed: `${load2.name}: ${error51 instanceof Error ? error51.message : String(error51)}`
48373
+ };
48374
+ }
48375
+ let sized = held;
48376
+ if (size.width < held.width) {
48377
+ try {
48378
+ const bitmap = await createImageBitmap(held.image, {
48379
+ resizeWidth: size.width,
48380
+ resizeHeight: size.height,
48381
+ resizeQuality: "high"
48382
+ });
48383
+ sized = {
48384
+ ...held,
48385
+ image: bitmap,
48386
+ width: size.width,
48387
+ height: size.height
48388
+ };
48389
+ } catch (error51) {
48390
+ return {
48391
+ image: null,
48392
+ failed: `"${load2.name}" could not be resized to ${size.width}\xD7${size.height} (${error51 instanceof Error ? error51.message : String(error51)})`
48393
+ };
48394
+ }
48395
+ }
48396
+ const bg = scene.branding.background;
48397
+ const blur = bg.kind === "wallpaper" || bg.kind === "image" ? bg.blur : 0;
48398
+ const radius = wallpaperBlurPx(at2, sized, blur ?? 0);
48399
+ try {
48400
+ return { image: blurWallpaper(sized, radius), failed: null, held };
48401
+ } catch (error51) {
48402
+ return {
48403
+ image: null,
48404
+ failed: `"${load2.name}" could not be blurred at ${sized.width}\xD7${sized.height} (${error51 instanceof Error ? error51.message : String(error51)})`
48405
+ };
48406
+ } finally {
48407
+ if (radius > 0 && sized !== held)
48408
+ sized.image.close();
48409
+ }
48410
+ };
48411
+ const wallpaperWarning = (at2, deepestScale, failed) => {
48412
+ if (failed !== null) {
48413
+ return {
48414
+ kind: "leftOut",
48415
+ sentence: `The wallpaper was left out: ${failed}; the ${fileType === "stills" ? "stills use" : "video uses"} the plain gradient.`
48416
+ };
48417
+ }
48418
+ const load2 = input.wallpaper;
48419
+ if (load2 === null || !load2.ok)
48420
+ return null;
48421
+ const { width, height } = load2.natural;
48422
+ const scale = Math.max(at2.width / width, at2.height / height) * deepestScale;
48423
+ const needs = {
48424
+ width: Math.round(width * scale),
48425
+ height: Math.round(height * scale)
48426
+ };
48427
+ return needs.width > width ? {
48428
+ kind: "soft",
48429
+ sentence: `The wallpaper "${load2.name}" is ${width}\xD7${height}, smaller than this export's deepest zoom needs (${needs.width}\xD7${needs.height}), so it will look soft.`
48430
+ } : null;
48431
+ };
48432
+ const release = (image, held) => {
48433
+ if (image !== null && image.image !== held?.image) {
48434
+ image.image.close();
48435
+ }
48436
+ };
48007
48437
  const plan = planScene(scene);
48008
48438
  const surface = createOffscreenSurface();
48009
48439
  const reclaimed = bundle.degradations.filter((d) => d.kind === "motionReclaimed").map((d) => ({
@@ -48024,16 +48454,30 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48024
48454
  }, widestKeyframe);
48025
48455
  const at2 = sized.target;
48026
48456
  const { logo, logoWarning: logoWarning2 } = await logoAt(at2);
48027
- const result2 = await renderStills({
48457
+ const wallpaper = await wallpaperAt(at2);
48458
+ const camera = options === void 0 ? void 0 : options.zoom ?? "none";
48459
+ let result2;
48460
+ try {
48461
+ result2 = await renderStills({
48462
+ plan,
48463
+ bundle,
48464
+ scene,
48465
+ target: at2,
48466
+ ports: { frames, surface, images: createPngSink() },
48467
+ logo,
48468
+ wallpaper: wallpaper.image,
48469
+ ...camera === void 0 ? {} : { camera },
48470
+ ...onFrame === void 0 ? {} : { onFrame }
48471
+ });
48472
+ } finally {
48473
+ release(wallpaper.image, wallpaper.held ?? null);
48474
+ }
48475
+ const deepest = camera === "none" || input.wallpaper?.ok !== true ? 1 : composeForTarget({
48028
48476
  plan,
48029
48477
  bundle,
48030
48478
  scene,
48031
- target: at2,
48032
- ports: { frames, surface, images: createPngSink() },
48033
- logo,
48034
- ...options === void 0 ? {} : { camera: options.zoom ?? "none" },
48035
- ...onFrame === void 0 ? {} : { onFrame }
48036
- });
48479
+ target: at2
48480
+ }).resolved.cameraKeys.reduce((m, k) => Math.max(m, k.scale), 1);
48037
48481
  return {
48038
48482
  files: result2.files.map((f) => ({ name: f.name, bytes: f.bytes })),
48039
48483
  facts: {
@@ -48042,6 +48486,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48042
48486
  unplacedStills: result2.unplacedStills,
48043
48487
  loweredZooms: result2.loweredZooms,
48044
48488
  logoWarning: logoWarning2,
48489
+ wallpaperWarning: wallpaperWarning(at2, deepest, wallpaper.failed),
48045
48490
  clampedRanges: result2.clampedRanges,
48046
48491
  rendered: { width: at2.width, height: at2.height, fps: at2.fps },
48047
48492
  ...sized.cappedFrom === null ? {} : { stillsCapped: { askedWidth: sized.cappedFrom } }
@@ -48050,23 +48495,35 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48050
48495
  }
48051
48496
  const renderAt = async (at2, maxBytes, saysWidth = false, pass) => {
48052
48497
  const { logo, logoWarning: logoWarning2 } = await logoAt(at2);
48498
+ const wallpaper = await wallpaperAt(at2);
48053
48499
  const ports = at2.format === "gif" ? {
48054
48500
  frames,
48055
48501
  surface,
48056
48502
  gif: createGifSink(at2, maxBytes === void 0 ? {} : { maxBytes })
48057
48503
  } : { frames, surface, video: createMp4Sink(at2) };
48058
- const result2 = await renderScene({
48059
- plan,
48060
- bundle,
48061
- scene,
48062
- target: at2,
48063
- ports,
48064
- logo,
48065
- ...onFrame === void 0 ? {} : {
48066
- onFrame: pass !== void 0 ? (done2, total) => onFrame(done2, total, at2.width, pass) : saysWidth ? (done2, total) => onFrame(done2, total, at2.width) : onFrame
48067
- }
48068
- });
48069
- return { result: result2, logoWarning: logoWarning2, at: at2 };
48504
+ let result2;
48505
+ try {
48506
+ result2 = await renderScene({
48507
+ plan,
48508
+ bundle,
48509
+ scene,
48510
+ target: at2,
48511
+ ports,
48512
+ logo,
48513
+ wallpaper: wallpaper.image,
48514
+ ...onFrame === void 0 ? {} : {
48515
+ onFrame: pass !== void 0 ? (done2, total) => onFrame(done2, total, at2.width, pass) : saysWidth ? (done2, total) => onFrame(done2, total, at2.width) : onFrame
48516
+ }
48517
+ });
48518
+ } finally {
48519
+ release(wallpaper.image, wallpaper.held ?? null);
48520
+ }
48521
+ return {
48522
+ result: result2,
48523
+ logoWarning: logoWarning2,
48524
+ wallpaperWarning: wallpaperWarning(at2, result2.deepestScale, wallpaper.failed),
48525
+ at: at2
48526
+ };
48070
48527
  };
48071
48528
  const budget = target.format === "gif" ? input.gifBudget : void 0;
48072
48529
  const cap = target.format === "mp4" ? input.mp4Cap : void 0;
@@ -48074,47 +48531,65 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48074
48531
  let videoCap;
48075
48532
  let done;
48076
48533
  if (cap !== void 0) {
48077
- const steps = [];
48078
- let upTo = 1;
48079
- for (let at2 = target; upTo <= MAX_CAP_STEPS; upTo++) {
48080
- const next = nextCapStep(at2, cap.share);
48081
- if (next === null)
48082
- break;
48083
- at2 = next.target;
48084
- }
48534
+ const { startMs, endMs } = composeForTarget({
48535
+ plan,
48536
+ bundle,
48537
+ scene,
48538
+ target: cap.floor
48539
+ }).resolved.range;
48540
+ const durationMs = endMs - startMs;
48541
+ const ladder = capLadder(target, cap, {
48542
+ bitrate: fitBitrate(cap.maxBytes, durationMs),
48543
+ durationMs
48544
+ });
48545
+ const upTo = ladder.length + 2;
48546
+ const over = (r) => r.result.bytes.byteLength > cap.maxBytes;
48085
48547
  let current = await renderAt(target, void 0, true, {
48086
48548
  render: 1,
48087
48549
  upTo
48088
48550
  });
48089
48551
  let kept = current;
48552
+ let keptStep;
48553
+ const steps = [];
48090
48554
  let failed;
48091
- while (current.result.bytes.byteLength > cap.maxBytes && steps.length < MAX_CAP_STEPS) {
48092
- const next = nextCapStep(current.at, cap.share);
48093
- if (next === null)
48094
- break;
48555
+ const take = async (rung) => {
48095
48556
  try {
48096
- current = await renderAt(next.target, void 0, true, {
48557
+ current = await renderAt(rung.target, void 0, true, {
48097
48558
  render: steps.length + 2,
48098
48559
  upTo
48099
48560
  });
48100
48561
  } catch (error51) {
48101
48562
  failed = {
48102
- step: next.step,
48563
+ step: rung.step,
48103
48564
  error: error51 instanceof Error ? error51.message : String(error51)
48104
48565
  };
48105
- break;
48566
+ return false;
48106
48567
  }
48107
- steps.push(next.step);
48568
+ steps.push(rung.step);
48108
48569
  if (current.result.bytes.byteLength <= kept.result.bytes.byteLength) {
48109
48570
  kept = current;
48571
+ keptStep = rung.step;
48110
48572
  }
48573
+ return true;
48574
+ };
48575
+ let last2;
48576
+ for (const rung of ladder) {
48577
+ if (!over(current))
48578
+ break;
48579
+ if (!await take(rung))
48580
+ break;
48581
+ last2 = rung;
48582
+ }
48583
+ if (failed === void 0 && last2?.step.kind === "fit" && over(current)) {
48584
+ await take(fitRetry(last2, cap.maxBytes, current.result.bytes.byteLength));
48111
48585
  }
48112
48586
  done = kept;
48113
48587
  videoCap = {
48114
48588
  maxBytes: cap.maxBytes,
48115
- met: kept.result.bytes.byteLength <= cap.maxBytes,
48589
+ met: !over(kept),
48116
48590
  steps,
48117
48591
  keptQuality: kept.at.encoder?.quality ?? null,
48592
+ belowFloor: keptStep?.kind === "fit",
48118
48593
  ...failed === void 0 ? {} : { failed }
48119
48594
  };
48120
48595
  } else if (budget === void 0) {
@@ -48156,7 +48631,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48156
48631
  if (done === void 0) {
48157
48632
  throw new Error("the GIF width ladder ended without a render");
48158
48633
  }
48159
- const { result, logoWarning, at } = done;
48634
+ const { result, logoWarning, wallpaperWarning: wallpaperSaid, at } = done;
48160
48635
  return {
48161
48636
  files: [{ name: null, bytes: result.bytes }],
48162
48637
  facts: {
@@ -48165,6 +48640,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48165
48640
  unplacedStills: [],
48166
48641
  loweredZooms: result.loweredZooms,
48167
48642
  logoWarning,
48643
+ wallpaperWarning: wallpaperSaid,
48168
48644
  clampedRanges: result.clampedRanges,
48169
48645
  rendered: { width: at.width, height: at.height, fps: at.fps },
48170
48646
  ...budget === void 0 ? {} : {
@@ -48174,11 +48650,140 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48174
48650
  refused
48175
48651
  }
48176
48652
  },
48177
- ...videoCap === void 0 ? {} : { videoCap }
48653
+ ...videoCap === void 0 ? {} : { videoCap },
48654
+ // From `done`, the render kept: a capped or budgeted file is the
48655
+ // last rung that was kept, and its screens are that render's.
48656
+ screens: result.screens
48178
48657
  }
48179
48658
  };
48180
48659
  }
48181
48660
 
48661
+ // ../../packages/run-core/dist/webp-size.js
48662
+ function webpSize(b) {
48663
+ const ascii2 = (at, n) => String.fromCharCode(...b.subarray(at, at + n));
48664
+ if (b.length < 30 || ascii2(0, 4) !== "RIFF" || ascii2(8, 4) !== "WEBP") {
48665
+ return null;
48666
+ }
48667
+ const view2 = new DataView(b.buffer, b.byteOffset, b.byteLength);
48668
+ const u242 = (at) => b[at] | b[at + 1] << 8 | b[at + 2] << 16;
48669
+ switch (ascii2(12, 4)) {
48670
+ case "VP8X":
48671
+ return { width: 1 + u242(24), height: 1 + u242(27) };
48672
+ case "VP8 ":
48673
+ if (b[23] !== 157 || b[24] !== 1 || b[25] !== 42)
48674
+ return null;
48675
+ return {
48676
+ width: view2.getUint16(26, true) & 16383,
48677
+ height: view2.getUint16(28, true) & 16383
48678
+ };
48679
+ case "VP8L": {
48680
+ if (b[20] !== 47)
48681
+ return null;
48682
+ const bits = view2.getUint32(21, true);
48683
+ return {
48684
+ width: 1 + (bits & 16383),
48685
+ height: 1 + (bits >>> 14 & 16383)
48686
+ };
48687
+ }
48688
+ default:
48689
+ return null;
48690
+ }
48691
+ }
48692
+
48693
+ // ../../packages/run-core/dist/wallpaper.js
48694
+ async function decodeWallpaper(bytes2, contentType, size) {
48695
+ const blob = new Blob([bytes2.slice()], { type: contentType });
48696
+ let image;
48697
+ try {
48698
+ image = await (size === void 0 ? createImageBitmap(blob) : createImageBitmap(blob, {
48699
+ resizeWidth: size.width,
48700
+ resizeHeight: size.height,
48701
+ resizeQuality: "high"
48702
+ }));
48703
+ } catch (error51) {
48704
+ throw new Error(`the ${contentType} could not be decoded: ${error51 instanceof Error ? error51.message : String(error51)}`);
48705
+ }
48706
+ return { image, width: image.width, height: image.height, sourceTimeMs: 0 };
48707
+ }
48708
+ async function wallpaperLoader(bytes2, contentType, name) {
48709
+ let held = null;
48710
+ let natural = webpSize(bytes2);
48711
+ if (natural === null) {
48712
+ held = await decodeWallpaper(bytes2, contentType);
48713
+ natural = { width: held.width, height: held.height };
48714
+ }
48715
+ const own = natural;
48716
+ const free2 = (image) => {
48717
+ if (image !== null && "close" in image.image)
48718
+ image.image.close();
48719
+ };
48720
+ return {
48721
+ ok: true,
48722
+ name,
48723
+ natural: own,
48724
+ async image(size) {
48725
+ if (held === null || held.width < size.width) {
48726
+ const next = await decodeWallpaper(bytes2, contentType, size.width >= own.width ? void 0 : size);
48727
+ free2(held);
48728
+ held = next;
48729
+ }
48730
+ return held;
48731
+ },
48732
+ close: () => {
48733
+ free2(held);
48734
+ held = null;
48735
+ }
48736
+ };
48737
+ }
48738
+ var FITTED_TYPE = "image/webp";
48739
+ var FITTED_QUALITY = 0.97;
48740
+ async function fitWallpaperImage(file2) {
48741
+ const name = file2 instanceof File ? file2.name : "(unnamed)";
48742
+ let image;
48743
+ let width;
48744
+ let height;
48745
+ try {
48746
+ if (file2.type === "image/svg+xml") {
48747
+ const svg = await decodeLogo(new Uint8Array(await file2.arrayBuffer()), file2.type);
48748
+ const raster = await svg.rasterAt(svg.aspect >= 1 ? WALLPAPER_LONG_SIDE / svg.aspect : WALLPAPER_LONG_SIDE);
48749
+ ({ image, width, height } = raster);
48750
+ } else {
48751
+ const bitmap = await createImageBitmap(file2);
48752
+ const scale = Math.min(1, WALLPAPER_LONG_SIDE / Math.max(bitmap.width, bitmap.height));
48753
+ width = Math.max(1, Math.round(bitmap.width * scale));
48754
+ height = Math.max(1, Math.round(bitmap.height * scale));
48755
+ image = scale === 1 ? bitmap : await createImageBitmap(bitmap, {
48756
+ resizeWidth: width,
48757
+ resizeHeight: height,
48758
+ resizeQuality: "high"
48759
+ });
48760
+ if (image !== bitmap)
48761
+ bitmap.close();
48762
+ }
48763
+ } catch (error51) {
48764
+ throw new Error(`The image "${name}" could not be opened as an image`, {
48765
+ cause: error51
48766
+ });
48767
+ }
48768
+ const canvas = new OffscreenCanvas(width, height);
48769
+ canvas.getContext("2d").drawImage(image, 0, 0);
48770
+ if ("close" in image)
48771
+ image.close();
48772
+ let blob;
48773
+ try {
48774
+ blob = await canvas.convertToBlob({
48775
+ type: FITTED_TYPE,
48776
+ quality: FITTED_QUALITY
48777
+ });
48778
+ } catch (error51) {
48779
+ throw new Error(`The image "${name}" opened but could not be saved as WebP: ${error51 instanceof Error ? error51.message : String(error51)}`);
48780
+ }
48781
+ if (blob.type !== FITTED_TYPE) {
48782
+ throw new Error(`The image "${name}" opened but this browser saved it as ${blob.type || "nothing"}, not WebP`);
48783
+ }
48784
+ return { blob, width, height };
48785
+ }
48786
+
48182
48787
  // dist/entry-globals.js
48183
48788
  var RENDER_ENTRY_GLOBAL = "__demomanRender";
48184
48789
  var RENDER_PROGRESS_BINDING = "__demomanRenderFrame";
@@ -48232,6 +48837,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48232
48837
  logo = { ok: false, error: messageOf(error51) };
48233
48838
  }
48234
48839
  }
48840
+ let wallpaper = null;
48841
+ const sent = manifest.wallpaper;
48842
+ if (sent !== null && "error" in sent) {
48843
+ wallpaper = { ok: false, error: sent.error };
48844
+ } else if (sent !== null) {
48845
+ try {
48846
+ wallpaper = await wallpaperLoader(bytesOf(sent.base64), sent.contentType, sent.name);
48847
+ } catch (error51) {
48848
+ wallpaper = { ok: false, error: `${sent.name}: ${messageOf(error51)}` };
48849
+ }
48850
+ }
48235
48851
  const report = globalThis[RENDER_PROGRESS_BINDING];
48236
48852
  const started = performance.now();
48237
48853
  const source = await framesFor(bundle, load);
@@ -48259,15 +48875,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48259
48875
  bundle,
48260
48876
  frames,
48261
48877
  logo,
48878
+ wallpaper,
48262
48879
  ...manifest.gifBudget === void 0 ? {} : { gifBudget: manifest.gifBudget },
48263
48880
  ...manifest.mp4Cap === void 0 ? {} : {
48264
48881
  mp4Cap: {
48265
48882
  ...manifest.mp4Cap,
48266
- share: softwareEncoded(manifest.mp4Cap.share)
48883
+ share: softwareEncoded(manifest.mp4Cap.share),
48884
+ floor: softwareEncoded(manifest.mp4Cap.floor)
48267
48885
  }
48268
48886
  },
48269
48887
  ...manifest.stills === void 0 ? {} : { stills: manifest.stills },
48270
48888
  onFrame: wholePercent((done, total, width, pass) => width === void 0 ? report?.(done, total) : pass === void 0 ? report?.(done, total, width) : report?.(done, total, width, pass))
48889
+ // The decoded image is freed once every output is rendered: the GIF
48890
+ // ladder and the MP4 cap re-render inside this call.
48891
+ }).finally(() => {
48892
+ if (wallpaper?.ok === true)
48893
+ wallpaper.close();
48271
48894
  });
48272
48895
  outputs = files.map((f) => f.bytes);
48273
48896
  return {
@@ -48293,7 +48916,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48293
48916
  }
48294
48917
  return btoa(binary);
48295
48918
  }
48296
- var entry = { render, readChunk };
48919
+ async function fitWallpaper(base643, contentType, name) {
48920
+ const fitted = await fitWallpaperImage(new File([bytesOf(base643).slice()], name, { type: contentType }));
48921
+ const bytes2 = new Uint8Array(await fitted.blob.arrayBuffer());
48922
+ outputs = [bytes2];
48923
+ return {
48924
+ width: fitted.width,
48925
+ height: fitted.height,
48926
+ byteLength: bytes2.byteLength
48927
+ };
48928
+ }
48929
+ var entry = { render, readChunk, fitWallpaper };
48297
48930
  globalThis[RENDER_ENTRY_GLOBAL] = entry;
48298
48931
  })();
48299
48932
  /*! Bundled license information: