@hyperframes/producer 0.9.22 → 0.9.25

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.
@@ -306,9 +306,24 @@ function parseRangeHeader(header, size, contentType = "application/octet-stream"
306
306
  const end = Math.min(requestedEnd, size - 1);
307
307
  return { kind: "satisfiable", start, end };
308
308
  }
309
- function buildVirtualTimeShim(options) {
310
- const seedRandomFromFrame = options.seedRandomFromFrame === true;
311
- const seededRandomBlock = seedRandomFromFrame ? String.raw`
309
+ var VIRTUAL_TIME_SHIM = String.raw`(function() {
310
+ if (window.__HF_VIRTUAL_TIME__) return;
311
+
312
+ var virtualNowMs = 0;
313
+ var rafId = 1;
314
+ var rafQueue = [];
315
+ var OriginalDate = Date;
316
+ var originalSetTimeout = window.setTimeout.bind(window);
317
+ var originalClearTimeout = window.clearTimeout.bind(window);
318
+ var originalSetInterval = window.setInterval.bind(window);
319
+ var originalClearInterval = window.clearInterval.bind(window);
320
+ var originalRequestAnimationFrame = window.requestAnimationFrame
321
+ ? window.requestAnimationFrame.bind(window)
322
+ : null;
323
+ var originalCancelAnimationFrame = window.cancelAnimationFrame
324
+ ? window.cancelAnimationFrame.bind(window)
325
+ : null;
326
+
312
327
  // Seeded Math.random / crypto.getRandomValues, keyed by virtual time.
313
328
  // Mulberry32: single uint32 state, deterministic, fast.
314
329
  var rngState = 0;
@@ -350,26 +365,7 @@ function buildVirtualTimeShim(options) {
350
365
  window.crypto.getRandomValues = __seededGetRandomValues;
351
366
  } catch (e) {}
352
367
  }
353
- ` : "";
354
- const seekToTimeReseedCall = seedRandomFromFrame ? "reseedRngFromTime(safeTimeMs);\n " : "";
355
- return String.raw`(function() {
356
- if (window.__HF_VIRTUAL_TIME__) return;
357
368
 
358
- var virtualNowMs = 0;
359
- var rafId = 1;
360
- var rafQueue = [];
361
- var OriginalDate = Date;
362
- var originalSetTimeout = window.setTimeout.bind(window);
363
- var originalClearTimeout = window.clearTimeout.bind(window);
364
- var originalSetInterval = window.setInterval.bind(window);
365
- var originalClearInterval = window.clearInterval.bind(window);
366
- var originalRequestAnimationFrame = window.requestAnimationFrame
367
- ? window.requestAnimationFrame.bind(window)
368
- : null;
369
- var originalCancelAnimationFrame = window.cancelAnimationFrame
370
- ? window.cancelAnimationFrame.bind(window)
371
- : null;
372
- ${seededRandomBlock}
373
369
  function flushAnimationFrame() {
374
370
  if (!rafQueue.length) return;
375
371
  var current = rafQueue.slice();
@@ -500,7 +496,8 @@ ${seededRandomBlock}
500
496
  // page starts there keep the schedule a one-worker render gives them.
501
497
  if (safeTimeMs > 0) seekToTime(0);
502
498
  }
503
- ${seekToTimeReseedCall}fireDueTimers(safeTimeMs);
499
+ reseedRngFromTime(safeTimeMs);
500
+ fireDueTimers(safeTimeMs);
504
501
  virtualNowMs = safeTimeMs;
505
502
  flushAnimationFrame();
506
503
  return virtualNowMs;
@@ -519,8 +516,6 @@ ${seededRandomBlock}
519
516
  },
520
517
  };
521
518
  })();`;
522
- }
523
- var VIRTUAL_TIME_SHIM = buildVirtualTimeShim({ seedRandomFromFrame: false });
524
519
  var RENDER_SEEK_MODE = process.env.PRODUCER_RUNTIME_RENDER_SEEK_MODE === "strict-boundary" ? "strict-boundary" : "preview-phase";
525
520
  var RENDER_SEEK_DIAGNOSTICS = process.env.PRODUCER_DEBUG_SEEK_DIAGNOSTICS === "true";
526
521
  var RENDER_SEEK_STEP = Math.max(
@@ -8604,7 +8599,7 @@ async function measurePlanSecondsPerFrame(input) {
8604
8599
  projectDir: compiledDir,
8605
8600
  compiledDir,
8606
8601
  port: 0,
8607
- preHeadScripts: [buildVirtualTimeShim({ seedRandomFromFrame: true })],
8602
+ preHeadScripts: [VIRTUAL_TIME_SHIM],
8608
8603
  fps: fpsRatio
8609
8604
  });
8610
8605
  let session = null;
@@ -12270,7 +12265,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
12270
12265
  projectDir: compiledDir,
12271
12266
  compiledDir,
12272
12267
  port: 0,
12273
- preHeadScripts: [buildVirtualTimeShim({ seedRandomFromFrame: true })],
12268
+ preHeadScripts: [VIRTUAL_TIME_SHIM],
12274
12269
  // These dimensions are frozen by the controller from the render job, so
12275
12270
  // chunk runtime seek quantization stays on the same fps grid as capture.
12276
12271
  fps: { num: plan.dimensions.fpsNum, den: plan.dimensions.fpsDen }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "0.1.0",
3
3
  "buildId": "dev",
4
- "sha256": "a42261c262fc9a936c9626d8dabb6459afdde52a8d51986331f622f0e815b4dd",
4
+ "sha256": "45f46e9913dc55f109773ed9565b251a21bb466671e246bb489abd72c2c08069",
5
5
  "artifacts": {
6
6
  "iife": "hyperframe.runtime.iife.js",
7
7
  "esm": "hyperframe.runtime.mjs"