@carlesandres/webreel-core 0.2.0
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/LICENSE +201 -0
- package/README.md +200 -0
- package/assets/click-1.mp3 +0 -0
- package/assets/click-2.mp3 +0 -0
- package/assets/click-3.mp3 +0 -0
- package/assets/click-4.mp3 +0 -0
- package/assets/key-1.mp3 +0 -0
- package/assets/key-2.mp3 +0 -0
- package/assets/key-3.mp3 +0 -0
- package/assets/key-4.mp3 +0 -0
- package/dist/__tests__/actions.test.d.ts +2 -0
- package/dist/__tests__/actions.test.d.ts.map +1 -0
- package/dist/__tests__/actions.test.js +252 -0
- package/dist/__tests__/actions.test.js.map +1 -0
- package/dist/__tests__/chrome.test.d.ts +2 -0
- package/dist/__tests__/chrome.test.d.ts.map +1 -0
- package/dist/__tests__/chrome.test.js +29 -0
- package/dist/__tests__/chrome.test.js.map +1 -0
- package/dist/__tests__/cursor-motion.test.d.ts +2 -0
- package/dist/__tests__/cursor-motion.test.d.ts.map +1 -0
- package/dist/__tests__/cursor-motion.test.js +39 -0
- package/dist/__tests__/cursor-motion.test.js.map +1 -0
- package/dist/__tests__/ffmpeg.test.d.ts +2 -0
- package/dist/__tests__/ffmpeg.test.d.ts.map +1 -0
- package/dist/__tests__/ffmpeg.test.js +90 -0
- package/dist/__tests__/ffmpeg.test.js.map +1 -0
- package/dist/__tests__/fs.test.d.ts +2 -0
- package/dist/__tests__/fs.test.d.ts.map +1 -0
- package/dist/__tests__/fs.test.js +42 -0
- package/dist/__tests__/fs.test.js.map +1 -0
- package/dist/__tests__/media.test.d.ts +2 -0
- package/dist/__tests__/media.test.d.ts.map +1 -0
- package/dist/__tests__/media.test.js +98 -0
- package/dist/__tests__/media.test.js.map +1 -0
- package/dist/__tests__/overlays.test.d.ts +2 -0
- package/dist/__tests__/overlays.test.d.ts.map +1 -0
- package/dist/__tests__/overlays.test.js +109 -0
- package/dist/__tests__/overlays.test.js.map +1 -0
- package/dist/__tests__/recorder.test.d.ts +2 -0
- package/dist/__tests__/recorder.test.d.ts.map +1 -0
- package/dist/__tests__/recorder.test.js +60 -0
- package/dist/__tests__/recorder.test.js.map +1 -0
- package/dist/__tests__/recording-context.test.d.ts +2 -0
- package/dist/__tests__/recording-context.test.d.ts.map +1 -0
- package/dist/__tests__/recording-context.test.js +46 -0
- package/dist/__tests__/recording-context.test.js.map +1 -0
- package/dist/__tests__/timeline.test.d.ts +2 -0
- package/dist/__tests__/timeline.test.d.ts.map +1 -0
- package/dist/__tests__/timeline.test.js +88 -0
- package/dist/__tests__/timeline.test.js.map +1 -0
- package/dist/actions.d.ts +65 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +729 -0
- package/dist/actions.js.map +1 -0
- package/dist/cdp.d.ts +3 -0
- package/dist/cdp.d.ts.map +1 -0
- package/dist/cdp.js +5 -0
- package/dist/cdp.js.map +1 -0
- package/dist/chrome.d.ts +16 -0
- package/dist/chrome.d.ts.map +1 -0
- package/dist/chrome.js +243 -0
- package/dist/chrome.js.map +1 -0
- package/dist/compositor.d.ts +8 -0
- package/dist/compositor.d.ts.map +1 -0
- package/dist/compositor.js +232 -0
- package/dist/compositor.js.map +1 -0
- package/dist/cursor-motion.d.ts +17 -0
- package/dist/cursor-motion.d.ts.map +1 -0
- package/dist/cursor-motion.js +138 -0
- package/dist/cursor-motion.js.map +1 -0
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +78 -0
- package/dist/download.js.map +1 -0
- package/dist/ffmpeg.d.ts +6 -0
- package/dist/ffmpeg.d.ts.map +1 -0
- package/dist/ffmpeg.js +106 -0
- package/dist/ffmpeg.js.map +1 -0
- package/dist/fs.d.ts +6 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +20 -0
- package/dist/fs.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/media.d.ts +23 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +167 -0
- package/dist/media.js.map +1 -0
- package/dist/overlays.d.ts +21 -0
- package/dist/overlays.d.ts.map +1 -0
- package/dist/overlays.js +97 -0
- package/dist/overlays.js.map +1 -0
- package/dist/recorder.d.ts +60 -0
- package/dist/recorder.d.ts.map +1 -0
- package/dist/recorder.js +283 -0
- package/dist/recorder.js.map +1 -0
- package/dist/timeline.d.ts +82 -0
- package/dist/timeline.d.ts.map +1 -0
- package/dist/timeline.js +140 -0
- package/dist/timeline.js.map +1 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,SAAS,SAAS,CAAC,UAAkB,EAAE,IAAc;IACnD,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE;QACzC,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;KAC5B,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,C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QACV,SAAS;QACT,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAChC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,iBAAiB,CACpD,UAAU,EACV,MAAM,EACN,WAAW,EACX,GAAG,CACJ,CAAC;QAEF,SAAS,CAAC,UAAU,EAAE;YACpB,IAAI;YACJ,GAAG,SAAS;YACZ,iBAAiB;YACjB,aAAa;YACb,MAAM;YACN,KAAK;YACL,MAAM;YACN,QAAQ;YACR,MAAM;YACN,MAAM;YACN,MAAM;YACN,SAAS;YACT,MAAM;YACN,MAAM;YACN,WAAW;YACX,UAAU;SACX,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,UAAkB,EAClB,SAAiB,EACjB,UAAkB,EAClB,OAAe;IAEf,SAAS,CAAC,UAAU,EAAE;QACpB,IAAI;QACJ,KAAK;QACL,MAAM,CAAC,OAAO,CAAC;QACf,IAAI;QACJ,SAAS;QACT,WAAW;QACX,GAAG;QACH,UAAU;KACX,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,UAAkB,EAClB,SAAiB,EACjB,UAAkB,EAClB,KAAa;IAEb,SAAS,CAAC,UAAU,EAAE;QACpB,IAAI;QACJ,IAAI;QACJ,SAAS;QACT,KAAK;QACL,gBAAgB,KAAK,qEAAqE;QAC1F,UAAU;KACX,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CDPClient } from "./types.js";
|
|
2
|
+
export interface OverlayTheme {
|
|
3
|
+
cursorSvg?: string;
|
|
4
|
+
cursorSize?: number;
|
|
5
|
+
cursorHotspot?: "top-left" | "center";
|
|
6
|
+
hud?: {
|
|
7
|
+
background?: string;
|
|
8
|
+
color?: string;
|
|
9
|
+
fontSize?: number;
|
|
10
|
+
fontFamily?: string;
|
|
11
|
+
borderRadius?: number;
|
|
12
|
+
position?: "top" | "bottom";
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare function injectOverlays(client: CDPClient, theme?: OverlayTheme, initialPosition?: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
export declare function showKeys(client: CDPClient, labels: string[]): Promise<void>;
|
|
20
|
+
export declare function hideKeys(client: CDPClient): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=overlays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlays.d.ts","sourceRoot":"","sources":["../src/overlays.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQ5C,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IACtC,GAAG,CAAC,EAAE;QACJ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;KAC7B,CAAC;CACH;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,YAAY,EACpB,eAAe,CAAC,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,OAAO,CAAC,IAAI,CAAC,CAwEf;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAcjF;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAO/D"}
|
package/dist/overlays.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DEFAULT_CURSOR_SVG, OFFSCREEN_MARGIN, DEFAULT_CURSOR_SIZE, DEFAULT_HUD_THEME, } from "./types.js";
|
|
2
|
+
export async function injectOverlays(client, theme, initialPosition) {
|
|
3
|
+
const cursorSize = theme?.cursorSize ?? DEFAULT_CURSOR_SIZE;
|
|
4
|
+
const cursorSvg = theme?.cursorSvg ?? DEFAULT_CURSOR_SVG;
|
|
5
|
+
const hotspotOffset = theme?.cursorHotspot === "center" ? cursorSize / 2 : 0;
|
|
6
|
+
const hudBg = theme?.hud?.background ?? DEFAULT_HUD_THEME.background;
|
|
7
|
+
const hudColor = theme?.hud?.color ?? DEFAULT_HUD_THEME.color;
|
|
8
|
+
const hudFontSize = theme?.hud?.fontSize ?? DEFAULT_HUD_THEME.fontSize;
|
|
9
|
+
const hudFontFamily = theme?.hud?.fontFamily ?? DEFAULT_HUD_THEME.fontFamily;
|
|
10
|
+
const hudBorderRadius = theme?.hud?.borderRadius ?? DEFAULT_HUD_THEME.borderRadius;
|
|
11
|
+
const hudPosition = theme?.hud?.position ?? DEFAULT_HUD_THEME.position;
|
|
12
|
+
await client.Runtime.evaluate({
|
|
13
|
+
expression: `(() => {
|
|
14
|
+
const zoom = parseFloat(getComputedStyle(document.documentElement).zoom) || 1;
|
|
15
|
+
|
|
16
|
+
const cursor = document.createElement("div");
|
|
17
|
+
cursor.id = "__demo-cursor";
|
|
18
|
+
cursor.style.cssText = [
|
|
19
|
+
"position:fixed",
|
|
20
|
+
"left:0",
|
|
21
|
+
"top:0",
|
|
22
|
+
"z-index:999999",
|
|
23
|
+
"pointer-events:none",
|
|
24
|
+
"width:${cursorSize}px",
|
|
25
|
+
"height:${cursorSize}px",
|
|
26
|
+
"margin-left:${-hotspotOffset}px",
|
|
27
|
+
"margin-top:${-hotspotOffset}px",
|
|
28
|
+
"transform-origin:top left",
|
|
29
|
+
"will-change:transform",
|
|
30
|
+
"transform:translate(${initialPosition?.x ?? -OFFSCREEN_MARGIN}px,${initialPosition?.y ?? -OFFSCREEN_MARGIN}px)",
|
|
31
|
+
"filter:drop-shadow(0 1px 2px rgba(0,0,0,0.5))",
|
|
32
|
+
].join(";");
|
|
33
|
+
cursor.dataset.cx = "${initialPosition?.x ?? -OFFSCREEN_MARGIN}";
|
|
34
|
+
cursor.dataset.cy = "${initialPosition?.y ?? -OFFSCREEN_MARGIN}";
|
|
35
|
+
cursor.innerHTML = ${JSON.stringify(cursorSvg)};
|
|
36
|
+
document.body.appendChild(cursor);
|
|
37
|
+
|
|
38
|
+
const z = (v) => (v / zoom) + "px";
|
|
39
|
+
const keys = document.createElement("div");
|
|
40
|
+
keys.id = "__demo-keys";
|
|
41
|
+
keys.style.cssText = [
|
|
42
|
+
"position:fixed",
|
|
43
|
+
"z-index:999999",
|
|
44
|
+
"pointer-events:none",
|
|
45
|
+
"${hudPosition}:" + z(48),
|
|
46
|
+
"left:50%",
|
|
47
|
+
"transform:translateX(-50%)",
|
|
48
|
+
"display:flex",
|
|
49
|
+
"gap:" + z(14),
|
|
50
|
+
"padding:" + z(16) + " " + z(36),
|
|
51
|
+
"border-radius:" + z(${hudBorderRadius}),
|
|
52
|
+
"background:${hudBg}",
|
|
53
|
+
"opacity:0",
|
|
54
|
+
].join(";");
|
|
55
|
+
document.body.appendChild(keys);
|
|
56
|
+
|
|
57
|
+
const style = document.createElement("style");
|
|
58
|
+
style.textContent = \`
|
|
59
|
+
.__demo-key {
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
color: ${hudColor};
|
|
64
|
+
font-family: ${hudFontFamily};
|
|
65
|
+
font-size: \${${hudFontSize} / zoom}px;
|
|
66
|
+
font-weight: 500;
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
}
|
|
69
|
+
\`;
|
|
70
|
+
document.head.appendChild(style);
|
|
71
|
+
})()`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export async function showKeys(client, labels) {
|
|
75
|
+
await client.Runtime.evaluate({
|
|
76
|
+
expression: `(() => {
|
|
77
|
+
const container = document.getElementById("__demo-keys");
|
|
78
|
+
if (!container) return;
|
|
79
|
+
container.innerHTML = ${JSON.stringify(labels)}
|
|
80
|
+
.map(k => {
|
|
81
|
+
const e = k.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
|
82
|
+
return '<span class="__demo-key">' + e + '</span>';
|
|
83
|
+
})
|
|
84
|
+
.join("");
|
|
85
|
+
container.style.opacity = "1";
|
|
86
|
+
})()`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export async function hideKeys(client) {
|
|
90
|
+
await client.Runtime.evaluate({
|
|
91
|
+
expression: `(() => {
|
|
92
|
+
const container = document.getElementById("__demo-keys");
|
|
93
|
+
if (container) container.style.opacity = "0";
|
|
94
|
+
})()`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=overlays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlays.js","sourceRoot":"","sources":["../src/overlays.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAgBpB,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,KAAoB,EACpB,eAA0C;IAE1C,MAAM,UAAU,GAAG,KAAK,EAAE,UAAU,IAAI,mBAAmB,CAAC;IAC5D,MAAM,SAAS,GA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,KAAK,UAAU,QAAQ,CAAC,MAAiB,EAAE,MAAgB;IAChE,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,UAAU,EAAE;;;8BAGc,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;;;;;;;SAO3C;KACN,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,MAAiB;IAC9C,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,UAAU,EAAE;;;SAGP;KACN,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CDPClient, CaptureFormat } from "./types.js";
|
|
2
|
+
import type { RecordingContext } from "./actions.js";
|
|
3
|
+
import { type SfxConfig } from "./media.js";
|
|
4
|
+
import type { InteractionTimeline, TimelineData } from "./timeline.js";
|
|
5
|
+
export declare function getFfmpegInputCodec(format: CaptureFormat): "mjpeg" | "png";
|
|
6
|
+
export declare function getFrameExtension(format: CaptureFormat): ".jpg" | ".png";
|
|
7
|
+
export declare function getCaptureScreenshotParams(format: CaptureFormat): {
|
|
8
|
+
format: CaptureFormat;
|
|
9
|
+
quality?: number;
|
|
10
|
+
optimizeForSpeed: true;
|
|
11
|
+
};
|
|
12
|
+
export interface RecorderOptions {
|
|
13
|
+
sfx?: SfxConfig;
|
|
14
|
+
fps?: number;
|
|
15
|
+
crf?: number;
|
|
16
|
+
framesDir?: string;
|
|
17
|
+
captureFormat?: CaptureFormat;
|
|
18
|
+
}
|
|
19
|
+
export declare function buildFfmpegRecorderArgs(options: {
|
|
20
|
+
fps: number;
|
|
21
|
+
crf: number;
|
|
22
|
+
captureFormat: CaptureFormat;
|
|
23
|
+
outputPath: string;
|
|
24
|
+
}): string[];
|
|
25
|
+
export declare class Recorder {
|
|
26
|
+
private outputPath;
|
|
27
|
+
private frameCount;
|
|
28
|
+
private running;
|
|
29
|
+
private capturePromise;
|
|
30
|
+
private events;
|
|
31
|
+
private outputWidth;
|
|
32
|
+
private outputHeight;
|
|
33
|
+
private sfx;
|
|
34
|
+
private fps;
|
|
35
|
+
private frameMs;
|
|
36
|
+
private crf;
|
|
37
|
+
private ffmpegPath;
|
|
38
|
+
private ffmpegProcess;
|
|
39
|
+
private tempVideo;
|
|
40
|
+
private drainResolve;
|
|
41
|
+
private droppedFrames;
|
|
42
|
+
private timeline;
|
|
43
|
+
private ctx;
|
|
44
|
+
private framesDir;
|
|
45
|
+
private stopResolve;
|
|
46
|
+
private stoppedPromise;
|
|
47
|
+
private captureFormat;
|
|
48
|
+
constructor(outputWidth?: number, outputHeight?: number, options?: RecorderOptions);
|
|
49
|
+
setTimeline(timeline: InteractionTimeline): void;
|
|
50
|
+
getTimeline(): InteractionTimeline | null;
|
|
51
|
+
getTimelineData(): TimelineData | null;
|
|
52
|
+
addEvent(type: "click" | "key"): void;
|
|
53
|
+
start(client: CDPClient, outputPath: string, ctx?: RecordingContext): Promise<void>;
|
|
54
|
+
private writeFrame;
|
|
55
|
+
private raceStop;
|
|
56
|
+
private captureLoop;
|
|
57
|
+
getTempVideoPath(): string;
|
|
58
|
+
stop(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../src/recorder.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAc,aAAa,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEvE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,GAAG,KAAK,CAE1E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,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,WAAW,CAA6B;IAChD,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,aAAa,CAAgB;gBAGnC,WAAW,SAAwB,EACnC,YAAY,SAAwB,EACpC,OAAO,CAAC,EAAE,eAAe;IAe3B,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAIhD,WAAW,IAAI,mBAAmB,GAAG,IAAI;IAIzC,eAAe,IAAI,YAAY,GAAG,IAAI;IAItC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK;IAOxB,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,gBAAgB;YA6C3D,UAAU;YAeV,QAAQ;YAMR,WAAW;IAgEzB,gBAAgB,IAAI,MAAM;IAIpB,IAAI;CAsFX"}
|
package/dist/recorder.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { resolve, extname } from "node:path";
|
|
5
|
+
import { TARGET_FPS, DEFAULT_VIEWPORT_SIZE } from "./types.js";
|
|
6
|
+
import { ensureFfmpeg } from "./ffmpeg.js";
|
|
7
|
+
import { finalizeMp4, finalizeWebm, finalizeGif } from "./media.js";
|
|
8
|
+
export function getFfmpegInputCodec(format) {
|
|
9
|
+
return format === "png" ? "png" : "mjpeg";
|
|
10
|
+
}
|
|
11
|
+
export function getFrameExtension(format) {
|
|
12
|
+
return format === "png" ? ".png" : ".jpg";
|
|
13
|
+
}
|
|
14
|
+
export function getCaptureScreenshotParams(format) {
|
|
15
|
+
if (format === "png") {
|
|
16
|
+
return { format: "png", optimizeForSpeed: true };
|
|
17
|
+
}
|
|
18
|
+
return { format: "jpeg", quality: 60, optimizeForSpeed: true };
|
|
19
|
+
}
|
|
20
|
+
export function buildFfmpegRecorderArgs(options) {
|
|
21
|
+
return [
|
|
22
|
+
"-y",
|
|
23
|
+
"-f",
|
|
24
|
+
"image2pipe",
|
|
25
|
+
"-framerate",
|
|
26
|
+
String(options.fps),
|
|
27
|
+
"-c:v",
|
|
28
|
+
getFfmpegInputCodec(options.captureFormat),
|
|
29
|
+
"-i",
|
|
30
|
+
"pipe:0",
|
|
31
|
+
"-c:v",
|
|
32
|
+
"libx264",
|
|
33
|
+
"-preset",
|
|
34
|
+
"ultrafast",
|
|
35
|
+
"-crf",
|
|
36
|
+
String(options.crf),
|
|
37
|
+
"-pix_fmt",
|
|
38
|
+
"yuv420p",
|
|
39
|
+
"-color_primaries",
|
|
40
|
+
"bt709",
|
|
41
|
+
"-color_trc",
|
|
42
|
+
"bt709",
|
|
43
|
+
"-colorspace",
|
|
44
|
+
"bt709",
|
|
45
|
+
"-movflags",
|
|
46
|
+
"+faststart",
|
|
47
|
+
"-r",
|
|
48
|
+
String(options.fps),
|
|
49
|
+
options.outputPath,
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
export class Recorder {
|
|
53
|
+
outputPath = "";
|
|
54
|
+
frameCount = 0;
|
|
55
|
+
running = false;
|
|
56
|
+
capturePromise = null;
|
|
57
|
+
events = [];
|
|
58
|
+
outputWidth;
|
|
59
|
+
outputHeight;
|
|
60
|
+
sfx;
|
|
61
|
+
fps;
|
|
62
|
+
frameMs;
|
|
63
|
+
crf;
|
|
64
|
+
ffmpegPath = "ffmpeg";
|
|
65
|
+
ffmpegProcess = null;
|
|
66
|
+
tempVideo = "";
|
|
67
|
+
drainResolve = null;
|
|
68
|
+
droppedFrames = 0;
|
|
69
|
+
timeline = null;
|
|
70
|
+
ctx = null;
|
|
71
|
+
framesDir = null;
|
|
72
|
+
stopResolve = null;
|
|
73
|
+
stoppedPromise = null;
|
|
74
|
+
captureFormat;
|
|
75
|
+
constructor(outputWidth = DEFAULT_VIEWPORT_SIZE, outputHeight = DEFAULT_VIEWPORT_SIZE, options) {
|
|
76
|
+
this.outputWidth = outputWidth;
|
|
77
|
+
this.outputHeight = outputHeight;
|
|
78
|
+
this.sfx = options?.sfx;
|
|
79
|
+
this.fps = options?.fps ?? TARGET_FPS;
|
|
80
|
+
this.frameMs = 1000 / this.fps;
|
|
81
|
+
this.crf = options?.crf ?? 18;
|
|
82
|
+
this.captureFormat = options?.captureFormat ?? "jpeg";
|
|
83
|
+
if (options?.framesDir) {
|
|
84
|
+
this.framesDir = options.framesDir;
|
|
85
|
+
mkdirSync(this.framesDir, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
setTimeline(timeline) {
|
|
89
|
+
this.timeline = timeline;
|
|
90
|
+
}
|
|
91
|
+
getTimeline() {
|
|
92
|
+
return this.timeline;
|
|
93
|
+
}
|
|
94
|
+
getTimelineData() {
|
|
95
|
+
return this.timeline?.toJSON() ?? null;
|
|
96
|
+
}
|
|
97
|
+
addEvent(type) {
|
|
98
|
+
if (this.running) {
|
|
99
|
+
const timeMs = (this.frameCount / this.fps) * 1000;
|
|
100
|
+
this.events.push({ type, timeMs });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async start(client, outputPath, ctx) {
|
|
104
|
+
this.ffmpegPath = await ensureFfmpeg();
|
|
105
|
+
this.outputPath = outputPath;
|
|
106
|
+
this.frameCount = 0;
|
|
107
|
+
this.droppedFrames = 0;
|
|
108
|
+
this.running = true;
|
|
109
|
+
this.events = [];
|
|
110
|
+
this.ctx = ctx ?? null;
|
|
111
|
+
if (this.ctx)
|
|
112
|
+
this.ctx.setRecorder(this);
|
|
113
|
+
const workDir = resolve(homedir(), ".webreel");
|
|
114
|
+
mkdirSync(workDir, { recursive: true });
|
|
115
|
+
this.tempVideo = resolve(workDir, `_rec_${Date.now()}.mp4`);
|
|
116
|
+
this.ffmpegProcess = spawn(this.ffmpegPath, buildFfmpegRecorderArgs({
|
|
117
|
+
fps: this.fps,
|
|
118
|
+
crf: this.crf,
|
|
119
|
+
captureFormat: this.captureFormat,
|
|
120
|
+
outputPath: this.tempVideo,
|
|
121
|
+
}), { stdio: ["pipe", "pipe", "pipe"] });
|
|
122
|
+
const resolveDrain = () => {
|
|
123
|
+
const resolve = this.drainResolve;
|
|
124
|
+
if (resolve) {
|
|
125
|
+
this.drainResolve = null;
|
|
126
|
+
resolve();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const stdin = this.ffmpegProcess.stdin;
|
|
130
|
+
if (!stdin)
|
|
131
|
+
throw new Error("ffmpeg process has no stdin pipe");
|
|
132
|
+
stdin.on("drain", resolveDrain);
|
|
133
|
+
this.ffmpegProcess.on("close", resolveDrain);
|
|
134
|
+
this.stoppedPromise = new Promise((resolve) => {
|
|
135
|
+
this.stopResolve = resolve;
|
|
136
|
+
});
|
|
137
|
+
this.capturePromise = this.captureLoop(client);
|
|
138
|
+
}
|
|
139
|
+
async writeFrame(buffer) {
|
|
140
|
+
if (!this.running)
|
|
141
|
+
return;
|
|
142
|
+
const stdin = this.ffmpegProcess?.stdin;
|
|
143
|
+
if (!stdin?.writable) {
|
|
144
|
+
this.droppedFrames++;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const ok = stdin.write(buffer);
|
|
148
|
+
if (!ok) {
|
|
149
|
+
await new Promise((res) => {
|
|
150
|
+
this.drainResolve = res;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async raceStop(promise) {
|
|
155
|
+
const stopped = this.stoppedPromise.then(() => null);
|
|
156
|
+
const result = await Promise.race([promise, stopped]);
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
async captureLoop(client) {
|
|
160
|
+
let lastFrameTime = Date.now();
|
|
161
|
+
let consecutiveErrors = 0;
|
|
162
|
+
while (this.running) {
|
|
163
|
+
try {
|
|
164
|
+
if (this.timeline) {
|
|
165
|
+
this.timeline.tick();
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
const evalResult = await this.raceStop(client.Runtime.evaluate({
|
|
169
|
+
expression: "window.__tickCursor&&window.__tickCursor()",
|
|
170
|
+
}));
|
|
171
|
+
if (!evalResult)
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
const screenshotResult = await this.raceStop(client.Page.captureScreenshot(getCaptureScreenshotParams(this.captureFormat)));
|
|
175
|
+
if (!screenshotResult)
|
|
176
|
+
break;
|
|
177
|
+
const buffer = Buffer.from(screenshotResult.data, "base64");
|
|
178
|
+
const now = Date.now();
|
|
179
|
+
const elapsed = now - lastFrameTime;
|
|
180
|
+
const frameSlots = Math.min(3, Math.max(1, Math.round(elapsed / this.frameMs)));
|
|
181
|
+
if (frameSlots > 1) {
|
|
182
|
+
for (let i = 0; i < frameSlots - 1; i++) {
|
|
183
|
+
if (this.timeline)
|
|
184
|
+
this.timeline.tickDuplicate();
|
|
185
|
+
await this.writeFrame(buffer);
|
|
186
|
+
this.frameCount++;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
await this.writeFrame(buffer);
|
|
190
|
+
this.frameCount++;
|
|
191
|
+
if (this.framesDir) {
|
|
192
|
+
const padded = String(this.frameCount).padStart(5, "0");
|
|
193
|
+
writeFileSync(resolve(this.framesDir, `frame-${padded}${getFrameExtension(this.captureFormat)}`), buffer);
|
|
194
|
+
}
|
|
195
|
+
lastFrameTime = now;
|
|
196
|
+
consecutiveErrors = 0;
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
if (!this.running)
|
|
200
|
+
break;
|
|
201
|
+
consecutiveErrors++;
|
|
202
|
+
if (consecutiveErrors >= 10) {
|
|
203
|
+
console.error(`Recording aborted after ${consecutiveErrors} consecutive capture failures:`, err);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
getTempVideoPath() {
|
|
210
|
+
return this.tempVideo;
|
|
211
|
+
}
|
|
212
|
+
async stop() {
|
|
213
|
+
this.running = false;
|
|
214
|
+
if (this.ctx)
|
|
215
|
+
this.ctx.setRecorder(null);
|
|
216
|
+
if (this.drainResolve) {
|
|
217
|
+
this.drainResolve();
|
|
218
|
+
this.drainResolve = null;
|
|
219
|
+
}
|
|
220
|
+
if (this.stopResolve) {
|
|
221
|
+
this.stopResolve();
|
|
222
|
+
this.stopResolve = null;
|
|
223
|
+
}
|
|
224
|
+
await this.capturePromise;
|
|
225
|
+
if (this.droppedFrames > 0) {
|
|
226
|
+
console.warn(`Warning: ${this.droppedFrames} frame(s) dropped during recording`);
|
|
227
|
+
}
|
|
228
|
+
if (this.ffmpegProcess) {
|
|
229
|
+
const proc = this.ffmpegProcess;
|
|
230
|
+
const FFMPEG_CLOSE_TIMEOUT_MS = 10_000;
|
|
231
|
+
const killTimer = setTimeout(() => {
|
|
232
|
+
try {
|
|
233
|
+
proc.kill("SIGKILL");
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
// Process may have already exited
|
|
237
|
+
}
|
|
238
|
+
}, FFMPEG_CLOSE_TIMEOUT_MS);
|
|
239
|
+
await new Promise((res) => {
|
|
240
|
+
if (proc.exitCode !== null) {
|
|
241
|
+
res();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
proc.once("close", () => res());
|
|
245
|
+
try {
|
|
246
|
+
proc.stdin?.end();
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
console.warn("Failed to close ffmpeg stdin:", err);
|
|
250
|
+
res();
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
clearTimeout(killTimer);
|
|
254
|
+
this.ffmpegProcess = null;
|
|
255
|
+
}
|
|
256
|
+
if (this.frameCount === 0) {
|
|
257
|
+
rmSync(this.tempVideo, { force: true });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
// When a timeline is set, the caller is responsible for the temp video
|
|
261
|
+
// (e.g. renaming it for later compositing). Don't delete or finalize it.
|
|
262
|
+
if (this.timeline) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
const durationSec = this.frameCount / this.fps;
|
|
267
|
+
const ext = extname(this.outputPath).toLowerCase();
|
|
268
|
+
if (ext === ".webm") {
|
|
269
|
+
finalizeWebm(this.ffmpegPath, this.tempVideo, this.outputPath, this.events, durationSec, this.sfx);
|
|
270
|
+
}
|
|
271
|
+
else if (ext === ".gif") {
|
|
272
|
+
finalizeGif(this.ffmpegPath, this.tempVideo, this.outputPath, this.outputWidth);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
finalizeMp4(this.ffmpegPath, this.tempVideo, this.outputPath, this.events, durationSec, { sfx: this.sfx });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
rmSync(this.tempVideo, { force: true });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorder.js","sourceRoot":"","sources":["../src/recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAG/D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AAGpF,MAAM,UAAU,mBAAmB,CAAC,MAAqB;IACvD,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAqB;IACrD,OAAO,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AI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,EACX,WAAW,EACX,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAClB,CAAC;YACJ,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Point, SoundEvent } from "./types.js";
|
|
2
|
+
interface CursorState {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
scale: number;
|
|
6
|
+
}
|
|
7
|
+
interface HudState {
|
|
8
|
+
labels: string[];
|
|
9
|
+
}
|
|
10
|
+
interface FrameData {
|
|
11
|
+
cursor: CursorState;
|
|
12
|
+
hud: HudState | null;
|
|
13
|
+
}
|
|
14
|
+
export interface TimelineData {
|
|
15
|
+
fps: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
zoom: number;
|
|
19
|
+
theme: {
|
|
20
|
+
cursorSvg: string;
|
|
21
|
+
cursorSize: number;
|
|
22
|
+
cursorHotspot: "top-left" | "center";
|
|
23
|
+
hud: {
|
|
24
|
+
background: string;
|
|
25
|
+
color: string;
|
|
26
|
+
fontSize: number;
|
|
27
|
+
fontFamily: string;
|
|
28
|
+
borderRadius: number;
|
|
29
|
+
position: "top" | "bottom";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
frames: FrameData[];
|
|
33
|
+
events: SoundEvent[];
|
|
34
|
+
}
|
|
35
|
+
export declare class InteractionTimeline {
|
|
36
|
+
private cursorPath;
|
|
37
|
+
private pathIndex;
|
|
38
|
+
private currentCursor;
|
|
39
|
+
private currentHud;
|
|
40
|
+
private frames;
|
|
41
|
+
private events;
|
|
42
|
+
private frameCount;
|
|
43
|
+
private tickResolvers;
|
|
44
|
+
private width;
|
|
45
|
+
private height;
|
|
46
|
+
private zoom;
|
|
47
|
+
private fps;
|
|
48
|
+
private cursorSvg;
|
|
49
|
+
private cursorSize;
|
|
50
|
+
private cursorHotspot;
|
|
51
|
+
private hudConfig;
|
|
52
|
+
constructor(width?: number, height?: number, options?: {
|
|
53
|
+
zoom?: number;
|
|
54
|
+
fps?: number;
|
|
55
|
+
initialCursor?: {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
};
|
|
59
|
+
cursorSvg?: string;
|
|
60
|
+
cursorSize?: number;
|
|
61
|
+
cursorHotspot?: "top-left" | "center";
|
|
62
|
+
hud?: Partial<TimelineData["theme"]["hud"]>;
|
|
63
|
+
loadedFrames?: FrameData[];
|
|
64
|
+
loadedEvents?: SoundEvent[];
|
|
65
|
+
});
|
|
66
|
+
setCursorPath(positions: Point[]): void;
|
|
67
|
+
setCursorScale(scale: number): void;
|
|
68
|
+
showHud(labels: string[]): void;
|
|
69
|
+
hideHud(): void;
|
|
70
|
+
addEvent(type: "click" | "key"): void;
|
|
71
|
+
waitForNextTick(): Promise<void>;
|
|
72
|
+
tick(): void;
|
|
73
|
+
tickDuplicate(): void;
|
|
74
|
+
private pushCurrentState;
|
|
75
|
+
getEvents(): SoundEvent[];
|
|
76
|
+
getFrameCount(): number;
|
|
77
|
+
toJSON(): TimelineData;
|
|
78
|
+
save(path: string): void;
|
|
79
|
+
static load(json: TimelineData): InteractionTimeline;
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../src/timeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAUpD,UAAU,WAAW;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;C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