@hyperframes/producer 0.8.210 → 0.8.212

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.
@@ -126,6 +126,7 @@ import { randomUUID } from "crypto";
126
126
  // src/services/fileServer.ts
127
127
  import { Hono } from "hono";
128
128
  import { serve } from "@hono/node-server";
129
+ import { settleOnBrowserSafePort } from "@hyperframes/engine";
129
130
  import {
130
131
  existsSync as existsSync2,
131
132
  realpathSync,
@@ -797,18 +798,21 @@ function createFileServer(options) {
797
798
  return new Promise((resolve10, reject) => {
798
799
  const connections = /* @__PURE__ */ new Set();
799
800
  const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
800
- resolve10({
801
- url: `http://localhost:${info.port}`,
802
- port: info.port,
803
- addPreHeadScript: (script) => {
804
- preHeadScripts.push(script);
805
- },
806
- close: () => {
807
- for (const socket of connections) socket.destroy();
808
- connections.clear();
809
- server.close();
810
- }
811
- });
801
+ const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
802
+ bound.then((boundPort) => {
803
+ resolve10({
804
+ url: `http://localhost:${boundPort}`,
805
+ port: boundPort,
806
+ addPreHeadScript: (script) => {
807
+ preHeadScripts.push(script);
808
+ },
809
+ close: () => {
810
+ for (const socket of connections) socket.destroy();
811
+ connections.clear();
812
+ server.close();
813
+ }
814
+ });
815
+ }, reject);
812
816
  });
813
817
  server.on("connection", (socket) => {
814
818
  connections.add(socket);
@@ -898,6 +902,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
898
902
  var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
899
903
  // resolves to a bogus renders dir.
900
904
  nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
905
+ var LEADING_PARENT_SEGMENT_RE = /^\.\.(?:[\\/]|$)/;
901
906
  function isPathInside2(childPath, parentPath, options = {}) {
902
907
  const resolvePath = options.pathModule?.resolve ?? nodeResolve;
903
908
  const relativePath = options.pathModule?.relative ?? nodeRelative;
@@ -906,7 +911,7 @@ function isPathInside2(childPath, parentPath, options = {}) {
906
911
  const absParent = resolvePath(parentPath);
907
912
  if (absChild === absParent) return true;
908
913
  const rel = relativePath(absParent, absChild);
909
- return rel !== "" && !rel.startsWith("..") && !isPathAbsolute(rel);
914
+ return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
910
915
  }
911
916
  function toExternalAssetKey(absPath) {
912
917
  if (absPath.startsWith("hf-ext/")) return absPath;
@@ -3048,9 +3053,10 @@ function detectShaderTransitionUsage(html) {
3048
3053
  async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes) {
3049
3054
  let filePath = src;
3050
3055
  if (isHttpUrl(src)) {
3051
- if (!existsSync6(downloadDir)) mkdirSync4(downloadDir, { recursive: true });
3056
+ const remoteDir = join6(downloadDir, REMOTE_MEDIA_SUBDIR);
3057
+ if (!existsSync6(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
3052
3058
  try {
3053
- filePath = await downloadToTemp(src, downloadDir, void 0, void 0, void 0, {
3059
+ filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
3054
3060
  onTelemetry: logRemoteDownloadTelemetry
3055
3061
  });
3056
3062
  } catch {
@@ -6951,7 +6957,7 @@ function videoEncoderOptions(input, engineCfg) {
6951
6957
  };
6952
6958
  }
6953
6959
  function canEncodeWhileCapturing(input, workerCount, cpuCount) {
6954
- return workerCount > 1 && workerCount < cpuCount && !input.isPngSequence && !input.isGif && !input.enableChunkedEncode && input.preset.codec === "h264" && !input.preset.hdr && input.job.config.useGpu !== true && input.captureImageFormat === "jpeg";
6960
+ return workerCount > 1 && workerCount < cpuCount && !input.isPngSequence && !input.isGif && !input.enableChunkedEncode && input.preset.codec === "h264" && !input.preset.hdr && input.captureImageFormat === "jpeg";
6955
6961
  }
6956
6962
  async function readLandedFrame(workerPath, mergedPath) {
6957
6963
  if (workerPath !== void 0) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "0.1.0",
3
3
  "buildId": "dev",
4
- "sha256": "7ab9e58fd46ca6b2743d6347ac25614c879b13b5dc8f6da20c0261d275d7b685",
4
+ "sha256": "e83a2fc411d8184425deaa4d183cef696809d79457ec0e21e68b6c8da863307e",
5
5
  "artifacts": {
6
6
  "iife": "hyperframe.runtime.iife.js",
7
7
  "esm": "hyperframe.runtime.mjs"