{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "error-report-core",
  "type": "registry:lib",
  "title": "reportError (first-load entry)",
  "description": "@interlace/ui — `reportError` and `installGlobalHandlers` and nothing else, so the first page load stays small. Sends nothing unless you set a reporter.",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "feedback",
    "util"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/error-report-log-model.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/lib/error-report-core.ts",
      "target": "lib/error-report-core.ts",
      "type": "registry:lib",
      "content": "import {\n  DEFAULT_COALESCE_MS,\n  DEFAULT_LIMITS,\n  DEFAULT_MAX,\n  attachGlobalHandlers,\n  buildReport,\n  createCoreLog,\n  defaultMakeId,\n  type ErrorLogCore,\n} from '@/lib/error-report-log-model';\n\n// @interlace/error-report-core v1.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/error-report-core\n// What changed since: https://ds.interlace.tools/c/error-report-core#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui: `reportError`, the one function every caught failure goes through, and the\n * little the first page load needs to make \"nothing fails silently\" true.\n *\n *   import { installGlobalHandlers, reportError } from '@interlace/ui/error-report-core';\n *\n *   installGlobalHandlers();                                  // browser: error + unhandledrejection\n *   try { await save(draft); } catch (error) { reportError(error, 'checkout: save'); }\n *\n * It builds a typed report, keeps the last few in memory, and hands each to a reporter. The\n * default reporter is a development console line and nothing else: no report leaves the device\n * unless the app calls `setReporter` with a function of its own. Nothing here calls `fetch`.\n *\n * This is the lean entry point: the default log and nothing that only a diagnostics screen needs.\n * Listening (`subscribeErrors`, `useRecentErrors`), keeping reports on the device\n * (`installErrorLog`, `restoreRecent`) and the text of a diagnostics screen (`formatReports`) are\n * in `error-report-model`. `error-report` re-exports every name for the imports that predate the\n * split, at the price of all of them.\n */\n\nexport * from '@/lib/error-report-log-model';\n\n/** The module's own small log: the one `reportError` writes to. `defaultErrorLog` is the same log, whole. */\nexport const coreErrorLog: ErrorLogCore = /* @__PURE__ */ createCoreLog({\n  max: DEFAULT_MAX,\n  coalesceMs: DEFAULT_COALESCE_MS,\n  now: () => Date.now(),\n  makeId: defaultMakeId,\n  build: (error, where, fatal, meta) => buildReport(error, where, fatal, meta, DEFAULT_LIMITS),\n});\n\nexport const reportError: ErrorLogCore['report'] = (error, where, fatal) =>\n  coreErrorLog.report(error, where, fatal);\nexport const recentErrors: ErrorLogCore['recent'] = () => coreErrorLog.recent();\nexport const setReporter: ErrorLogCore['setReporter'] = (next) => coreErrorLog.setReporter(next);\n\n/**\n * Report `error` and `unhandledrejection` on the page (or on `target`). Idempotent; returns the\n * remover. It does not call `preventDefault`, so the browser console still logs. On a server,\n * where there is no `window`, it does nothing.\n */\nexport function installGlobalHandlers(\n  target?: Parameters<typeof attachGlobalHandlers>[0],\n  log: Pick<ErrorLogCore, 'report'> = coreErrorLog,\n): () => void {\n  const where = target ?? (typeof window === 'undefined' ? undefined : window);\n  return where ? attachGlobalHandlers(where, log) : () => undefined;\n}\n"
    }
  ],
  "meta": {
    "tier": "util",
    "client": false,
    "minViewport": null,
    "loading": false,
    "version": "1.0.0",
    "since": "2.4.0"
  },
  "docs": "## @interlace/error-report-core\n\nInstalled to `lib/error-report-core.ts`.\n\n```tsx\nimport { /* … */ } from '@/lib/error-report-core';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/error-report-core"
}
