demoman 0.8.0 → 0.8.2
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/THIRD_PARTY_NOTICES +1 -1
- package/dist/demoman.mjs +19646 -13607
- package/dist/page/decode-probe-entry.js +23071 -0
- package/dist/page/executor-entry.js +102 -17
- package/dist/page/mux-entry.js +351 -107
- package/dist/page/render-entry.js +1931 -1147
- package/dist/recipe.md +248 -292
- package/dist/skills/record-demo/SKILL.md +5 -4
- package/dist/studio/assets/confirm-dialog-BGEp6bKH.css +1 -0
- package/dist/studio/assets/confirm-dialog-F4BR4FU0.js +72 -0
- package/dist/studio/assets/editor-63atCcDn.js +4 -0
- package/dist/studio/assets/{editor-inline-7e387eed.css → editor-inline-d74caea2.css} +10 -0
- package/dist/studio/assets/library-L3IU8F5q.js +1 -0
- package/dist/studio/assets/library-inline-3627d15c.css +1426 -0
- package/dist/studio/assets/settings-g3t2C3Eo.js +1 -0
- package/dist/studio/assets/{settings-inline-ff6d2eee.css → settings-inline-2f59fbb0.css} +12 -0
- package/dist/studio/assets/state-eyG4SxVq.js +1 -0
- package/dist/studio/assets/topbar-CgsXzkpk.js +1 -0
- package/dist/studio/assets/view-DzaxHB2c.js +1 -0
- package/dist/studio/editor.html +11 -10
- package/dist/studio/library.html +9 -8
- package/dist/studio/settings.html +8 -7
- package/dist/studio/studio-build.json +3 -3
- package/dist/studio/wallpapers/dark-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/dark-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/dark-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/dark-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/dark-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/dark-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/light-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/light-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/light-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/light-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/light-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/light-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-3-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-3-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-3-thumb.webp +0 -0
- package/dist/studio/wallpapers/muted-4-landscape.webp +0 -0
- package/dist/studio/wallpapers/muted-4-portrait.webp +0 -0
- package/dist/studio/wallpapers/muted-4-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-1-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-1-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-1-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-2-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-2-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-2-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-3-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-3-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-3-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-4-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-4-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-4-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-5-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-5-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-5-thumb.webp +0 -0
- package/dist/studio/wallpapers/vivid-6-landscape.webp +0 -0
- package/dist/studio/wallpapers/vivid-6-portrait.webp +0 -0
- package/dist/studio/wallpapers/vivid-6-thumb.webp +0 -0
- package/package.json +1 -1
- package/dist/studio/assets/confirm-dialog-Bcrw3f1a.js +0 -72
- package/dist/studio/assets/confirm-dialog-DSKBZQdV.css +0 -1
- package/dist/studio/assets/editor-DUZKtJ2T.js +0 -4
- package/dist/studio/assets/library-BPokDo6m.js +0 -1
- package/dist/studio/assets/library-inline-216fd6fd.css +0 -659
- package/dist/studio/assets/settings-RZj4oUzT.js +0 -1
- package/dist/studio/assets/state-tew-ACWl.js +0 -1
- package/dist/studio/assets/topbar-sSUyITjl.js +0 -1
- package/dist/studio/assets/view-SxAupNyx.js +0 -1
|
@@ -842,108 +842,6 @@
|
|
|
842
842
|
}
|
|
843
843
|
});
|
|
844
844
|
|
|
845
|
-
// ../../packages/run-core/dist/logo.js
|
|
846
|
-
var SVG_RASTER_CACHE_SIZE = 4;
|
|
847
|
-
var frame = (image) => ({
|
|
848
|
-
image,
|
|
849
|
-
width: image.width,
|
|
850
|
-
height: image.height,
|
|
851
|
-
// A logo is branding, not a timeline sample — it has no source instant.
|
|
852
|
-
sourceTimeMs: 0
|
|
853
|
-
});
|
|
854
|
-
function parseSvg(text) {
|
|
855
|
-
const doc = new DOMParser().parseFromString(text, "image/svg+xml");
|
|
856
|
-
const root = doc.documentElement;
|
|
857
|
-
if (doc.querySelector("parsererror") !== null || root.nodeName.toLowerCase() !== "svg") {
|
|
858
|
-
throw new Error("the file is not an SVG");
|
|
859
|
-
}
|
|
860
|
-
return root;
|
|
861
|
-
}
|
|
862
|
-
var length = (value) => {
|
|
863
|
-
if (value === null)
|
|
864
|
-
return null;
|
|
865
|
-
const n = Number.parseFloat(value);
|
|
866
|
-
return Number.isFinite(n) && n > 0 && !value.trim().endsWith("%") ? n : null;
|
|
867
|
-
};
|
|
868
|
-
function svgAspect(svgText) {
|
|
869
|
-
const root = parseSvg(svgText);
|
|
870
|
-
const w = length(root.getAttribute("width"));
|
|
871
|
-
const h = length(root.getAttribute("height"));
|
|
872
|
-
if (w !== null && h !== null)
|
|
873
|
-
return w / h;
|
|
874
|
-
const box2 = root.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number);
|
|
875
|
-
if (box2 && box2.length === 4 && box2[2] > 0 && box2[3] > 0) {
|
|
876
|
-
return box2[2] / box2[3];
|
|
877
|
-
}
|
|
878
|
-
throw new Error("the SVG has no width, height or viewBox, so there is no size to draw it at");
|
|
879
|
-
}
|
|
880
|
-
async function svgSource(bytes2) {
|
|
881
|
-
const text = new TextDecoder().decode(bytes2);
|
|
882
|
-
const aspect = svgAspect(text);
|
|
883
|
-
const cache = /* @__PURE__ */ new Map();
|
|
884
|
-
const render2 = async (heightPx) => {
|
|
885
|
-
const width = Math.max(1, Math.round(heightPx * aspect));
|
|
886
|
-
const height = Math.max(1, Math.round(heightPx));
|
|
887
|
-
const url3 = URL.createObjectURL(new Blob([bytes2.slice()], { type: "image/svg+xml" }));
|
|
888
|
-
try {
|
|
889
|
-
const img = new Image();
|
|
890
|
-
img.src = url3;
|
|
891
|
-
await img.decode().catch((error51) => {
|
|
892
|
-
throw new Error(`the SVG could not be decoded: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
893
|
-
});
|
|
894
|
-
const canvas = new OffscreenCanvas(width, height);
|
|
895
|
-
canvas.getContext("2d").drawImage(img, 0, 0, width, height);
|
|
896
|
-
return frame(await createImageBitmap(canvas));
|
|
897
|
-
} finally {
|
|
898
|
-
URL.revokeObjectURL(url3);
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
return {
|
|
902
|
-
contentType: "image/svg+xml",
|
|
903
|
-
aspect,
|
|
904
|
-
naturalHeight: null,
|
|
905
|
-
rasterAt(heightPx) {
|
|
906
|
-
const key = Math.max(1, Math.round(heightPx));
|
|
907
|
-
let hit = cache.get(key);
|
|
908
|
-
if (hit === void 0) {
|
|
909
|
-
const fresh = render2(key);
|
|
910
|
-
hit = fresh;
|
|
911
|
-
fresh.catch(() => {
|
|
912
|
-
if (cache.get(key) === fresh)
|
|
913
|
-
cache.delete(key);
|
|
914
|
-
});
|
|
915
|
-
} else {
|
|
916
|
-
cache.delete(key);
|
|
917
|
-
}
|
|
918
|
-
cache.set(key, hit);
|
|
919
|
-
while (cache.size > SVG_RASTER_CACHE_SIZE) {
|
|
920
|
-
cache.delete(cache.keys().next().value);
|
|
921
|
-
}
|
|
922
|
-
return hit;
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
async function decodeLogo(bytes2, contentType) {
|
|
927
|
-
if (contentType === "image/svg+xml") {
|
|
928
|
-
const source = await svgSource(bytes2);
|
|
929
|
-
await source.rasterAt(64);
|
|
930
|
-
return source;
|
|
931
|
-
}
|
|
932
|
-
let bitmap;
|
|
933
|
-
try {
|
|
934
|
-
bitmap = await createImageBitmap(new Blob([bytes2.slice()], { type: contentType }));
|
|
935
|
-
} catch (error51) {
|
|
936
|
-
throw new Error(`the ${contentType} could not be decoded: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
937
|
-
}
|
|
938
|
-
const image = frame(bitmap);
|
|
939
|
-
return {
|
|
940
|
-
contentType,
|
|
941
|
-
aspect: bitmap.width / bitmap.height,
|
|
942
|
-
naturalHeight: bitmap.height,
|
|
943
|
-
rasterAt: async () => image
|
|
944
|
-
};
|
|
945
|
-
}
|
|
946
|
-
|
|
947
845
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
948
846
|
var external_exports = {};
|
|
949
847
|
__export(external_exports, {
|
|
@@ -15465,7 +15363,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15465
15363
|
moveTo: { cursorTravels: true, approach: "nearest" },
|
|
15466
15364
|
scrollTo: { cursorTravels: false, approach: "landing" },
|
|
15467
15365
|
waitFor: { cursorTravels: false, approach: "none" },
|
|
15468
|
-
drag: { cursorTravels: true, approach: "nearest" }
|
|
15366
|
+
drag: { cursorTravels: true, approach: "nearest" },
|
|
15367
|
+
press: { cursorTravels: false, approach: "none" }
|
|
15469
15368
|
};
|
|
15470
15369
|
|
|
15471
15370
|
// ../../packages/compositor/dist/bundle.js
|
|
@@ -15978,8 +15877,75 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15978
15877
|
userAgentMetadata: UserAgentMetadataSchema.optional()
|
|
15979
15878
|
});
|
|
15980
15879
|
|
|
15880
|
+
// ../../packages/scene-schema/dist/wallpapers.js
|
|
15881
|
+
var WALLPAPERS = [
|
|
15882
|
+
{
|
|
15883
|
+
id: "muted-1",
|
|
15884
|
+
family: "muted",
|
|
15885
|
+
swatch: { from: "#141422", to: "#26233e" }
|
|
15886
|
+
},
|
|
15887
|
+
{
|
|
15888
|
+
id: "muted-2",
|
|
15889
|
+
family: "muted",
|
|
15890
|
+
swatch: { from: "#bfb5aa", to: "#a19486" }
|
|
15891
|
+
},
|
|
15892
|
+
{
|
|
15893
|
+
id: "muted-3",
|
|
15894
|
+
family: "muted",
|
|
15895
|
+
swatch: { from: "#1b1e1d", to: "#51625d" }
|
|
15896
|
+
},
|
|
15897
|
+
{
|
|
15898
|
+
id: "muted-4",
|
|
15899
|
+
family: "muted",
|
|
15900
|
+
swatch: { from: "#a3a299", to: "#cfcbc3" }
|
|
15901
|
+
},
|
|
15902
|
+
{
|
|
15903
|
+
id: "vivid-1",
|
|
15904
|
+
family: "vivid",
|
|
15905
|
+
swatch: { from: "#3527bc", to: "#ce1676" }
|
|
15906
|
+
},
|
|
15907
|
+
{
|
|
15908
|
+
id: "vivid-2",
|
|
15909
|
+
family: "vivid",
|
|
15910
|
+
swatch: { from: "#0769ca", to: "#1e26b7" }
|
|
15911
|
+
},
|
|
15912
|
+
{
|
|
15913
|
+
id: "vivid-3",
|
|
15914
|
+
family: "vivid",
|
|
15915
|
+
swatch: { from: "#c90757", to: "#ed480d" }
|
|
15916
|
+
},
|
|
15917
|
+
{
|
|
15918
|
+
id: "vivid-4",
|
|
15919
|
+
family: "vivid",
|
|
15920
|
+
swatch: { from: "#0ba393", to: "#0575c7" }
|
|
15921
|
+
},
|
|
15922
|
+
{
|
|
15923
|
+
id: "vivid-5",
|
|
15924
|
+
family: "vivid",
|
|
15925
|
+
swatch: { from: "#f28b0a", to: "#df2d21" }
|
|
15926
|
+
},
|
|
15927
|
+
{
|
|
15928
|
+
id: "vivid-6",
|
|
15929
|
+
family: "vivid",
|
|
15930
|
+
swatch: { from: "#3d0dbf", to: "#133ac7" }
|
|
15931
|
+
},
|
|
15932
|
+
{
|
|
15933
|
+
id: "light-1",
|
|
15934
|
+
family: "light",
|
|
15935
|
+
swatch: { from: "#b7bff3", to: "#eda9c5" }
|
|
15936
|
+
},
|
|
15937
|
+
{
|
|
15938
|
+
id: "light-2",
|
|
15939
|
+
family: "light",
|
|
15940
|
+
swatch: { from: "#afe5f0", to: "#98c5e8" }
|
|
15941
|
+
},
|
|
15942
|
+
{ id: "dark-1", family: "dark", swatch: { from: "#150217", to: "#3d044b" } },
|
|
15943
|
+
{ id: "dark-2", family: "dark", swatch: { from: "#02576e", to: "#023758" } }
|
|
15944
|
+
];
|
|
15945
|
+
var DEFAULT_WALLPAPER_ID = "muted-1";
|
|
15946
|
+
|
|
15981
15947
|
// ../../packages/scene-schema/dist/document.js
|
|
15982
|
-
var CURRENT_SCHEMA_VERSION =
|
|
15948
|
+
var CURRENT_SCHEMA_VERSION = 15;
|
|
15983
15949
|
var Rect = external_exports.object({
|
|
15984
15950
|
x: external_exports.number(),
|
|
15985
15951
|
y: external_exports.number(),
|
|
@@ -16072,9 +16038,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16072
16038
|
signal: external_exports.enum(["mutation", "style"]).optional()
|
|
16073
16039
|
});
|
|
16074
16040
|
var TEXT_LINES_MAX = 200;
|
|
16041
|
+
var PRESS_KEYS = [
|
|
16042
|
+
"Enter",
|
|
16043
|
+
"Tab",
|
|
16044
|
+
"Escape",
|
|
16045
|
+
"Backspace",
|
|
16046
|
+
"Delete",
|
|
16047
|
+
"ArrowUp",
|
|
16048
|
+
"ArrowDown",
|
|
16049
|
+
"ArrowLeft",
|
|
16050
|
+
"ArrowRight",
|
|
16051
|
+
"Space"
|
|
16052
|
+
];
|
|
16053
|
+
var Spot = external_exports.object({
|
|
16054
|
+
x: external_exports.number().min(0).max(1),
|
|
16055
|
+
y: external_exports.number().min(0).max(1)
|
|
16056
|
+
});
|
|
16075
16057
|
var Click = external_exports.object({
|
|
16076
16058
|
...actionBase,
|
|
16077
16059
|
kind: external_exports.literal("click"),
|
|
16060
|
+
/** Where in the target's box the click lands, as fractions of it (v14); absent: its centre. */
|
|
16061
|
+
at: Spot.optional(),
|
|
16078
16062
|
button: external_exports.enum(["left", "middle", "right"]).optional(),
|
|
16079
16063
|
/**
|
|
16080
16064
|
* The lines of text on screen when the click was measured, in the space
|
|
@@ -16150,9 +16134,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16150
16134
|
kind: external_exports.literal("waitFor"),
|
|
16151
16135
|
condition: external_exports.enum(["visible", "hidden", "loaded"]).optional()
|
|
16152
16136
|
});
|
|
16153
|
-
var
|
|
16154
|
-
|
|
16155
|
-
|
|
16137
|
+
var Press = external_exports.object({
|
|
16138
|
+
...actionBase,
|
|
16139
|
+
anchorId: external_exports.null(),
|
|
16140
|
+
kind: external_exports.literal("press"),
|
|
16141
|
+
key: external_exports.enum(PRESS_KEYS)
|
|
16156
16142
|
});
|
|
16157
16143
|
var Drag = external_exports.object({
|
|
16158
16144
|
...actionBase,
|
|
@@ -16177,7 +16163,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16177
16163
|
TypeAction,
|
|
16178
16164
|
ScrollTo,
|
|
16179
16165
|
WaitFor,
|
|
16180
|
-
Drag
|
|
16166
|
+
Drag,
|
|
16167
|
+
Press
|
|
16181
16168
|
]);
|
|
16182
16169
|
var MarkerSchema2 = external_exports.object({
|
|
16183
16170
|
actionId: external_exports.string().min(1),
|
|
@@ -16202,14 +16189,35 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16202
16189
|
scale: external_exports.number().positive().optional(),
|
|
16203
16190
|
/** Why the aim is not what the click asked for (`aimFallback`), or
|
|
16204
16191
|
* anything else the editor owes the author about this zoom. */
|
|
16205
|
-
note: external_exports.string().optional()
|
|
16192
|
+
note: external_exports.string().optional(),
|
|
16193
|
+
/**
|
|
16194
|
+
* Where this zoom came from: `click` was generated for a click, `author`
|
|
16195
|
+
* was written by the author (the Studio's addZoom, or a click zoom the
|
|
16196
|
+
* author moved; a script's `zoom` stays `click` with `scaleSetBy: "script"`). The record that
|
|
16197
|
+
* write-back reads; never inferred from the event's shape. Absent on every
|
|
16198
|
+
* take saved before v15 — those are not guessed.
|
|
16199
|
+
*/
|
|
16200
|
+
source: external_exports.enum(["click", "author"]).optional(),
|
|
16201
|
+
/**
|
|
16202
|
+
* Who chose `scale`: `script` set it explicitly, `author` is the studio's
|
|
16203
|
+
* own edit. The record that write-back reads, never inferred from the
|
|
16204
|
+
* scale's value. Absent when the scale was the default.
|
|
16205
|
+
*/
|
|
16206
|
+
scaleSetBy: external_exports.enum(["script", "author"]).optional()
|
|
16206
16207
|
});
|
|
16207
16208
|
var ZoomSkipped = external_exports.union([
|
|
16208
16209
|
external_exports.object({
|
|
16209
16210
|
actionId: external_exports.string().min(1),
|
|
16210
16211
|
reason: external_exports.enum(["tooClose", "sameTarget"]),
|
|
16211
16212
|
afterActionId: external_exports.string().min(1),
|
|
16212
|
-
gapMs: external_exports.number()
|
|
16213
|
+
gapMs: external_exports.number(),
|
|
16214
|
+
/** The scale the script asked for on this click, which the gap refused.
|
|
16215
|
+
* The record that write-back reads, never inferred. */
|
|
16216
|
+
askedScale: external_exports.number().optional()
|
|
16217
|
+
}),
|
|
16218
|
+
external_exports.object({
|
|
16219
|
+
actionId: external_exports.string().min(1),
|
|
16220
|
+
reason: external_exports.literal("off")
|
|
16213
16221
|
}),
|
|
16214
16222
|
external_exports.object({
|
|
16215
16223
|
actionId: external_exports.string().min(1),
|
|
@@ -16302,7 +16310,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16302
16310
|
* it came with the v10 bump all the same: a build from before would read
|
|
16303
16311
|
* `capture` without it and rebuild a phone take on the desktop.
|
|
16304
16312
|
*/
|
|
16305
|
-
device: CaptureDeviceSchema.optional()
|
|
16313
|
+
device: CaptureDeviceSchema.optional(),
|
|
16314
|
+
/**
|
|
16315
|
+
* The display scale the run filmed motion at: the scale screencast spans
|
|
16316
|
+
* follow, which `dpr` (the stills' scale) is not. Written by the run that
|
|
16317
|
+
* decided it (the CLI's browser session, at launch), so `keep` reads it
|
|
16318
|
+
* rather than guessing from the frames. Absent on takes filmed before it
|
|
16319
|
+
* and where the run could not know it (a visible window, whose scale is
|
|
16320
|
+
* the OS's). Widening with an optional field is backward compatible, as
|
|
16321
|
+
* `mode`'s was: `CURRENT_SCHEMA_VERSION` stays and no migration is owed.
|
|
16322
|
+
*/
|
|
16323
|
+
displayScale: external_exports.number().positive().optional()
|
|
16306
16324
|
}),
|
|
16307
16325
|
/**
|
|
16308
16326
|
* Which render this scene wants: `screen` serves the frames the take
|
|
@@ -16382,6 +16400,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16382
16400
|
aspect: "auto"
|
|
16383
16401
|
});
|
|
16384
16402
|
var BrandColorSchema = external_exports.string().regex(/^#[0-9a-f]{6}$/);
|
|
16403
|
+
var WallpaperBlurSchema = external_exports.number().min(0).max(1).optional();
|
|
16404
|
+
var DEFAULT_WALLPAPER_BLUR = 0;
|
|
16385
16405
|
var BackgroundSchema = external_exports.discriminatedUnion("kind", [
|
|
16386
16406
|
external_exports.object({ kind: external_exports.literal("solid"), color: BrandColorSchema }),
|
|
16387
16407
|
external_exports.object({
|
|
@@ -16390,6 +16410,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16390
16410
|
to: BrandColorSchema,
|
|
16391
16411
|
/** CSS convention: 0 = to top, 90 = to right, 180 = to bottom. */
|
|
16392
16412
|
angle: external_exports.number().int().min(0).max(359)
|
|
16413
|
+
}),
|
|
16414
|
+
// Not restricted to `WALLPAPERS`: a take naming an id a later build
|
|
16415
|
+
// removed still loads, and export says so. A script is checked against
|
|
16416
|
+
// the list in `DemoScriptSchema`.
|
|
16417
|
+
external_exports.object({
|
|
16418
|
+
kind: external_exports.literal("wallpaper"),
|
|
16419
|
+
id: external_exports.string().regex(/^[a-z0-9-]+$/),
|
|
16420
|
+
blur: WallpaperBlurSchema
|
|
16421
|
+
}),
|
|
16422
|
+
external_exports.object({
|
|
16423
|
+
kind: external_exports.literal("image"),
|
|
16424
|
+
ref: external_exports.string().min(1),
|
|
16425
|
+
blur: WallpaperBlurSchema
|
|
16393
16426
|
})
|
|
16394
16427
|
]);
|
|
16395
16428
|
var LOGO_CORNERS = [
|
|
@@ -16424,21 +16457,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16424
16457
|
angle: 150
|
|
16425
16458
|
});
|
|
16426
16459
|
var BRANDING_DEFAULTS = Object.freeze({
|
|
16427
|
-
background:
|
|
16460
|
+
background: Object.freeze({
|
|
16461
|
+
kind: "wallpaper",
|
|
16462
|
+
id: DEFAULT_WALLPAPER_ID,
|
|
16463
|
+
blur: DEFAULT_WALLPAPER_BLUR
|
|
16464
|
+
}),
|
|
16428
16465
|
logo: null,
|
|
16429
16466
|
/**
|
|
16430
|
-
*
|
|
16431
|
-
*
|
|
16432
|
-
*
|
|
16433
|
-
*
|
|
16434
|
-
*
|
|
16435
|
-
* `
|
|
16467
|
+
* 12%: the author's call on 2026-10-28, from a side-by-side with the
|
|
16468
|
+
* wallpapers, which want more of the frame to show. It was 8% from
|
|
16469
|
+
* 2026-10-05 (the margin of a polished recording, 8.4% measured), the
|
|
16470
|
+
* smallest padding that draws the default logo at full size; documents
|
|
16471
|
+
* migrated from v7 still get that 8% (`migrations.ts`), so nothing saved
|
|
16472
|
+
* changes. `placeLogo` keeps a mark 0.02 × short in from the edge and
|
|
16473
|
+
* clear of the recording, so a logo of size `s` fits only when the padding
|
|
16474
|
+
* is at least `s + 0.02`; `LOGO_DEFAULTS.size` is 0.06, well inside.
|
|
16436
16475
|
*
|
|
16437
16476
|
* Landscape exports used 15% until 2026-10-05 for zoom headroom: a
|
|
16438
16477
|
* smaller window leaves more source detail per output pixel. That trade
|
|
16439
16478
|
* is the author's now; `clampToSourceDetail` reports what it costs.
|
|
16440
16479
|
*/
|
|
16441
|
-
padding: 0.
|
|
16480
|
+
padding: 0.12
|
|
16442
16481
|
});
|
|
16443
16482
|
var LOGO_DEFAULTS = Object.freeze({
|
|
16444
16483
|
corner: "bottom-right",
|
|
@@ -16658,8 +16697,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16658
16697
|
if (at === void 0) {
|
|
16659
16698
|
return { x: rect2.x + rect2.width / 2, y: rect2.y + rect2.height / 2 };
|
|
16660
16699
|
}
|
|
16661
|
-
return {
|
|
16700
|
+
return {
|
|
16701
|
+
x: inside(rect2.x, rect2.width, at.x),
|
|
16702
|
+
y: inside(rect2.y, rect2.height, at.y)
|
|
16703
|
+
};
|
|
16662
16704
|
}
|
|
16705
|
+
function inside(start, size, fraction) {
|
|
16706
|
+
const inset = Math.min(EDGE_INSET_PX, size / 2);
|
|
16707
|
+
return Math.min(Math.max(start + fraction * size, start + inset), start + size - inset);
|
|
16708
|
+
}
|
|
16709
|
+
var EDGE_INSET_PX = 0.5;
|
|
16663
16710
|
function dragEndPoint(start, to, toRect) {
|
|
16664
16711
|
if ("by" in to)
|
|
16665
16712
|
return { x: start.x + to.by.x, y: start.y + to.by.y };
|
|
@@ -16676,7 +16723,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16676
16723
|
// ../../packages/scene-schema/dist/removed.js
|
|
16677
16724
|
function stepsInsideRemoved(doc) {
|
|
16678
16725
|
const index = new Map(doc.actions.map((a, i) => [a.id, i]));
|
|
16679
|
-
const
|
|
16726
|
+
const inside2 = /* @__PURE__ */ new Set();
|
|
16680
16727
|
for (const range of doc.edits.removed ?? []) {
|
|
16681
16728
|
const s = range.start === null ? null : index.get(range.start.actionId);
|
|
16682
16729
|
const e = range.end === null ? null : index.get(range.end.actionId);
|
|
@@ -16686,10 +16733,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16686
16733
|
const afterStart = range.start === null || s === null || s < i || i === s && range.start.sourceOffsetMs <= 0;
|
|
16687
16734
|
const beforeEnd = range.end === null || e === null || i < e || i === e && range.end.sourceOffsetMs > 0;
|
|
16688
16735
|
if (afterStart && beforeEnd)
|
|
16689
|
-
|
|
16736
|
+
inside2.add(action.id);
|
|
16690
16737
|
});
|
|
16691
16738
|
}
|
|
16692
|
-
return
|
|
16739
|
+
return inside2;
|
|
16693
16740
|
}
|
|
16694
16741
|
|
|
16695
16742
|
// ../../packages/scene-schema/dist/script.js
|
|
@@ -16699,6 +16746,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16699
16746
|
var SCRIPT_VERSION_DEVICE = 4;
|
|
16700
16747
|
var SCRIPT_VERSION_ACCOUNT = 5;
|
|
16701
16748
|
var SCRIPT_VERSION_DRAG = 6;
|
|
16749
|
+
var SCRIPT_VERSION_PRESS = 7;
|
|
16750
|
+
var SCRIPT_VERSION_EDITS = 8;
|
|
16751
|
+
var ZOOM_MAX_SCALE = 2.5;
|
|
16702
16752
|
var ACCOUNT_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
16703
16753
|
var ACCOUNT_NAME_RULE = 'lower-case letters, digits, "-" and "_", starting with a letter or digit, at most 64 characters';
|
|
16704
16754
|
var ScriptTargetSchema = external_exports.union([
|
|
@@ -16716,10 +16766,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16716
16766
|
by: external_exports.object({ x: external_exports.number().finite(), y: external_exports.number().finite() }).strict()
|
|
16717
16767
|
}).strict()
|
|
16718
16768
|
]);
|
|
16769
|
+
var ZoomIntentSchema = external_exports.union([
|
|
16770
|
+
external_exports.literal(false),
|
|
16771
|
+
external_exports.object({
|
|
16772
|
+
scale: external_exports.number().gt(1, {
|
|
16773
|
+
message: "a zoom scale is over 1; use `zoom: false` for none"
|
|
16774
|
+
}).max(ZOOM_MAX_SCALE, {
|
|
16775
|
+
message: `a zoom scale is at most ${ZOOM_MAX_SCALE}, the camera's limit`
|
|
16776
|
+
})
|
|
16777
|
+
}).strict()
|
|
16778
|
+
]);
|
|
16719
16779
|
var ScriptStepSchema = external_exports.discriminatedUnion("do", [
|
|
16720
16780
|
external_exports.object({
|
|
16721
16781
|
do: external_exports.literal("click"),
|
|
16722
16782
|
on: ScriptTargetSchema,
|
|
16783
|
+
/** Where in the target's box to click (its centre if absent). */
|
|
16784
|
+
at: DragSpotSchema.optional(),
|
|
16785
|
+
zoom: ZoomIntentSchema.optional(),
|
|
16723
16786
|
/**
|
|
16724
16787
|
* The recorded action this step was derived from (`scriptFromTake` writes
|
|
16725
16788
|
* it). How the recording layer pairs a run's step with the author's —
|
|
@@ -16770,6 +16833,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16770
16833
|
do: external_exports.literal("drag"),
|
|
16771
16834
|
from: DragFromSchema,
|
|
16772
16835
|
to: DragToSchema,
|
|
16836
|
+
zoom: ZoomIntentSchema.optional(),
|
|
16837
|
+
recorded: RecordedSchema
|
|
16838
|
+
}).strict(),
|
|
16839
|
+
external_exports.object({
|
|
16840
|
+
do: external_exports.literal("press"),
|
|
16841
|
+
key: external_exports.enum(PRESS_KEYS),
|
|
16773
16842
|
recorded: RecordedSchema
|
|
16774
16843
|
}).strict(),
|
|
16775
16844
|
external_exports.object({ do: external_exports.literal("waitForLoad"), recorded: RecordedSchema }).strict(),
|
|
@@ -16782,21 +16851,56 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16782
16851
|
scrollTo: true,
|
|
16783
16852
|
waitFor: true,
|
|
16784
16853
|
drag: true,
|
|
16854
|
+
press: true,
|
|
16785
16855
|
waitForLoad: true,
|
|
16786
16856
|
pause: false
|
|
16787
16857
|
};
|
|
16858
|
+
var SHOWN_STEP = {
|
|
16859
|
+
click: true,
|
|
16860
|
+
type: true,
|
|
16861
|
+
hover: true,
|
|
16862
|
+
scrollTo: true,
|
|
16863
|
+
waitFor: false,
|
|
16864
|
+
drag: true,
|
|
16865
|
+
press: true,
|
|
16866
|
+
waitForLoad: false,
|
|
16867
|
+
pause: false
|
|
16868
|
+
};
|
|
16869
|
+
function trimStepIndex(script, side) {
|
|
16870
|
+
const step = script.trim?.[side]?.step;
|
|
16871
|
+
if (step !== void 0)
|
|
16872
|
+
return step - 1;
|
|
16873
|
+
const shown = script.steps.flatMap((s, i) => SHOWN_STEP[s.do] ? [i] : []);
|
|
16874
|
+
return (side === "start" ? shown[0] : shown.at(-1)) ?? null;
|
|
16875
|
+
}
|
|
16876
|
+
var ScriptTrimSchema = external_exports.object({
|
|
16877
|
+
start: external_exports.object({
|
|
16878
|
+
ms: external_exports.number().finite().nonnegative(),
|
|
16879
|
+
step: external_exports.number().int().positive().optional()
|
|
16880
|
+
}).strict().optional(),
|
|
16881
|
+
end: external_exports.object({
|
|
16882
|
+
ms: external_exports.number().finite().nonnegative(),
|
|
16883
|
+
step: external_exports.number().int().positive().optional(),
|
|
16884
|
+
after: external_exports.enum(["zoomOut", "action"]).optional()
|
|
16885
|
+
}).strict().optional()
|
|
16886
|
+
}).strict();
|
|
16788
16887
|
var ScriptBrandingSchema = BrandingSchema.extend({
|
|
16789
16888
|
padding: BrandingSchema.shape.padding.default(BRANDING_DEFAULTS.padding)
|
|
16790
16889
|
});
|
|
16890
|
+
var ScriptVersionSchema = external_exports.literal([
|
|
16891
|
+
SCRIPT_VERSION,
|
|
16892
|
+
SCRIPT_VERSION_KIT,
|
|
16893
|
+
SCRIPT_VERSION_MOTION,
|
|
16894
|
+
SCRIPT_VERSION_DEVICE,
|
|
16895
|
+
SCRIPT_VERSION_ACCOUNT,
|
|
16896
|
+
SCRIPT_VERSION_DRAG,
|
|
16897
|
+
SCRIPT_VERSION_PRESS,
|
|
16898
|
+
SCRIPT_VERSION_EDITS
|
|
16899
|
+
]);
|
|
16900
|
+
var laterVersion = (a, b) => b > a ? b : a;
|
|
16791
16901
|
var DemoScriptShape = external_exports.object({
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
SCRIPT_VERSION_KIT,
|
|
16795
|
-
SCRIPT_VERSION_MOTION,
|
|
16796
|
-
SCRIPT_VERSION_DEVICE,
|
|
16797
|
-
SCRIPT_VERSION_ACCOUNT,
|
|
16798
|
-
SCRIPT_VERSION_DRAG
|
|
16799
|
-
]),
|
|
16902
|
+
/** Optional: Demoman sets it (see `minimumScriptVersion`); a lower one is raised. */
|
|
16903
|
+
scriptVersion: ScriptVersionSchema.optional(),
|
|
16800
16904
|
name: external_exports.string().min(1),
|
|
16801
16905
|
target: external_exports.url(),
|
|
16802
16906
|
/** Absent means the run's own window size, recorded into the document. */
|
|
@@ -16813,6 +16917,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16813
16917
|
message: `an account name is ${ACCOUNT_NAME_RULE}`
|
|
16814
16918
|
}).optional(),
|
|
16815
16919
|
steps: external_exports.array(ScriptStepSchema).min(1),
|
|
16920
|
+
/** Cut the film's start and end (`ScriptTrimSchema`). Absent: the whole take. */
|
|
16921
|
+
trim: ScriptTrimSchema.optional(),
|
|
16816
16922
|
/**
|
|
16817
16923
|
* The take that steps' `recorded` ids refer to (`scriptFromTake` writes it).
|
|
16818
16924
|
* Absent on a script nobody derived from a recording.
|
|
@@ -16847,51 +16953,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16847
16953
|
}).optional()
|
|
16848
16954
|
});
|
|
16849
16955
|
var DemoScriptSchema = DemoScriptShape.superRefine((script, ctx) => {
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
code: "custom",
|
|
16853
|
-
message: `a script that names look.kit declares scriptVersion ${SCRIPT_VERSION_KIT}: a build from before brand kits would drop the kit and record the default look`,
|
|
16854
|
-
path: ["scriptVersion"]
|
|
16855
|
-
});
|
|
16856
|
-
}
|
|
16857
|
-
if (script.look?.motion !== void 0 && script.scriptVersion < SCRIPT_VERSION_MOTION) {
|
|
16858
|
-
ctx.addIssue({
|
|
16859
|
-
code: "custom",
|
|
16860
|
-
message: `a script that names look.motion declares scriptVersion ${SCRIPT_VERSION_MOTION}: a build from before camera motion settings would drop them and record the default camera`,
|
|
16861
|
-
path: ["scriptVersion"]
|
|
16862
|
-
});
|
|
16863
|
-
}
|
|
16864
|
-
if (cursorPolishNamed(script.look?.cursor) && script.scriptVersion < SCRIPT_VERSION_MOTION) {
|
|
16865
|
-
ctx.addIssue({
|
|
16866
|
-
code: "custom",
|
|
16867
|
-
message: `a script that names look.cursor.tilt or look.cursor.clickBounce declares scriptVersion ${SCRIPT_VERSION_MOTION}: a build from before them would drop them and draw the default lean and press`,
|
|
16868
|
-
path: ["scriptVersion"]
|
|
16869
|
-
});
|
|
16870
|
-
}
|
|
16871
|
-
if (script.device !== void 0 && script.scriptVersion < SCRIPT_VERSION_DEVICE) {
|
|
16872
|
-
ctx.addIssue({
|
|
16873
|
-
code: "custom",
|
|
16874
|
-
message: `a script that names device declares scriptVersion ${SCRIPT_VERSION_DEVICE}: a build from before devices would drop it and record the desktop`,
|
|
16875
|
-
path: ["scriptVersion"]
|
|
16876
|
-
});
|
|
16877
|
-
}
|
|
16878
|
-
if (script.account !== void 0 && script.scriptVersion < SCRIPT_VERSION_ACCOUNT) {
|
|
16956
|
+
const bg = script.look?.branding?.background;
|
|
16957
|
+
if (bg?.kind === "wallpaper" && !WALLPAPERS.some((w) => w.id === bg.id)) {
|
|
16879
16958
|
ctx.addIssue({
|
|
16880
16959
|
code: "custom",
|
|
16881
|
-
message: `
|
|
16882
|
-
path: ["
|
|
16960
|
+
message: `unknown wallpaper "${bg.id}" \u2014 one of ${WALLPAPERS.map((w) => w.id).join(", ")}`,
|
|
16961
|
+
path: ["look", "branding", "background", "id"]
|
|
16883
16962
|
});
|
|
16884
16963
|
}
|
|
16885
16964
|
script.steps.forEach((step, index) => {
|
|
16886
16965
|
if (step.do !== "drag")
|
|
16887
16966
|
return;
|
|
16888
|
-
if (script.scriptVersion < SCRIPT_VERSION_DRAG) {
|
|
16889
|
-
ctx.addIssue({
|
|
16890
|
-
code: "custom",
|
|
16891
|
-
message: `a script that uses drag declares scriptVersion ${SCRIPT_VERSION_DRAG}: a build from before drag would refuse the step`,
|
|
16892
|
-
path: ["scriptVersion"]
|
|
16893
|
-
});
|
|
16894
|
-
}
|
|
16895
16967
|
const nowhere = "by" in step.to ? step.to.by.x === 0 && step.to.by.y === 0 : JSON.stringify(step.to.on) === JSON.stringify(step.from.on) && (step.to.at?.x ?? 0.5) === (step.from.at?.x ?? 0.5) && (step.to.at?.y ?? 0.5) === (step.from.at?.y ?? 0.5);
|
|
16896
16968
|
if (nowhere) {
|
|
16897
16969
|
ctx.addIssue({
|
|
@@ -16928,6 +17000,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16928
17000
|
});
|
|
16929
17001
|
});
|
|
16930
17002
|
}
|
|
17003
|
+
if (script.trim)
|
|
17004
|
+
trimIssues(script, ctx);
|
|
16931
17005
|
if (script.steps.some((step) => ACTS_ON_THE_PAGE[step.do]))
|
|
16932
17006
|
return;
|
|
16933
17007
|
ctx.addIssue({
|
|
@@ -16935,178 +17009,591 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16935
17009
|
message: "a script needs at least one step that acts on the page; every step here is a pause, which is a duration and performs nothing, so this script can never produce a take",
|
|
16936
17010
|
path: ["steps"]
|
|
16937
17011
|
});
|
|
16938
|
-
})
|
|
17012
|
+
}).transform((script) => ({
|
|
17013
|
+
...script,
|
|
17014
|
+
scriptVersion: laterVersion(script.scriptVersion ?? SCRIPT_VERSION, minimumScriptVersion(script))
|
|
17015
|
+
}));
|
|
17016
|
+
function trimIssues(script, ctx) {
|
|
17017
|
+
const { steps, trim = {} } = script;
|
|
17018
|
+
let bad = false;
|
|
17019
|
+
for (const edge of ["start", "end"]) {
|
|
17020
|
+
const step = trim[edge]?.step;
|
|
17021
|
+
if (step === void 0)
|
|
17022
|
+
continue;
|
|
17023
|
+
const why = step > steps.length ? `trim.${edge}.step is ${step}, but the script has ${steps.length} steps` : steps[step - 1]?.do === "pause" ? `trim.${edge}.step is ${step}, a pause: name a step that does something` : void 0;
|
|
17024
|
+
if (!why)
|
|
17025
|
+
continue;
|
|
17026
|
+
bad = true;
|
|
17027
|
+
ctx.addIssue({
|
|
17028
|
+
code: "custom",
|
|
17029
|
+
message: why,
|
|
17030
|
+
path: ["trim", edge, "step"]
|
|
17031
|
+
});
|
|
17032
|
+
}
|
|
17033
|
+
const start = trimStepIndex(script, "start");
|
|
17034
|
+
const end = trimStepIndex(script, "end");
|
|
17035
|
+
if (!bad && start !== null && end !== null && start > end) {
|
|
17036
|
+
ctx.addIssue({
|
|
17037
|
+
code: "custom",
|
|
17038
|
+
message: `trim starts at step ${start + 1}, after the step it ends at (${end + 1}): the film would be empty`,
|
|
17039
|
+
path: ["trim", "start", "step"]
|
|
17040
|
+
});
|
|
17041
|
+
}
|
|
17042
|
+
}
|
|
17043
|
+
function minimumScriptVersion(script) {
|
|
17044
|
+
const rules = [
|
|
17045
|
+
[script.look?.kit !== void 0, SCRIPT_VERSION_KIT],
|
|
17046
|
+
[script.look?.motion !== void 0, SCRIPT_VERSION_MOTION],
|
|
17047
|
+
[cursorPolishNamed(script.look?.cursor), SCRIPT_VERSION_MOTION],
|
|
17048
|
+
[script.device !== void 0, SCRIPT_VERSION_DEVICE],
|
|
17049
|
+
[script.account !== void 0, SCRIPT_VERSION_ACCOUNT],
|
|
17050
|
+
[script.steps.some((step) => step.do === "drag"), SCRIPT_VERSION_DRAG],
|
|
17051
|
+
[
|
|
17052
|
+
script.trim !== void 0 || script.steps.some((step) => (step.do === "click" || step.do === "drag") && step.zoom !== void 0),
|
|
17053
|
+
SCRIPT_VERSION_EDITS
|
|
17054
|
+
],
|
|
17055
|
+
[
|
|
17056
|
+
script.steps.some((step) => step.do === "press" || step.do === "click" && step.at),
|
|
17057
|
+
SCRIPT_VERSION_PRESS
|
|
17058
|
+
]
|
|
17059
|
+
];
|
|
17060
|
+
return rules.filter(([on]) => on).map(([, v]) => v).reduce(laterVersion, SCRIPT_VERSION);
|
|
17061
|
+
}
|
|
16939
17062
|
function cursorPolishNamed(cursor) {
|
|
16940
17063
|
return cursor?.tilt !== void 0 || cursor?.clickBounce !== void 0;
|
|
16941
17064
|
}
|
|
16942
17065
|
|
|
16943
|
-
// ../../packages/compositor/dist/plan/
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
17066
|
+
// ../../packages/compositor/dist/plan/smooth.js
|
|
17067
|
+
var CURSOR_SMOOTHING_MS = 30;
|
|
17068
|
+
var KERNEL_REACH_SIGMAS = 3;
|
|
17069
|
+
var CURSOR_REST_MS = 50;
|
|
17070
|
+
function bracketIndices(samples, times) {
|
|
17071
|
+
const out = /* @__PURE__ */ new Set();
|
|
17072
|
+
for (const t of times) {
|
|
17073
|
+
let before = null;
|
|
17074
|
+
let after = null;
|
|
17075
|
+
for (let i = 0; i < samples.length; i++) {
|
|
17076
|
+
const at = samples[i]?.sourceTimeMs;
|
|
17077
|
+
if (at === void 0)
|
|
17078
|
+
continue;
|
|
17079
|
+
if (at <= t)
|
|
17080
|
+
before = i;
|
|
17081
|
+
if (at >= t) {
|
|
17082
|
+
after = i;
|
|
17083
|
+
break;
|
|
17084
|
+
}
|
|
16953
17085
|
}
|
|
17086
|
+
if (before !== null)
|
|
17087
|
+
out.add(before);
|
|
17088
|
+
if (after !== null)
|
|
17089
|
+
out.add(after);
|
|
16954
17090
|
}
|
|
16955
17091
|
return out;
|
|
16956
17092
|
}
|
|
16957
|
-
function
|
|
16958
|
-
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
}
|
|
16967
|
-
function cutRanges(plan, bundle, sourceDurationMs) {
|
|
16968
|
-
const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
|
|
16969
|
-
const resolved = [];
|
|
16970
|
-
const unplacedCuts = [];
|
|
16971
|
-
for (const piece of plan.removed ?? []) {
|
|
16972
|
-
const ids = [piece.id];
|
|
16973
|
-
const sourceOf = (point2, ifNull) => {
|
|
16974
|
-
if (point2 === null)
|
|
16975
|
-
return ifNull;
|
|
16976
|
-
const marker = markerAt.get(point2.actionId);
|
|
16977
|
-
if (marker === void 0) {
|
|
16978
|
-
return `these frames carry no marker for "${point2.actionId}", so where this piece ${ifNull === 0 ? "starts" : "ends"} is unknown and no frames were removed`;
|
|
16979
|
-
}
|
|
16980
|
-
return clamp(marker + point2.sourceOffsetMs, 0, sourceDurationMs);
|
|
16981
|
-
};
|
|
16982
|
-
const start = sourceOf(piece.start, 0);
|
|
16983
|
-
const end = sourceOf(piece.end, sourceDurationMs);
|
|
16984
|
-
if (typeof start === "string" || typeof end === "string") {
|
|
16985
|
-
unplacedCuts.push({
|
|
16986
|
-
ids,
|
|
16987
|
-
reason: typeof start === "string" ? start : end
|
|
16988
|
-
});
|
|
16989
|
-
continue;
|
|
16990
|
-
}
|
|
16991
|
-
if (end <= start) {
|
|
16992
|
-
unplacedCuts.push({
|
|
16993
|
-
ids,
|
|
16994
|
-
reason: `this piece's two ends land at the same instant (${Math.round(start)}ms) or out of order, so it covers no frames`
|
|
16995
|
-
});
|
|
16996
|
-
continue;
|
|
16997
|
-
}
|
|
16998
|
-
resolved.push({
|
|
16999
|
-
ids,
|
|
17000
|
-
srcStartMs: start,
|
|
17001
|
-
srcEndMs: end,
|
|
17002
|
-
trailing: end >= sourceDurationMs
|
|
17003
|
-
});
|
|
17004
|
-
}
|
|
17005
|
-
resolved.sort((a, b) => a.srcStartMs - b.srcStartMs);
|
|
17006
|
-
const cuts = [];
|
|
17007
|
-
for (const cut of resolved) {
|
|
17008
|
-
const previous = cuts[cuts.length - 1];
|
|
17009
|
-
if (previous && cut.srcStartMs <= previous.srcEndMs) {
|
|
17010
|
-
previous.ids.push(...cut.ids);
|
|
17011
|
-
previous.srcEndMs = Math.max(previous.srcEndMs, cut.srcEndMs);
|
|
17012
|
-
previous.trailing ||= cut.trailing;
|
|
17093
|
+
function runBounds(samples, boundaryMs, gaps) {
|
|
17094
|
+
const start = new Array(samples.length).fill(0);
|
|
17095
|
+
const end = new Array(samples.length).fill(samples.length - 1);
|
|
17096
|
+
let runStart = 0;
|
|
17097
|
+
for (let i = 1; i <= samples.length; i++) {
|
|
17098
|
+
const previous = samples[i - 1];
|
|
17099
|
+
const current = samples[i];
|
|
17100
|
+
const broken = current === void 0 || previous === void 0 || current.sourceTimeMs - previous.sourceTimeMs > boundaryMs || overlapsGap(gaps, previous.sourceTimeMs, current.sourceTimeMs);
|
|
17101
|
+
if (!broken)
|
|
17013
17102
|
continue;
|
|
17103
|
+
for (let j = runStart; j < i; j++) {
|
|
17104
|
+
start[j] = runStart;
|
|
17105
|
+
end[j] = i - 1;
|
|
17014
17106
|
}
|
|
17015
|
-
|
|
17107
|
+
runStart = i;
|
|
17016
17108
|
}
|
|
17017
|
-
return {
|
|
17018
|
-
}
|
|
17019
|
-
function insideCutClosed(cuts, sourceMs) {
|
|
17020
|
-
return cuts.some((c) => sourceMs > c.srcStartMs && sourceMs <= c.srcEndMs);
|
|
17021
|
-
}
|
|
17022
|
-
function insideCutOpen(cuts, sourceMs) {
|
|
17023
|
-
return cuts.some((c) => sourceMs > c.srcStartMs && sourceMs < c.srcEndMs);
|
|
17109
|
+
return { start, end };
|
|
17024
17110
|
}
|
|
17025
|
-
|
|
17026
|
-
|
|
17027
|
-
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17111
|
+
function smoothCursor(samples, sigmaMs, pinnedMs = [], gaps = []) {
|
|
17112
|
+
if (sigmaMs <= 0 || samples.length < 3)
|
|
17113
|
+
return samples;
|
|
17114
|
+
const pinned = bracketIndices(samples, pinnedMs);
|
|
17115
|
+
const runs = runBounds(samples, CURSOR_REST_MS, gaps);
|
|
17116
|
+
const maxReach = KERNEL_REACH_SIGMAS * sigmaMs;
|
|
17117
|
+
const twoSigmaSquared = 2 * sigmaMs * sigmaMs;
|
|
17118
|
+
const SLACK_MS = 1e-6;
|
|
17119
|
+
let lo = 0;
|
|
17120
|
+
let hi = 0;
|
|
17121
|
+
let currentRun = -1;
|
|
17122
|
+
let cadence = 0;
|
|
17123
|
+
let padBefore = 0;
|
|
17124
|
+
let padAfter = 0;
|
|
17125
|
+
return samples.map((sample, i) => {
|
|
17126
|
+
const runStart = runs.start[i];
|
|
17127
|
+
const runEnd = runs.end[i];
|
|
17128
|
+
const first = samples[runStart];
|
|
17129
|
+
const last2 = samples[runEnd];
|
|
17130
|
+
if (runStart !== currentRun) {
|
|
17131
|
+
currentRun = runStart;
|
|
17132
|
+
lo = runStart;
|
|
17133
|
+
hi = runStart;
|
|
17134
|
+
const span = last2.sourceTimeMs - first.sourceTimeMs;
|
|
17135
|
+
cadence = runEnd > runStart ? span / (runEnd - runStart) : 0;
|
|
17136
|
+
const previousEnd = runStart > 0 ? samples[runStart - 1].sourceTimeMs : 0;
|
|
17137
|
+
const nextStart = runEnd < samples.length - 1 ? samples[runEnd + 1].sourceTimeMs : 0;
|
|
17138
|
+
const quietBefore = runStart > 0 && !overlapsGap(gaps, previousEnd, first.sourceTimeMs) ? first.sourceTimeMs - previousEnd : 0;
|
|
17139
|
+
const quietAfter = runEnd < samples.length - 1 && !overlapsGap(gaps, last2.sourceTimeMs, nextStart) ? nextStart - last2.sourceTimeMs : 0;
|
|
17140
|
+
padBefore = Math.min(maxReach, quietBefore);
|
|
17141
|
+
padAfter = Math.min(maxReach, quietAfter);
|
|
17142
|
+
}
|
|
17143
|
+
if (i === runStart || i === runEnd)
|
|
17144
|
+
return sample;
|
|
17145
|
+
if (pinned.has(i))
|
|
17146
|
+
return sample;
|
|
17147
|
+
const at = sample.sourceTimeMs;
|
|
17148
|
+
const reach = Math.min(maxReach, at - first.sourceTimeMs + padBefore, last2.sourceTimeMs - at + padAfter);
|
|
17149
|
+
if (reach <= 0)
|
|
17150
|
+
return sample;
|
|
17151
|
+
while (lo <= runEnd && at - samples[lo].sourceTimeMs > reach + SLACK_MS)
|
|
17152
|
+
lo++;
|
|
17153
|
+
if (hi < lo)
|
|
17154
|
+
hi = lo;
|
|
17155
|
+
while (hi <= runEnd && samples[hi].sourceTimeMs - at <= reach + SLACK_MS)
|
|
17156
|
+
hi++;
|
|
17157
|
+
let sx = 0;
|
|
17158
|
+
let sy = 0;
|
|
17159
|
+
let weight = 0;
|
|
17160
|
+
for (let j = lo; j < hi; j++) {
|
|
17161
|
+
const other = samples[j];
|
|
17162
|
+
if (!other)
|
|
17163
|
+
continue;
|
|
17164
|
+
const dt = other.sourceTimeMs - at;
|
|
17165
|
+
if (Math.abs(dt) > reach)
|
|
17166
|
+
continue;
|
|
17167
|
+
const w = Math.exp(-(dt * dt) / twoSigmaSquared);
|
|
17168
|
+
sx += other.x * w;
|
|
17169
|
+
sy += other.y * w;
|
|
17170
|
+
weight += w;
|
|
17171
|
+
}
|
|
17172
|
+
if (cadence > 0) {
|
|
17173
|
+
for (let step = cadence; step <= padBefore + SLACK_MS; step += cadence) {
|
|
17174
|
+
const dt = first.sourceTimeMs - step - at;
|
|
17175
|
+
if (-dt > reach + SLACK_MS)
|
|
17176
|
+
break;
|
|
17177
|
+
const w = Math.exp(-(dt * dt) / twoSigmaSquared);
|
|
17178
|
+
sx += first.x * w;
|
|
17179
|
+
sy += first.y * w;
|
|
17180
|
+
weight += w;
|
|
17039
17181
|
}
|
|
17040
|
-
|
|
17041
|
-
|
|
17182
|
+
for (let step = cadence; step <= padAfter + SLACK_MS; step += cadence) {
|
|
17183
|
+
const dt = last2.sourceTimeMs + step - at;
|
|
17184
|
+
if (dt > reach + SLACK_MS)
|
|
17185
|
+
break;
|
|
17186
|
+
const w = Math.exp(-(dt * dt) / twoSigmaSquared);
|
|
17187
|
+
sx += last2.x * w;
|
|
17188
|
+
sy += last2.y * w;
|
|
17189
|
+
weight += w;
|
|
17190
|
+
}
|
|
17191
|
+
}
|
|
17192
|
+
return weight === 0 ? sample : { sourceTimeMs: at, x: sx / weight, y: sy / weight };
|
|
17193
|
+
});
|
|
17042
17194
|
}
|
|
17043
|
-
|
|
17044
|
-
|
|
17045
|
-
|
|
17046
|
-
|
|
17047
|
-
|
|
17048
|
-
if (end > start)
|
|
17049
|
-
motionMs += end - start;
|
|
17050
|
-
}
|
|
17051
|
-
return motionMs;
|
|
17195
|
+
|
|
17196
|
+
// ../../packages/compositor/dist/plan/cursor-spring.js
|
|
17197
|
+
var CURSOR_SPRING_TAU_MS = 55;
|
|
17198
|
+
function springLeadMs(tauMs) {
|
|
17199
|
+
return 2 * tauMs;
|
|
17052
17200
|
}
|
|
17053
|
-
function
|
|
17054
|
-
return
|
|
17201
|
+
function springSettleMs(tauMs) {
|
|
17202
|
+
return 6 * tauMs;
|
|
17055
17203
|
}
|
|
17056
|
-
function
|
|
17057
|
-
|
|
17058
|
-
|
|
17059
|
-
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
|
|
17063
|
-
for (const pace of plan.paces) {
|
|
17064
|
-
const from = markerAt.get(pace.afterActionId);
|
|
17065
|
-
const to = markerAt.get(pace.beforeActionId);
|
|
17066
|
-
if (from === void 0 || to === void 0) {
|
|
17067
|
-
unplacedPaces++;
|
|
17204
|
+
function positionAt(samples, ms) {
|
|
17205
|
+
const first = samples[0];
|
|
17206
|
+
if (ms <= first.sourceTimeMs)
|
|
17207
|
+
return { x: first.x, y: first.y };
|
|
17208
|
+
for (let i = 1; i < samples.length; i++) {
|
|
17209
|
+
const to = samples[i];
|
|
17210
|
+
if (to.sourceTimeMs < ms)
|
|
17068
17211
|
continue;
|
|
17212
|
+
const from = samples[i - 1];
|
|
17213
|
+
const span = to.sourceTimeMs - from.sourceTimeMs;
|
|
17214
|
+
const u = span === 0 ? 0 : (ms - from.sourceTimeMs) / span;
|
|
17215
|
+
return { x: from.x + (to.x - from.x) * u, y: from.y + (to.y - from.y) * u };
|
|
17216
|
+
}
|
|
17217
|
+
const last2 = samples[samples.length - 1];
|
|
17218
|
+
return { x: last2.x, y: last2.y };
|
|
17219
|
+
}
|
|
17220
|
+
function readerFor(samples) {
|
|
17221
|
+
let i = 1;
|
|
17222
|
+
return (ms) => {
|
|
17223
|
+
const first = samples[0];
|
|
17224
|
+
if (ms <= first.sourceTimeMs)
|
|
17225
|
+
return { x: first.x, y: first.y };
|
|
17226
|
+
while (i < samples.length && samples[i].sourceTimeMs < ms) {
|
|
17227
|
+
i++;
|
|
17069
17228
|
}
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
|
|
17074
|
-
const shortfall = Math.max(0, idleTargetMsFor(pace, motionMs) - idleMs);
|
|
17075
|
-
if (shortfall > 0) {
|
|
17076
|
-
instants.push({ sourceTimeMs: to, durationMs: shortfall });
|
|
17229
|
+
const to = samples[i];
|
|
17230
|
+
if (!to) {
|
|
17231
|
+
const last2 = samples[samples.length - 1];
|
|
17232
|
+
return { x: last2.x, y: last2.y };
|
|
17077
17233
|
}
|
|
17078
|
-
|
|
17079
|
-
|
|
17080
|
-
|
|
17081
|
-
|
|
17234
|
+
const from = samples[i - 1];
|
|
17235
|
+
const span = to.sourceTimeMs - from.sourceTimeMs;
|
|
17236
|
+
const u = span === 0 ? 0 : (ms - from.sourceTimeMs) / span;
|
|
17237
|
+
return { x: from.x + (to.x - from.x) * u, y: from.y + (to.y - from.y) * u };
|
|
17082
17238
|
};
|
|
17083
17239
|
}
|
|
17084
|
-
|
|
17085
|
-
|
|
17086
|
-
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
|
|
17092
|
-
for (
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
|
|
17097
|
-
const isMotion = (start, end) => motion.some((s) => s.startMs <= start && s.endMs >= end && end > start);
|
|
17098
|
-
const raw = [];
|
|
17099
|
-
for (let i = 1; i < ordered.length; i++) {
|
|
17100
|
-
const srcStartMs = ordered[i - 1];
|
|
17101
|
-
const srcEndMs = ordered[i];
|
|
17102
|
-
if (srcStartMs === void 0 || srcEndMs === void 0)
|
|
17103
|
-
continue;
|
|
17104
|
-
const srcDuration = srcEndMs - srcStartMs;
|
|
17105
|
-
if (srcDuration <= 0)
|
|
17106
|
-
continue;
|
|
17107
|
-
if (insideCutClosed(cuts, (srcStartMs + srcEndMs) / 2))
|
|
17240
|
+
var SPRING_GRID_MS = 8;
|
|
17241
|
+
function followWithSpring(samples, tauMs, anchorMs, gaps = []) {
|
|
17242
|
+
if (tauMs <= 0 || samples.length < 2)
|
|
17243
|
+
return samples;
|
|
17244
|
+
if (gaps.length === 0)
|
|
17245
|
+
return followOneStretch(samples, tauMs, anchorMs);
|
|
17246
|
+
const out = [];
|
|
17247
|
+
let start = 0;
|
|
17248
|
+
for (let i = 1; i <= samples.length; i++) {
|
|
17249
|
+
const current = samples[i];
|
|
17250
|
+
const previous = samples[i - 1];
|
|
17251
|
+
const broken = current === void 0 || overlapsGap(gaps, previous.sourceTimeMs, current.sourceTimeMs);
|
|
17252
|
+
if (!broken)
|
|
17108
17253
|
continue;
|
|
17109
|
-
const
|
|
17254
|
+
const stretch = samples.slice(start, i);
|
|
17255
|
+
const from = stretch[0];
|
|
17256
|
+
const to = stretch[stretch.length - 1];
|
|
17257
|
+
out.push(...stretch.length < 2 ? stretch : followOneStretch(stretch, tauMs, anchorMs.filter((ms) => ms >= from.sourceTimeMs && ms <= to.sourceTimeMs)));
|
|
17258
|
+
start = i;
|
|
17259
|
+
}
|
|
17260
|
+
return out;
|
|
17261
|
+
}
|
|
17262
|
+
function followOneStretch(samples, tauMs, anchorMs) {
|
|
17263
|
+
const omega = 1 / tauMs;
|
|
17264
|
+
const settleMs = springSettleMs(tauMs);
|
|
17265
|
+
const first = samples[0];
|
|
17266
|
+
const out = [{ ...first }];
|
|
17267
|
+
let x = first.x;
|
|
17268
|
+
let y = first.y;
|
|
17269
|
+
let vx = 0;
|
|
17270
|
+
let vy = 0;
|
|
17271
|
+
const advance = (dt, targetX, targetY, atMs) => {
|
|
17272
|
+
if (dt <= 0) {
|
|
17273
|
+
out.push({ sourceTimeMs: atMs, x, y });
|
|
17274
|
+
return;
|
|
17275
|
+
}
|
|
17276
|
+
const decay = Math.exp(-omega * dt);
|
|
17277
|
+
const ex = x - targetX;
|
|
17278
|
+
const ey = y - targetY;
|
|
17279
|
+
const bx = vx + omega * ex;
|
|
17280
|
+
const by = vy + omega * ey;
|
|
17281
|
+
const nx = (ex + bx * dt) * decay;
|
|
17282
|
+
const ny = (ey + by * dt) * decay;
|
|
17283
|
+
vx = (bx - omega * (ex + bx * dt)) * decay;
|
|
17284
|
+
vy = (by - omega * (ey + by * dt)) * decay;
|
|
17285
|
+
x = targetX + nx;
|
|
17286
|
+
y = targetY + ny;
|
|
17287
|
+
out.push({ sourceTimeMs: atMs, x, y });
|
|
17288
|
+
};
|
|
17289
|
+
const lead = springLeadMs(tauMs);
|
|
17290
|
+
const times = [];
|
|
17291
|
+
for (let i = 1; i < samples.length; i++) {
|
|
17292
|
+
const from = samples[i - 1];
|
|
17293
|
+
const to = samples[i];
|
|
17294
|
+
if (to.sourceTimeMs - from.sourceTimeMs > CURSOR_REST_MS) {
|
|
17295
|
+
const headUntil = Math.min(to.sourceTimeMs, from.sourceTimeMs + settleMs);
|
|
17296
|
+
const tailFrom = Math.max(from.sourceTimeMs, to.sourceTimeMs - lead - settleMs);
|
|
17297
|
+
for (let ms = from.sourceTimeMs + SPRING_GRID_MS; ms < to.sourceTimeMs; ms += SPRING_GRID_MS) {
|
|
17298
|
+
if (ms < headUntil || ms >= tailFrom)
|
|
17299
|
+
times.push(ms);
|
|
17300
|
+
}
|
|
17301
|
+
}
|
|
17302
|
+
times.push(to.sourceTimeMs);
|
|
17303
|
+
}
|
|
17304
|
+
const read = readerFor(samples);
|
|
17305
|
+
let previous = first.sourceTimeMs;
|
|
17306
|
+
for (const ms of times) {
|
|
17307
|
+
const target = read((previous + ms) / 2 + lead);
|
|
17308
|
+
advance(ms - previous, target.x, target.y, ms);
|
|
17309
|
+
previous = ms;
|
|
17310
|
+
}
|
|
17311
|
+
const last2 = samples[samples.length - 1];
|
|
17312
|
+
for (let ms = previous + SPRING_GRID_MS; ms <= last2.sourceTimeMs + settleMs; ms += SPRING_GRID_MS) {
|
|
17313
|
+
advance(ms - previous, last2.x, last2.y, ms);
|
|
17314
|
+
previous = ms;
|
|
17315
|
+
}
|
|
17316
|
+
return anchor(out, samples, anchorMs, settleMs);
|
|
17317
|
+
}
|
|
17318
|
+
function anchor(drawn, target, anchorMs, shoulderMs) {
|
|
17319
|
+
const anchors = [...new Set(anchorMs)].sort((a, b) => a - b);
|
|
17320
|
+
if (anchors.length === 0 || shoulderMs <= 0)
|
|
17321
|
+
return drawn;
|
|
17322
|
+
const out = drawn.map((s) => ({ ...s }));
|
|
17323
|
+
for (const [index, ms] of anchors.entries()) {
|
|
17324
|
+
const previous = anchors[index - 1];
|
|
17325
|
+
const next = anchors[index + 1];
|
|
17326
|
+
const room = Math.min(previous === void 0 ? Number.POSITIVE_INFINITY : (ms - previous) / 2, next === void 0 ? Number.POSITIVE_INFINITY : (next - ms) / 2);
|
|
17327
|
+
const shoulder = Math.min(shoulderMs, room);
|
|
17328
|
+
if (!Number.isFinite(shoulder) || shoulder <= 0)
|
|
17329
|
+
continue;
|
|
17330
|
+
const truth = positionAt(target, ms);
|
|
17331
|
+
const here = positionAt(out, ms);
|
|
17332
|
+
const dx = truth.x - here.x;
|
|
17333
|
+
const dy = truth.y - here.y;
|
|
17334
|
+
if (dx === 0 && dy === 0)
|
|
17335
|
+
continue;
|
|
17336
|
+
for (const sample of out) {
|
|
17337
|
+
const away = Math.abs(sample.sourceTimeMs - ms);
|
|
17338
|
+
if (away > shoulder)
|
|
17339
|
+
continue;
|
|
17340
|
+
const weight = 0.5 * (1 + Math.cos(Math.PI * away / shoulder));
|
|
17341
|
+
sample.x += dx * weight;
|
|
17342
|
+
sample.y += dy * weight;
|
|
17343
|
+
}
|
|
17344
|
+
}
|
|
17345
|
+
return out;
|
|
17346
|
+
}
|
|
17347
|
+
|
|
17348
|
+
// ../../packages/compositor/dist/plan/screen-space.js
|
|
17349
|
+
function transformAt(transforms, sourceTimeMs) {
|
|
17350
|
+
let at = transforms[0] ?? null;
|
|
17351
|
+
for (const t of transforms) {
|
|
17352
|
+
if (t.sourceTimeMs > sourceTimeMs)
|
|
17353
|
+
break;
|
|
17354
|
+
at = t;
|
|
17355
|
+
}
|
|
17356
|
+
return at;
|
|
17357
|
+
}
|
|
17358
|
+
var point = (p, t) => ({
|
|
17359
|
+
x: (p.x - t.offsetX) * t.scale,
|
|
17360
|
+
y: (p.y - t.offsetY) * t.scale
|
|
17361
|
+
});
|
|
17362
|
+
var rect = (r, t) => ({
|
|
17363
|
+
...r,
|
|
17364
|
+
...point(r, t),
|
|
17365
|
+
width: r.width * t.scale,
|
|
17366
|
+
height: r.height * t.scale
|
|
17367
|
+
});
|
|
17368
|
+
var isIdentity = (t) => t.scale === 1 && t.offsetX === 0 && t.offsetY === 0;
|
|
17369
|
+
function inScreenSpace(bundle, scene) {
|
|
17370
|
+
const transforms = bundle.viewportTransforms ?? [];
|
|
17371
|
+
if (transforms.every(isIdentity)) {
|
|
17372
|
+
return transforms.length === 0 ? { bundle, scene } : { bundle: { ...bundle, viewportTransforms: [] }, scene };
|
|
17373
|
+
}
|
|
17374
|
+
const markerMs = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
|
|
17375
|
+
const at = (ms) => transformAt(transforms, ms);
|
|
17376
|
+
const atAction = (actionId) => at((actionId === void 0 ? void 0 : markerMs.get(actionId)) ?? 0);
|
|
17377
|
+
const converted = {
|
|
17378
|
+
...bundle,
|
|
17379
|
+
viewportTransforms: [],
|
|
17380
|
+
cursorSamples: bundle.cursorSamples.map((s) => ({
|
|
17381
|
+
...s,
|
|
17382
|
+
...point(s, at(s.sourceTimeMs))
|
|
17383
|
+
})),
|
|
17384
|
+
anchorRects: bundle.anchorRects.map((e) => ({
|
|
17385
|
+
...e,
|
|
17386
|
+
rect: rect(e.rect, atAction(e.actionId))
|
|
17387
|
+
}))
|
|
17388
|
+
};
|
|
17389
|
+
if (scene === void 0)
|
|
17390
|
+
return { bundle: converted, scene };
|
|
17391
|
+
const firstSeen = /* @__PURE__ */ new Map();
|
|
17392
|
+
for (const action of scene.actions) {
|
|
17393
|
+
const anchorId = "anchorId" in action ? action.anchorId : void 0;
|
|
17394
|
+
if (typeof anchorId === "string" && !firstSeen.has(anchorId)) {
|
|
17395
|
+
firstSeen.set(anchorId, action.id);
|
|
17396
|
+
}
|
|
17397
|
+
}
|
|
17398
|
+
const sceneOut = {
|
|
17399
|
+
...scene,
|
|
17400
|
+
actions: scene.actions.map((a) => "rect" in a && a.rect !== void 0 ? { ...a, rect: rect(a.rect, atAction(a.id)) } : a),
|
|
17401
|
+
anchors: scene.anchors.map((anchor2) => {
|
|
17402
|
+
const r = anchor2.fingerprint.boundingRect;
|
|
17403
|
+
if (!r)
|
|
17404
|
+
return anchor2;
|
|
17405
|
+
return {
|
|
17406
|
+
...anchor2,
|
|
17407
|
+
fingerprint: {
|
|
17408
|
+
...anchor2.fingerprint,
|
|
17409
|
+
boundingRect: rect(r, atAction(firstSeen.get(anchor2.id)))
|
|
17410
|
+
}
|
|
17411
|
+
};
|
|
17412
|
+
})
|
|
17413
|
+
};
|
|
17414
|
+
return { bundle: converted, scene: sceneOut };
|
|
17415
|
+
}
|
|
17416
|
+
function segmentsInScreenSpace(segments, transforms, markerSourceMs) {
|
|
17417
|
+
if (transforms.every(isIdentity))
|
|
17418
|
+
return [...segments];
|
|
17419
|
+
return segments.map((s) => {
|
|
17420
|
+
const t = transformAt(transforms, markerSourceMs.get(s.toActionId) ?? 0);
|
|
17421
|
+
return {
|
|
17422
|
+
...s,
|
|
17423
|
+
from: point(s.from, t),
|
|
17424
|
+
to: point(s.to, t),
|
|
17425
|
+
via: s.via.map((v) => point(v, t))
|
|
17426
|
+
};
|
|
17427
|
+
});
|
|
17428
|
+
}
|
|
17429
|
+
|
|
17430
|
+
// ../../packages/compositor/dist/plan/timeline.js
|
|
17431
|
+
function merge2(spans) {
|
|
17432
|
+
const sorted = [...spans].filter((s) => s.endMs > s.startMs).sort((a, b) => a.startMs - b.startMs);
|
|
17433
|
+
const out = [];
|
|
17434
|
+
for (const span of sorted) {
|
|
17435
|
+
const last2 = out[out.length - 1];
|
|
17436
|
+
if (last2 && span.startMs <= last2.endMs) {
|
|
17437
|
+
last2.endMs = Math.max(last2.endMs, span.endMs);
|
|
17438
|
+
} else {
|
|
17439
|
+
out.push({ startMs: span.startMs, endMs: span.endMs });
|
|
17440
|
+
}
|
|
17441
|
+
}
|
|
17442
|
+
return out;
|
|
17443
|
+
}
|
|
17444
|
+
function isUnkeptMotion(d) {
|
|
17445
|
+
return d.kind === "keyframeOnly" || d.kind === "surfaceMismatch" || d.kind === "encodeRefused" || d.kind === "motionReclaimed";
|
|
17446
|
+
}
|
|
17447
|
+
function motionSpansOf(bundle, hints = []) {
|
|
17448
|
+
return merge2([
|
|
17449
|
+
...bundle.motionSpans.map((s) => ({ startMs: s.startMs, endMs: s.endMs })),
|
|
17450
|
+
...bundle.degradations.filter(isUnkeptMotion).map((d) => ({ startMs: d.startMs, endMs: d.endMs })),
|
|
17451
|
+
...hints
|
|
17452
|
+
]);
|
|
17453
|
+
}
|
|
17454
|
+
function cutRanges(plan, bundle, sourceDurationMs) {
|
|
17455
|
+
const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
|
|
17456
|
+
const resolved = [];
|
|
17457
|
+
const unplacedCuts = [];
|
|
17458
|
+
for (const piece of plan.removed ?? []) {
|
|
17459
|
+
const ids = [piece.id];
|
|
17460
|
+
const sourceOf = (point2, ifNull) => {
|
|
17461
|
+
if (point2 === null)
|
|
17462
|
+
return ifNull;
|
|
17463
|
+
const marker = markerAt.get(point2.actionId);
|
|
17464
|
+
if (marker === void 0) {
|
|
17465
|
+
return `these frames carry no marker for "${point2.actionId}", so where this piece ${ifNull === 0 ? "starts" : "ends"} is unknown and no frames were removed`;
|
|
17466
|
+
}
|
|
17467
|
+
return clamp(marker + point2.sourceOffsetMs, 0, sourceDurationMs);
|
|
17468
|
+
};
|
|
17469
|
+
const start = sourceOf(piece.start, 0);
|
|
17470
|
+
const end = sourceOf(piece.end, sourceDurationMs);
|
|
17471
|
+
if (typeof start === "string" || typeof end === "string") {
|
|
17472
|
+
unplacedCuts.push({
|
|
17473
|
+
ids,
|
|
17474
|
+
reason: typeof start === "string" ? start : end
|
|
17475
|
+
});
|
|
17476
|
+
continue;
|
|
17477
|
+
}
|
|
17478
|
+
if (end <= start) {
|
|
17479
|
+
unplacedCuts.push({
|
|
17480
|
+
ids,
|
|
17481
|
+
reason: `this piece's two ends land at the same instant (${Math.round(start)}ms) or out of order, so it covers no frames`
|
|
17482
|
+
});
|
|
17483
|
+
continue;
|
|
17484
|
+
}
|
|
17485
|
+
resolved.push({
|
|
17486
|
+
ids,
|
|
17487
|
+
srcStartMs: start,
|
|
17488
|
+
srcEndMs: end,
|
|
17489
|
+
trailing: end >= sourceDurationMs
|
|
17490
|
+
});
|
|
17491
|
+
}
|
|
17492
|
+
resolved.sort((a, b) => a.srcStartMs - b.srcStartMs);
|
|
17493
|
+
const cuts = [];
|
|
17494
|
+
for (const cut of resolved) {
|
|
17495
|
+
const previous = cuts[cuts.length - 1];
|
|
17496
|
+
if (previous && cut.srcStartMs <= previous.srcEndMs) {
|
|
17497
|
+
previous.ids.push(...cut.ids);
|
|
17498
|
+
previous.srcEndMs = Math.max(previous.srcEndMs, cut.srcEndMs);
|
|
17499
|
+
previous.trailing ||= cut.trailing;
|
|
17500
|
+
continue;
|
|
17501
|
+
}
|
|
17502
|
+
cuts.push(cut);
|
|
17503
|
+
}
|
|
17504
|
+
return { cuts, unplacedCuts };
|
|
17505
|
+
}
|
|
17506
|
+
function insideCutClosed(cuts, sourceMs) {
|
|
17507
|
+
return cuts.some((c) => sourceMs > c.srcStartMs && sourceMs <= c.srcEndMs);
|
|
17508
|
+
}
|
|
17509
|
+
function insideCutOpen(cuts, sourceMs) {
|
|
17510
|
+
return cuts.some((c) => sourceMs > c.srcStartMs && sourceMs < c.srcEndMs);
|
|
17511
|
+
}
|
|
17512
|
+
var HOLD_EPSILON_MS = 1e-6;
|
|
17513
|
+
function holdInstants(plan, bundle, sourceDurationMs, cuts) {
|
|
17514
|
+
const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
|
|
17515
|
+
return plan.holds.flatMap((hold) => {
|
|
17516
|
+
const marker = markerAt.get(hold.actionId);
|
|
17517
|
+
if (marker === void 0)
|
|
17518
|
+
return [];
|
|
17519
|
+
const sourceTimeMs = clamp(marker + hold.offsetMs, 0, sourceDurationMs);
|
|
17520
|
+
if (insideCutOpen(cuts, sourceTimeMs))
|
|
17521
|
+
return [];
|
|
17522
|
+
return [
|
|
17523
|
+
{
|
|
17524
|
+
sourceTimeMs,
|
|
17525
|
+
durationMs: Math.max(0, hold.durationMs)
|
|
17526
|
+
}
|
|
17527
|
+
];
|
|
17528
|
+
}).sort((a, b) => a.sourceTimeMs - b.sourceTimeMs);
|
|
17529
|
+
}
|
|
17530
|
+
function motionMsBetween(motion, fromMs, toMs) {
|
|
17531
|
+
let motionMs = 0;
|
|
17532
|
+
for (const span of motion) {
|
|
17533
|
+
const start = Math.max(span.startMs, fromMs);
|
|
17534
|
+
const end = Math.min(span.endMs, toMs);
|
|
17535
|
+
if (end > start)
|
|
17536
|
+
motionMs += end - start;
|
|
17537
|
+
}
|
|
17538
|
+
return motionMs;
|
|
17539
|
+
}
|
|
17540
|
+
function idleTargetMsFor(pace, motionMs) {
|
|
17541
|
+
return pace.origin === "authored" ? pace.idleTargetMs : Math.max(0, pace.recordedSpanMs - motionMs);
|
|
17542
|
+
}
|
|
17543
|
+
function paceInstants(plan, bundle, motion, cuts) {
|
|
17544
|
+
if (plan.paces === null || isRealTime(bundle)) {
|
|
17545
|
+
return { instants: [], unplacedPaces: 0 };
|
|
17546
|
+
}
|
|
17547
|
+
const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
|
|
17548
|
+
const instants = [];
|
|
17549
|
+
let unplacedPaces = 0;
|
|
17550
|
+
for (const pace of plan.paces) {
|
|
17551
|
+
const from = markerAt.get(pace.afterActionId);
|
|
17552
|
+
const to = markerAt.get(pace.beforeActionId);
|
|
17553
|
+
if (from === void 0 || to === void 0) {
|
|
17554
|
+
unplacedPaces++;
|
|
17555
|
+
continue;
|
|
17556
|
+
}
|
|
17557
|
+
if (insideCutClosed(cuts, to))
|
|
17558
|
+
continue;
|
|
17559
|
+
const motionMs = motionMsBetween(motion, from, to);
|
|
17560
|
+
const idleMs = Math.max(0, to - from - motionMs);
|
|
17561
|
+
const shortfall = Math.max(0, idleTargetMsFor(pace, motionMs) - idleMs);
|
|
17562
|
+
if (shortfall > 0) {
|
|
17563
|
+
instants.push({ sourceTimeMs: to, durationMs: shortfall });
|
|
17564
|
+
}
|
|
17565
|
+
}
|
|
17566
|
+
return {
|
|
17567
|
+
instants: instants.sort((a, b) => a.sourceTimeMs - b.sourceTimeMs),
|
|
17568
|
+
unplacedPaces
|
|
17569
|
+
};
|
|
17570
|
+
}
|
|
17571
|
+
function rawSegmentsOf(plan, bundle, motion, sourceDurationMs, cuts) {
|
|
17572
|
+
const cutSet = /* @__PURE__ */ new Set([0, sourceDurationMs]);
|
|
17573
|
+
for (const marker of bundle.markers)
|
|
17574
|
+
cutSet.add(marker.sourceTimeMs);
|
|
17575
|
+
for (const span of motion) {
|
|
17576
|
+
cutSet.add(span.startMs);
|
|
17577
|
+
cutSet.add(span.endMs);
|
|
17578
|
+
}
|
|
17579
|
+
for (const cut of cuts) {
|
|
17580
|
+
cutSet.add(cut.srcStartMs);
|
|
17581
|
+
cutSet.add(cut.srcEndMs);
|
|
17582
|
+
}
|
|
17583
|
+
const ordered = [...cutSet].filter((t) => t >= 0 && t <= sourceDurationMs).sort((a, b) => a - b);
|
|
17584
|
+
const isMotion = (start, end) => motion.some((s) => s.startMs <= start && s.endMs >= end && end > start);
|
|
17585
|
+
const raw = [];
|
|
17586
|
+
for (let i = 1; i < ordered.length; i++) {
|
|
17587
|
+
const srcStartMs = ordered[i - 1];
|
|
17588
|
+
const srcEndMs = ordered[i];
|
|
17589
|
+
if (srcStartMs === void 0 || srcEndMs === void 0)
|
|
17590
|
+
continue;
|
|
17591
|
+
const srcDuration = srcEndMs - srcStartMs;
|
|
17592
|
+
if (srcDuration <= 0)
|
|
17593
|
+
continue;
|
|
17594
|
+
if (insideCutClosed(cuts, (srcStartMs + srcEndMs) / 2))
|
|
17595
|
+
continue;
|
|
17596
|
+
const kind = isMotion(srcStartMs, srcEndMs) ? "motion" : "idle";
|
|
17110
17597
|
const outDurationMs = kind === "motion" ? srcDuration : idleOutputFor(plan, bundle, motion, cuts, srcStartMs, srcEndMs, srcDuration);
|
|
17111
17598
|
raw.push({ srcStartMs, srcEndMs, kind, outDurationMs });
|
|
17112
17599
|
}
|
|
@@ -17198,10 +17685,32 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17198
17685
|
}
|
|
17199
17686
|
return merge2(out);
|
|
17200
17687
|
}
|
|
17688
|
+
var CURSOR_MOTION_EPSILON_PX = 0.5;
|
|
17689
|
+
function cursorMotionSpans(samples) {
|
|
17690
|
+
const spans = [];
|
|
17691
|
+
for (let i = 1; i < samples.length; i++) {
|
|
17692
|
+
const from = samples[i - 1];
|
|
17693
|
+
const to = samples[i];
|
|
17694
|
+
if (!from || !to)
|
|
17695
|
+
continue;
|
|
17696
|
+
if (to.sourceTimeMs <= from.sourceTimeMs)
|
|
17697
|
+
continue;
|
|
17698
|
+
if (Math.hypot(to.x - from.x, to.y - from.y) < CURSOR_MOTION_EPSILON_PX) {
|
|
17699
|
+
continue;
|
|
17700
|
+
}
|
|
17701
|
+
spans.push({ startMs: from.sourceTimeMs, endMs: to.sourceTimeMs });
|
|
17702
|
+
}
|
|
17703
|
+
return spans;
|
|
17704
|
+
}
|
|
17705
|
+
function sourceDurationOf(bundle) {
|
|
17706
|
+
const lastKeyframe = bundle.keyframes[bundle.keyframes.length - 1];
|
|
17707
|
+
const travel = cursorMotionSpans(inScreenSpace(bundle, void 0).bundle.cursorSamples).at(-1);
|
|
17708
|
+
const settleMs = bundle.source === "capture" ? springSettleMs(CURSOR_SPRING_TAU_MS) : 0;
|
|
17709
|
+
return Math.max(lastKeyframe?.sourceTimeMs ?? 0, ...bundle.markers.map((m) => m.sourceTimeMs), ...motionSpansOf(bundle).map((m) => m.endMs), travel === void 0 ? 0 : travel.endMs + settleMs);
|
|
17710
|
+
}
|
|
17201
17711
|
function buildTimeline(plan, bundle, hints = []) {
|
|
17202
17712
|
const motion = motionSpansOf(bundle, hints);
|
|
17203
|
-
const
|
|
17204
|
-
const sourceDurationMs = Math.max(lastKeyframe?.sourceTimeMs ?? 0, ...bundle.markers.map((m) => m.sourceTimeMs), ...motion.map((m) => m.endMs));
|
|
17713
|
+
const sourceDurationMs = sourceDurationOf(bundle);
|
|
17205
17714
|
const { cuts, unplacedCuts } = cutRanges(plan, bundle, sourceDurationMs);
|
|
17206
17715
|
const interruptions = interruptionsOf(bundle, cuts);
|
|
17207
17716
|
const removed = [
|
|
@@ -17632,6 +18141,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17632
18141
|
const { minPlateauMs } = CAMERA_DEFAULTS.neutral;
|
|
17633
18142
|
return nextArrivalMs - timings.zoomInMs - minPlateauMs >= heldUntilMs + minPlateauMs + timings.zoomOutMs;
|
|
17634
18143
|
}
|
|
18144
|
+
function pullOutLandsAt(heldUntilMs, timings) {
|
|
18145
|
+
return heldUntilMs + CAMERA_DEFAULTS.neutral.zoomHoldMs + timings.zoomOutMs;
|
|
18146
|
+
}
|
|
17635
18147
|
function insertNeutralKeys(seeds, outputDurationMs, timings, holds = []) {
|
|
17636
18148
|
const { neutral } = CAMERA_DEFAULTS;
|
|
17637
18149
|
const { zoomOutMs } = timings;
|
|
@@ -17660,7 +18172,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17660
18172
|
const next = seeds[i + 1];
|
|
17661
18173
|
const heldUntil = heldUntilOf(seed, next?.actionMs ?? Number.POSITIVE_INFINITY, holds);
|
|
17662
18174
|
const earliestMs = heldUntil + neutral.minPlateauMs + zoomOutMs;
|
|
17663
|
-
const idealMs = heldUntil
|
|
18175
|
+
const idealMs = pullOutLandsAt(heldUntil, timings);
|
|
17664
18176
|
const wantedMs = seed.authoredEndMs ?? idealMs;
|
|
17665
18177
|
const resolvedAuthored = seed.authoredEndMs !== null;
|
|
17666
18178
|
const authored = resolvedAuthored || seed.endUnplaced;
|
|
@@ -17858,8 +18370,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17858
18370
|
}
|
|
17859
18371
|
return stretches;
|
|
17860
18372
|
}
|
|
17861
|
-
function sampleTrack(track, outputTimeMs) {
|
|
17862
|
-
const
|
|
18373
|
+
function sampleTrack(track, outputTimeMs, legal = (center) => center) {
|
|
18374
|
+
const keys = track.cameraKeys.map((key) => ({
|
|
18375
|
+
...key,
|
|
18376
|
+
center: legal(key.center, key.scale)
|
|
18377
|
+
}));
|
|
18378
|
+
const base = sampleCamera(keys, outputTimeMs);
|
|
17863
18379
|
if (base.scale <= 1)
|
|
17864
18380
|
return base;
|
|
17865
18381
|
const stretch = track.cameraFollow.find((s) => s.startMs <= outputTimeMs && outputTimeMs <= s.endMs);
|
|
@@ -17872,13 +18388,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17872
18388
|
const next = stretch.centers[i + 1];
|
|
17873
18389
|
const spring = next === void 0 ? here : lerpVec(here, next, (outputTimeMs - timeOf(i)) / (timeOf(i + 1) - timeOf(i)));
|
|
17874
18390
|
if (outputTimeMs < stretch.pullOutDepartMs) {
|
|
17875
|
-
return { center: spring, scale: base.scale };
|
|
18391
|
+
return { center: legal(spring, base.scale), scale: base.scale };
|
|
17876
18392
|
}
|
|
17877
|
-
const from = sampleCamera(
|
|
18393
|
+
const from = sampleCamera(keys, stretch.pullOutDepartMs).scale;
|
|
17878
18394
|
if (from <= 1)
|
|
17879
18395
|
return base;
|
|
17880
|
-
const
|
|
17881
|
-
|
|
18396
|
+
const landing = sampleCamera(keys, stretch.endMs).center;
|
|
18397
|
+
const w = (1 / from - 1 / base.scale) / (1 / from - 1);
|
|
18398
|
+
return {
|
|
18399
|
+
center: lerpVec(legal(spring, from), landing, w),
|
|
18400
|
+
scale: base.scale
|
|
18401
|
+
};
|
|
18402
|
+
}
|
|
18403
|
+
function frameTrack(track, outputTimeMs, base, frameRect, viewport, canvas) {
|
|
18404
|
+
const legal = (center, scale) => frameCamera({ center, scale }, base, frameRect, viewport, canvas).center;
|
|
18405
|
+
return frameCamera(sampleTrack(track, outputTimeMs, legal), base, frameRect, viewport, canvas);
|
|
17882
18406
|
}
|
|
17883
18407
|
|
|
17884
18408
|
// ../../packages/compositor/dist/plan/cursor.js
|
|
@@ -17940,7 +18464,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17940
18464
|
return [];
|
|
17941
18465
|
}
|
|
17942
18466
|
const rect2 = rectOf(action.anchorId, action.id);
|
|
17943
|
-
return rect2 ? [
|
|
18467
|
+
return rect2 ? [
|
|
18468
|
+
{
|
|
18469
|
+
action,
|
|
18470
|
+
point: spotIn(rect2, action.kind === "click" ? action.at : void 0)
|
|
18471
|
+
}
|
|
18472
|
+
] : [];
|
|
17944
18473
|
});
|
|
17945
18474
|
if (targets.length === 0)
|
|
17946
18475
|
return [];
|
|
@@ -17964,405 +18493,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17964
18493
|
});
|
|
17965
18494
|
}
|
|
17966
18495
|
|
|
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
|
-
// ../../packages/compositor/dist/plan/smooth.js
|
|
18085
|
-
var CURSOR_SMOOTHING_MS = 30;
|
|
18086
|
-
var KERNEL_REACH_SIGMAS = 3;
|
|
18087
|
-
var CURSOR_REST_MS = 50;
|
|
18088
|
-
function bracketIndices(samples, times) {
|
|
18089
|
-
const out = /* @__PURE__ */ new Set();
|
|
18090
|
-
for (const t of times) {
|
|
18091
|
-
let before = null;
|
|
18092
|
-
let after = null;
|
|
18093
|
-
for (let i = 0; i < samples.length; i++) {
|
|
18094
|
-
const at = samples[i]?.sourceTimeMs;
|
|
18095
|
-
if (at === void 0)
|
|
18096
|
-
continue;
|
|
18097
|
-
if (at <= t)
|
|
18098
|
-
before = i;
|
|
18099
|
-
if (at >= t) {
|
|
18100
|
-
after = i;
|
|
18101
|
-
break;
|
|
18102
|
-
}
|
|
18103
|
-
}
|
|
18104
|
-
if (before !== null)
|
|
18105
|
-
out.add(before);
|
|
18106
|
-
if (after !== null)
|
|
18107
|
-
out.add(after);
|
|
18108
|
-
}
|
|
18109
|
-
return out;
|
|
18110
|
-
}
|
|
18111
|
-
function runBounds(samples, boundaryMs, gaps) {
|
|
18112
|
-
const start = new Array(samples.length).fill(0);
|
|
18113
|
-
const end = new Array(samples.length).fill(samples.length - 1);
|
|
18114
|
-
let runStart = 0;
|
|
18115
|
-
for (let i = 1; i <= samples.length; i++) {
|
|
18116
|
-
const previous = samples[i - 1];
|
|
18117
|
-
const current = samples[i];
|
|
18118
|
-
const broken = current === void 0 || previous === void 0 || current.sourceTimeMs - previous.sourceTimeMs > boundaryMs || overlapsGap(gaps, previous.sourceTimeMs, current.sourceTimeMs);
|
|
18119
|
-
if (!broken)
|
|
18120
|
-
continue;
|
|
18121
|
-
for (let j = runStart; j < i; j++) {
|
|
18122
|
-
start[j] = runStart;
|
|
18123
|
-
end[j] = i - 1;
|
|
18124
|
-
}
|
|
18125
|
-
runStart = i;
|
|
18126
|
-
}
|
|
18127
|
-
return { start, end };
|
|
18128
|
-
}
|
|
18129
|
-
function smoothCursor(samples, sigmaMs, pinnedMs = [], gaps = []) {
|
|
18130
|
-
if (sigmaMs <= 0 || samples.length < 3)
|
|
18131
|
-
return samples;
|
|
18132
|
-
const pinned = bracketIndices(samples, pinnedMs);
|
|
18133
|
-
const runs = runBounds(samples, CURSOR_REST_MS, gaps);
|
|
18134
|
-
const maxReach = KERNEL_REACH_SIGMAS * sigmaMs;
|
|
18135
|
-
const twoSigmaSquared = 2 * sigmaMs * sigmaMs;
|
|
18136
|
-
const SLACK_MS = 1e-6;
|
|
18137
|
-
let lo = 0;
|
|
18138
|
-
let hi = 0;
|
|
18139
|
-
let currentRun = -1;
|
|
18140
|
-
let cadence = 0;
|
|
18141
|
-
let padBefore = 0;
|
|
18142
|
-
let padAfter = 0;
|
|
18143
|
-
return samples.map((sample, i) => {
|
|
18144
|
-
const runStart = runs.start[i];
|
|
18145
|
-
const runEnd = runs.end[i];
|
|
18146
|
-
const first = samples[runStart];
|
|
18147
|
-
const last2 = samples[runEnd];
|
|
18148
|
-
if (runStart !== currentRun) {
|
|
18149
|
-
currentRun = runStart;
|
|
18150
|
-
lo = runStart;
|
|
18151
|
-
hi = runStart;
|
|
18152
|
-
const span = last2.sourceTimeMs - first.sourceTimeMs;
|
|
18153
|
-
cadence = runEnd > runStart ? span / (runEnd - runStart) : 0;
|
|
18154
|
-
const previousEnd = runStart > 0 ? samples[runStart - 1].sourceTimeMs : 0;
|
|
18155
|
-
const nextStart = runEnd < samples.length - 1 ? samples[runEnd + 1].sourceTimeMs : 0;
|
|
18156
|
-
const quietBefore = runStart > 0 && !overlapsGap(gaps, previousEnd, first.sourceTimeMs) ? first.sourceTimeMs - previousEnd : 0;
|
|
18157
|
-
const quietAfter = runEnd < samples.length - 1 && !overlapsGap(gaps, last2.sourceTimeMs, nextStart) ? nextStart - last2.sourceTimeMs : 0;
|
|
18158
|
-
padBefore = Math.min(maxReach, quietBefore);
|
|
18159
|
-
padAfter = Math.min(maxReach, quietAfter);
|
|
18160
|
-
}
|
|
18161
|
-
if (i === runStart || i === runEnd)
|
|
18162
|
-
return sample;
|
|
18163
|
-
if (pinned.has(i))
|
|
18164
|
-
return sample;
|
|
18165
|
-
const at = sample.sourceTimeMs;
|
|
18166
|
-
const reach = Math.min(maxReach, at - first.sourceTimeMs + padBefore, last2.sourceTimeMs - at + padAfter);
|
|
18167
|
-
if (reach <= 0)
|
|
18168
|
-
return sample;
|
|
18169
|
-
while (lo <= runEnd && at - samples[lo].sourceTimeMs > reach + SLACK_MS)
|
|
18170
|
-
lo++;
|
|
18171
|
-
if (hi < lo)
|
|
18172
|
-
hi = lo;
|
|
18173
|
-
while (hi <= runEnd && samples[hi].sourceTimeMs - at <= reach + SLACK_MS)
|
|
18174
|
-
hi++;
|
|
18175
|
-
let sx = 0;
|
|
18176
|
-
let sy = 0;
|
|
18177
|
-
let weight = 0;
|
|
18178
|
-
for (let j = lo; j < hi; j++) {
|
|
18179
|
-
const other = samples[j];
|
|
18180
|
-
if (!other)
|
|
18181
|
-
continue;
|
|
18182
|
-
const dt = other.sourceTimeMs - at;
|
|
18183
|
-
if (Math.abs(dt) > reach)
|
|
18184
|
-
continue;
|
|
18185
|
-
const w = Math.exp(-(dt * dt) / twoSigmaSquared);
|
|
18186
|
-
sx += other.x * w;
|
|
18187
|
-
sy += other.y * w;
|
|
18188
|
-
weight += w;
|
|
18189
|
-
}
|
|
18190
|
-
if (cadence > 0) {
|
|
18191
|
-
for (let step = cadence; step <= padBefore + SLACK_MS; step += cadence) {
|
|
18192
|
-
const dt = first.sourceTimeMs - step - at;
|
|
18193
|
-
if (-dt > reach + SLACK_MS)
|
|
18194
|
-
break;
|
|
18195
|
-
const w = Math.exp(-(dt * dt) / twoSigmaSquared);
|
|
18196
|
-
sx += first.x * w;
|
|
18197
|
-
sy += first.y * w;
|
|
18198
|
-
weight += w;
|
|
18199
|
-
}
|
|
18200
|
-
for (let step = cadence; step <= padAfter + SLACK_MS; step += cadence) {
|
|
18201
|
-
const dt = last2.sourceTimeMs + step - at;
|
|
18202
|
-
if (dt > reach + SLACK_MS)
|
|
18203
|
-
break;
|
|
18204
|
-
const w = Math.exp(-(dt * dt) / twoSigmaSquared);
|
|
18205
|
-
sx += last2.x * w;
|
|
18206
|
-
sy += last2.y * w;
|
|
18207
|
-
weight += w;
|
|
18208
|
-
}
|
|
18209
|
-
}
|
|
18210
|
-
return weight === 0 ? sample : { sourceTimeMs: at, x: sx / weight, y: sy / weight };
|
|
18211
|
-
});
|
|
18212
|
-
}
|
|
18213
|
-
|
|
18214
|
-
// ../../packages/compositor/dist/plan/cursor-spring.js
|
|
18215
|
-
var CURSOR_SPRING_TAU_MS = 55;
|
|
18216
|
-
function springLeadMs(tauMs) {
|
|
18217
|
-
return 2 * tauMs;
|
|
18218
|
-
}
|
|
18219
|
-
function springSettleMs(tauMs) {
|
|
18220
|
-
return 6 * tauMs;
|
|
18221
|
-
}
|
|
18222
|
-
function positionAt(samples, ms) {
|
|
18223
|
-
const first = samples[0];
|
|
18224
|
-
if (ms <= first.sourceTimeMs)
|
|
18225
|
-
return { x: first.x, y: first.y };
|
|
18226
|
-
for (let i = 1; i < samples.length; i++) {
|
|
18227
|
-
const to = samples[i];
|
|
18228
|
-
if (to.sourceTimeMs < ms)
|
|
18229
|
-
continue;
|
|
18230
|
-
const from = samples[i - 1];
|
|
18231
|
-
const span = to.sourceTimeMs - from.sourceTimeMs;
|
|
18232
|
-
const u = span === 0 ? 0 : (ms - from.sourceTimeMs) / span;
|
|
18233
|
-
return { x: from.x + (to.x - from.x) * u, y: from.y + (to.y - from.y) * u };
|
|
18234
|
-
}
|
|
18235
|
-
const last2 = samples[samples.length - 1];
|
|
18236
|
-
return { x: last2.x, y: last2.y };
|
|
18237
|
-
}
|
|
18238
|
-
function readerFor(samples) {
|
|
18239
|
-
let i = 1;
|
|
18240
|
-
return (ms) => {
|
|
18241
|
-
const first = samples[0];
|
|
18242
|
-
if (ms <= first.sourceTimeMs)
|
|
18243
|
-
return { x: first.x, y: first.y };
|
|
18244
|
-
while (i < samples.length && samples[i].sourceTimeMs < ms) {
|
|
18245
|
-
i++;
|
|
18246
|
-
}
|
|
18247
|
-
const to = samples[i];
|
|
18248
|
-
if (!to) {
|
|
18249
|
-
const last2 = samples[samples.length - 1];
|
|
18250
|
-
return { x: last2.x, y: last2.y };
|
|
18251
|
-
}
|
|
18252
|
-
const from = samples[i - 1];
|
|
18253
|
-
const span = to.sourceTimeMs - from.sourceTimeMs;
|
|
18254
|
-
const u = span === 0 ? 0 : (ms - from.sourceTimeMs) / span;
|
|
18255
|
-
return { x: from.x + (to.x - from.x) * u, y: from.y + (to.y - from.y) * u };
|
|
18256
|
-
};
|
|
18257
|
-
}
|
|
18258
|
-
var SPRING_GRID_MS = 8;
|
|
18259
|
-
function followWithSpring(samples, tauMs, anchorMs, gaps = []) {
|
|
18260
|
-
if (tauMs <= 0 || samples.length < 2)
|
|
18261
|
-
return samples;
|
|
18262
|
-
if (gaps.length === 0)
|
|
18263
|
-
return followOneStretch(samples, tauMs, anchorMs);
|
|
18264
|
-
const out = [];
|
|
18265
|
-
let start = 0;
|
|
18266
|
-
for (let i = 1; i <= samples.length; i++) {
|
|
18267
|
-
const current = samples[i];
|
|
18268
|
-
const previous = samples[i - 1];
|
|
18269
|
-
const broken = current === void 0 || overlapsGap(gaps, previous.sourceTimeMs, current.sourceTimeMs);
|
|
18270
|
-
if (!broken)
|
|
18271
|
-
continue;
|
|
18272
|
-
const stretch = samples.slice(start, i);
|
|
18273
|
-
const from = stretch[0];
|
|
18274
|
-
const to = stretch[stretch.length - 1];
|
|
18275
|
-
out.push(...stretch.length < 2 ? stretch : followOneStretch(stretch, tauMs, anchorMs.filter((ms) => ms >= from.sourceTimeMs && ms <= to.sourceTimeMs)));
|
|
18276
|
-
start = i;
|
|
18277
|
-
}
|
|
18278
|
-
return out;
|
|
18279
|
-
}
|
|
18280
|
-
function followOneStretch(samples, tauMs, anchorMs) {
|
|
18281
|
-
const omega = 1 / tauMs;
|
|
18282
|
-
const settleMs = springSettleMs(tauMs);
|
|
18283
|
-
const first = samples[0];
|
|
18284
|
-
const out = [{ ...first }];
|
|
18285
|
-
let x = first.x;
|
|
18286
|
-
let y = first.y;
|
|
18287
|
-
let vx = 0;
|
|
18288
|
-
let vy = 0;
|
|
18289
|
-
const advance = (dt, targetX, targetY, atMs) => {
|
|
18290
|
-
if (dt <= 0) {
|
|
18291
|
-
out.push({ sourceTimeMs: atMs, x, y });
|
|
18292
|
-
return;
|
|
18293
|
-
}
|
|
18294
|
-
const decay = Math.exp(-omega * dt);
|
|
18295
|
-
const ex = x - targetX;
|
|
18296
|
-
const ey = y - targetY;
|
|
18297
|
-
const bx = vx + omega * ex;
|
|
18298
|
-
const by = vy + omega * ey;
|
|
18299
|
-
const nx = (ex + bx * dt) * decay;
|
|
18300
|
-
const ny = (ey + by * dt) * decay;
|
|
18301
|
-
vx = (bx - omega * (ex + bx * dt)) * decay;
|
|
18302
|
-
vy = (by - omega * (ey + by * dt)) * decay;
|
|
18303
|
-
x = targetX + nx;
|
|
18304
|
-
y = targetY + ny;
|
|
18305
|
-
out.push({ sourceTimeMs: atMs, x, y });
|
|
18306
|
-
};
|
|
18307
|
-
const lead = springLeadMs(tauMs);
|
|
18308
|
-
const times = [];
|
|
18309
|
-
for (let i = 1; i < samples.length; i++) {
|
|
18310
|
-
const from = samples[i - 1];
|
|
18311
|
-
const to = samples[i];
|
|
18312
|
-
if (to.sourceTimeMs - from.sourceTimeMs > CURSOR_REST_MS) {
|
|
18313
|
-
const headUntil = Math.min(to.sourceTimeMs, from.sourceTimeMs + settleMs);
|
|
18314
|
-
const tailFrom = Math.max(from.sourceTimeMs, to.sourceTimeMs - lead - settleMs);
|
|
18315
|
-
for (let ms = from.sourceTimeMs + SPRING_GRID_MS; ms < to.sourceTimeMs; ms += SPRING_GRID_MS) {
|
|
18316
|
-
if (ms < headUntil || ms >= tailFrom)
|
|
18317
|
-
times.push(ms);
|
|
18318
|
-
}
|
|
18319
|
-
}
|
|
18320
|
-
times.push(to.sourceTimeMs);
|
|
18321
|
-
}
|
|
18322
|
-
const read = readerFor(samples);
|
|
18323
|
-
let previous = first.sourceTimeMs;
|
|
18324
|
-
for (const ms of times) {
|
|
18325
|
-
const target = read((previous + ms) / 2 + lead);
|
|
18326
|
-
advance(ms - previous, target.x, target.y, ms);
|
|
18327
|
-
previous = ms;
|
|
18328
|
-
}
|
|
18329
|
-
const last2 = samples[samples.length - 1];
|
|
18330
|
-
for (let ms = previous + SPRING_GRID_MS; ms <= last2.sourceTimeMs + settleMs; ms += SPRING_GRID_MS) {
|
|
18331
|
-
advance(ms - previous, last2.x, last2.y, ms);
|
|
18332
|
-
previous = ms;
|
|
18333
|
-
}
|
|
18334
|
-
return anchor(out, samples, anchorMs, settleMs);
|
|
18335
|
-
}
|
|
18336
|
-
function anchor(drawn, target, anchorMs, shoulderMs) {
|
|
18337
|
-
const anchors = [...new Set(anchorMs)].sort((a, b) => a - b);
|
|
18338
|
-
if (anchors.length === 0 || shoulderMs <= 0)
|
|
18339
|
-
return drawn;
|
|
18340
|
-
const out = drawn.map((s) => ({ ...s }));
|
|
18341
|
-
for (const [index, ms] of anchors.entries()) {
|
|
18342
|
-
const previous = anchors[index - 1];
|
|
18343
|
-
const next = anchors[index + 1];
|
|
18344
|
-
const room = Math.min(previous === void 0 ? Number.POSITIVE_INFINITY : (ms - previous) / 2, next === void 0 ? Number.POSITIVE_INFINITY : (next - ms) / 2);
|
|
18345
|
-
const shoulder = Math.min(shoulderMs, room);
|
|
18346
|
-
if (!Number.isFinite(shoulder) || shoulder <= 0)
|
|
18347
|
-
continue;
|
|
18348
|
-
const truth = positionAt(target, ms);
|
|
18349
|
-
const here = positionAt(out, ms);
|
|
18350
|
-
const dx = truth.x - here.x;
|
|
18351
|
-
const dy = truth.y - here.y;
|
|
18352
|
-
if (dx === 0 && dy === 0)
|
|
18353
|
-
continue;
|
|
18354
|
-
for (const sample of out) {
|
|
18355
|
-
const away = Math.abs(sample.sourceTimeMs - ms);
|
|
18356
|
-
if (away > shoulder)
|
|
18357
|
-
continue;
|
|
18358
|
-
const weight = 0.5 * (1 + Math.cos(Math.PI * away / shoulder));
|
|
18359
|
-
sample.x += dx * weight;
|
|
18360
|
-
sample.y += dy * weight;
|
|
18361
|
-
}
|
|
18362
|
-
}
|
|
18363
|
-
return out;
|
|
18364
|
-
}
|
|
18365
|
-
|
|
18366
18496
|
// ../../packages/compositor/dist/plan/cursor-timing.js
|
|
18367
18497
|
function arcLengths(samples, start, end) {
|
|
18368
18498
|
const s = [0];
|
|
@@ -18520,8 +18650,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18520
18650
|
var OFF_PAGE_MARGIN = 0.25;
|
|
18521
18651
|
function offPageDirection(at, velocity, viewport) {
|
|
18522
18652
|
const speed = Math.hypot(velocity.x, velocity.y);
|
|
18523
|
-
const
|
|
18524
|
-
if (
|
|
18653
|
+
const inside2 = at.x >= 0 && at.x <= viewport.width && at.y >= 0 && at.y <= viewport.height;
|
|
18654
|
+
if (inside2 && speed >= MIN_HEADING_SPEED) {
|
|
18525
18655
|
const heading = { x: velocity.x / speed, y: velocity.y / speed };
|
|
18526
18656
|
const reach = OFF_PAGE_EDGE_PX + speed * OFF_PAGE_REACH_MS;
|
|
18527
18657
|
if (distanceToEdge(at, heading, viewport) <= reach)
|
|
@@ -18542,8 +18672,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18542
18672
|
function distanceToEdge(at, heading, viewport) {
|
|
18543
18673
|
const toBound = (p, d2, size) => d2 > 0 ? (size - p) / d2 : d2 < 0 ? -p / d2 : Number.POSITIVE_INFINITY;
|
|
18544
18674
|
const d = Math.min(toBound(at.x, heading.x, viewport.width), toBound(at.y, heading.y, viewport.height));
|
|
18545
|
-
const
|
|
18546
|
-
return
|
|
18675
|
+
const inside2 = at.x >= 0 && at.x <= viewport.width && at.y >= 0 && at.y <= viewport.height;
|
|
18676
|
+
return inside2 ? Math.max(0, d) : 0;
|
|
18547
18677
|
}
|
|
18548
18678
|
function sightingBeside(observed, ms, side) {
|
|
18549
18679
|
if (side === "before") {
|
|
@@ -18669,86 +18799,121 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18669
18799
|
var speedOf = (v) => Math.hypot(v.x, v.y);
|
|
18670
18800
|
var negate = (v) => ({ x: -v.x, y: -v.y });
|
|
18671
18801
|
|
|
18672
|
-
// ../../packages/compositor/dist/
|
|
18673
|
-
|
|
18674
|
-
|
|
18675
|
-
|
|
18676
|
-
|
|
18677
|
-
|
|
18678
|
-
|
|
18679
|
-
|
|
18680
|
-
|
|
18802
|
+
// ../../packages/compositor/dist/version.js
|
|
18803
|
+
var COMPOSITOR_VERSION = "1.1.0";
|
|
18804
|
+
|
|
18805
|
+
// ../../packages/compositor/dist/plan/cosmetics.js
|
|
18806
|
+
function planCosmetics(scene) {
|
|
18807
|
+
return scene.edits.masks.map((m) => ({
|
|
18808
|
+
id: m.id,
|
|
18809
|
+
kind: "mask",
|
|
18810
|
+
rect: m.rect,
|
|
18811
|
+
// Both or neither, by the schema's refinement. Neither is the whole take.
|
|
18812
|
+
range: m.start && m.end ? { start: m.start, end: m.end } : null
|
|
18813
|
+
}));
|
|
18681
18814
|
}
|
|
18682
|
-
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
|
|
18693
|
-
function inScreenSpace(bundle, scene) {
|
|
18694
|
-
const transforms = bundle.viewportTransforms ?? [];
|
|
18695
|
-
if (transforms.every(isIdentity)) {
|
|
18696
|
-
return transforms.length === 0 ? { bundle, scene } : { bundle: { ...bundle, viewportTransforms: [] }, scene };
|
|
18815
|
+
|
|
18816
|
+
// ../../packages/compositor/dist/plan/plan.js
|
|
18817
|
+
var RETIMING_DEFAULTS = {
|
|
18818
|
+
motionDiffThreshold: 0.02
|
|
18819
|
+
};
|
|
18820
|
+
function planScene(scene, opts = {}) {
|
|
18821
|
+
const anchorRects = /* @__PURE__ */ new Map();
|
|
18822
|
+
for (const anchor2 of scene.anchors) {
|
|
18823
|
+
const rect2 = anchor2.fingerprint.boundingRect;
|
|
18824
|
+
if (rect2)
|
|
18825
|
+
anchorRects.set(anchor2.id, rect2);
|
|
18697
18826
|
}
|
|
18698
|
-
const
|
|
18699
|
-
const at = (ms) => transformAt(transforms, ms);
|
|
18700
|
-
const atAction = (actionId) => at((actionId === void 0 ? void 0 : markerMs.get(actionId)) ?? 0);
|
|
18701
|
-
const converted = {
|
|
18702
|
-
...bundle,
|
|
18703
|
-
viewportTransforms: [],
|
|
18704
|
-
cursorSamples: bundle.cursorSamples.map((s) => ({
|
|
18705
|
-
...s,
|
|
18706
|
-
...point(s, at(s.sourceTimeMs))
|
|
18707
|
-
})),
|
|
18708
|
-
anchorRects: bundle.anchorRects.map((e) => ({
|
|
18709
|
-
...e,
|
|
18710
|
-
rect: rect(e.rect, atAction(e.actionId))
|
|
18711
|
-
}))
|
|
18712
|
-
};
|
|
18713
|
-
if (scene === void 0)
|
|
18714
|
-
return { bundle: converted, scene };
|
|
18715
|
-
const firstSeen = /* @__PURE__ */ new Map();
|
|
18827
|
+
const actionRects = /* @__PURE__ */ new Map();
|
|
18716
18828
|
for (const action of scene.actions) {
|
|
18717
|
-
|
|
18718
|
-
|
|
18719
|
-
firstSeen.set(anchorId, action.id);
|
|
18720
|
-
}
|
|
18829
|
+
if (action.rect)
|
|
18830
|
+
actionRects.set(action.id, action.rect);
|
|
18721
18831
|
}
|
|
18722
|
-
const
|
|
18723
|
-
|
|
18724
|
-
|
|
18725
|
-
|
|
18726
|
-
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
|
|
18730
|
-
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
|
|
18832
|
+
const rectOf = (anchorId, actionId) => actionRects.get(actionId) ?? anchorRects.get(anchorId) ?? null;
|
|
18833
|
+
const lastAction = scene.actions[scene.actions.length - 1];
|
|
18834
|
+
const removed = scene.edits.removed ?? [];
|
|
18835
|
+
const cutSteps = stepsInsideRemoved(scene);
|
|
18836
|
+
const attachedToCuts = [];
|
|
18837
|
+
const gapAfter = new Map((scene.edits.gaps ?? []).map((gap) => [gap.afterActionId, gap]));
|
|
18838
|
+
const paces = [];
|
|
18839
|
+
for (let i = 0; i + 1 < scene.actions.length; i++) {
|
|
18840
|
+
const from = scene.actions[i];
|
|
18841
|
+
const to = scene.actions[i + 1];
|
|
18842
|
+
if (!from || !to)
|
|
18843
|
+
continue;
|
|
18844
|
+
const authored = gapAfter.get(from.id);
|
|
18845
|
+
const anchors = { afterActionId: from.id, beforeActionId: to.id };
|
|
18846
|
+
paces.push(authored ? { ...anchors, origin: "authored", idleTargetMs: authored.durationMs } : {
|
|
18847
|
+
...anchors,
|
|
18848
|
+
origin: "recorded",
|
|
18849
|
+
// Raw, and negative when the log does not ascend. This carried a
|
|
18850
|
+
// `max(0, …)` until 2026-09-25, under a comment claiming the
|
|
18851
|
+
// floor "cannot fire through any path the editor offers" —
|
|
18852
|
+
// `resequence` rewrites timestamps after a reorder, the trims
|
|
18853
|
+
// only remove entries, `insertedAt` interpolates. All true, and
|
|
18854
|
+
// all about the EDITOR; the capture path was never checked.
|
|
18855
|
+
// `expandWaits` (extension `core/reduce.ts`) stamped a readiness
|
|
18856
|
+
// wait at the moment its element appeared, which for anything
|
|
18857
|
+
// present at page load is the take's origin, and placed it
|
|
18858
|
+
// beside the action it gates — dropping an early timestamp into
|
|
18859
|
+
// the middle of an otherwise ascending log. The floor turned
|
|
18860
|
+
// that pair's interval into a clean 0, indistinguishable from
|
|
18861
|
+
// two simultaneous actions, while the pair AFTER it went on to
|
|
18862
|
+
// claim the dead air this pair should have carried. A rebuild
|
|
18863
|
+
// froze for both and rendered 0:44 against a 0:31 take.
|
|
18864
|
+
//
|
|
18865
|
+
// The stamp is fixed at its source. The floor moves to
|
|
18866
|
+
// `idleTargetMsFor`, which needs it anyway (a negative target
|
|
18867
|
+
// would walk the output cursor backwards and break the
|
|
18868
|
+
// monotonicity of `toSourceMs`/`toOutputMs`), and the fact
|
|
18869
|
+
// survives the trip so `buildTimeline` can count it into
|
|
18870
|
+
// `Timeline.nonMonotonicPaces` rather than smooth it away.
|
|
18871
|
+
recordedSpanMs: to.timestamp - from.timestamp
|
|
18872
|
+
});
|
|
18873
|
+
}
|
|
18874
|
+
return {
|
|
18875
|
+
planVersion: 1,
|
|
18876
|
+
compositorVersion: COMPOSITOR_VERSION,
|
|
18877
|
+
sceneId: scene.meta.id,
|
|
18878
|
+
viewport: scene.meta.capture.viewport,
|
|
18879
|
+
// Deliberately NOT filtered by `cutSteps`. This is SP5's replay
|
|
18880
|
+
// instruction list, not a drawing decision: a rebuild performs every
|
|
18881
|
+
// step the take holds, and the cut removes the frames it produced
|
|
18882
|
+
// afterwards. Skipping a cut step here would drive the app down a path
|
|
18883
|
+
// the author never recorded.
|
|
18884
|
+
cursorSegments: planCursorSegments(scene, rectOf),
|
|
18885
|
+
cameraIntents: planCameraIntents(scene, cutSteps, attachedToCuts),
|
|
18886
|
+
cosmetics: planCosmetics(scene),
|
|
18887
|
+
holds: (scene.edits.holds ?? []).flatMap((hold) => {
|
|
18888
|
+
if (cutSteps.has(hold.marker.actionId)) {
|
|
18889
|
+
attachedToCuts.push({
|
|
18890
|
+
id: hold.id,
|
|
18891
|
+
kind: "hold",
|
|
18892
|
+
actionId: hold.marker.actionId
|
|
18893
|
+
});
|
|
18894
|
+
return [];
|
|
18895
|
+
}
|
|
18896
|
+
return [
|
|
18897
|
+
{
|
|
18898
|
+
id: hold.id,
|
|
18899
|
+
actionId: hold.marker.actionId,
|
|
18900
|
+
offsetMs: hold.marker.offsetMs,
|
|
18901
|
+
durationMs: hold.durationMs
|
|
18734
18902
|
}
|
|
18735
|
-
|
|
18736
|
-
})
|
|
18903
|
+
];
|
|
18904
|
+
}),
|
|
18905
|
+
paces,
|
|
18906
|
+
removed,
|
|
18907
|
+
removedSteps: [...cutSteps],
|
|
18908
|
+
attachedToCuts,
|
|
18909
|
+
trim: {
|
|
18910
|
+
head: scene.edits.trim?.head ?? null,
|
|
18911
|
+
tail: scene.edits.trim?.tail ?? null
|
|
18912
|
+
},
|
|
18913
|
+
retiming: { ...RETIMING_DEFAULTS, ...opts.retiming },
|
|
18914
|
+
hoverSensitive: scene.flags.hoverSensitive,
|
|
18915
|
+
durationHintMs: lastAction?.timestamp ?? 0
|
|
18737
18916
|
};
|
|
18738
|
-
return { bundle: converted, scene: sceneOut };
|
|
18739
|
-
}
|
|
18740
|
-
function segmentsInScreenSpace(segments, transforms, markerSourceMs) {
|
|
18741
|
-
if (transforms.every(isIdentity))
|
|
18742
|
-
return [...segments];
|
|
18743
|
-
return segments.map((s) => {
|
|
18744
|
-
const t = transformAt(transforms, markerSourceMs.get(s.toActionId) ?? 0);
|
|
18745
|
-
return {
|
|
18746
|
-
...s,
|
|
18747
|
-
from: point(s.from, t),
|
|
18748
|
-
to: point(s.to, t),
|
|
18749
|
-
via: s.via.map((v) => point(v, t))
|
|
18750
|
-
};
|
|
18751
|
-
});
|
|
18752
18917
|
}
|
|
18753
18918
|
|
|
18754
18919
|
// ../../packages/compositor/dist/plan/resolve.js
|
|
@@ -18847,23 +19012,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18847
19012
|
}
|
|
18848
19013
|
return samples.sort((a, b) => a.sourceTimeMs - b.sourceTimeMs);
|
|
18849
19014
|
}
|
|
18850
|
-
var CURSOR_MOTION_EPSILON_PX = 0.5;
|
|
18851
|
-
function cursorMotionSpans(samples) {
|
|
18852
|
-
const spans = [];
|
|
18853
|
-
for (let i = 1; i < samples.length; i++) {
|
|
18854
|
-
const from = samples[i - 1];
|
|
18855
|
-
const to = samples[i];
|
|
18856
|
-
if (!from || !to)
|
|
18857
|
-
continue;
|
|
18858
|
-
if (to.sourceTimeMs <= from.sourceTimeMs)
|
|
18859
|
-
continue;
|
|
18860
|
-
if (Math.hypot(to.x - from.x, to.y - from.y) < CURSOR_MOTION_EPSILON_PX) {
|
|
18861
|
-
continue;
|
|
18862
|
-
}
|
|
18863
|
-
spans.push({ startMs: from.sourceTimeMs, endMs: to.sourceTimeMs });
|
|
18864
|
-
}
|
|
18865
|
-
return spans;
|
|
18866
|
-
}
|
|
18867
19015
|
var CURSOR_IDLE_HIDE_MS = 1e3;
|
|
18868
19016
|
var CURSOR_IDLE_FADE_MS = 250;
|
|
18869
19017
|
var CUT_BRIDGE_MS = 250;
|
|
@@ -19088,7 +19236,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19088
19236
|
note: `zoom "${segment.id}" was asked to end at an instant the camera cannot reach \u2014 too close to its own push-in or to the next zoom \u2014 so it returns at ${Math.round(segment.endMs)}ms instead`
|
|
19089
19237
|
});
|
|
19090
19238
|
}
|
|
19091
|
-
const clickKinds = new Set(bundle.source === "replay" ? ["click", "type", "drag"] : ["click"]);
|
|
19239
|
+
const clickKinds = new Set(bundle.source === "replay" ? ["click", "type", "drag", "press"] : ["click"]);
|
|
19092
19240
|
const clickActionIds = new Set((scene?.actions ?? []).filter((a) => clickKinds.has(a.kind)).map((a) => a.id));
|
|
19093
19241
|
const clickOutputMs = bundle.markers.filter((m) => clickActionIds.has(m.actionId)).map((m) => toOutputMs(timeline, m.sourceTimeMs)).sort((a, b) => a - b);
|
|
19094
19242
|
const touch = scene?.meta.capture.device?.touch === true;
|
|
@@ -19151,6 +19299,303 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19151
19299
|
};
|
|
19152
19300
|
}
|
|
19153
19301
|
|
|
19302
|
+
// ../../packages/compositor/dist/render/draw-cursor.js
|
|
19303
|
+
var PULSE_DURATION_MS = 400;
|
|
19304
|
+
var PRESS_DURATION_MS = 110;
|
|
19305
|
+
var CURSOR_UPRIGHT = Object.freeze({
|
|
19306
|
+
press: 1,
|
|
19307
|
+
angleRad: 0
|
|
19308
|
+
});
|
|
19309
|
+
var ARROW = [
|
|
19310
|
+
{ x: 0, y: 0 },
|
|
19311
|
+
{ x: 0, y: 0.75 },
|
|
19312
|
+
{ x: 0.19, y: 0.58 },
|
|
19313
|
+
{ x: 0.31, y: 0.87 },
|
|
19314
|
+
{ x: 0.45, y: 0.81 },
|
|
19315
|
+
{ x: 0.33, y: 0.53 },
|
|
19316
|
+
{ x: 0.56, y: 0.52 }
|
|
19317
|
+
];
|
|
19318
|
+
var TOUCH_RADIUS = 0.42;
|
|
19319
|
+
var CURSOR_ART = {
|
|
19320
|
+
light: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
|
|
19321
|
+
dark: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
|
|
19322
|
+
touch: {
|
|
19323
|
+
height: 40,
|
|
19324
|
+
hotspot: { x: 0.5, y: 0.5 },
|
|
19325
|
+
ink: {
|
|
19326
|
+
min: { x: 0.5 - TOUCH_RADIUS, y: 0.5 - TOUCH_RADIUS },
|
|
19327
|
+
max: { x: 0.5 + TOUCH_RADIUS, y: 0.5 + TOUCH_RADIUS }
|
|
19328
|
+
}
|
|
19329
|
+
}
|
|
19330
|
+
};
|
|
19331
|
+
function bounds(points) {
|
|
19332
|
+
const xs = points.map((p) => p.x);
|
|
19333
|
+
const ys = points.map((p) => p.y);
|
|
19334
|
+
return {
|
|
19335
|
+
min: { x: Math.min(...xs), y: Math.min(...ys) },
|
|
19336
|
+
max: { x: Math.max(...xs), y: Math.max(...ys) }
|
|
19337
|
+
};
|
|
19338
|
+
}
|
|
19339
|
+
var INK = {
|
|
19340
|
+
light: { fill: "#ffffff", stroke: "#111827" },
|
|
19341
|
+
dark: { fill: "#111827", stroke: "#ffffff" },
|
|
19342
|
+
touch: { fill: "rgba(255, 255, 255, 0.45)", stroke: "#111827" }
|
|
19343
|
+
};
|
|
19344
|
+
function drawCursor(ctx, at, scale, pose, style = "light") {
|
|
19345
|
+
const size = CURSOR_ART[style].height * scale * pose.press;
|
|
19346
|
+
const ink = INK[style];
|
|
19347
|
+
ctx.save();
|
|
19348
|
+
ctx.translate(at.x, at.y);
|
|
19349
|
+
if (style !== "touch" && pose.angleRad !== 0)
|
|
19350
|
+
ctx.rotate(pose.angleRad);
|
|
19351
|
+
ctx.beginPath();
|
|
19352
|
+
if (style === "touch") {
|
|
19353
|
+
ctx.arc(0, 0, size * TOUCH_RADIUS, 0, Math.PI * 2);
|
|
19354
|
+
} else {
|
|
19355
|
+
const first = ARROW[0];
|
|
19356
|
+
if (first) {
|
|
19357
|
+
ctx.moveTo(first.x * size, first.y * size);
|
|
19358
|
+
for (const point2 of ARROW.slice(1))
|
|
19359
|
+
ctx.lineTo(point2.x * size, point2.y * size);
|
|
19360
|
+
}
|
|
19361
|
+
}
|
|
19362
|
+
ctx.closePath();
|
|
19363
|
+
ctx.shadowColor = "rgba(15, 23, 42, 0.35)";
|
|
19364
|
+
ctx.shadowBlur = 3 * scale;
|
|
19365
|
+
ctx.shadowOffsetY = 1.5 * scale;
|
|
19366
|
+
ctx.fillStyle = ink.fill;
|
|
19367
|
+
ctx.fill();
|
|
19368
|
+
ctx.shadowColor = "transparent";
|
|
19369
|
+
ctx.lineWidth = Math.max(1, 1.4 * scale);
|
|
19370
|
+
ctx.lineJoin = "round";
|
|
19371
|
+
ctx.strokeStyle = ink.stroke;
|
|
19372
|
+
ctx.stroke();
|
|
19373
|
+
ctx.restore();
|
|
19374
|
+
}
|
|
19375
|
+
var CURSOR_EXPOSURE_MS = 32;
|
|
19376
|
+
var CURSOR_TRAIL_MIN_TRAVEL_PX = 1;
|
|
19377
|
+
var TRAIL_PEAK_ALPHA = 0.55;
|
|
19378
|
+
function cursorTrailStamps(motionBlur) {
|
|
19379
|
+
if (motionBlur <= 0)
|
|
19380
|
+
return 0;
|
|
19381
|
+
return Math.ceil(2 + 8 * clamp(motionBlur, 0, 1));
|
|
19382
|
+
}
|
|
19383
|
+
function drawCursorTrail(ctx, positions, scale, style) {
|
|
19384
|
+
if (positions.length === 0)
|
|
19385
|
+
return;
|
|
19386
|
+
const priorAlpha = ctx.globalAlpha;
|
|
19387
|
+
positions.forEach((position, i) => {
|
|
19388
|
+
const t = (i + 1) / (positions.length + 1);
|
|
19389
|
+
ctx.globalAlpha = priorAlpha * t * t * TRAIL_PEAK_ALPHA;
|
|
19390
|
+
const pose = { press: 1, angleRad: position.angleRad ?? 0 };
|
|
19391
|
+
drawCursor(ctx, position, scale, pose, style);
|
|
19392
|
+
});
|
|
19393
|
+
ctx.globalAlpha = priorAlpha;
|
|
19394
|
+
}
|
|
19395
|
+
function drawClickPulse(ctx, at, scale, t) {
|
|
19396
|
+
if (t < 0 || t > 1)
|
|
19397
|
+
return;
|
|
19398
|
+
const eased = 1 - (1 - t) ** 3;
|
|
19399
|
+
const radius = 16 * scale * (1 + 2.2 * eased);
|
|
19400
|
+
const alpha = 1 - t;
|
|
19401
|
+
const core = Math.max(1, 2.5 * scale);
|
|
19402
|
+
const edge = Math.max(0.75, 1.25 * scale);
|
|
19403
|
+
const offset = (core + edge) / 2;
|
|
19404
|
+
ctx.save();
|
|
19405
|
+
ring(ctx, at, radius - offset, edge, `rgba(15, 23, 42, ${0.75 * alpha})`);
|
|
19406
|
+
ring(ctx, at, radius + offset, edge, `rgba(15, 23, 42, ${0.75 * alpha})`);
|
|
19407
|
+
ring(ctx, at, radius, core, `rgba(255, 255, 255, ${0.95 * alpha})`);
|
|
19408
|
+
ctx.restore();
|
|
19409
|
+
}
|
|
19410
|
+
function ring(ctx, at, radius, width, style) {
|
|
19411
|
+
if (radius <= 0)
|
|
19412
|
+
return;
|
|
19413
|
+
ctx.beginPath();
|
|
19414
|
+
ctx.arc(at.x, at.y, radius, 0, Math.PI * 2);
|
|
19415
|
+
ctx.lineWidth = width;
|
|
19416
|
+
ctx.strokeStyle = style;
|
|
19417
|
+
ctx.stroke();
|
|
19418
|
+
}
|
|
19419
|
+
|
|
19420
|
+
// ../../packages/compositor/dist/render/cursor-pose.js
|
|
19421
|
+
var PRESS_DEPTH = 0.14;
|
|
19422
|
+
var RELEASE_DECAY_MS = 80;
|
|
19423
|
+
var RELEASE_PERIOD_MS = 320;
|
|
19424
|
+
var RELEASE_MS = 450;
|
|
19425
|
+
var smoothstep = (u) => {
|
|
19426
|
+
const x = clamp(u, 0, 1);
|
|
19427
|
+
return x * x * (3 - 2 * x);
|
|
19428
|
+
};
|
|
19429
|
+
function cursorPressScale(outputTimeMs, clickOutputMs, bounce, holds = []) {
|
|
19430
|
+
const depth = PRESS_DEPTH * clamp(bounce, 0, 2);
|
|
19431
|
+
if (depth <= 0)
|
|
19432
|
+
return 1;
|
|
19433
|
+
if (holds.some((h) => outputTimeMs >= h.startMs && outputTimeMs < h.endMs)) {
|
|
19434
|
+
return 1 - depth;
|
|
19435
|
+
}
|
|
19436
|
+
let previous = Number.NEGATIVE_INFINITY;
|
|
19437
|
+
let next = Number.POSITIVE_INFINITY;
|
|
19438
|
+
for (const click of [...clickOutputMs, ...holds.map((h) => h.endMs)]) {
|
|
19439
|
+
if (click <= outputTimeMs)
|
|
19440
|
+
previous = Math.max(previous, click);
|
|
19441
|
+
else
|
|
19442
|
+
next = Math.min(next, click);
|
|
19443
|
+
}
|
|
19444
|
+
const release = (at) => {
|
|
19445
|
+
const since = at - previous;
|
|
19446
|
+
if (!(since >= 0 && since <= RELEASE_MS))
|
|
19447
|
+
return 1;
|
|
19448
|
+
return 1 - depth * Math.exp(-since / RELEASE_DECAY_MS) * Math.cos(2 * Math.PI * since / RELEASE_PERIOD_MS);
|
|
19449
|
+
};
|
|
19450
|
+
if (next !== Number.POSITIVE_INFINITY) {
|
|
19451
|
+
const pressStart = Math.max(next - PRESS_DURATION_MS, previous);
|
|
19452
|
+
if (outputTimeMs >= pressStart) {
|
|
19453
|
+
const from = release(pressStart);
|
|
19454
|
+
const u = (outputTimeMs - pressStart) / (next - pressStart);
|
|
19455
|
+
return from + (1 - depth - from) * smoothstep(u);
|
|
19456
|
+
}
|
|
19457
|
+
}
|
|
19458
|
+
return release(outputTimeMs);
|
|
19459
|
+
}
|
|
19460
|
+
var TILT_MAX_RAD = 15 * Math.PI / 180;
|
|
19461
|
+
var TILT_VELOCITY_MS = 16;
|
|
19462
|
+
var TILT_FULL_SPEED_WIDTHS_PER_S = 1.1;
|
|
19463
|
+
var TILT_VERTICAL_WEIGHT = 0.65;
|
|
19464
|
+
var TILT_TAPS = 8;
|
|
19465
|
+
var TILT_TAP_MS = 20;
|
|
19466
|
+
var TILT_TAU_MS = 60;
|
|
19467
|
+
var TILT_SETTLE_MS = TILT_VELOCITY_MS + (TILT_TAPS - 1) * TILT_TAP_MS;
|
|
19468
|
+
function cursorTiltRawRad(resolved, outputTimeMs, tilt) {
|
|
19469
|
+
const amount = clamp(tilt, 0, 1);
|
|
19470
|
+
const first = resolved.cursor[0];
|
|
19471
|
+
const fromMs = outputTimeMs - TILT_VELOCITY_MS;
|
|
19472
|
+
if (amount <= 0 || !first || fromMs < 0)
|
|
19473
|
+
return 0;
|
|
19474
|
+
const fromSourceMs = toSourceMs(resolved.timeline, fromMs);
|
|
19475
|
+
if (fromSourceMs < first.sourceTimeMs)
|
|
19476
|
+
return 0;
|
|
19477
|
+
const from = sampleCursor(resolved.cursor, fromSourceMs);
|
|
19478
|
+
const to = sampleCursor(resolved.cursor, toSourceMs(resolved.timeline, outputTimeMs));
|
|
19479
|
+
if (!from || !to)
|
|
19480
|
+
return 0;
|
|
19481
|
+
const vx = (to.x - from.x) * 1e3 / TILT_VELOCITY_MS;
|
|
19482
|
+
const vy = (to.y - from.y) * 1e3 / TILT_VELOCITY_MS;
|
|
19483
|
+
const speed = Math.hypot(vx, vy);
|
|
19484
|
+
if (speed < 1e-3)
|
|
19485
|
+
return 0;
|
|
19486
|
+
const bias = clamp((vx + TILT_VERTICAL_WEIGHT * vy) / speed, -1, 1);
|
|
19487
|
+
const width = resolved.plan.viewport.width;
|
|
19488
|
+
const fullSpeed = TILT_FULL_SPEED_WIDTHS_PER_S * (width > 0 ? width : 1);
|
|
19489
|
+
return bias * Math.min(1, speed / fullSpeed) * TILT_MAX_RAD * amount;
|
|
19490
|
+
}
|
|
19491
|
+
function cursorTiltRad(resolved, outputTimeMs, tilt) {
|
|
19492
|
+
if (!(tilt > 0))
|
|
19493
|
+
return 0;
|
|
19494
|
+
let sum = 0;
|
|
19495
|
+
let weights = 0;
|
|
19496
|
+
for (let k = 0; k < TILT_TAPS; k++) {
|
|
19497
|
+
const weight = Math.exp(-k * TILT_TAP_MS / TILT_TAU_MS);
|
|
19498
|
+
sum += weight * cursorTiltRawRad(resolved, outputTimeMs - k * TILT_TAP_MS, tilt);
|
|
19499
|
+
weights += weight;
|
|
19500
|
+
}
|
|
19501
|
+
return sum / weights;
|
|
19502
|
+
}
|
|
19503
|
+
|
|
19504
|
+
// ../../packages/compositor/dist/plan/moments.js
|
|
19505
|
+
var MIN_SCREEN_MS = 100;
|
|
19506
|
+
var CAMERA_STILL_PX = 0.05;
|
|
19507
|
+
var CAMERA_STILL_SCALE = 1e-4;
|
|
19508
|
+
var CURSOR_SETTLE_MS = 200;
|
|
19509
|
+
function merge3(spans) {
|
|
19510
|
+
const out = [];
|
|
19511
|
+
for (const s of [...spans].sort((a, b) => a.startMs - b.startMs)) {
|
|
19512
|
+
const last2 = out[out.length - 1];
|
|
19513
|
+
if (last2 && s.startMs <= last2.endMs) {
|
|
19514
|
+
last2.endMs = Math.max(last2.endMs, s.endMs);
|
|
19515
|
+
} else {
|
|
19516
|
+
out.push({ ...s });
|
|
19517
|
+
}
|
|
19518
|
+
}
|
|
19519
|
+
return out;
|
|
19520
|
+
}
|
|
19521
|
+
function busySpans(resolved) {
|
|
19522
|
+
const { timeline } = resolved;
|
|
19523
|
+
const cursor = merge3(cursorMotionSpans(resolved.cursor).map((s) => ({
|
|
19524
|
+
startMs: toOutputMs(timeline, s.startMs),
|
|
19525
|
+
endMs: toOutputMs(timeline, s.endMs) + CURSOR_SETTLE_MS
|
|
19526
|
+
})));
|
|
19527
|
+
const page = timeline.segments.filter((s) => s.kind === "motion").map((s) => ({ startMs: s.outStartMs, endMs: s.outEndMs }));
|
|
19528
|
+
const presses = [
|
|
19529
|
+
...resolved.clickOutputMs.map((ms) => ({ startMs: ms, endMs: ms })),
|
|
19530
|
+
...resolved.taps.map((tap) => ({
|
|
19531
|
+
startMs: tap.outputMs,
|
|
19532
|
+
endMs: tap.outputMs
|
|
19533
|
+
})),
|
|
19534
|
+
...resolved.holdOutputMs
|
|
19535
|
+
].map((h) => ({
|
|
19536
|
+
startMs: h.startMs - PRESS_DURATION_MS,
|
|
19537
|
+
endMs: h.endMs + Math.max(PULSE_DURATION_MS, RELEASE_MS)
|
|
19538
|
+
}));
|
|
19539
|
+
const fades = resolved.cursorLook.hideWhenIdle ? resolved.cursorRestOutputMs.flatMap((rest) => [
|
|
19540
|
+
{
|
|
19541
|
+
startMs: rest.startMs + CURSOR_IDLE_HIDE_MS,
|
|
19542
|
+
endMs: rest.startMs + CURSOR_IDLE_HIDE_MS + CURSOR_IDLE_FADE_MS
|
|
19543
|
+
},
|
|
19544
|
+
{ startMs: rest.endMs, endMs: rest.endMs + CURSOR_IDLE_FADE_MS }
|
|
19545
|
+
]) : [];
|
|
19546
|
+
const camera = [];
|
|
19547
|
+
let before = sampleTrack(resolved, 0);
|
|
19548
|
+
for (let t = 0; t < timeline.outputDurationMs; t += FOLLOW_STEP_MS) {
|
|
19549
|
+
const next = Math.min(t + FOLLOW_STEP_MS, timeline.outputDurationMs);
|
|
19550
|
+
const at = sampleTrack(resolved, next);
|
|
19551
|
+
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) {
|
|
19552
|
+
camera.push({ startMs: t, endMs: next });
|
|
19553
|
+
}
|
|
19554
|
+
before = at;
|
|
19555
|
+
}
|
|
19556
|
+
return {
|
|
19557
|
+
busy: merge3([...cursor, ...page, ...presses, ...fades, ...camera]),
|
|
19558
|
+
cursor,
|
|
19559
|
+
camera: merge3(camera)
|
|
19560
|
+
};
|
|
19561
|
+
}
|
|
19562
|
+
function stillUpTo(busy, fromMs, toMs) {
|
|
19563
|
+
let start = fromMs;
|
|
19564
|
+
for (const span of busy) {
|
|
19565
|
+
if (span.startMs < toMs)
|
|
19566
|
+
start = Math.max(start, span.endMs);
|
|
19567
|
+
}
|
|
19568
|
+
return toMs - start >= MIN_SCREEN_MS ? (start + toMs) / 2 : null;
|
|
19569
|
+
}
|
|
19570
|
+
function screenMoments(resolved, scene, bundle) {
|
|
19571
|
+
const { timeline, range } = resolved;
|
|
19572
|
+
const { busy, cursor, camera } = busySpans(resolved);
|
|
19573
|
+
const approaches = merge3([...cursor, ...camera]);
|
|
19574
|
+
const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
|
|
19575
|
+
const stepOfIntent = new Map(resolved.plan.cameraIntents.map((c) => [c.id, c.actionId]));
|
|
19576
|
+
const moments = [];
|
|
19577
|
+
const place = (step, at) => {
|
|
19578
|
+
if (at !== null && at >= range.startMs && at <= range.endMs) {
|
|
19579
|
+
moments.push({ step, ms: at - range.startMs });
|
|
19580
|
+
}
|
|
19581
|
+
};
|
|
19582
|
+
let fromMs = 0;
|
|
19583
|
+
for (const [i, action] of scene.actions.entries()) {
|
|
19584
|
+
const sourceMs = markerAt.get(action.id);
|
|
19585
|
+
if (sourceMs === void 0)
|
|
19586
|
+
continue;
|
|
19587
|
+
const atMs = toOutputMs(timeline, sourceMs);
|
|
19588
|
+
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));
|
|
19589
|
+
const run = approaches.filter((s) => s.startMs > fromMs && s.startMs <= atMs);
|
|
19590
|
+
const moving = busy.find((s) => s.startMs <= atMs && atMs <= s.endMs);
|
|
19591
|
+
const approachMs = Math.min(atMs, ...zoom, ...run.length > 0 ? [run[run.length - 1].startMs] : [], ...moving ? [moving.startMs] : []);
|
|
19592
|
+
place(i, stillUpTo(busy, fromMs, approachMs));
|
|
19593
|
+
fromMs = atMs;
|
|
19594
|
+
}
|
|
19595
|
+
place(null, stillUpTo(busy, fromMs, timeline.outputDurationMs));
|
|
19596
|
+
return { steps: scene.actions.length, moments };
|
|
19597
|
+
}
|
|
19598
|
+
|
|
19154
19599
|
// ../../packages/compositor/dist/ports/keyframe.js
|
|
19155
19600
|
function findKeyframe(bundle, sourceTimeMs) {
|
|
19156
19601
|
const keyframe = keyframeAt(bundle, sourceTimeMs);
|
|
@@ -39083,7 +39528,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
39083
39528
|
const { id, color, alpha } = event.data;
|
|
39084
39529
|
chain = chain.then(async () => {
|
|
39085
39530
|
try {
|
|
39086
|
-
const frame2 = await
|
|
39531
|
+
const frame2 = await merge4(color, alpha);
|
|
39087
39532
|
self.postMessage({ id, frame: frame2 }, { transfer: [frame2] });
|
|
39088
39533
|
} catch (error51) {
|
|
39089
39534
|
self.postMessage({ id, error: error51.message });
|
|
@@ -39093,7 +39538,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
39093
39538
|
}
|
|
39094
39539
|
});
|
|
39095
39540
|
});
|
|
39096
|
-
const
|
|
39541
|
+
const merge4 = async (color, alpha) => {
|
|
39097
39542
|
const format = color.format;
|
|
39098
39543
|
const alphaFormat = alpha.format;
|
|
39099
39544
|
if (!format || !alphaFormat) {
|
|
@@ -46759,6 +47204,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
46759
47204
|
|
|
46760
47205
|
// ../../packages/compositor/dist/ports/sink-mp4.js
|
|
46761
47206
|
var ENCODER_USED_GLOBAL = "__demomanMp4Encoder";
|
|
47207
|
+
var SINK_TIMES_GLOBAL = "__demomanMp4SinkTimes";
|
|
47208
|
+
var sinkTimes = () => globalThis[SINK_TIMES_GLOBAL];
|
|
46762
47209
|
function createMp4Sink(target) {
|
|
46763
47210
|
const output = new Output({
|
|
46764
47211
|
format: new Mp4OutputFormat(),
|
|
@@ -46796,13 +47243,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
46796
47243
|
throw new Error("sink already finish()ed; cannot accept more frames");
|
|
46797
47244
|
started ??= output.start();
|
|
46798
47245
|
await started;
|
|
47246
|
+
const times = sinkTimes();
|
|
47247
|
+
const t0 = performance.now();
|
|
46799
47248
|
const sample = new VideoSample(canvas, {
|
|
46800
47249
|
timestamp: timestampSec,
|
|
46801
47250
|
duration: durationSec
|
|
46802
47251
|
});
|
|
47252
|
+
const t1 = performance.now();
|
|
46803
47253
|
await source.add(sample);
|
|
46804
47254
|
sample.close();
|
|
46805
47255
|
frames += 1;
|
|
47256
|
+
if (times !== void 0) {
|
|
47257
|
+
times.copyMs += t1 - t0;
|
|
47258
|
+
times.encodeMs += performance.now() - t1;
|
|
47259
|
+
times.frames += 1;
|
|
47260
|
+
}
|
|
46806
47261
|
},
|
|
46807
47262
|
// Bytes or a reason, never an empty array: a 0-byte file stored as a
|
|
46808
47263
|
// successful output is a Download button that does nothing, and the
|
|
@@ -46815,7 +47270,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
46815
47270
|
}
|
|
46816
47271
|
started ??= output.start();
|
|
46817
47272
|
await started;
|
|
47273
|
+
const t = performance.now();
|
|
46818
47274
|
await output.finalize();
|
|
47275
|
+
const times = sinkTimes();
|
|
47276
|
+
if (times !== void 0)
|
|
47277
|
+
times.finishMs += performance.now() - t;
|
|
46819
47278
|
const buffer = output.target.buffer;
|
|
46820
47279
|
if (!buffer) {
|
|
46821
47280
|
throw new Error(`mp4 muxer produced no bytes after ${frames} frame${frames === 1 ? "" : "s"}`);
|
|
@@ -46873,7 +47332,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
46873
47332
|
{ x: canvas.width, y: canvas.height }
|
|
46874
47333
|
];
|
|
46875
47334
|
const passAt = (at) => {
|
|
46876
|
-
const then =
|
|
47335
|
+
const then = frameTrack(args.camera, at, args.base, frameRect, args.viewport, canvas);
|
|
46877
47336
|
const r = then.scale / current.scale;
|
|
46878
47337
|
return {
|
|
46879
47338
|
scale: r,
|
|
@@ -46959,208 +47418,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
46959
47418
|
ctx.restore();
|
|
46960
47419
|
}
|
|
46961
47420
|
|
|
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
47421
|
// ../../packages/compositor/dist/render/draw-cosmetics.js
|
|
47165
47422
|
var MASK_FILL = "#4b5563";
|
|
47166
47423
|
function drawMask(ctx, rect2) {
|
|
@@ -47174,6 +47431,80 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47174
47431
|
drawMask(ctx, toOutput(cosmetic.rect));
|
|
47175
47432
|
}
|
|
47176
47433
|
|
|
47434
|
+
// ../../packages/compositor/dist/render/target.js
|
|
47435
|
+
var LANDSCAPE_4K = {
|
|
47436
|
+
format: "mp4",
|
|
47437
|
+
width: 3840,
|
|
47438
|
+
height: 2160,
|
|
47439
|
+
fps: 60,
|
|
47440
|
+
bitrate: 4e7,
|
|
47441
|
+
cornerRadius: 36,
|
|
47442
|
+
fit: "contain"
|
|
47443
|
+
};
|
|
47444
|
+
var LANDSCAPE_1440P = {
|
|
47445
|
+
format: "mp4",
|
|
47446
|
+
width: 2560,
|
|
47447
|
+
height: 1440,
|
|
47448
|
+
fps: 60,
|
|
47449
|
+
bitrate: 18e6,
|
|
47450
|
+
cornerRadius: 24,
|
|
47451
|
+
fit: "contain"
|
|
47452
|
+
};
|
|
47453
|
+
var VERTICAL_1080 = {
|
|
47454
|
+
format: "mp4",
|
|
47455
|
+
width: 1080,
|
|
47456
|
+
height: 1920,
|
|
47457
|
+
fps: 60,
|
|
47458
|
+
bitrate: 12e6,
|
|
47459
|
+
cornerRadius: 24,
|
|
47460
|
+
fit: "cover"
|
|
47461
|
+
};
|
|
47462
|
+
var HIGH_LANDSCAPE = {
|
|
47463
|
+
...LANDSCAPE_1440P,
|
|
47464
|
+
bitrate: 8e6
|
|
47465
|
+
};
|
|
47466
|
+
var HIGH_VERTICAL = {
|
|
47467
|
+
...VERTICAL_1080,
|
|
47468
|
+
bitrate: HIGH_LANDSCAPE.bitrate
|
|
47469
|
+
};
|
|
47470
|
+
function verticalCameraIntents(intents) {
|
|
47471
|
+
return intents.map((intent) => {
|
|
47472
|
+
const scale = clamp(intent.scale, 1, CAMERA_DEFAULTS.verticalMaxScale);
|
|
47473
|
+
return scale < intent.scale ? {
|
|
47474
|
+
...intent,
|
|
47475
|
+
scale,
|
|
47476
|
+
requestedScale: intent.requestedScale ?? intent.scale
|
|
47477
|
+
} : { ...intent, scale };
|
|
47478
|
+
});
|
|
47479
|
+
}
|
|
47480
|
+
function cameraIntentsForTarget(target, intents) {
|
|
47481
|
+
return target.fit === "cover" ? verticalCameraIntents(intents) : intents;
|
|
47482
|
+
}
|
|
47483
|
+
|
|
47484
|
+
// ../../packages/compositor/dist/render/wallpaper.js
|
|
47485
|
+
var WALLPAPER_LONG_SIDE = LANDSCAPE_4K.width * CAMERA_DEFAULTS.maxScale;
|
|
47486
|
+
var WALLPAPER_SHORT_SIDE = WALLPAPER_LONG_SIDE * 3 / 4;
|
|
47487
|
+
function coverRect(image, box2) {
|
|
47488
|
+
const scale = Math.max(box2.width / image.width, box2.height / image.height);
|
|
47489
|
+
const sw = Math.min(image.width, box2.width / scale);
|
|
47490
|
+
const sh = Math.min(image.height, box2.height / scale);
|
|
47491
|
+
return { sx: (image.width - sw) / 2, sy: (image.height - sh) / 2, sw, sh };
|
|
47492
|
+
}
|
|
47493
|
+
function wallpaperShape(target) {
|
|
47494
|
+
return target.height > target.width ? "portrait" : "landscape";
|
|
47495
|
+
}
|
|
47496
|
+
function masterFor(target) {
|
|
47497
|
+
return wallpaperShape(target) === "portrait" ? { width: WALLPAPER_SHORT_SIDE, height: WALLPAPER_LONG_SIDE } : { width: WALLPAPER_LONG_SIDE, height: WALLPAPER_SHORT_SIDE };
|
|
47498
|
+
}
|
|
47499
|
+
function wallpaperRasterSize(target, image = masterFor(target)) {
|
|
47500
|
+
const cover = Math.max(target.width / image.width, target.height / image.height);
|
|
47501
|
+
const scale = Math.min(1, cover * CAMERA_DEFAULTS.maxScale);
|
|
47502
|
+
return {
|
|
47503
|
+
width: Math.ceil(image.width * scale),
|
|
47504
|
+
height: Math.ceil(image.height * scale)
|
|
47505
|
+
};
|
|
47506
|
+
}
|
|
47507
|
+
|
|
47177
47508
|
// ../../packages/compositor/dist/render/presentation.js
|
|
47178
47509
|
var MIN_LOGO_SIZE = 0.02;
|
|
47179
47510
|
function placeLogo(logo, aspect, target, frameRect) {
|
|
@@ -47211,7 +47542,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47211
47542
|
return 0;
|
|
47212
47543
|
return Math.ceil(branding.logo.size * Math.min(target.width, target.height));
|
|
47213
47544
|
}
|
|
47214
|
-
function derivePresentation(branding, target, viewport, logo = null) {
|
|
47545
|
+
function derivePresentation(branding, target, viewport, logo = null, wallpaper = null) {
|
|
47215
47546
|
const pad = Math.min(target.width, target.height) * branding.padding;
|
|
47216
47547
|
const box2 = {
|
|
47217
47548
|
x: pad,
|
|
@@ -47238,7 +47569,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47238
47569
|
frameRect,
|
|
47239
47570
|
padding: branding.padding,
|
|
47240
47571
|
logo: spec !== null && logo !== null && logoPlacement !== null && logoPlacement.effectiveSize > 0 ? { image: logo, opacity: spec.opacity, rect: logoPlacement.rect } : null,
|
|
47241
|
-
logoPlacement
|
|
47572
|
+
logoPlacement,
|
|
47573
|
+
wallpaper: branding.background.kind === "wallpaper" || branding.background.kind === "image" ? wallpaper : null
|
|
47242
47574
|
};
|
|
47243
47575
|
}
|
|
47244
47576
|
function contentScale(frameRect, viewport) {
|
|
@@ -47263,13 +47595,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47263
47595
|
if (bg.kind === "solid") {
|
|
47264
47596
|
ctx.fillStyle = bg.color;
|
|
47265
47597
|
} else {
|
|
47266
|
-
const
|
|
47598
|
+
const g = bg.kind === "gradient" ? bg : NEUTRAL_BACKGROUND;
|
|
47599
|
+
const { x0, y0, x1, y1 } = gradientLine(g.angle, target.width, target.height);
|
|
47267
47600
|
const gradient = ctx.createLinearGradient(x0, y0, x1, y1);
|
|
47268
|
-
gradient.addColorStop(0,
|
|
47269
|
-
gradient.addColorStop(1,
|
|
47601
|
+
gradient.addColorStop(0, g.from);
|
|
47602
|
+
gradient.addColorStop(1, g.to);
|
|
47270
47603
|
ctx.fillStyle = gradient;
|
|
47271
47604
|
}
|
|
47272
47605
|
ctx.fillRect(0, 0, target.width, target.height);
|
|
47606
|
+
const image = presentation.wallpaper;
|
|
47607
|
+
if (image === null || bg.kind === "solid" || bg.kind === "gradient")
|
|
47608
|
+
return;
|
|
47609
|
+
const { sx, sy, sw, sh } = coverRect(image, target);
|
|
47610
|
+
ctx.imageSmoothingEnabled = true;
|
|
47611
|
+
ctx.imageSmoothingQuality = "high";
|
|
47612
|
+
ctx.drawImage(image.image, sx, sy, sw, sh, 0, 0, target.width, target.height);
|
|
47273
47613
|
}
|
|
47274
47614
|
function framePath(ctx, presentation) {
|
|
47275
47615
|
const { frameRect: r, cornerRadius } = presentation;
|
|
@@ -47311,6 +47651,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47311
47651
|
ctx.restore();
|
|
47312
47652
|
}
|
|
47313
47653
|
|
|
47654
|
+
// ../../packages/compositor/dist/render/window.js
|
|
47655
|
+
function sceneCameraAt(resolved, presentation, target, outputTimeMs) {
|
|
47656
|
+
const viewport = resolved.plan.viewport;
|
|
47657
|
+
const { frameRect } = presentation;
|
|
47658
|
+
return frameTrack(resolved, outputTimeMs, contentScale(frameRect, viewport), frameRect, viewport, target);
|
|
47659
|
+
}
|
|
47660
|
+
function windowOnScreen(presentation, camera) {
|
|
47661
|
+
const { frameRect: r, cornerRadius } = presentation;
|
|
47662
|
+
const s = camera.scale;
|
|
47663
|
+
return {
|
|
47664
|
+
x: r.x + r.width / 2 + (r.x - camera.focus.x) * s,
|
|
47665
|
+
y: r.y + r.height / 2 + (r.y - camera.focus.y) * s,
|
|
47666
|
+
width: r.width * s,
|
|
47667
|
+
height: r.height * s,
|
|
47668
|
+
radius: Math.min(cornerRadius, r.width / 2, r.height / 2) * s
|
|
47669
|
+
};
|
|
47670
|
+
}
|
|
47671
|
+
|
|
47314
47672
|
// ../../packages/compositor/dist/render/compose.js
|
|
47315
47673
|
function cssToOutput(point2, camera, frameRect, viewport) {
|
|
47316
47674
|
const k = contentScale(frameRect, viewport) * camera.scale;
|
|
@@ -47368,7 +47726,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47368
47726
|
const { frameRect } = presentation;
|
|
47369
47727
|
const sourceMs = toSourceMs(resolved.timeline, outputTimeMs);
|
|
47370
47728
|
const base = contentScale(frameRect, viewport);
|
|
47371
|
-
const camera =
|
|
47729
|
+
const camera = sceneCameraAt(resolved, presentation, target, outputTimeMs);
|
|
47372
47730
|
const fetchStartedAt = args.onStage ? performance.now() : 0;
|
|
47373
47731
|
const frame2 = await frames.at(sourceMs);
|
|
47374
47732
|
args.onStage?.("fetch", performance.now() - fetchStartedAt);
|
|
@@ -47547,48 +47905,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47547
47905
|
return out;
|
|
47548
47906
|
}
|
|
47549
47907
|
|
|
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
47908
|
// ../../packages/compositor/dist/render/compose-for-target.js
|
|
47593
47909
|
function framedPlan(plan, target) {
|
|
47594
47910
|
const cameraIntents = cameraIntentsForTarget(target, plan.cameraIntents);
|
|
@@ -47601,9 +47917,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47601
47917
|
return { width: frameRect.width / k, height: frameRect.height / k };
|
|
47602
47918
|
}
|
|
47603
47919
|
function composeForTarget(args) {
|
|
47604
|
-
const { plan, bundle, scene, target, hints, logo = null } = args;
|
|
47920
|
+
const { plan, bundle, scene, target, hints, logo = null, wallpaper = null } = args;
|
|
47605
47921
|
const detailTarget = args.detailTarget ?? target;
|
|
47606
|
-
const presentation = derivePresentation(scene?.branding ?? BRANDING_DEFAULTS, target, plan.viewport, logo);
|
|
47922
|
+
const presentation = derivePresentation(scene?.branding ?? BRANDING_DEFAULTS, target, plan.viewport, logo, wallpaper);
|
|
47607
47923
|
const detailFrame = detailTarget === target ? presentation.frameRect : derivePresentation(scene?.branding ?? BRANDING_DEFAULTS, detailTarget, plan.viewport, logo).frameRect;
|
|
47608
47924
|
const resolved = resolvePlan(framedPlan(plan, target), bundle, scene, hints, coverWindow(target, detailFrame, plan.viewport));
|
|
47609
47925
|
const detail = clampToSourceDetail({
|
|
@@ -47679,13 +47995,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47679
47995
|
|
|
47680
47996
|
// ../../packages/compositor/dist/render/render.js
|
|
47681
47997
|
async function renderScene(args) {
|
|
47682
|
-
const { plan, bundle, scene, target, ports, logo = null, onFrame } = args;
|
|
47998
|
+
const { plan, bundle, scene, target, ports, logo = null, wallpaper = null, onFrame } = args;
|
|
47683
47999
|
const sink = target.format === "mp4" ? ports.video : target.format === "gif" ? ports.gif : ports.images;
|
|
47684
48000
|
if (!sink) {
|
|
47685
48001
|
throw new Error(`render target "${target.format}" needs a matching ${target.format === "mp4" ? "video sink" : `${target.format} sink`}`);
|
|
47686
48002
|
}
|
|
47687
48003
|
const hints = target.format === "png" ? [] : await detectKeyframeMotion(bundle, ports.frames, plan.retiming.motionDiffThreshold);
|
|
47688
|
-
const { resolved: composed, presentation, violations } = composeForTarget({
|
|
48004
|
+
const { resolved: composed, presentation, violations } = composeForTarget({
|
|
48005
|
+
plan,
|
|
48006
|
+
bundle,
|
|
48007
|
+
scene,
|
|
48008
|
+
target,
|
|
48009
|
+
hints,
|
|
48010
|
+
logo,
|
|
48011
|
+
wallpaper
|
|
48012
|
+
});
|
|
47689
48013
|
const canvas = ports.surface.create(target.width, target.height);
|
|
47690
48014
|
const ctx = canvas.getContext("2d");
|
|
47691
48015
|
const step = 1e3 / target.fps;
|
|
@@ -47723,6 +48047,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47723
48047
|
}
|
|
47724
48048
|
onFrame?.(i + 1, frameCount);
|
|
47725
48049
|
}
|
|
48050
|
+
const found = scene ? screenMoments(composed, scene, bundle) : { steps: 0, moments: [] };
|
|
48051
|
+
const r = (v) => Math.round(v * 100) / 100;
|
|
48052
|
+
const screens = {
|
|
48053
|
+
...found,
|
|
48054
|
+
moments: found.moments.map((m) => {
|
|
48055
|
+
const w = windowOnScreen(presentation, sceneCameraAt(composed, presentation, target, startMs + m.ms));
|
|
48056
|
+
return {
|
|
48057
|
+
...m,
|
|
48058
|
+
window: {
|
|
48059
|
+
x: r(w.x),
|
|
48060
|
+
y: r(w.y),
|
|
48061
|
+
width: r(w.width),
|
|
48062
|
+
height: r(w.height),
|
|
48063
|
+
radius: r(w.radius)
|
|
48064
|
+
}
|
|
48065
|
+
};
|
|
48066
|
+
})
|
|
48067
|
+
};
|
|
47726
48068
|
const bytes2 = await (async () => {
|
|
47727
48069
|
if (target.format === "mp4" && ports.video)
|
|
47728
48070
|
return ports.video.finish();
|
|
@@ -47742,7 +48084,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47742
48084
|
detailViolations: violations,
|
|
47743
48085
|
unavailableSpans: ports.frames.unavailable?.() ?? [],
|
|
47744
48086
|
loweredZooms: composed.loweredZooms,
|
|
47745
|
-
clampedRanges: composed.clampedRanges
|
|
48087
|
+
clampedRanges: composed.clampedRanges,
|
|
48088
|
+
screens,
|
|
48089
|
+
deepestScale: composed.cameraKeys.reduce((m, k) => Math.max(m, k.scale), 1)
|
|
47746
48090
|
};
|
|
47747
48091
|
}
|
|
47748
48092
|
function stillSourceMs(bundle, marker) {
|
|
@@ -47784,11 +48128,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47784
48128
|
return { beats, unplaced };
|
|
47785
48129
|
}
|
|
47786
48130
|
async function renderStills(args) {
|
|
47787
|
-
const { plan, bundle, scene, target, ports, logo = null } = args;
|
|
48131
|
+
const { plan, bundle, scene, target, ports, logo = null, wallpaper = null } = args;
|
|
47788
48132
|
const images = ports.images;
|
|
47789
48133
|
if (!images)
|
|
47790
48134
|
throw new Error('render target "png" needs a matching png sink');
|
|
47791
|
-
const { resolved: composed, presentation, violations } = composeForTarget({ plan, bundle, scene, target, logo });
|
|
48135
|
+
const { resolved: composed, presentation, violations } = composeForTarget({ plan, bundle, scene, target, logo, wallpaper });
|
|
47792
48136
|
const canvas = ports.surface.create(target.width, target.height);
|
|
47793
48137
|
const ctx = canvas.getContext("2d");
|
|
47794
48138
|
const supplied = args.outputTimesMs;
|
|
@@ -47873,43 +48217,193 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
47873
48217
|
};
|
|
47874
48218
|
}
|
|
47875
48219
|
|
|
48220
|
+
// ../../packages/compositor/dist/render/wallpaper-blur.js
|
|
48221
|
+
var WALLPAPER_BLUR_MAX = 0.12;
|
|
48222
|
+
function wallpaperBlurPx(target, raster, blur) {
|
|
48223
|
+
const perFramePx = coverRect(raster, target).sw / target.width;
|
|
48224
|
+
return blur * WALLPAPER_BLUR_MAX * Math.min(target.width, target.height) * perFramePx;
|
|
48225
|
+
}
|
|
48226
|
+
function blurWallpaper(image, radiusPx) {
|
|
48227
|
+
if (radiusPx <= 0)
|
|
48228
|
+
return image;
|
|
48229
|
+
const { width: w, height: h } = image;
|
|
48230
|
+
const pad = Math.min(Math.ceil(radiusPx * 3), w, h);
|
|
48231
|
+
const padded = new OffscreenCanvas(w + 2 * pad, h + 2 * pad);
|
|
48232
|
+
const p = padded.getContext("2d");
|
|
48233
|
+
if (p === null)
|
|
48234
|
+
throw new Error(`no 2D context to blur ${w}\xD7${h} on`);
|
|
48235
|
+
for (const i of [-1, 0, 1]) {
|
|
48236
|
+
for (const j of [-1, 0, 1]) {
|
|
48237
|
+
p.setTransform(i === 0 ? 1 : -1, 0, 0, j === 0 ? 1 : -1, i === 1 ? pad + 2 * w : pad, j === 1 ? pad + 2 * h : pad);
|
|
48238
|
+
p.drawImage(image.image, 0, 0, w, h);
|
|
48239
|
+
}
|
|
48240
|
+
}
|
|
48241
|
+
const out = new OffscreenCanvas(w, h);
|
|
48242
|
+
const ctx = out.getContext("2d");
|
|
48243
|
+
if (ctx === null)
|
|
48244
|
+
throw new Error(`no 2D context to blur ${w}\xD7${h} on`);
|
|
48245
|
+
ctx.filter = `blur(${radiusPx}px)`;
|
|
48246
|
+
ctx.drawImage(padded, -pad, -pad);
|
|
48247
|
+
return { ...image, image: out.transferToImageBitmap() };
|
|
48248
|
+
}
|
|
48249
|
+
|
|
48250
|
+
// ../../packages/run-core/dist/logo.js
|
|
48251
|
+
var SVG_RASTER_CACHE_SIZE = 4;
|
|
48252
|
+
var frame = (image) => ({
|
|
48253
|
+
image,
|
|
48254
|
+
width: image.width,
|
|
48255
|
+
height: image.height,
|
|
48256
|
+
// A logo is branding, not a timeline sample — it has no source instant.
|
|
48257
|
+
sourceTimeMs: 0
|
|
48258
|
+
});
|
|
48259
|
+
function parseSvg(text) {
|
|
48260
|
+
const doc = new DOMParser().parseFromString(text, "image/svg+xml");
|
|
48261
|
+
const root = doc.documentElement;
|
|
48262
|
+
if (doc.querySelector("parsererror") !== null || root.nodeName.toLowerCase() !== "svg") {
|
|
48263
|
+
throw new Error("the file is not an SVG");
|
|
48264
|
+
}
|
|
48265
|
+
return root;
|
|
48266
|
+
}
|
|
48267
|
+
var length = (value) => {
|
|
48268
|
+
if (value === null)
|
|
48269
|
+
return null;
|
|
48270
|
+
const n = Number.parseFloat(value);
|
|
48271
|
+
return Number.isFinite(n) && n > 0 && !value.trim().endsWith("%") ? n : null;
|
|
48272
|
+
};
|
|
48273
|
+
function svgAspect(svgText) {
|
|
48274
|
+
const root = parseSvg(svgText);
|
|
48275
|
+
const w = length(root.getAttribute("width"));
|
|
48276
|
+
const h = length(root.getAttribute("height"));
|
|
48277
|
+
if (w !== null && h !== null)
|
|
48278
|
+
return w / h;
|
|
48279
|
+
const box2 = root.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number);
|
|
48280
|
+
if (box2 && box2.length === 4 && box2[2] > 0 && box2[3] > 0) {
|
|
48281
|
+
return box2[2] / box2[3];
|
|
48282
|
+
}
|
|
48283
|
+
throw new Error("the SVG has no width, height or viewBox, so there is no size to draw it at");
|
|
48284
|
+
}
|
|
48285
|
+
async function svgSource(bytes2) {
|
|
48286
|
+
const text = new TextDecoder().decode(bytes2);
|
|
48287
|
+
const aspect = svgAspect(text);
|
|
48288
|
+
const cache = /* @__PURE__ */ new Map();
|
|
48289
|
+
const render2 = async (heightPx) => {
|
|
48290
|
+
const width = Math.max(1, Math.round(heightPx * aspect));
|
|
48291
|
+
const height = Math.max(1, Math.round(heightPx));
|
|
48292
|
+
const url3 = URL.createObjectURL(new Blob([bytes2.slice()], { type: "image/svg+xml" }));
|
|
48293
|
+
try {
|
|
48294
|
+
const img = new Image();
|
|
48295
|
+
img.src = url3;
|
|
48296
|
+
await img.decode().catch((error51) => {
|
|
48297
|
+
throw new Error(`the SVG could not be decoded: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
48298
|
+
});
|
|
48299
|
+
const canvas = new OffscreenCanvas(width, height);
|
|
48300
|
+
canvas.getContext("2d").drawImage(img, 0, 0, width, height);
|
|
48301
|
+
return frame(await createImageBitmap(canvas));
|
|
48302
|
+
} finally {
|
|
48303
|
+
URL.revokeObjectURL(url3);
|
|
48304
|
+
}
|
|
48305
|
+
};
|
|
48306
|
+
return {
|
|
48307
|
+
contentType: "image/svg+xml",
|
|
48308
|
+
aspect,
|
|
48309
|
+
naturalHeight: null,
|
|
48310
|
+
rasterAt(heightPx) {
|
|
48311
|
+
const key = Math.max(1, Math.round(heightPx));
|
|
48312
|
+
let hit = cache.get(key);
|
|
48313
|
+
if (hit === void 0) {
|
|
48314
|
+
const fresh = render2(key);
|
|
48315
|
+
hit = fresh;
|
|
48316
|
+
fresh.catch(() => {
|
|
48317
|
+
if (cache.get(key) === fresh)
|
|
48318
|
+
cache.delete(key);
|
|
48319
|
+
});
|
|
48320
|
+
} else {
|
|
48321
|
+
cache.delete(key);
|
|
48322
|
+
}
|
|
48323
|
+
cache.set(key, hit);
|
|
48324
|
+
while (cache.size > SVG_RASTER_CACHE_SIZE) {
|
|
48325
|
+
cache.delete(cache.keys().next().value);
|
|
48326
|
+
}
|
|
48327
|
+
return hit;
|
|
48328
|
+
}
|
|
48329
|
+
};
|
|
48330
|
+
}
|
|
48331
|
+
async function decodeLogo(bytes2, contentType) {
|
|
48332
|
+
if (contentType === "image/svg+xml") {
|
|
48333
|
+
const source = await svgSource(bytes2);
|
|
48334
|
+
await source.rasterAt(64);
|
|
48335
|
+
return source;
|
|
48336
|
+
}
|
|
48337
|
+
let bitmap;
|
|
48338
|
+
try {
|
|
48339
|
+
bitmap = await createImageBitmap(new Blob([bytes2.slice()], { type: contentType }));
|
|
48340
|
+
} catch (error51) {
|
|
48341
|
+
throw new Error(`the ${contentType} could not be decoded: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
48342
|
+
}
|
|
48343
|
+
const image = frame(bitmap);
|
|
48344
|
+
return {
|
|
48345
|
+
contentType,
|
|
48346
|
+
aspect: bitmap.width / bitmap.height,
|
|
48347
|
+
naturalHeight: bitmap.height,
|
|
48348
|
+
rasterAt: async () => image
|
|
48349
|
+
};
|
|
48350
|
+
}
|
|
48351
|
+
|
|
47876
48352
|
// ../../packages/run-core/dist/render/mp4-cap.js
|
|
47877
|
-
var
|
|
47878
|
-
function
|
|
48353
|
+
var HEADROOM = 0.92;
|
|
48354
|
+
function fitBitrate(maxBytes, durationMs) {
|
|
48355
|
+
return Math.round(maxBytes * HEADROOM * 8 / (durationMs / 1e3));
|
|
48356
|
+
}
|
|
48357
|
+
var sizeOf = (t) => ({ width: t.width, height: t.height });
|
|
48358
|
+
function capLadder(asked, { share, floor }, fit) {
|
|
48359
|
+
const rungs = [];
|
|
48360
|
+
let at = asked;
|
|
47879
48361
|
if (at.fps > share.fps) {
|
|
47880
|
-
|
|
47881
|
-
|
|
47882
|
-
|
|
47883
|
-
|
|
47884
|
-
bitrate: Math.round(at.bitrate * share.fps / at.fps)
|
|
47885
|
-
},
|
|
47886
|
-
step: { kind: "fps", from: at.fps, to: share.fps }
|
|
48362
|
+
const target = {
|
|
48363
|
+
...at,
|
|
48364
|
+
fps: share.fps,
|
|
48365
|
+
bitrate: Math.round(at.bitrate * share.fps / at.fps)
|
|
47887
48366
|
};
|
|
48367
|
+
rungs.push({ target, step: { kind: "fps", from: at.fps, to: share.fps } });
|
|
48368
|
+
at = target;
|
|
47888
48369
|
}
|
|
47889
48370
|
const shareQuality = share.encoder?.quality;
|
|
47890
48371
|
const quality = at.encoder?.quality;
|
|
47891
48372
|
const atShare = at.width === share.width && at.height === share.height && (shareQuality === void 0 || quality !== void 0 && quality <= shareQuality);
|
|
47892
48373
|
if (!atShare) {
|
|
47893
|
-
|
|
48374
|
+
rungs.push({
|
|
47894
48375
|
target: share,
|
|
47895
48376
|
step: {
|
|
47896
48377
|
kind: "share",
|
|
47897
|
-
from:
|
|
47898
|
-
to:
|
|
48378
|
+
from: sizeOf(at),
|
|
48379
|
+
to: sizeOf(share),
|
|
47899
48380
|
...shareQuality === void 0 ? {} : { quality: shareQuality }
|
|
47900
48381
|
}
|
|
47901
|
-
};
|
|
48382
|
+
});
|
|
48383
|
+
at = share;
|
|
47902
48384
|
}
|
|
47903
|
-
if (
|
|
47904
|
-
|
|
47905
|
-
target:
|
|
47906
|
-
|
|
47907
|
-
|
|
47908
|
-
},
|
|
47909
|
-
step: { kind: "quality", from: quality, to: SHARE_QUALITY_FLOOR }
|
|
47910
|
-
};
|
|
48385
|
+
if (at.width !== floor.width || at.height !== floor.height) {
|
|
48386
|
+
rungs.push({
|
|
48387
|
+
target: floor,
|
|
48388
|
+
step: { kind: "frame", from: sizeOf(at), to: sizeOf(floor) }
|
|
48389
|
+
});
|
|
47911
48390
|
}
|
|
47912
|
-
|
|
48391
|
+
const { quality: _byQuality, ...byBitrate } = floor.encoder ?? {};
|
|
48392
|
+
rungs.push({
|
|
48393
|
+
target: { ...floor, bitrate: fit.bitrate, encoder: byBitrate },
|
|
48394
|
+
step: { kind: "fit", ...fit }
|
|
48395
|
+
});
|
|
48396
|
+
return rungs;
|
|
48397
|
+
}
|
|
48398
|
+
function fitRetry(fit, maxBytes, actualBytes) {
|
|
48399
|
+
const bitrate = Math.round(fit.target.bitrate * maxBytes * HEADROOM / actualBytes);
|
|
48400
|
+
if (fit.step.kind !== "fit") {
|
|
48401
|
+
throw new Error(`fitRetry retries a fit rung, not a ${fit.step.kind} one`);
|
|
48402
|
+
}
|
|
48403
|
+
return {
|
|
48404
|
+
target: { ...fit.target, bitrate },
|
|
48405
|
+
step: { kind: "fit", bitrate, durationMs: fit.step.durationMs }
|
|
48406
|
+
};
|
|
47913
48407
|
}
|
|
47914
48408
|
|
|
47915
48409
|
// ../../packages/run-core/dist/export/target.js
|
|
@@ -48004,6 +48498,88 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48004
48498
|
};
|
|
48005
48499
|
}
|
|
48006
48500
|
};
|
|
48501
|
+
const wallpaperAt = async (at2) => {
|
|
48502
|
+
const load2 = input.wallpaper;
|
|
48503
|
+
const kind = scene.branding.background.kind;
|
|
48504
|
+
if (load2 === null)
|
|
48505
|
+
return {
|
|
48506
|
+
image: null,
|
|
48507
|
+
failed: kind === "wallpaper" || kind === "image" ? "no wallpaper was supplied to the render" : null
|
|
48508
|
+
};
|
|
48509
|
+
if (!load2.ok)
|
|
48510
|
+
return { image: null, failed: load2.error };
|
|
48511
|
+
const size = wallpaperRasterSize(at2, load2.natural);
|
|
48512
|
+
let held;
|
|
48513
|
+
try {
|
|
48514
|
+
held = await load2.image(size);
|
|
48515
|
+
} catch (error51) {
|
|
48516
|
+
return {
|
|
48517
|
+
image: null,
|
|
48518
|
+
failed: `${load2.name}: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
48519
|
+
};
|
|
48520
|
+
}
|
|
48521
|
+
let sized = held;
|
|
48522
|
+
if (size.width < held.width) {
|
|
48523
|
+
try {
|
|
48524
|
+
const bitmap = await createImageBitmap(held.image, {
|
|
48525
|
+
resizeWidth: size.width,
|
|
48526
|
+
resizeHeight: size.height,
|
|
48527
|
+
resizeQuality: "high"
|
|
48528
|
+
});
|
|
48529
|
+
sized = {
|
|
48530
|
+
...held,
|
|
48531
|
+
image: bitmap,
|
|
48532
|
+
width: size.width,
|
|
48533
|
+
height: size.height
|
|
48534
|
+
};
|
|
48535
|
+
} catch (error51) {
|
|
48536
|
+
return {
|
|
48537
|
+
image: null,
|
|
48538
|
+
failed: `"${load2.name}" could not be resized to ${size.width}\xD7${size.height} (${error51 instanceof Error ? error51.message : String(error51)})`
|
|
48539
|
+
};
|
|
48540
|
+
}
|
|
48541
|
+
}
|
|
48542
|
+
const bg = scene.branding.background;
|
|
48543
|
+
const blur = bg.kind === "wallpaper" || bg.kind === "image" ? bg.blur : 0;
|
|
48544
|
+
const radius = wallpaperBlurPx(at2, sized, blur ?? 0);
|
|
48545
|
+
try {
|
|
48546
|
+
return { image: blurWallpaper(sized, radius), failed: null, held };
|
|
48547
|
+
} catch (error51) {
|
|
48548
|
+
return {
|
|
48549
|
+
image: null,
|
|
48550
|
+
failed: `"${load2.name}" could not be blurred at ${sized.width}\xD7${sized.height} (${error51 instanceof Error ? error51.message : String(error51)})`
|
|
48551
|
+
};
|
|
48552
|
+
} finally {
|
|
48553
|
+
if (radius > 0 && sized !== held)
|
|
48554
|
+
sized.image.close();
|
|
48555
|
+
}
|
|
48556
|
+
};
|
|
48557
|
+
const wallpaperWarning = (at2, deepestScale, failed) => {
|
|
48558
|
+
if (failed !== null) {
|
|
48559
|
+
return {
|
|
48560
|
+
kind: "leftOut",
|
|
48561
|
+
sentence: `The wallpaper was left out: ${failed}; the ${fileType === "stills" ? "stills use" : "video uses"} the plain gradient.`
|
|
48562
|
+
};
|
|
48563
|
+
}
|
|
48564
|
+
const load2 = input.wallpaper;
|
|
48565
|
+
if (load2 === null || !load2.ok)
|
|
48566
|
+
return null;
|
|
48567
|
+
const { width, height } = load2.natural;
|
|
48568
|
+
const scale = Math.max(at2.width / width, at2.height / height) * deepestScale;
|
|
48569
|
+
const needs = {
|
|
48570
|
+
width: Math.round(width * scale),
|
|
48571
|
+
height: Math.round(height * scale)
|
|
48572
|
+
};
|
|
48573
|
+
return needs.width > width ? {
|
|
48574
|
+
kind: "soft",
|
|
48575
|
+
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.`
|
|
48576
|
+
} : null;
|
|
48577
|
+
};
|
|
48578
|
+
const release = (image, held) => {
|
|
48579
|
+
if (image !== null && image.image !== held?.image) {
|
|
48580
|
+
image.image.close();
|
|
48581
|
+
}
|
|
48582
|
+
};
|
|
48007
48583
|
const plan = planScene(scene);
|
|
48008
48584
|
const surface = createOffscreenSurface();
|
|
48009
48585
|
const reclaimed = bundle.degradations.filter((d) => d.kind === "motionReclaimed").map((d) => ({
|
|
@@ -48024,16 +48600,31 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48024
48600
|
}, widestKeyframe);
|
|
48025
48601
|
const at2 = sized.target;
|
|
48026
48602
|
const { logo, logoWarning: logoWarning2 } = await logoAt(at2);
|
|
48027
|
-
const
|
|
48603
|
+
const wallpaper = await wallpaperAt(at2);
|
|
48604
|
+
const camera = options === void 0 ? void 0 : options.zoom ?? "none";
|
|
48605
|
+
let result2;
|
|
48606
|
+
try {
|
|
48607
|
+
result2 = await renderStills({
|
|
48608
|
+
plan,
|
|
48609
|
+
bundle,
|
|
48610
|
+
scene,
|
|
48611
|
+
target: at2,
|
|
48612
|
+
ports: { frames, surface, images: createPngSink() },
|
|
48613
|
+
logo,
|
|
48614
|
+
wallpaper: wallpaper.image,
|
|
48615
|
+
...camera === void 0 ? {} : { camera },
|
|
48616
|
+
...input.outputTimesMs === void 0 ? {} : { outputTimesMs: input.outputTimesMs },
|
|
48617
|
+
...onFrame === void 0 ? {} : { onFrame }
|
|
48618
|
+
});
|
|
48619
|
+
} finally {
|
|
48620
|
+
release(wallpaper.image, wallpaper.held ?? null);
|
|
48621
|
+
}
|
|
48622
|
+
const deepest = camera === "none" || input.wallpaper?.ok !== true ? 1 : composeForTarget({
|
|
48028
48623
|
plan,
|
|
48029
48624
|
bundle,
|
|
48030
48625
|
scene,
|
|
48031
|
-
target: at2
|
|
48032
|
-
|
|
48033
|
-
logo,
|
|
48034
|
-
...options === void 0 ? {} : { camera: options.zoom ?? "none" },
|
|
48035
|
-
...onFrame === void 0 ? {} : { onFrame }
|
|
48036
|
-
});
|
|
48626
|
+
target: at2
|
|
48627
|
+
}).resolved.cameraKeys.reduce((m, k) => Math.max(m, k.scale), 1);
|
|
48037
48628
|
return {
|
|
48038
48629
|
files: result2.files.map((f) => ({ name: f.name, bytes: f.bytes })),
|
|
48039
48630
|
facts: {
|
|
@@ -48042,6 +48633,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48042
48633
|
unplacedStills: result2.unplacedStills,
|
|
48043
48634
|
loweredZooms: result2.loweredZooms,
|
|
48044
48635
|
logoWarning: logoWarning2,
|
|
48636
|
+
wallpaperWarning: wallpaperWarning(at2, deepest, wallpaper.failed),
|
|
48045
48637
|
clampedRanges: result2.clampedRanges,
|
|
48046
48638
|
rendered: { width: at2.width, height: at2.height, fps: at2.fps },
|
|
48047
48639
|
...sized.cappedFrom === null ? {} : { stillsCapped: { askedWidth: sized.cappedFrom } }
|
|
@@ -48050,23 +48642,35 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48050
48642
|
}
|
|
48051
48643
|
const renderAt = async (at2, maxBytes, saysWidth = false, pass) => {
|
|
48052
48644
|
const { logo, logoWarning: logoWarning2 } = await logoAt(at2);
|
|
48645
|
+
const wallpaper = await wallpaperAt(at2);
|
|
48053
48646
|
const ports = at2.format === "gif" ? {
|
|
48054
48647
|
frames,
|
|
48055
48648
|
surface,
|
|
48056
48649
|
gif: createGifSink(at2, maxBytes === void 0 ? {} : { maxBytes })
|
|
48057
48650
|
} : { frames, surface, video: createMp4Sink(at2) };
|
|
48058
|
-
|
|
48059
|
-
|
|
48060
|
-
|
|
48061
|
-
|
|
48062
|
-
|
|
48063
|
-
|
|
48064
|
-
|
|
48065
|
-
|
|
48066
|
-
|
|
48067
|
-
|
|
48068
|
-
|
|
48069
|
-
|
|
48651
|
+
let result2;
|
|
48652
|
+
try {
|
|
48653
|
+
result2 = await renderScene({
|
|
48654
|
+
plan,
|
|
48655
|
+
bundle,
|
|
48656
|
+
scene,
|
|
48657
|
+
target: at2,
|
|
48658
|
+
ports,
|
|
48659
|
+
logo,
|
|
48660
|
+
wallpaper: wallpaper.image,
|
|
48661
|
+
...onFrame === void 0 ? {} : {
|
|
48662
|
+
onFrame: pass !== void 0 ? (done2, total) => onFrame(done2, total, at2.width, pass) : saysWidth ? (done2, total) => onFrame(done2, total, at2.width) : onFrame
|
|
48663
|
+
}
|
|
48664
|
+
});
|
|
48665
|
+
} finally {
|
|
48666
|
+
release(wallpaper.image, wallpaper.held ?? null);
|
|
48667
|
+
}
|
|
48668
|
+
return {
|
|
48669
|
+
result: result2,
|
|
48670
|
+
logoWarning: logoWarning2,
|
|
48671
|
+
wallpaperWarning: wallpaperWarning(at2, result2.deepestScale, wallpaper.failed),
|
|
48672
|
+
at: at2
|
|
48673
|
+
};
|
|
48070
48674
|
};
|
|
48071
48675
|
const budget = target.format === "gif" ? input.gifBudget : void 0;
|
|
48072
48676
|
const cap = target.format === "mp4" ? input.mp4Cap : void 0;
|
|
@@ -48074,47 +48678,65 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48074
48678
|
let videoCap;
|
|
48075
48679
|
let done;
|
|
48076
48680
|
if (cap !== void 0) {
|
|
48077
|
-
const
|
|
48078
|
-
|
|
48079
|
-
|
|
48080
|
-
|
|
48081
|
-
|
|
48082
|
-
|
|
48083
|
-
|
|
48084
|
-
|
|
48681
|
+
const { startMs, endMs } = composeForTarget({
|
|
48682
|
+
plan,
|
|
48683
|
+
bundle,
|
|
48684
|
+
scene,
|
|
48685
|
+
target: cap.floor
|
|
48686
|
+
}).resolved.range;
|
|
48687
|
+
const durationMs = endMs - startMs;
|
|
48688
|
+
const ladder = capLadder(target, cap, {
|
|
48689
|
+
bitrate: fitBitrate(cap.maxBytes, durationMs),
|
|
48690
|
+
durationMs
|
|
48691
|
+
});
|
|
48692
|
+
const upTo = ladder.length + 2;
|
|
48693
|
+
const over = (r) => r.result.bytes.byteLength > cap.maxBytes;
|
|
48085
48694
|
let current = await renderAt(target, void 0, true, {
|
|
48086
48695
|
render: 1,
|
|
48087
48696
|
upTo
|
|
48088
48697
|
});
|
|
48089
48698
|
let kept = current;
|
|
48699
|
+
let keptStep;
|
|
48700
|
+
const steps = [];
|
|
48090
48701
|
let failed;
|
|
48091
|
-
|
|
48092
|
-
const next = nextCapStep(current.at, cap.share);
|
|
48093
|
-
if (next === null)
|
|
48094
|
-
break;
|
|
48702
|
+
const take = async (rung) => {
|
|
48095
48703
|
try {
|
|
48096
|
-
current = await renderAt(
|
|
48704
|
+
current = await renderAt(rung.target, void 0, true, {
|
|
48097
48705
|
render: steps.length + 2,
|
|
48098
48706
|
upTo
|
|
48099
48707
|
});
|
|
48100
48708
|
} catch (error51) {
|
|
48101
48709
|
failed = {
|
|
48102
|
-
step:
|
|
48710
|
+
step: rung.step,
|
|
48103
48711
|
error: error51 instanceof Error ? error51.message : String(error51)
|
|
48104
48712
|
};
|
|
48105
|
-
|
|
48713
|
+
return false;
|
|
48106
48714
|
}
|
|
48107
|
-
steps.push(
|
|
48715
|
+
steps.push(rung.step);
|
|
48108
48716
|
if (current.result.bytes.byteLength <= kept.result.bytes.byteLength) {
|
|
48109
48717
|
kept = current;
|
|
48718
|
+
keptStep = rung.step;
|
|
48110
48719
|
}
|
|
48720
|
+
return true;
|
|
48721
|
+
};
|
|
48722
|
+
let last2;
|
|
48723
|
+
for (const rung of ladder) {
|
|
48724
|
+
if (!over(current))
|
|
48725
|
+
break;
|
|
48726
|
+
if (!await take(rung))
|
|
48727
|
+
break;
|
|
48728
|
+
last2 = rung;
|
|
48729
|
+
}
|
|
48730
|
+
if (failed === void 0 && last2?.step.kind === "fit" && over(current)) {
|
|
48731
|
+
await take(fitRetry(last2, cap.maxBytes, current.result.bytes.byteLength));
|
|
48111
48732
|
}
|
|
48112
48733
|
done = kept;
|
|
48113
48734
|
videoCap = {
|
|
48114
48735
|
maxBytes: cap.maxBytes,
|
|
48115
|
-
met: kept
|
|
48736
|
+
met: !over(kept),
|
|
48116
48737
|
steps,
|
|
48117
48738
|
keptQuality: kept.at.encoder?.quality ?? null,
|
|
48739
|
+
belowFloor: keptStep?.kind === "fit",
|
|
48118
48740
|
...failed === void 0 ? {} : { failed }
|
|
48119
48741
|
};
|
|
48120
48742
|
} else if (budget === void 0) {
|
|
@@ -48156,7 +48778,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48156
48778
|
if (done === void 0) {
|
|
48157
48779
|
throw new Error("the GIF width ladder ended without a render");
|
|
48158
48780
|
}
|
|
48159
|
-
const { result, logoWarning, at } = done;
|
|
48781
|
+
const { result, logoWarning, wallpaperWarning: wallpaperSaid, at } = done;
|
|
48160
48782
|
return {
|
|
48161
48783
|
files: [{ name: null, bytes: result.bytes }],
|
|
48162
48784
|
facts: {
|
|
@@ -48165,6 +48787,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48165
48787
|
unplacedStills: [],
|
|
48166
48788
|
loweredZooms: result.loweredZooms,
|
|
48167
48789
|
logoWarning,
|
|
48790
|
+
wallpaperWarning: wallpaperSaid,
|
|
48168
48791
|
clampedRanges: result.clampedRanges,
|
|
48169
48792
|
rendered: { width: at.width, height: at.height, fps: at.fps },
|
|
48170
48793
|
...budget === void 0 ? {} : {
|
|
@@ -48174,9 +48797,138 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48174
48797
|
refused
|
|
48175
48798
|
}
|
|
48176
48799
|
},
|
|
48177
|
-
...videoCap === void 0 ? {} : { videoCap }
|
|
48800
|
+
...videoCap === void 0 ? {} : { videoCap },
|
|
48801
|
+
// From `done`, the render kept: a capped or budgeted file is the
|
|
48802
|
+
// last rung that was kept, and its screens are that render's.
|
|
48803
|
+
screens: result.screens
|
|
48804
|
+
}
|
|
48805
|
+
};
|
|
48806
|
+
}
|
|
48807
|
+
|
|
48808
|
+
// ../../packages/run-core/dist/webp-size.js
|
|
48809
|
+
function webpSize(b) {
|
|
48810
|
+
const ascii2 = (at, n) => String.fromCharCode(...b.subarray(at, at + n));
|
|
48811
|
+
if (b.length < 30 || ascii2(0, 4) !== "RIFF" || ascii2(8, 4) !== "WEBP") {
|
|
48812
|
+
return null;
|
|
48813
|
+
}
|
|
48814
|
+
const view2 = new DataView(b.buffer, b.byteOffset, b.byteLength);
|
|
48815
|
+
const u242 = (at) => b[at] | b[at + 1] << 8 | b[at + 2] << 16;
|
|
48816
|
+
switch (ascii2(12, 4)) {
|
|
48817
|
+
case "VP8X":
|
|
48818
|
+
return { width: 1 + u242(24), height: 1 + u242(27) };
|
|
48819
|
+
case "VP8 ":
|
|
48820
|
+
if (b[23] !== 157 || b[24] !== 1 || b[25] !== 42)
|
|
48821
|
+
return null;
|
|
48822
|
+
return {
|
|
48823
|
+
width: view2.getUint16(26, true) & 16383,
|
|
48824
|
+
height: view2.getUint16(28, true) & 16383
|
|
48825
|
+
};
|
|
48826
|
+
case "VP8L": {
|
|
48827
|
+
if (b[20] !== 47)
|
|
48828
|
+
return null;
|
|
48829
|
+
const bits = view2.getUint32(21, true);
|
|
48830
|
+
return {
|
|
48831
|
+
width: 1 + (bits & 16383),
|
|
48832
|
+
height: 1 + (bits >>> 14 & 16383)
|
|
48833
|
+
};
|
|
48178
48834
|
}
|
|
48835
|
+
default:
|
|
48836
|
+
return null;
|
|
48837
|
+
}
|
|
48838
|
+
}
|
|
48839
|
+
|
|
48840
|
+
// ../../packages/run-core/dist/wallpaper.js
|
|
48841
|
+
async function decodeWallpaper(bytes2, contentType, size) {
|
|
48842
|
+
const blob = new Blob([bytes2.slice()], { type: contentType });
|
|
48843
|
+
let image;
|
|
48844
|
+
try {
|
|
48845
|
+
image = await (size === void 0 ? createImageBitmap(blob) : createImageBitmap(blob, {
|
|
48846
|
+
resizeWidth: size.width,
|
|
48847
|
+
resizeHeight: size.height,
|
|
48848
|
+
resizeQuality: "high"
|
|
48849
|
+
}));
|
|
48850
|
+
} catch (error51) {
|
|
48851
|
+
throw new Error(`the ${contentType} could not be decoded: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
48852
|
+
}
|
|
48853
|
+
return { image, width: image.width, height: image.height, sourceTimeMs: 0 };
|
|
48854
|
+
}
|
|
48855
|
+
async function wallpaperLoader(bytes2, contentType, name) {
|
|
48856
|
+
let held = null;
|
|
48857
|
+
let natural = webpSize(bytes2);
|
|
48858
|
+
if (natural === null) {
|
|
48859
|
+
held = await decodeWallpaper(bytes2, contentType);
|
|
48860
|
+
natural = { width: held.width, height: held.height };
|
|
48861
|
+
}
|
|
48862
|
+
const own = natural;
|
|
48863
|
+
const free2 = (image) => {
|
|
48864
|
+
if (image !== null && "close" in image.image)
|
|
48865
|
+
image.image.close();
|
|
48179
48866
|
};
|
|
48867
|
+
return {
|
|
48868
|
+
ok: true,
|
|
48869
|
+
name,
|
|
48870
|
+
natural: own,
|
|
48871
|
+
async image(size) {
|
|
48872
|
+
if (held === null || held.width < size.width) {
|
|
48873
|
+
const next = await decodeWallpaper(bytes2, contentType, size.width >= own.width ? void 0 : size);
|
|
48874
|
+
free2(held);
|
|
48875
|
+
held = next;
|
|
48876
|
+
}
|
|
48877
|
+
return held;
|
|
48878
|
+
},
|
|
48879
|
+
close: () => {
|
|
48880
|
+
free2(held);
|
|
48881
|
+
held = null;
|
|
48882
|
+
}
|
|
48883
|
+
};
|
|
48884
|
+
}
|
|
48885
|
+
var FITTED_TYPE = "image/webp";
|
|
48886
|
+
var FITTED_QUALITY = 0.97;
|
|
48887
|
+
async function fitWallpaperImage(file2) {
|
|
48888
|
+
const name = file2 instanceof File ? file2.name : "(unnamed)";
|
|
48889
|
+
let image;
|
|
48890
|
+
let width;
|
|
48891
|
+
let height;
|
|
48892
|
+
try {
|
|
48893
|
+
if (file2.type === "image/svg+xml") {
|
|
48894
|
+
const svg = await decodeLogo(new Uint8Array(await file2.arrayBuffer()), file2.type);
|
|
48895
|
+
const raster = await svg.rasterAt(svg.aspect >= 1 ? WALLPAPER_LONG_SIDE / svg.aspect : WALLPAPER_LONG_SIDE);
|
|
48896
|
+
({ image, width, height } = raster);
|
|
48897
|
+
} else {
|
|
48898
|
+
const bitmap = await createImageBitmap(file2);
|
|
48899
|
+
const scale = Math.min(1, WALLPAPER_LONG_SIDE / Math.max(bitmap.width, bitmap.height));
|
|
48900
|
+
width = Math.max(1, Math.round(bitmap.width * scale));
|
|
48901
|
+
height = Math.max(1, Math.round(bitmap.height * scale));
|
|
48902
|
+
image = scale === 1 ? bitmap : await createImageBitmap(bitmap, {
|
|
48903
|
+
resizeWidth: width,
|
|
48904
|
+
resizeHeight: height,
|
|
48905
|
+
resizeQuality: "high"
|
|
48906
|
+
});
|
|
48907
|
+
if (image !== bitmap)
|
|
48908
|
+
bitmap.close();
|
|
48909
|
+
}
|
|
48910
|
+
} catch (error51) {
|
|
48911
|
+
throw new Error(`The image "${name}" could not be opened as an image`, {
|
|
48912
|
+
cause: error51
|
|
48913
|
+
});
|
|
48914
|
+
}
|
|
48915
|
+
const canvas = new OffscreenCanvas(width, height);
|
|
48916
|
+
canvas.getContext("2d").drawImage(image, 0, 0);
|
|
48917
|
+
if ("close" in image)
|
|
48918
|
+
image.close();
|
|
48919
|
+
let blob;
|
|
48920
|
+
try {
|
|
48921
|
+
blob = await canvas.convertToBlob({
|
|
48922
|
+
type: FITTED_TYPE,
|
|
48923
|
+
quality: FITTED_QUALITY
|
|
48924
|
+
});
|
|
48925
|
+
} catch (error51) {
|
|
48926
|
+
throw new Error(`The image "${name}" opened but could not be saved as WebP: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
48927
|
+
}
|
|
48928
|
+
if (blob.type !== FITTED_TYPE) {
|
|
48929
|
+
throw new Error(`The image "${name}" opened but this browser saved it as ${blob.type || "nothing"}, not WebP`);
|
|
48930
|
+
}
|
|
48931
|
+
return { blob, width, height };
|
|
48180
48932
|
}
|
|
48181
48933
|
|
|
48182
48934
|
// dist/entry-globals.js
|
|
@@ -48232,7 +48984,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48232
48984
|
logo = { ok: false, error: messageOf(error51) };
|
|
48233
48985
|
}
|
|
48234
48986
|
}
|
|
48987
|
+
let wallpaper = null;
|
|
48988
|
+
const sent = manifest.wallpaper;
|
|
48989
|
+
if (sent !== null && "error" in sent) {
|
|
48990
|
+
wallpaper = { ok: false, error: sent.error };
|
|
48991
|
+
} else if (sent !== null) {
|
|
48992
|
+
try {
|
|
48993
|
+
wallpaper = await wallpaperLoader(bytesOf(sent.base64), sent.contentType, sent.name);
|
|
48994
|
+
} catch (error51) {
|
|
48995
|
+
wallpaper = { ok: false, error: `${sent.name}: ${messageOf(error51)}` };
|
|
48996
|
+
}
|
|
48997
|
+
}
|
|
48235
48998
|
const report = globalThis[RENDER_PROGRESS_BINDING];
|
|
48999
|
+
const sink = { copyMs: 0, encodeMs: 0, finishMs: 0, frames: 0 };
|
|
49000
|
+
globalThis[SINK_TIMES_GLOBAL] = sink;
|
|
48236
49001
|
const started = performance.now();
|
|
48237
49002
|
const source = await framesFor(bundle, load);
|
|
48238
49003
|
let framesMs = 0;
|
|
@@ -48259,15 +49024,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48259
49024
|
bundle,
|
|
48260
49025
|
frames,
|
|
48261
49026
|
logo,
|
|
49027
|
+
wallpaper,
|
|
48262
49028
|
...manifest.gifBudget === void 0 ? {} : { gifBudget: manifest.gifBudget },
|
|
48263
49029
|
...manifest.mp4Cap === void 0 ? {} : {
|
|
48264
49030
|
mp4Cap: {
|
|
48265
49031
|
...manifest.mp4Cap,
|
|
48266
|
-
share: softwareEncoded(manifest.mp4Cap.share)
|
|
49032
|
+
share: softwareEncoded(manifest.mp4Cap.share),
|
|
49033
|
+
floor: softwareEncoded(manifest.mp4Cap.floor)
|
|
48267
49034
|
}
|
|
48268
49035
|
},
|
|
48269
49036
|
...manifest.stills === void 0 ? {} : { stills: manifest.stills },
|
|
49037
|
+
...manifest.outputTimesMs === void 0 ? {} : { outputTimesMs: manifest.outputTimesMs },
|
|
48270
49038
|
onFrame: wholePercent((done, total, width, pass) => width === void 0 ? report?.(done, total) : pass === void 0 ? report?.(done, total, width) : report?.(done, total, width, pass))
|
|
49039
|
+
// The decoded image is freed once every output is rendered: the GIF
|
|
49040
|
+
// ladder and the MP4 cap re-render inside this call.
|
|
49041
|
+
}).finally(() => {
|
|
49042
|
+
if (wallpaper?.ok === true)
|
|
49043
|
+
wallpaper.close();
|
|
48271
49044
|
});
|
|
48272
49045
|
outputs = files.map((f) => f.bytes);
|
|
48273
49046
|
return {
|
|
@@ -48276,7 +49049,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48276
49049
|
timing: {
|
|
48277
49050
|
renderMs: performance.now() - started,
|
|
48278
49051
|
framesMs,
|
|
48279
|
-
frameReads
|
|
49052
|
+
frameReads,
|
|
49053
|
+
sink: fileType === "mp4" ? sink : null
|
|
48280
49054
|
}
|
|
48281
49055
|
};
|
|
48282
49056
|
}
|
|
@@ -48293,7 +49067,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
48293
49067
|
}
|
|
48294
49068
|
return btoa(binary);
|
|
48295
49069
|
}
|
|
48296
|
-
|
|
49070
|
+
async function fitWallpaper(base643, contentType, name) {
|
|
49071
|
+
const fitted = await fitWallpaperImage(new File([bytesOf(base643).slice()], name, { type: contentType }));
|
|
49072
|
+
const bytes2 = new Uint8Array(await fitted.blob.arrayBuffer());
|
|
49073
|
+
outputs = [bytes2];
|
|
49074
|
+
return {
|
|
49075
|
+
width: fitted.width,
|
|
49076
|
+
height: fitted.height,
|
|
49077
|
+
byteLength: bytes2.byteLength
|
|
49078
|
+
};
|
|
49079
|
+
}
|
|
49080
|
+
var entry = { render, readChunk, fitWallpaper };
|
|
48297
49081
|
globalThis[RENDER_ENTRY_GLOBAL] = entry;
|
|
48298
49082
|
})();
|
|
48299
49083
|
/*! Bundled license information:
|