init commit

This commit is contained in:
Carlos
2026-02-21 10:33:18 +01:00
parent c863a943ed
commit 9d955bf338
9512 changed files with 2015317 additions and 1305 deletions

View File

@@ -0,0 +1,23 @@
import type { Page } from '../browser/BrowserPage';
import type { SymbolicatedStackFrame } from '../symbolicate-stacktrace';
export declare class ErrorWithStackFrame extends Error {
symbolicatedStackFrames: SymbolicatedStackFrame[] | null;
frame: number | null;
chunk: number | null;
name: string;
delayRenderCall: SymbolicatedStackFrame[] | null;
constructor({ message, symbolicatedStackFrames, frame, name, delayRenderCall, stack, chunk }: {
message: string;
symbolicatedStackFrames: SymbolicatedStackFrame[] | null;
frame: number | null;
chunk: number | null;
name: string;
delayRenderCall: SymbolicatedStackFrame[] | null;
stack: string | undefined;
});
}
export declare const handleJavascriptException: ({ page, onError, frame, }: {
page: Page;
frame: number | null;
onError: (err: Error) => void;
}) => () => Promise<void>;

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleJavascriptException = exports.ErrorWithStackFrame = void 0;
const no_react_1 = require("remotion/no-react");
const symbolicateable_error_1 = require("./symbolicateable-error");
class ErrorWithStackFrame extends Error {
symbolicatedStackFrames;
frame;
chunk;
name;
delayRenderCall;
constructor({ message, symbolicatedStackFrames, frame, name, delayRenderCall, stack, chunk, }) {
super(message);
this.symbolicatedStackFrames = symbolicatedStackFrames;
this.frame = frame;
this.chunk = chunk;
this.name = name;
this.delayRenderCall = delayRenderCall;
// If error symbolication did not yield any stack frames, we print the original stack
this.stack = stack;
}
}
exports.ErrorWithStackFrame = ErrorWithStackFrame;
const cleanUpErrorMessage = (exception) => {
var _a, _b, _c;
var _d;
let errorMessage = (_a = exception.exceptionDetails.exception) === null || _a === void 0 ? void 0 : _a.description;
if (!errorMessage) {
return null;
}
const errorType = (_b = exception.exceptionDetails.exception) === null || _b === void 0 ? void 0 : _b.className;
const prefix = `${errorType}: `;
if (errorMessage.startsWith(prefix)) {
errorMessage = errorMessage.substring(prefix.length);
}
const frames = (_d = (_c = exception.exceptionDetails.stackTrace) === null || _c === void 0 ? void 0 : _c.callFrames.length) !== null && _d !== void 0 ? _d : 0;
const split = errorMessage.split('\n');
return split.slice(0, Math.max(1, split.length - frames)).join('\n');
};
const removeDelayRenderStack = (message) => {
const index = message.indexOf(no_react_1.NoReactInternals.DELAY_RENDER_CALLSTACK_TOKEN);
if (index === -1) {
return message;
}
return message.substring(0, index);
};
const callFrameToStackFrame = (callFrame) => {
return {
columnNumber: callFrame.columnNumber,
fileName: callFrame.url,
functionName: callFrame.functionName,
lineNumber: callFrame.lineNumber,
};
};
const handleJavascriptException = ({ page, onError, frame, }) => {
const client = page._client();
const handler = (exception) => {
var _a, _b, _c;
const rawErrorMessage = (_a = exception.exceptionDetails.exception) === null || _a === void 0 ? void 0 : _a.description;
const cleanErrorMessage = cleanUpErrorMessage(exception);
if (!cleanErrorMessage) {
// eslint-disable-next-line no-console
console.error(exception);
const err = new Error(rawErrorMessage);
err.stack = rawErrorMessage;
onError(err);
return;
}
if (!exception.exceptionDetails.stackTrace) {
const err = new Error(removeDelayRenderStack(cleanErrorMessage));
err.stack = rawErrorMessage;
onError(err);
return;
}
const errorType = (_b = exception.exceptionDetails.exception) === null || _b === void 0 ? void 0 : _b.className;
const symbolicatedErr = new symbolicateable_error_1.SymbolicateableError({
message: removeDelayRenderStack(cleanErrorMessage),
stackFrame: exception.exceptionDetails.stackTrace.callFrames.map((f) => callFrameToStackFrame(f)),
frame,
name: errorType,
stack: (_c = exception.exceptionDetails.exception) === null || _c === void 0 ? void 0 : _c.description,
chunk: null,
});
onError(symbolicatedErr);
};
client.on('Runtime.exceptionThrown', handler);
return () => {
client.off('Runtime.exceptionThrown', handler);
return Promise.resolve();
};
};
exports.handleJavascriptException = handleJavascriptException;

View File

@@ -0,0 +1,3 @@
import { ErrorWithStackFrame } from './handle-javascript-exception';
import type { SymbolicateableError } from './symbolicateable-error';
export declare const symbolicateError: (symbolicateableError: SymbolicateableError) => Promise<ErrorWithStackFrame>;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.symbolicateError = void 0;
const symbolicate_stacktrace_1 = require("../symbolicate-stacktrace");
const truthy_1 = require("../truthy");
const handle_javascript_exception_1 = require("./handle-javascript-exception");
const symbolicateError = async (symbolicateableError) => {
const { delayRenderCall, stackFrame } = symbolicateableError;
const [mainErrorFrames, delayRenderFrames] = await Promise.all([
stackFrame ? (0, symbolicate_stacktrace_1.symbolicateStackTraceFromRemoteFrames)(stackFrame) : null,
delayRenderCall
? (0, symbolicate_stacktrace_1.symbolicateStackTraceFromRemoteFrames)(delayRenderCall)
: null,
].filter(truthy_1.truthy));
const symbolicatedErr = new handle_javascript_exception_1.ErrorWithStackFrame({
message: symbolicateableError.message,
symbolicatedStackFrames: mainErrorFrames,
frame: symbolicateableError.frame,
name: symbolicateableError.name,
delayRenderCall: delayRenderFrames,
stack: symbolicateableError.stack,
chunk: symbolicateableError.chunk,
});
return symbolicatedErr;
};
exports.symbolicateError = symbolicateError;

View File

@@ -0,0 +1,18 @@
/**
* A symbolicateable error is an error that can be symolicated by fetching the original sources. By throwing a symbolicateable error, Remotion CLI will attempt to symplicate it
*/
import type { UnsymbolicatedStackFrame } from '../parse-browser-error-stack';
export declare class SymbolicateableError extends Error {
stackFrame: UnsymbolicatedStackFrame[] | null;
delayRenderCall: UnsymbolicatedStackFrame[] | null;
frame: number | null;
chunk: number | null;
constructor({ message, stack, stackFrame, frame, name, chunk }: {
message: string;
stack: string | undefined;
frame: number | null;
name: string;
stackFrame: UnsymbolicatedStackFrame[] | null;
chunk: number | null;
});
}

View File

@@ -0,0 +1,23 @@
"use strict";
/**
* A symbolicateable error is an error that can be symolicated by fetching the original sources. By throwing a symbolicateable error, Remotion CLI will attempt to symplicate it
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SymbolicateableError = void 0;
const delay_render_embedded_stack_1 = require("../delay-render-embedded-stack");
class SymbolicateableError extends Error {
stackFrame;
delayRenderCall;
frame;
chunk;
constructor({ message, stack, stackFrame, frame, name, chunk, }) {
super(message);
this.stack = stack;
this.stackFrame = stackFrame;
this.frame = frame;
this.chunk = chunk;
this.name = name;
this.delayRenderCall = stack ? (0, delay_render_embedded_stack_1.parseDelayRenderEmbeddedStack)(stack) : null;
}
}
exports.SymbolicateableError = SymbolicateableError;