@hyperframes/producer 0.4.16 → 0.4.17

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/dist/logger.d.ts CHANGED
@@ -13,6 +13,25 @@ export interface ProducerLogger {
13
13
  warn(message: string, meta?: Record<string, unknown>): void;
14
14
  info(message: string, meta?: Record<string, unknown>): void;
15
15
  debug(message: string, meta?: Record<string, unknown>): void;
16
+ /**
17
+ * Optional fast level check used to skip expensive metadata construction
18
+ * at the call site. When the call site needs to build a non-trivial meta
19
+ * object (e.g. snapshot a struct, format numbers, run `Array.find` over
20
+ * scene state) just to attach to a debug log, gate it with this method:
21
+ *
22
+ * ```ts
23
+ * if (log.isLevelEnabled?.("debug") ?? true) {
24
+ * const meta = buildExpensiveMeta();
25
+ * log.debug("hot-path event", meta);
26
+ * }
27
+ * ```
28
+ *
29
+ * The default coalescence (`?? true`) preserves today's behavior for
30
+ * loggers that omit this method — they keep building the meta object as
31
+ * before. Custom integrations (Pino, Winston, structured loggers) should
32
+ * implement this to enable the optimization.
33
+ */
34
+ isLevelEnabled?(level: LogLevel): boolean;
16
35
  }
17
36
  /**
18
37
  * Create a console-based logger with level filtering.
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,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-109666,6 +109666,9 @@ function createConsoleLogger(level = "info") {
109666
109666
  if (shouldLog("debug")) {
109667
109667
  console.log(`[DEBUG] ${message}${formatMeta(meta)}`);
109668
109668
  }
109669
+ },
109670
+ isLevelEnabled(msgLevel) {
109671
+ return shouldLog(msgLevel);
109669
109672
  }
109670
109673
  };
109671
109674
  }
@@ -110147,6 +110150,19 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
110147
110150
  const enableChunkedEncode = cfg.enableChunkedEncode;
110148
110151
  const chunkedEncodeSize = cfg.chunkSizeFrames;
110149
110152
  const enableStreamingEncode = cfg.enableStreamingEncode;
110153
+ let peakRssBytes = 0;
110154
+ let peakHeapUsedBytes = 0;
110155
+ const sampleMemory = () => {
110156
+ try {
110157
+ const m = process.memoryUsage();
110158
+ if (m.rss > peakRssBytes) peakRssBytes = m.rss;
110159
+ if (m.heapUsed > peakHeapUsedBytes) peakHeapUsedBytes = m.heapUsed;
110160
+ } catch {
110161
+ }
110162
+ };
110163
+ sampleMemory();
110164
+ const memSamplerInterval = setInterval(sampleMemory, 250);
110165
+ memSamplerInterval.unref?.();
110150
110166
  try {
110151
110167
  const assertNotAborted = () => {
110152
110168
  if (abortSignal?.aborted) {
@@ -110850,7 +110866,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
110850
110866
  const activeTransition = transitionRanges.find(
110851
110867
  (t) => i >= t.startFrame && i <= t.endFrame
110852
110868
  );
110853
- if (i % 30 === 0) {
110869
+ if (i % 30 === 0 && (log.isLevelEnabled?.("debug") ?? true)) {
110854
110870
  const hdrEl = stackingInfo.find((e) => e.isHdr);
110855
110871
  log.debug("[Render] HDR layer composite frame", {
110856
110872
  frame: i,
@@ -111293,6 +111309,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
111293
111309
  job.outputPath = outputPath;
111294
111310
  updateJobStatus(job, "complete", "Render complete", 100, onProgress);
111295
111311
  const totalElapsed = Date.now() - pipelineStart;
111312
+ sampleMemory();
111296
111313
  const perfSummary = {
111297
111314
  renderId: job.id,
111298
111315
  totalElapsedMs: totalElapsed,
@@ -111308,7 +111325,9 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
111308
111325
  audioCount: composition.audios.length,
111309
111326
  stages: perfStages,
111310
111327
  hdrDiagnostics: hdrDiagnostics.videoExtractionFailures > 0 || hdrDiagnostics.imageDecodeFailures > 0 ? { ...hdrDiagnostics } : void 0,
111311
- captureAvgMs: totalFrames > 0 ? Math.round((perfStages.captureMs ?? 0) / totalFrames) : void 0
111328
+ captureAvgMs: totalFrames > 0 ? Math.round((perfStages.captureMs ?? 0) / totalFrames) : void 0,
111329
+ peakRssMb: Math.round(peakRssBytes / (1024 * 1024)),
111330
+ peakHeapUsedMb: Math.round(peakHeapUsedBytes / (1024 * 1024))
111312
111331
  };
111313
111332
  job.perfSummary = perfSummary;
111314
111333
  if (job.config.debug) {
@@ -111416,6 +111435,8 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
111416
111435
  }
111417
111436
  if (restoreLogger) restoreLogger();
111418
111437
  throw error;
111438
+ } finally {
111439
+ clearInterval(memSamplerInterval);
111419
111440
  }
111420
111441
  }
111421
111442