Files
ComfyUI_frontend/src/base/common/devAssert.ts
bymyself 53b119d280 fix: address code review items for viewport PR
- Uncomment canvasNotMeasurable guards in DragAndScale fitToBounds/animateToBounds
- Make LGraphCanvas.resize() delegate to measureViewport/applyViewport
- Move devAssert to src/base/common/ (DDD layer compliance)
- Enhance devAssert with pluggable reporter hook; wire Sentry + toast in main.ts
- Set ADR 0009 status to Proposed (pending full migration in follow-up)
2026-04-20 19:42:05 -07:00

22 lines
484 B
TypeScript

type AssertReporter = (formatted: string) => void
let reporter: AssertReporter | undefined
function setDevAssertReporter(fn: AssertReporter) {
reporter = fn
}
function devAssert(condition: boolean, message: string): asserts condition {
if (!condition) {
const formatted = `[Invariant] ${message}`
console.error(formatted)
reporter?.(formatted)
if (import.meta.env.DEV) {
throw new Error(formatted)
}
}
}
export { devAssert, setDevAssertReporter }